This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

scan and parse manufacturer specific data (zephyr)

Hi. 

Hope someone could help me on how to scan and parse the Manufacturer Specific Data that comes after the Company ID. I am using zephyr with nRF52840.

Thanks!

  • Hi

    First off, is the central device going to connect to the peripheral device or will it just be a scanner retrieving advertising data from nearby peripherals? Have you added the manufacturer specific data as part of the advertising data in your peripheral application? 

    The best way to parse advertising data is to use the bt_data_parse() helper function on the received adv data given to the bt_le_scan_cb_t callback. You can check out the central_hr sample project for an example on how this function can be used.

    Best regards,

    Simon

  • It will just be a scanner retrieving the advertising data. I have used the function bt_data_parse() but I still cannot get the Manufacturer Data. 

  • Hi

    What do you see on the central side when the bt_data_parse() when using the "ad" parameter that is supposed to parse the advertising data as given to the bt_le_scan_cb_t callback? Do you print this data so you should be able to see the advertising data on a terminal for example? And are you certain that the advertising device is transmitting its manufacturer specific data? As far as I know, the bt_data_parse function should be the way to help you see additional advertiisng data.

    Best regards,

    Simon

  • What I am trying to do is in this thread: https://devzone.nordicsemi.com/f/nordic-q-a/58478/parsing-adv-data---manufacturer-data-parsing 

    But the difference is that I am using zephyr. The screenshot that he presented was accurate. I want also to parse the same data. The above thread was also not answered. 

    I am sure that the advertising devices are transmitting manufacturer specific data. 

    Yes. I print the data using a the terminal but it is garbage data. 

    Best regards,

    Oli

  • Hi

    My colleague has provided you with what should be a working example in your private ticket, and has requested that you continue the discussion there.

    For any other DevZone users finding this thread, modify the Zephyr beacon sample accordingly:

    static char mfg_data[] = "simon_manuf";
    
    static const struct bt_data ad[] = {
    	BT_DATA(BT_DATA_MANUFACTURER_DATA, mfg_data, sizeof(mfg_data)),
    };

    Program that onto I.E. an nRF52840 DK or Dongle, then modify the observer sample like this and program that onto another DK:

    static bool data_cb(struct bt_data *data, void *user_data)
    {
    	char *name = user_data;
    	uint8_t len;
    
    	switch (data->type) {
    	case BT_DATA_MANUFACTURER_DATA:
    		len = MIN(data->data_len, NAME_LEN - 1);
    		memcpy(name, data->data, len);
    		name[len] = '\0';
    		return false;
    	default:
    		return true;
    	}
    }

    Best regards,

    Simon

Related