You are here

Dynamic Advertising for Peripheral's local name? | Cypress Semiconductor

Dynamic Advertising for Peripheral's local name?

Summary: 1 Reply, Latest post by jrow on 01 Nov 2016 06:37 AM PDT
Verified Answers: 0
Last post
Log in to post new comments.
Pat Dolan's picture
User
28 posts

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

  }

   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.

 

jrow's picture
Cypress Employee
37 posts

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.

Log in to post new comments.