Dynamic Advertising for Peripheral's local name?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
PaDo_1228851
Level 3
Level 3
25 replies posted 10 replies posted 10 questions asked

I want the iOS central's user to able to select the contents of any of several characteristics (always 19 char in length) as the peripheral's local name displayed in the Advertising Data during a scan.  From what I've read in this forum I've come up with the following code whose function is supposed to take whatever 19 char string is written to the CYBLE_TOW_SERVICE_UPDATE_AD_DATA_CHAR_HANDLE characteristic and make it become the new local name AND update the advertising data with same:

   

________________________

   

Stack_Handler( uint32 eventCode, void *eventParam )

   

{

   

CYBLE_GATTS_WRITE_REQ_PARAM_T *wrReqParam;

   

switch ( eventCode )

   

{

   

case CYBLE_EVT_STACK_ON:

   

.

   

.

   

.

   

.

   

case CYBLE_EVT_GATTS_WRITE_REQ:

   

     wrReqParam = (CYBLE_GATTS_WRITE_REQ_PARAM_T *)eventParam;

   

     switch ( wrReqParam->handleValPair.attrHandle )

   

   {

   

    case CYBLE_TOW_SERVICE_UPDATE_AD_DATA_CHAR_HANDLE:

   

    CyBle_GattsWriteAttributeValue( &wrReqParam->handleValPair, 0, &connectionHandle, CYBLE_GATT_DB_LOCALLY_INITIATED);

   

   CyBle_GattsWriteRsp(connectionHandle);

   

   uint8 newName[19];

   

   sensorNameHandle.attrHandle = CYBLE_TOW_SERVICE_UPDATE_AD_DATA_CHAR_HANDLE;

   

   sensorNameHandle.value.val = newName;

   

   sensorNameHandle.value.len = 19;

   

   CyBle_GattsReadAttributeValue(&sensorNameHandle,&connectionHandle, CYBLE_GATT_DB_LOCALLY_INITIATED);

   

   int i;

   

  for(i=0; i<19; i++){

   

  cyBle_discoveryData.advData[i+5] = newName;

   

  }

   

   cyBle_discoveryData.advDataLen = 19;

   

  CyBle_GapSetLocalName((char *)newName);

   

  CyBle_GapUpdateAdvData(cyBle_discoveryModeInfo.advData, cyBle_discoveryModeInfo.scanRspData);

   

  break;

   

__________________________________________

   

The perpheral's chracteristic CYBLE_TOW_SERVICE_UPDATE_AD_DATA_CHAR_HANDLE can be written to without problem but the local name and advertising data don't update.

   

Any pointers greatly appreciated.  Thanks.

0 Likes
1 Reply
Anonymous
Not applicable

What are you using to test on the client side? iOS caches certain things, particularly the device name after connecting and discovering the server's GATT structure. Can you perform the scan and connect/update tests using the CySmart dongle and software, which don't cache any values? This will also give you a complete byte-for-byte look at exactly what is in the advertisement payload.

0 Likes