1 Reply Latest reply on Nov 1, 2016 6:37 AM by jrow

    Dynamic Advertising for Peripheral's local name?


      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 )






      switch ( eventCode )




      case CYBLE_EVT_STACK_ON:












           wrReqParam = (CYBLE_GATTS_WRITE_REQ_PARAM_T *)eventParam;


           switch ( wrReqParam->handleValPair.attrHandle )






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




         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[i];




         cyBle_discoveryData.advDataLen = 19;


        CyBle_GapSetLocalName((char *)newName);


        CyBle_GapUpdateAdvData(cyBle_discoveryModeInfo.advData, cyBle_discoveryModeInfo.scanRspData);






      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.

        • 1. Re: Dynamic Advertising for Peripheral's local name?

          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.