This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
CC26x2
Note: The following instructions have been written for SDK 3_40_00_02 but can be adapted to quite any SDK version (that is why I provided the sources but also the diff files). In addition, the code was written for CC2642R but can be adapted to all the devices of the family (CC2652R, CC2652P, CC1352R, CC1352P)
By removing the secondary advertisement (sometimes called "long range" advertisement) from the simple_peripheral example you can significantly save power. The power consumption due to the secondary advertisement (generally long range advertisement) can represent up to 80% of the power consumption of the advertisement period. Please consult the BT-POWER-CALC to have more details regarding power consumption.
In addition, this modification can help you to save memory.
How to do this?
Using SysConfig, reduce the number of Advertisement Set to only 1 (this must be done in BLE > Broadcaster Configuration). This will raise a warning saying we need to update the application code… this is what we are going to do now :)
Here is a screenshot showing how to proceed. You can also use the SysConfig I have modified for you (it encloses the modifications we required to remove the display)
Note: It is perfectly normal and expected if the compilation of your project fails after this step… be patient and go to the next step.
Modify simple_peripheral.c to remove the code related to the #2 advertisement. For example, you can look for the variable advHandleLongRange and remove the code associated. The code associated to advData2 and advParams2 should also be removed.
Here is the diff file and the file you are supposed to get if you also removed the display:
--- C:\ti\simplelink_cc13x2_26x2_sdk_3_40_00_02\examples\rtos\CC26X2R1_LAUNCHXL\ble5stack\simple_peripheral\Application\simple_peripheral_withoutDisplay.c Mon Feb 10 15:50:31 2020 +++ C:\ti\simplelink_cc13x2_26x2_sdk_3_40_00_02\examples\rtos\CC26X2R1_LAUNCHXL\ble5stack\simple_peripheral\Application\simple_peripheral_SIMPLE.c Tue Feb 11 16:32:11 2020 @@ -282,7 +282,6 @@ // Advertising handles static uint8 advHandleLegacy; -static uint8 advHandleLongRange; // Address mode static GAP_Addr_Modes_t addrMode = DEFAULT_ADDRESS_MODE; @@ -936,26 +935,6 @@ status = GapAdv_enable(advHandleLegacy, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0); SIMPLEPERIPHERAL_ASSERT(status == SUCCESS); - // Create Advertisement set #2 and assign handle - status = GapAdv_create(&SimplePeripheral_advCallback, &advParams2, - &advHandleLongRange); - SIMPLEPERIPHERAL_ASSERT(status == SUCCESS); - - // Load advertising data for set #2 that is statically allocated by the app - status = GapAdv_loadByHandle(advHandleLongRange, GAP_ADV_DATA_TYPE_ADV, - sizeof(advData2), advData2); - SIMPLEPERIPHERAL_ASSERT(status == SUCCESS); - - // Set event mask for set #2 - status = GapAdv_setEventMask(advHandleLongRange, - GAP_ADV_EVT_MASK_START_AFTER_ENABLE | - GAP_ADV_EVT_MASK_END_AFTER_DISABLE | - GAP_ADV_EVT_MASK_SET_TERMINATED); - - // Enable long range advertising for set #2 - status = GapAdv_enable(advHandleLongRange, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0); - SIMPLEPERIPHERAL_ASSERT(status == SUCCESS); - if (addrMode > ADDRMODE_RANDOM) { SimplePeripheral_updateRPA(); @@ -988,12 +967,10 @@ { // Start advertising since there is room for more connections GapAdv_enable(advHandleLegacy, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0); - GapAdv_enable(advHandleLongRange, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0); } else { // Stop advertising since there is no room for more connections - GapAdv_disable(advHandleLongRange); GapAdv_disable(advHandleLegacy); } break; @@ -1017,7 +994,6 @@ // Start advertising since there is room for more connections GapAdv_enable(advHandleLegacy, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0); - GapAdv_enable(advHandleLongRange, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0); break; } @@ -1521,14 +1497,10 @@ { if (autoConnect != AUTOCONNECT_GROUP_A) { - GapAdv_disable(advHandleLongRange); GapAdv_disable(advHandleLegacy); advData1[2] = 'G'; advData1[3] = 'A'; - advData2[2] = 'G'; - advData2[3] = 'A'; GapAdv_enable(advHandleLegacy, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0); - GapAdv_enable(advHandleLongRange, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0); autoConnect = AUTOCONNECT_GROUP_A; } } @@ -1536,14 +1508,10 @@ { if (autoConnect != AUTOCONNECT_GROUP_B) { - GapAdv_disable(advHandleLongRange); GapAdv_disable(advHandleLegacy); advData1[2] = 'G'; advData1[3] = 'B'; - advData2[2] = 'G'; - advData2[3] = 'B'; GapAdv_enable(advHandleLegacy, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0); - GapAdv_enable(advHandleLongRange, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0); autoConnect = AUTOCONNECT_GROUP_B; } } @@ -1551,14 +1519,10 @@ { if (autoConnect) { - GapAdv_disable(advHandleLongRange); GapAdv_disable(advHandleLegacy); advData1[2] = 'S'; advData1[3] = 'P'; - advData2[2] = 'S'; - advData2[3] = 'P'; GapAdv_enable(advHandleLegacy, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0); - GapAdv_enable(advHandleLongRange, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0); autoConnect = AUTOCONNECT_DISABLE; } }
Compile and test your project… You might have a warning due to SysConfig (this warning only appears if SysConfig is run, i.e. if you modify the content of the SysConfig file or if you “Rebuild” the project). Above that, no warning or error should be raised at build time and the project should still work smoothly!
Here are the links to the different threads I wrote regarding simple_peripheral FLASH size optimization:
Remove display CC26x2 / CC13x2: e2e.ti.com/.../879276
Remove display CC2640R2: e2e.ti.com/.../3252666
Remove #2 advertisement CC26x2 / CC13x2: e2e.ti.com/.../3255504
Remove #2 advertisement CC2640R2: e2e.ti.com/.../880139
Remove RSSI monitoring and auto PHY update CC26x2 / CC13x2: e2e.ti.com/.../880155
Remove RSSI monitoring and auto PHY update CC2640R2: e2e.ti.com/.../880151
Remove connection params updates CC26x2 / CC13x2: e2e.ti.com/.../880171
Remove connection params updates CC2640R2: e2e.ti.com/.../880163
Remove pairing CC26x2 / CC13x2: e2e.ti.com/.../880181
Remove pairing CC2640R2: e2e.ti.com/.../880177