Closed brain113 closed 1 year ago
Hi brain112,
GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData), advertData);
This function is designed to be called in the initialization state,so it may cause status errors when called in other stages.
You can use this function to update the advertising data:
/**
* @brief Setup or change advertising and scan response data.
*
* @note if the return status from this function is SUCCESS,the task isn't complete
* until the GAP_ADV_DATA_UPDATE_DONE_EVENT is sent to the calling application task.
*
* @param taskID - task ID of the app requesting the change
* @param adType - TRUE - advertisement data, FALSE - scan response data
* @param dataLen - Octet length of advertData
* @param pAdvertData - advertising or scan response data
*
* @return SUCCESS: data accepted
* bleIncorrectMode: invalid profile role
*/
extern bStatus_t GAP_UpdateAdvertisingData( uint8_t taskID, uint8_t adType, uint16_t dataLen, uint8_t *pAdvertData );
This function wiil send a message to a valid taskID
, if you use the Peripheral_TaskID
, you can handle the message here:
static void Peripheral_ProcessGAPMsg(gapRoleEvent_t *pEvent)
{
switch(pEvent->gap.opcode)
{
case GAP_ADV_DATA_UPDATE_DONE_EVENT:
PRINT("%s data update status: %#x\n",
pEvent->dataUpdate.adType ? "adv" : "scan", pEvent->dataUpdate.hdr.status);
break;
...
Hi zerosensei, This works! Thank you!
Dear OpenWCH team. I'm designing peripherial device that should keep advettisement when connected. I found that updating GAPROLE_ADVERT_DATA parameter in connected and advertised mode causes change of GAP state from GAPROLE_CONNECTED_ADV to GAPROLE_ADVERTISING, but actually device keep to be connected and advertised.
How to reproduce with BLE_LIB 1.7: In Peripheral example add the following
to the end of performPeriodicTask() function. And add the following
to the end of Peripheral_LinkEstablished(...) func.
Now if you connected to the device, it reports GAPROLE_STATE: 5 in console. (GAPROLE_CONNECTED_ADV state). This is OK.
Next, add the following
GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData), advertData);
to the very end of performPeriodicTask() function (after printing added earlier).Now if you connected to the device, it reports GAPROLE_STATE: 2. (GAPROLE_ADVERTISING). So, GAP role state was changed by updateing data to advertise. My expectation is that updating the adv data should not affect to GAP state.