How to update Manufacturer Specific Data like RSSI and display it on the serial terminal?

This thread serves as reference for follow up from How to display manufacturer-specific data on peripheral devices that are scanning advertisements?

When using peripheral with sensor which can update its data to the manufacture part in advertising payload, the advertising payload can be updated in two ways:

  1. Cancel advantage and update the payload and then start advertising.
  2. In the advertising mode, use GAPM_UPDATE_ADVERTISE_DATA_CMD to
    update advertising payload.

Hi @twc024600,

To change the Manufacturer Specific Data that is being displayed on the UART of the ble_central_scan sample application developed in thread How to display manufacturer-specific data on peripheral devices that are scanning advertisements? please have a look into the void SCAN_AdvReportInd_Handler() function, within app_scan.c, outlined below:

void SCAN_AdvReportInd_Handler(const struct gapm_adv_report_ind *p)
{
    for (uint8_t i = 0; i < adv_report_list_size + 1; i++)
    {
        /* Check if the address is already in the list. If so update RSSI */
        if(!memcmp(p->report.adv_addr.addr, adv_report_list[i].adv_addr.addr, BD_ADDR_LEN))
        {
            adv_report_list[i].rssi = p->report.rssi;
            return;
        }
    }

    if(adv_report_list_size < ADV_REPORT_LIST_MAX)
    {
        /* Add adv report to the list, sorted by RSSI */
        memcpy(&adv_report_list[adv_report_list_size], &(p->report), sizeof(adv_report_t));

        /* Search payload for short name or name and update name field */
        SCAN_AdvReport_ExtractName(p->report.data, p->report.data_len, adv_report_list[adv_report_list_size].data);

        /* Search payload for short name or name and update name field */
        SCAN_AdvReport_ExtractManuSpecificData(p->report.data, p->report.data_len, manu_specific_info[adv_report_list_size]);

        adv_report_list_size++;
    }

This handler is called each time a new Advertisement packet is received, and constructs/manages the list array of advertising data that will be displayed over UART. It can be seen in the following portion, that the function will look through the existing list for a matching BLE Address, and if found, will simply update only the RSSI, and ignore all other information and exit the function:

    for (uint8_t i = 0; i < adv_report_list_size + 1; i++)
    {
        /* Check if the address is already in the list. If so update RSSI */
        if(!memcmp(p->report.adv_addr.addr, adv_report_list[i].adv_addr.addr, BD_ADDR_LEN))
        {
            adv_report_list[i].rssi = p->report.rssi;
            return;
        }
    }

By editing the code to also update the Manufacture Data, if the BLE Address exists in the list, you can achieve the desired functionality. Please see the required change below:

    for (uint8_t i = 0; i < adv_report_list_size + 1; i++)
    {
        /* Check if the address is already in the list. If so update RSSI */
        if(!memcmp(p->report.adv_addr.addr, adv_report_list[i].adv_addr.addr, BD_ADDR_LEN))
        {
            adv_report_list[i].rssi = p->report.rssi;

            memset(&manu_specific_info[i], 0, GAP_ADV_DATA_LEN);
            SCAN_AdvReport_ExtractManuSpecificData(p->report.data, p->report.data_len, manu_specific_info[i]);

            return;
        }
    }

Thank you for using our Community Forum.

Hi,
Thanks for you answer.
This description give me useful help.

It is successful that the manufacturer-specific data can be updated and displayed on the serial terminal.

Thank you.

Hi,

You are welcome.

Thank you for using our Community Forum.