Psoc6 BLE Advertisement Packet

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

cross mob
lola_1650581
Level 3
Level 3
First like received

Hi all:

    About the manufacturer specific data of the Advertisement Packet,the company  is showed which must be the member of bluetooth SIG?

0 Likes
1 Solution

Hi msur:

    Thanks.Another question about the advertisement packet and the scan response packet. I added the following code in the CE220167:

cy_stc_ble_gapp_disc_mode_info_t advDataInfo;

cy_stc_ble_gapp_disc_data_t advdata={

0x07,0x08,0x65,0x65,0x65,0x65,0x65,0x65,\

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\

0x08   

};

cy_stc_ble_gapp_scan_rsp_data_t scanRspData={

0x07,0x08,0x65,0x65,0x65,0x65,0x65,0x65,\

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\

0x08   

};  

cy_stc_ble_gapp_disc_mode_info_t *aPadvDataInfo;

void isrGPIO(void)

{

    /* Clear the GPIO interrupt*/

    Cy_GPIO_ClearInterrupt(Advertise_0_PORT,Advertise_0_NUM);

    NVIC_ClearPendingIRQ(isr_gpio_cfg.intrSrc); 

   

    /* Restart BLE advertisement */

    RestartBleAdvertisement();

    advDataInfo.advData=&advdata;

    advDataInfo.scanRspData=&scanRspData;

    aPadvDataInfo=&advDataInfo;

    Cy_BLE_GAPP_UpdateAdvScanData(aPadvDataInfo);

}

I use the "Cy_BLE_GAPP_UpdateAdvScanData "function to update the advertisement and scan response data.However I found that in the first time to wake up from the DS mode the advertisement and scan response data can't update.

pastedImage_0.png

However the data will be update if I press the key SW2 once more.

pastedImage_1.png

The advertisement and scan response data change to the initialization data after the chip wake up from DS mode or a rest handle.

I want to know that  the why the "Cy_BLE_GAPP_UpdateAdvScanData "function can't work at the first time?And if the customer want to change the advertisement and scan response data by the user application and can work immediately and also can work after wake up from DS mode or a rest handle ,How can I do?Can I change the initialization data  of the advertisement and scan response data by the user code?

View solution in original post

0 Likes
12 Replies
MeenakshiR_71
Employee
Employee
100 likes received 50 likes received 25 likes received

Hello 769482734_1650581​,

Yes, the company need to be a good standing member of the Bluetooth SIG. Refer this page for details - https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers

Regards,

Meenakshi Sundaram R

0 Likes

Hi msur:

    If the Psoc6 BLE Advertisement Packet  don't contain the "Local Name",the master can show it ?

pastedImage_2.png

  As show in the picture.However it will not show in the CySmart if  the "Local Name" is't included in the  Advertisement Packet .

pastedImage_3.png

pastedImage_4.png

   The customer want to know why and how to achieve it. Can you help me please?

0 Likes

The peripheral need to include the local name in either the advertisement or the scan response packet for the central/master to display it in the devices list.

If the slave/peripheral uses a connectable/scannable advertisement, then Master/Central can receive two advertisement related packets (i.e. packets without a connection) - one is an advertisement and another is a scan response packet.

Both these packets are 31 bytes of size and Advertisement packet is what is broadcasted by the device to all. Scan response is the packet that is sent to a central device on request (as the name indicates, it is a response to a scan request). Typically, advertisement packets contain less data (as it is sent out more frequently), whereas Scan response packets have more data and many vendors choose scan response for device names, if name is big or if they want to save power sending advertisement data.

It should be noted that most of the central devices available with us like phones and dongles, perform active scanning and always request the scan response packet. Hence, even if the advertisement packet does not contain the device's name and if its scan response includes, then the name will be known to the central device after a scan response from the peripheral.

pastedImage_0.png

Let me know if this answers your query.

Regards,

Meenakshi Sundaram R

0 Likes

Hi msur:

    Thanks.Another question about the advertisement packet and the scan response packet. I added the following code in the CE220167:

cy_stc_ble_gapp_disc_mode_info_t advDataInfo;

cy_stc_ble_gapp_disc_data_t advdata={

0x07,0x08,0x65,0x65,0x65,0x65,0x65,0x65,\

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\

0x08   

};

cy_stc_ble_gapp_scan_rsp_data_t scanRspData={

0x07,0x08,0x65,0x65,0x65,0x65,0x65,0x65,\

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\

0x08   

};  

cy_stc_ble_gapp_disc_mode_info_t *aPadvDataInfo;

void isrGPIO(void)

{

    /* Clear the GPIO interrupt*/

    Cy_GPIO_ClearInterrupt(Advertise_0_PORT,Advertise_0_NUM);

    NVIC_ClearPendingIRQ(isr_gpio_cfg.intrSrc); 

   

    /* Restart BLE advertisement */

    RestartBleAdvertisement();

    advDataInfo.advData=&advdata;

    advDataInfo.scanRspData=&scanRspData;

    aPadvDataInfo=&advDataInfo;

    Cy_BLE_GAPP_UpdateAdvScanData(aPadvDataInfo);

}

I use the "Cy_BLE_GAPP_UpdateAdvScanData "function to update the advertisement and scan response data.However I found that in the first time to wake up from the DS mode the advertisement and scan response data can't update.

pastedImage_0.png

However the data will be update if I press the key SW2 once more.

pastedImage_1.png

The advertisement and scan response data change to the initialization data after the chip wake up from DS mode or a rest handle.

I want to know that  the why the "Cy_BLE_GAPP_UpdateAdvScanData "function can't work at the first time?And if the customer want to change the advertisement and scan response data by the user application and can work immediately and also can work after wake up from DS mode or a rest handle ,How can I do?Can I change the initialization data  of the advertisement and scan response data by the user code?

0 Likes

I do not expect any issue with "Cy_BLE_GAPP_UpdateAdvScanData(aPadvDataInfo);" API. Just make sure, the API returns CY_BLE_SUCCESS and you call Cy_BLE_ProcessEvents() after that. This will initiate the advertisement/scan response data update and once complete, you will receive "CY_BLE_EVT_GAPP_UPDATE_ADV_SCAN_DATA_COMPLETE" event in the EventHandler.

Try these and let me know if this helps. I can try out your code tomorrow to see if there are any issues.

0 Likes

Hi msur:

    As you say ,I add the Cy_BLE_ProcessEvents() after that.However it seem not work.

   The API returns CY_BLE_SUCCESS and the "CY_BLE_EVT_GAPP_UPDATE_ADV_SCAN_DATA_COMPLETE" event happened.

   But after the advertisement time out happened ,I press the "SW2" key ,the advertisement and scan response data can't not be update:

pastedImage_0.png

   However if I press the "SW2" key one more:

pastedImage_1.png

   A more question I found the the advertisement/scan response data update  back to the initialization data automatically even the time out not happened.

   Can you help me to check it?pastedImage_3.png

0 Likes

I think I get your issue.

Please do the below -

1. Before calling the UpdateAdvScanData(), make sure your BLE configuration data points to the updated adv and scan response data that you want. You can use the below line of code for that.

        cy_ble_configPtr->discoveryModeInfo[CY_BLE_PERIPHERAL_CONFIGURATION_0_INDEX].advData = &advdata;

        cy_ble_configPtr->discoveryModeInfo[CY_BLE_PERIPHERAL_CONFIGURATION_0_INDEX].scanRspData = &scanRspData;

2. Call UpdateAdvScanData API as shown below -

       Cy_BLE_GAPP_UpdateAdvScanData(&cy_ble_configPtr->discoveryModeInfo[CY_BLE_PERIPHERAL_CONFIGURATION_0_INDEX]);

3. Make sure step 2 returns success, call ProcessEvents and once CY_BLE_EVT_GAPP_UPDATE_ADV_SCAN_DATA_COMPLETE event happens, the scan/adv data should be updated from the current advertisement packet.

Now everytime you call StartAdvertisement after timeout with CY_BLE_PERIPHERAL_CONFIGURATION_0_INDEX, your advertisement will use the new data.

Let me know if this fixes the issue.

Regards,

Meenakshi Sundaram R

0 Likes

Hi musr:

    I think it's not work:

    If I add the code at the here as follow:

    pastedImage_0.png

it can work at the first time pressing the key SW2.

pastedImage_2.png

However something strange happened  on my second time pressing the key when the advertisement  time out happened is that the BLESS can't advertising :

pastedImage_1.png

In addition the code seem can work only here.If I add the code in the position as follow:

pastedImage_4.png

The advertisement can't  work  directly after the power on:pastedImage_5.png

The advertisement/scan response data update  be added is there a position limit?

Can you help me check it please ,thanks.

0 Likes

I just noticed that the advertisement data you are trying to update is invalid, please use the below for proper operation (basically start advertisement returns INVALID_PARAM using the advData you provided in the earlier post).

cy_stc_ble_gapp_disc_data_t advdata={0x02u, 0x01u, 0x05u, //Required for Advertisement

0x07,0x09,0x65,0x65,0x65,0x65,0x65,0x65, //Second byte on this denotes 'Local Name' and it should be 0x09 and not 0x08 used in your data

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\

0x0B 

};

cy_stc_ble_gapp_scan_rsp_data_t scanRspData={

0x07,0x09,0x65,0x65,0x65,0x65,0x65,0x65,\

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\

0x08 

};

Please use the above advertisement and scan response data. It worked in my code.

Note that if the advertisement has not started, then do not call Cy_BLE_GAPP_UpdateAdvScanData() API. As StartAdvertisement API will call it anyway. The Cy_BLE_GAPP_UpdateAdvScanData() should be called only when you are already advertising to update the advertisement parameters.

So the below code is good enough -

/* Check if the advertisement needs to be restarted */

        if(restartBleAdvertisement)

        {

            /* Reset 'restartBleAdvertisement' flag */

            restartBleAdvertisement = false;

          

            cy_ble_configPtr->discoveryModeInfo[CY_BLE_PERIPHERAL_CONFIGURATION_0_INDEX].advData = &advdata;

            cy_ble_configPtr->discoveryModeInfo[CY_BLE_PERIPHERAL_CONFIGURATION_0_INDEX].scanRspData = &scanRspData;

                      

            /* Start Advertisement and enter discoverable mode */

            Cy_BLE_GAPP_StartAdvertisement

             (CY_BLE_ADVERTISING_FAST,CY_BLE_PERIPHERAL_CONFIGURATION_0_INDEX);  

        }

Let me know if this helps.

Regards,

Meenakshi Sundaram R

0 Likes

Hi musr:

    I found that it seem can not update the advertisement data immediately.

    In the isrGPIO function ,I add some the code as follow:

pastedImage_1.png

   However when I press the SW2 key ,the advertisement data will change in about 13 minutes later.

  

  

0 Likes
lock attach
Attachments are accessible only for community members.

Hi,

Please test the attached project.

The devices advertises as "BLE UI" on reset and if switch is pressed and it is still advertising, I change the name to "iiiii". If it is not advertising when switch is pressed, then I change the name to "eeeee" and start advertisement. I removed the RestartAdvertisement API as it was not required. I checked in CySmart App and it works fine.

Let me know if this clarifies your understanding.

Regards,

Meenakshi Sundaram R

0 Likes

Hi musr:

    I'm so sorry to got the wrong units,is the advertisement data will change in about 13 seconds later

0 Likes