HW layer for the Nucleo board, it only work with old BLE_API
Dependents: Hello_BLE F446RE-BLE
Fork of X_NUCLEO_IDB0XA1 by
Diff: BlueNRGGap.cpp
- Revision:
- 25:f3ea48a2008b
- Parent:
- 20:718d56821672
- Parent:
- 24:1c7266497633
- Child:
- 26:047d45ea379e
--- a/BlueNRGGap.cpp Wed Aug 13 10:06:18 2014 +0000 +++ b/BlueNRGGap.cpp Tue Aug 19 05:41:48 2014 +0000 @@ -30,7 +30,8 @@ /**************************************************************************/ /*! - @brief Sets the advertising parameters and payload for the device + @brief Sets the advertising parameters and payload for the device. + Note: Some data types give error when their adv data is updated using aci_gap_update_adv_data() API @param[in] params Basic advertising details, including the advertising @@ -78,19 +79,22 @@ return BLE_ERROR_PARAM_OUT_OF_RANGE; } else { PayloadPtr loadPtr(advData.getPayload(), advData.getPayloadLen()); - for(uint8_t index=0; index<loadPtr.getPayloadUnitCount(); index++) { - // add AD data to the + for(uint8_t index=0; index<loadPtr.getPayloadUnitCount(); index++) { PayloadUnit unit = loadPtr.getUnitAtIndex(index); + DEBUG("adData[%d].length=%d\n\r", index,(uint8_t)(*loadPtr.getUnitAtIndex(index).getLenPtr())); DEBUG("adData[%d].AdType=0x%x\n\r", index,(uint8_t)(*loadPtr.getUnitAtIndex(index).getAdTypePtr())); - #if 0 - int err = aci_gap_update_adv_data(*loadPtr.getUnitAtIndex(index).getLenPtr(), loadPtr.getUnitAtIndex(index).getAdTypePtr()); - + + #if 1 + + int err = aci_gap_update_adv_data(*loadPtr.getUnitAtIndex(index).getLenPtr(), loadPtr.getUnitAtIndex(index).getAdTypePtr()); if(BLE_STATUS_SUCCESS!=err) { DEBUG("error occurred while adding adv data\n\r"); return BLE_ERROR_PARAM_OUT_OF_RANGE; // no other suitable error code is available - } - #endif + DEBUG("error occurred while adding adv data for Adv type 0x%x, errCode = 0x%x\n", *loadPtr.getUnitAtIndex(index).getAdTypePtr(), err); + //return BLE_ERROR_PARAM_OUT_OF_RANGE; // no other suitable error code is available + } + #endif //UnitPayload unitLoad = load.getPayLoadAtIndex(index); switch(*loadPtr.getUnitAtIndex(index).getAdTypePtr()) { case GapAdvertisingData::FLAGS: /* ref *Flags */ @@ -99,6 +103,14 @@ break; case GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS: /**< Complete list of 16-bit Service IDs */ DEBUG("Advertising type: COMPLETE_LIST_16BIT_SERVICE_IDS\n\r"); + DEBUG("Advertising type: COMPLETE_LIST_16BIT_SERVICE_IDS\n"); + #if 0 + int err = aci_gap_update_adv_data(*loadPtr.getUnitAtIndex(index).getLenPtr(), loadPtr.getUnitAtIndex(index).getAdTypePtr()); + if(BLE_STATUS_SUCCESS!=err) { + DEBUG("error occurred while adding adv data\n"); + return BLE_ERROR_PARAM_OUT_OF_RANGE; // no other suitable error code is available + } + #endif break; case GapAdvertisingData::INCOMPLETE_LIST_32BIT_SERVICE_IDS: /**< Incomplete list of 32-bit Service IDs (not relevant for Bluetooth 4.0) */ break; @@ -115,8 +127,7 @@ loadPtr.getUnitAtIndex(index).printDataAsString(); local_name_length = *loadPtr.getUnitAtIndex(index).getLenPtr()-1; local_name = (const char*)loadPtr.getUnitAtIndex(index).getAdTypePtr(); - //for(int i=0; i<local_name_length; i++) - // DEBUG("\n%c", local_name[i]); + //for(int i=0; i<local_name_length; i++) DEBUG("\n%c", local_name[i]); aci_gatt_update_char_value(g_gap_service_handle, g_device_name_char_handle, 0,