- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am trying to broadcast counter value. You can see BLE configuration below:
In the picture, as you can see there is "Data" bar. I tried to change its value from the code using "cy_ble_discoveryModeInfo->advData->advData[28] = newData" and "Cy_BLE_GAPP_UpdateAdvScanData(cy_ble_discoveryModeInfo)".
How can I do this and where should I write related code pieces in my main file?
Thanks a lot!
Solved! Go to Solution.
- Tags:
- ble beacon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
As you can see from our documentation (Cypress PSoC 6 Bluetooth Low Energy Middleware Library 3.50: More Information (cypresssemiconductorc...), the event CY_BLE_EVT_GAPP_UPDATE_ADV_SCAN_DATA_COMPLETE is generated after calling the API Cy_BLE_GAPP_UpdateAdvScanData(). But, as per your code, you will call this API only after you receive CY_BLE_EVT_GAPP_UPDATE_ADV_SCAN_DATA_COMPLETE event.
Could you please modify your main() function as below and see if it resolves your issue? (Also, remove the call to Cy_BLE_GAPP_UpdateAdvScanData() from the event CY_BLE_EVT_GAPP_UPDATE_ADV_SCAN_DATA_COMPLETE ).
int main(void)
{
cy_en_ble_api_result_t apiResult;
__enable_irq();
apiResult = Cy_BLE_Start(StackEventHandler);
CY_ASSERT(apiResult == CY_BLE_SUCCESS);
for(;;)
{
/* Place your application code here. */
Cy_BLE_ProcessEvents();
if(Cy_BLE_GetAdvertisementState() == CY_BLE_ADV_STATE_ADVERTISING)
{
if(Cy_BLE_StackGetBleSsState() == CY_BLE_BLESS_STATE_EVENT_CLOSE)
{
/* Updating the ADV and SCAN Response data */
cy_ble_discoveryModeInfo->advData->advData[5]='A';
cy_ble_discoveryModeInfo->scanRspData->scanRspData[5]='S';
/* Updating the ADV and SCAN Response data */
Cy_BLE_GAPP_UpdateAdvScanData(cy_ble_discoveryModeInfo);
}
}
}
}
Thanks and Regards,
Sudheesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello BeKA_4795986 ,
After advertisement start, you can use Cy_BLE_GAPP_UpdateAdvScanData API functoin for setting the advertisement and scan response data while advertising is ongoing. On completion of this operation, the GAP Peripheral application receives the CY_BLE_EVT_GAPP_UPDATE_ADV_SCAN_DATA_COMPLETE event. This API function must be called when Cy_BLE_StackGetBleSsState() returns the CY_BLE_BLESS_STATE_EVENT_CLOSE state. See the following sample code segment:
************************************************************************
if(Cy_BLE_GetAdvertisementState() == CY_BLE_ADV_STATE_ADVERTISING)
{
if(Cy_BLE_StackGetBleSsState() == CY_BLE_BLESS_STATE_EVENT_CLOSE)
{
/* Updating the ADV and SCAN Response data */
cy_ble_discoveryModeInfo->advData->advData[5]='A';
cy_ble_discoveryModeInfo->scanRspData->scanRspData[5]='S';
/* Updating the ADV and SCAN Response data */
Cy_BLE_GAPP_UpdateAdvScanData(cy_ble_discoveryModeInfo);
}
}
************************************************************************
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Yugandhar,
I am very appreciate to your answer. I would like to share my code with you. Still, I am doing something wrong...
void StackEventHandler(uint32_t event, void *eventParam)
{
switch(event) {
case CY_BLE_EVT_STACK_ON:
case CY_BLE_EVT_GAP_DEVICE_DISCONNECTED:
Cy_BLE_GAPP_StartAdvertisement(CY_BLE_ADVERTISING_FAST, CY_BLE_BROADCASTER_CONFIGURATION_0_INDEX);
Cy_BLE_GAPP_UpdateAdvScanData(cy_ble_discoveryModeInfo); //?
Cy_GPIO_Write(Pin_1_PORT,Pin_1_NUM,1);
break;
case CY_BLE_EVT_GAPP_UPDATE_ADV_SCAN_DATA_COMPLETE:
if(Cy_BLE_GetAdvertisementState() == CY_BLE_ADV_STATE_ADVERTISING)
{
if(Cy_BLE_StackGetBleSsState() == CY_BLE_BLESS_STATE_EVENT_CLOSE)
{
/* Updating the ADV and SCAN Response data */
cy_ble_discoveryModeInfo->advData->advDataLen = 1;
cy_ble_discoveryModeInfo->advData->advData[28]=count++;
//cy_ble_discoveryModeInfo->scanRspData->scanRspData[5]='S';
/* Updating the ADV and SCAN Response data */
Cy_BLE_GAPP_UpdateAdvScanData(cy_ble_discoveryModeInfo);
}
}
break;
case CY_BLE_EVT_TIMEOUT:
Cy_GPIO_Write(Pin_1_PORT,Pin_1_NUM,0);
break;
default:
break;
}
}
int main(void)
{
cy_en_ble_api_result_t apiResult;
__enable_irq();
apiResult = Cy_BLE_Start(StackEventHandler);
CY_ASSERT(apiResult == CY_BLE_SUCCESS);
for(;;)
{
/* Place your application code here. */
Cy_BLE_ProcessEvents();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
As you can see from our documentation (Cypress PSoC 6 Bluetooth Low Energy Middleware Library 3.50: More Information (cypresssemiconductorc...), the event CY_BLE_EVT_GAPP_UPDATE_ADV_SCAN_DATA_COMPLETE is generated after calling the API Cy_BLE_GAPP_UpdateAdvScanData(). But, as per your code, you will call this API only after you receive CY_BLE_EVT_GAPP_UPDATE_ADV_SCAN_DATA_COMPLETE event.
Could you please modify your main() function as below and see if it resolves your issue? (Also, remove the call to Cy_BLE_GAPP_UpdateAdvScanData() from the event CY_BLE_EVT_GAPP_UPDATE_ADV_SCAN_DATA_COMPLETE ).
int main(void)
{
cy_en_ble_api_result_t apiResult;
__enable_irq();
apiResult = Cy_BLE_Start(StackEventHandler);
CY_ASSERT(apiResult == CY_BLE_SUCCESS);
for(;;)
{
/* Place your application code here. */
Cy_BLE_ProcessEvents();
if(Cy_BLE_GetAdvertisementState() == CY_BLE_ADV_STATE_ADVERTISING)
{
if(Cy_BLE_StackGetBleSsState() == CY_BLE_BLESS_STATE_EVENT_CLOSE)
{
/* Updating the ADV and SCAN Response data */
cy_ble_discoveryModeInfo->advData->advData[5]='A';
cy_ble_discoveryModeInfo->scanRspData->scanRspData[5]='S';
/* Updating the ADV and SCAN Response data */
Cy_BLE_GAPP_UpdateAdvScanData(cy_ble_discoveryModeInfo);
}
}
}
}
Thanks and Regards,
Sudheesh