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

no mfg data during scan response when bt_data_parse

Hello,
the device name is being parsed ok, but the mfg data in scan response seems to be there but not sure how to print it out.
Using ncs bt sample direction_finding_connectionless_rx modified for nRF52840DK since it was using bt_le_scan_recv_info and bt_data_parse.
The nrf terminal is showing the name for Thingy-1, but not the output for mfg of data_len 6 during case BT_DATA_MANUFACTURER_DATA.

How best to get mfg data in scan response?
(based on case, https://devzone.nordicsemi.com/f/nordic-q-a/84753/scan-and-parse-manufacturer-specific-data-zephyr/353172#353172)

thank-you,

Parents
  • Hello,

    I believe you already have the manufacturer data in your scan response, but you are trying to print it as if it was a character string (which a name will be, but the manufacturer data is probably not that). 

    Try to do something like:

    As mentioned, the manufacturer data is not necessarily a character string, so you need to know up front what the manufacturer data represents, as it is completely proprietary. Perhaps it is a measured temperature, the advertised TX Power, or something completely else.

    Best regards,

    Edvin

  • That's how,...ok.

    If I could add here BT_SCAN_NAME_FILTER from this case,
    https://devzone.nordicsemi.com/f/nordic-q-a/79991/ble-scan-filter-by-device-name/331924

    A name filter is set in scan_init, but BT_DATA_NAME_COMPLETE in data_cb is picking up other devices than what is filtered.

    I tested BT_SCAN_NAME_FILTER with central_uart and peripheral_uart filtering for Nordic_UART_Service and Thingy-1, and central_uart only connected when name Filters matched.

    Checking to confirm that data_cb is in fact separate from what is set in scan_init and will process all devices regardless of what is filtered, or that data_cb should be part of the filter and for some reason is not filtering?

    thank-you,

  • Hello,

    There are still some very important differences between the central_uart sample and your setup with regards to filtering. 

    First, a minor detail:

    in scan_init() in the central_uart sample, you can see that it says .connfect_if_match = 1, so this means that when the filter is matched, then it will connect to that peripheral. 

    Then, there is a difference in how the callbacks are set up.

    You use bt_le_scan_cb_register() to register the .recv. This callback will trigger on every scan event. What you probably want to do is to create a filter_match callback. Look at how this is done in the central_uart sample:

    So the macto BT_SCAN_CB_INIT() creates a callback struct called scan_cb, with several callback functions. scan_filter_match, which will trigger whenever there is a filter match, scan_connecting_error which will trigger if they can't connect, and scan_connecting which will trigger upon connection. In case you want a callback when you don't have a filter match, but receive an advertising report, you can insert that instead of the "NULL" in BT_SCAN_CB_INIT().

    The filter match callback is on this form:

    So replace "(*filter_match)" with the name you want to use for the callback function, and implement it in your main.c. You can see how this is done i the central_uart sample.

    Best regards,

    Edvin

  • Originally an attempt was made to use scan_filter_match to filter beacon like devices and read the scan response.
    But scan_filter_match did not seem to have any access to scan response and mfg data.
    Also it seems that scan_filter_match is a one off,
    unlike something like .recv which can read new advertised data "on every scan event".
    A filter is setup in BT_DATA_MANUFACTURER_DATA to search for unique bytes in the scan response,
    which seems to be working ok.
    Wanted to double check if scan_filter_match could be a better way.

    thank-you,

  • I guess it doesn't really matter how you do it. The filter match events are just generated whenever an advertisement matched the filter. If you use the built in filters, or create a filter manually wouldn't really make a difference for preformance, so if you have something that is working, I see no need for changing that.

    BR,
    Edvin

  • ok, ....thank-you,

Reply Children
No Data