This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to read manufacturer specific data

Hi, i'm working a BLE gateway with NRF52DK and S132 by using the demo example central uart.

The peripheral equipement advertise manufacturer data like this: 0x0001 during 5sec then 0x0002 during 5 sec and stop advertise.

But I want my gateway can only connect if the device advertise 0x0002 and not 0x0001.

So my question is how to get the manufacturer specific data in ble_app_uart_c ?

Thanks you for your answers !

Parents
  • Hi,

    You can check if manufacturer specific data is present in the advertising report using the function adv_report_parse(BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA,&adv_data, &dev_name), which is defined in the BLE Multi-link example. If found, the length and pointer to data will be stored in the argument dev_name.

    Best regards,

    Jørgen

  • Hi Jorgen,

    I am using SDK 15.2.0, and I have the same query to display the manufacturer specific data.

    I could not find the function adv_report_parse(BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA,&adv_data, &dev_name in the Multi-link example.

    Thanks

  • There was a new scanner module introduced in SDK 15.2.0, that use filters to only pass devices that fit the filter parameter to the handler. You will have to remove the scanner module and use the old method if you want to display any Manufacturer specific data. You might be better off with porting the example from SDK 15.0.0, where the module was not used.

  • Do you mean that there is not API that can parse a scan data in new SDK like SDK 15.3 for a manufacturer data ?

  • The filter feature only supports the following types:

    /**@brief Types of filters.
     */
    typedef enum
    {
        SCAN_NAME_FILTER,       /**< Filter for names. */
        SCAN_SHORT_NAME_FILTER, /**< Filter for short names. */
        SCAN_ADDR_FILTER,       /**< Filter for addresses. */
        SCAN_UUID_FILTER,       /**< Filter for UUIDs. */
        SCAN_APPEARANCE_FILTER, /**< Filter for appearances. */
    } nrf_ble_scan_filter_type_t;

  • This is for 15.3.0, but you might find it helpful:

    // Scan Events
    static char * ble_scan_event_description[] =
    {
    /* NRF_BLE_SCAN_EVT_FILTER_MATCH",        */ " 0 Filter matched in the multifilter mode",
    /* NRF_BLE_SCAN_EVT_WHITELIST_REQUEST:    */ " 1 Request the whitelist from the main application",
    /* NRF_BLE_SCAN_EVT_WHITELIST_ADV_REPORT: */ " 2 Device from the whitelist is found",
    /* NRF_BLE_SCAN_EVT_NOT_FOUND:            */ " 3 Filter not matched for the scan data",
    /* NRF_BLE_SCAN_EVT_SCAN_TIMEOUT:         */ " 4 Scan timeout",
    /* NRF_BLE_SCAN_EVT_SCAN_REQ_REPORT:      */ " 5 Scan request report",
    /* NRF_BLE_SCAN_EVT_CONNECTING_ERROR:     */ " 6 Error occurred when establishing the connection from sd_ble_gap_connect",
    /* NRF_BLE_SCAN_EVT_CONNECTED:            */ " 7 Connected to device"
    };
    #define NUM_BLE_SCAN_EVENTS (sizeof(ble_scan_event_description)/sizeof(ble_scan_event_description[0]))
    /**@brief Function for handling Scanning Module events.
     */
    static void scan_evt_handler(scan_evt_t const * p_scan_evt)
    {
        ret_code_t err_code;
    
        switch(p_scan_evt->scan_evt_id)
        {
             case NRF_BLE_SCAN_EVT_CONNECTING_ERROR:     // Error occurred when establishing the connection. In this event, an error is passed from the function call @ref sd_ble_gap_connect
             {
                  err_code = p_scan_evt->params.connecting_err.err_code;
                  APP_ERROR_CHECK(err_code);
             } break;
    
             case NRF_BLE_SCAN_EVT_CONNECTED:            // Connected to device
             {
                  ble_gap_evt_connected_t const * p_connected = p_scan_evt->params.connected.p_connected;
                 // Scan is automatically stopped by the connection.
                 NRF_LOG_INFO("Connect to Id %02x%02x%02x%02x%02x%02x",
                          p_connected->peer_addr.addr[0],
                          p_connected->peer_addr.addr[1],
                          p_connected->peer_addr.addr[2],
                          p_connected->peer_addr.addr[3],
                          p_connected->peer_addr.addr[4],
                          p_connected->peer_addr.addr[5]
                          );
             } break;
    
             case NRF_BLE_SCAN_EVT_SCAN_TIMEOUT:         // Scan timeout
             {
                 NRF_LOG_INFO("Scan timed out.");
                 scan_start();
             } break;
    
             case NRF_BLE_SCAN_EVT_FILTER_MATCH:         // A filter is matched or all filters are matched in the multifilter mode
                 {
                   ble_gap_evt_adv_report_t const *p_adv_report = p_scan_evt->params.filter_match.p_adv_report;
                   NRF_LOG_INFO("Scan Match Id: %02x%02x%02x%02x%02x%02x",
                          p_adv_report->peer_addr.addr[0],
                          p_adv_report->peer_addr.addr[1],
                          p_adv_report->peer_addr.addr[2],
                          p_adv_report->peer_addr.addr[3],
                          p_adv_report->peer_addr.addr[4],
                          p_adv_report->peer_addr.addr[5]
                          );
                 }
                 break;
    
             case NRF_BLE_SCAN_EVT_NOT_FOUND:            // The filter was not matched for the scan data
                 {
                   ble_gap_evt_adv_report_t const *p_not_found = p_scan_evt->params.p_not_found;
                   NRF_LOG_INFO("Deny Id: %02x%02x%02x%02x%02x%02x",
                          p_not_found->peer_addr.addr[0],
                          p_not_found->peer_addr.addr[1],
                          p_not_found->peer_addr.addr[2],
                          p_not_found->peer_addr.addr[3],
                          p_not_found->peer_addr.addr[4],
                          p_not_found->peer_addr.addr[5]
                          );
                 }
                 break;
    
             default:
    //       case NRF_BLE_SCAN_EVT_FILTER_MATCH:         // A filter is matched or all filters are matched in the multifilter mode
             case NRF_BLE_SCAN_EVT_WHITELIST_REQUEST:    // Request the whitelist from the main application. For whitelist scanning to work, the whitelist must be set when this event occurs
             case NRF_BLE_SCAN_EVT_WHITELIST_ADV_REPORT: // Send notification to the main application when a device from the whitelist is found
    //       case NRF_BLE_SCAN_EVT_NOT_FOUND:            // The filter was not matched for the scan data
             case NRF_BLE_SCAN_EVT_SCAN_REQ_REPORT:      // Scan request report
                if (p_scan_evt->scan_evt_id < NUM_BLE_SCAN_EVENTS)
                {
                   NRF_LOG_INFO("scan_evt_id: %d %s", p_scan_evt->scan_evt_id, ble_scan_event_description[p_scan_evt->scan_evt_id]);
                }
                else
                {
                   NRF_LOG_INFO("Unhandled scan_evt_id: %d", p_scan_evt->scan_evt_id);
                }
                 break;
        }
    }
    

Reply
  • This is for 15.3.0, but you might find it helpful:

    // Scan Events
    static char * ble_scan_event_description[] =
    {
    /* NRF_BLE_SCAN_EVT_FILTER_MATCH",        */ " 0 Filter matched in the multifilter mode",
    /* NRF_BLE_SCAN_EVT_WHITELIST_REQUEST:    */ " 1 Request the whitelist from the main application",
    /* NRF_BLE_SCAN_EVT_WHITELIST_ADV_REPORT: */ " 2 Device from the whitelist is found",
    /* NRF_BLE_SCAN_EVT_NOT_FOUND:            */ " 3 Filter not matched for the scan data",
    /* NRF_BLE_SCAN_EVT_SCAN_TIMEOUT:         */ " 4 Scan timeout",
    /* NRF_BLE_SCAN_EVT_SCAN_REQ_REPORT:      */ " 5 Scan request report",
    /* NRF_BLE_SCAN_EVT_CONNECTING_ERROR:     */ " 6 Error occurred when establishing the connection from sd_ble_gap_connect",
    /* NRF_BLE_SCAN_EVT_CONNECTED:            */ " 7 Connected to device"
    };
    #define NUM_BLE_SCAN_EVENTS (sizeof(ble_scan_event_description)/sizeof(ble_scan_event_description[0]))
    /**@brief Function for handling Scanning Module events.
     */
    static void scan_evt_handler(scan_evt_t const * p_scan_evt)
    {
        ret_code_t err_code;
    
        switch(p_scan_evt->scan_evt_id)
        {
             case NRF_BLE_SCAN_EVT_CONNECTING_ERROR:     // Error occurred when establishing the connection. In this event, an error is passed from the function call @ref sd_ble_gap_connect
             {
                  err_code = p_scan_evt->params.connecting_err.err_code;
                  APP_ERROR_CHECK(err_code);
             } break;
    
             case NRF_BLE_SCAN_EVT_CONNECTED:            // Connected to device
             {
                  ble_gap_evt_connected_t const * p_connected = p_scan_evt->params.connected.p_connected;
                 // Scan is automatically stopped by the connection.
                 NRF_LOG_INFO("Connect to Id %02x%02x%02x%02x%02x%02x",
                          p_connected->peer_addr.addr[0],
                          p_connected->peer_addr.addr[1],
                          p_connected->peer_addr.addr[2],
                          p_connected->peer_addr.addr[3],
                          p_connected->peer_addr.addr[4],
                          p_connected->peer_addr.addr[5]
                          );
             } break;
    
             case NRF_BLE_SCAN_EVT_SCAN_TIMEOUT:         // Scan timeout
             {
                 NRF_LOG_INFO("Scan timed out.");
                 scan_start();
             } break;
    
             case NRF_BLE_SCAN_EVT_FILTER_MATCH:         // A filter is matched or all filters are matched in the multifilter mode
                 {
                   ble_gap_evt_adv_report_t const *p_adv_report = p_scan_evt->params.filter_match.p_adv_report;
                   NRF_LOG_INFO("Scan Match Id: %02x%02x%02x%02x%02x%02x",
                          p_adv_report->peer_addr.addr[0],
                          p_adv_report->peer_addr.addr[1],
                          p_adv_report->peer_addr.addr[2],
                          p_adv_report->peer_addr.addr[3],
                          p_adv_report->peer_addr.addr[4],
                          p_adv_report->peer_addr.addr[5]
                          );
                 }
                 break;
    
             case NRF_BLE_SCAN_EVT_NOT_FOUND:            // The filter was not matched for the scan data
                 {
                   ble_gap_evt_adv_report_t const *p_not_found = p_scan_evt->params.p_not_found;
                   NRF_LOG_INFO("Deny Id: %02x%02x%02x%02x%02x%02x",
                          p_not_found->peer_addr.addr[0],
                          p_not_found->peer_addr.addr[1],
                          p_not_found->peer_addr.addr[2],
                          p_not_found->peer_addr.addr[3],
                          p_not_found->peer_addr.addr[4],
                          p_not_found->peer_addr.addr[5]
                          );
                 }
                 break;
    
             default:
    //       case NRF_BLE_SCAN_EVT_FILTER_MATCH:         // A filter is matched or all filters are matched in the multifilter mode
             case NRF_BLE_SCAN_EVT_WHITELIST_REQUEST:    // Request the whitelist from the main application. For whitelist scanning to work, the whitelist must be set when this event occurs
             case NRF_BLE_SCAN_EVT_WHITELIST_ADV_REPORT: // Send notification to the main application when a device from the whitelist is found
    //       case NRF_BLE_SCAN_EVT_NOT_FOUND:            // The filter was not matched for the scan data
             case NRF_BLE_SCAN_EVT_SCAN_REQ_REPORT:      // Scan request report
                if (p_scan_evt->scan_evt_id < NUM_BLE_SCAN_EVENTS)
                {
                   NRF_LOG_INFO("scan_evt_id: %d %s", p_scan_evt->scan_evt_id, ble_scan_event_description[p_scan_evt->scan_evt_id]);
                }
                else
                {
                   NRF_LOG_INFO("Unhandled scan_evt_id: %d", p_scan_evt->scan_evt_id);
                }
                 break;
        }
    }
    

Children
No Data
Related