Other Parts Discussed in Thread: SYSCONFIG, CC2340R5
Tool/software:
In our application loop, we expect one BLE advertisement every 5 seconds. To conserve power, we disable the BLE advertisement before exiting the loop and call the sleep() function to introduce a delay between consecutive BLE advertisements.
Our system needs to be highly power-efficient, and we anticipate that the sleep() call will put the BLE CC2340 into sleep mode, thus reducing the overall system current consumption to approximately 10 microamps between each BLE advertisement.
However, we are observing ripples between each BLE advertisement transmission. We are uncertain about what we are missing or what causes the BLE controller to enter sleep mode.
The attached picture illustrates our application's behavior between consecutive BLE advertisement transmissions.
The average current observed in the system is approximately a constant 166 microamps which will cause our battery to losses its capacity to deliver energy.
The code snippet provided facilitates the enabling and disabling of advertisements, as well as handling them. Additionally, it ensures synchronization across various system tasks by utilizing a semaphore to complete the advertisement process, and by confirming that the actions to enable and disable BLE advertisements are properly executed within the TI BLE stack.
Does CC23400R5 stack has APIs that allow the BLE processor to transition to low power mode and revert back immediately after those APIs are called.
-----------------------------------------------------------------------------------------------------------------------------------------------------
void appEnableBle(char *pData)
{
bStatus_t status;
char* cpyData = pData;
status = Broadcaster_adv_enable();
if(SUCCESS == status)
{
sem_post(&blesem);
}
}
void appDisableBle(char *pData)
{
bStatus_t status;
char* cpyData = pData;
status = Broadcaster_adv_disable();
if(SUCCESS == status)
{
sem_post(&blesem);
}
}
loop <repeated Ble Transimssion>
bleStatus = BLEAppUtil_invokeFunctionNoData(appEnableBle);
if (SUCCESS == bleStatus)
{
/* Wait for Enable advertisement operation to complete */
sem_wait(&blesem);
}
/* Wait for advertisement to complete */
sem_wait(&bleAdv);
/* disable Advertisement */
bleStatus = BLEAppUtil_invokeFunctionNoData(appDisableBle);
if (SUCCESS == bleStatus)
{
/* Wait for Disable advertisement operation to complete */
sem_wait(&blesem);
}
sleep(5);
End loop <repeated Ble Transimssion>
Advertisement Handler
void Broadcaster_AdvEventHandler(uint32 event, BLEAppUtil_msgHdr_t *pMsgData)
{
BLEAppUtil_AdvEventData_t *advData = (BLEAppUtil_AdvEventData_t*) pMsgData;
static uint8_t i=0;
static uint8_t j=0;
bStatus_t status;
uint8_t debug1 = 0;
uint8_t debug2 = 0;
switch (event)
{
case BLEAPPUTIL_ADV_START_AFTER_ENABLE:
{
debug1 = advData->pBuf->advHandle;
break;
}
case BLEAPPUTIL_ADV_END_AFTER_DISABLE:
{
debug2 = advData->pBuf->advHandle;
break;
}
case BLEAPPUTIL_ADV_END:
{
if (bleDataAvailable)
{
for (i = 0; i < B_ADDR_LEN; i++)
{
advData1[i + USER_ADV_DATA_OFFSET] = data[i];
}
for (j = 0; j < bleDataLength; j++)
{
advData1[i + USER_ADV_DATA_OFFSET] = bleDataarr[j];
i++;
}
for (j = i; j < sizeof(advData1); j++)
{
advData1[j + USER_ADV_DATA_OFFSET] = 0x00;
}
bleDataAvailable = 0;
GapAdv_prepareLoadByHandle(broadcasterAdvHandle_1,
GAP_ADV_FREE_OPTION_DONT_FREE);
GapAdv_loadByHandle(broadcasterAdvHandle_1, GAP_ADV_DATA_TYPE_ADV,
sizeof(advData1), advData1);
sem_post(&bleAdv);
}
break;
}
default:
{
break;
}
}
}
Thanks
Ilanchezhian T