Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to receive manufacturer specific data when using the LE Coded PHY

Hello, I'm trying to get manufacturer specific data from peripheral, but I don't know how to do this when the peripheral is using extended advertisement with LE Coded PHY.

I'm using long_range_demo examples [ https://github.com/NordicPlayground/nRF52-ble-long-range-demo ] with some modifications as below

peripheral_long_range_demo_kit/main.c:

/* Add these code near the top of the source code */
/* add these lines */
#define MANUF_DATA 0x54, 0x00

static uint8_t manuf_data_block[] = {
    MANUF_DATA,
};

static uint8_array_t const manuf_data_array = {
    .size               = sizeof(manuf_data_block),
    .p_data             = manuf_data_block,
};

static ble_advdata_manuf_data_t manuf_data;
/* add these lines */

/* set non-connectable as default */
static adv_scan_type_seclection_t   m_adv_scan_type_selected = SELECTION_NON_CONNECTABLE;   /**< Global variable holding the current scan selection mode. */

/* edit static ble_gap_adv_data_t m_adv_data */
/**@brief Struct that contains pointers to the encoded advertising data. */
static ble_gap_adv_data_t m_adv_data =
{
    .adv_data =
    {
        .p_data = NULL,
        .len    = 0
    },
    .scan_rsp_data =
    {
        .p_data = m_enc_scandata,
        .len    = BLE_GAP_SCAN_BUFFER_EXTENDED_MIN

    }
};
/* edit static ble_gap_adv_data_t m_adv_data */

/* In static void advertising_data_set(void), add/modify code as below */
/* add */
// initialize manufacturer specific data
manuf_data.company_identifier = 0x0059;
manuf_data.data = manuf_data_array;
/* add */

ble_advdata_t const adv_data =
{
    .name_type             = BLE_ADVDATA_FULL_NAME,
    .flags                 = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE,
    .include_appearance    = false,
    .p_manuf_specific_data = &manuf_data,  /* add this line */
};

else if(m_adv_scan_type_selected == SELECTION_NON_CONNECTABLE)
{
    NRF_LOG_INFO("Advertising type set to EXTENDED_NONCONNECTABLE_SCANNABLE_UNDIRECTED ");
    adv_params.properties.type = BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_SCANNABLE_UNDIRECTED;

    /* uncomment these two lines */
    ret = ble_advdata_encode(&adv_data, m_adv_data_ext.scan_rsp_data.p_data, &m_adv_data_ext.scan_rsp_data.len);
    APP_ERROR_CHECK(ret);
    /* uncomment these two lines */

    ret = sd_ble_gap_adv_set_configure(&m_adv_handle, NULL, &adv_params);
    APP_ERROR_CHECK(ret);			
}

central_long_range_demo_kit/main.c:

/* in function static void on_adv_report(ble_gap_evt_adv_report_t const * p_adv_report)
edit these lines */
}else if (p_adv_report->primary_phy == BLE_GAP_PHY_CODED )
{
  NRF_LOG_INFO("Received ADV report, RSSI %d, phy: coded",rssi_value);
  // Dump BLE data
  uint16_t len = p_adv_report->data.len;
  if(p_adv_report->peer_addr.addr[5] == 0xD8) {   // change here to show data from specific MAC address
    NRF_LOG_DEBUG("type::status=%d", p_adv_report->type.status);
    NRF_LOG_DEBUG("%d", p_adv_report->data.len);
    NRF_LOG_HEXDUMP_DEBUG(p_adv_report->data.p_data, p_adv_report->data.len);
  }
}

If I debug peripheral_long_range_demo_kit, the encoded advertising data has manufacturer specific data. However the data is not showing up in the serial console of the central board.

I suppose the auxiliary advertising packet contains the manufacturer specific data and the device name, but I could not find helpful information about how to achieve this. Is there any ways to receive the manufacturer specific data when using the LE Coded PHY?

Parents
  • Hello,

    The advertisement report event should give you the payload transmitted on the data channels.  Does the size of the received advertisement packet correspond with the size of the packet you sent? You can use ble_advdata_search() to extract the manufacturer field from the encoded data.  

  • No. data.len field of advertising report was zero (although the advertising packet was 26 octets long). bel_advdata_search also returned zero with the received advertising packet.

    Here are the modifications I made on central_long_range_demo_kit/main.c, and the content of m_adv_data.scan_rsp_data.p_data after calling ble_advdata_encode on the peripheral side.

    central_long_range_demo_kit/main.c:

    //NRF_LOG_HEXDUMP_DEBUG(p_adv_report->data.p_data, p_adv_report->data.len);
    uint16_t ofs;
    uint16_t res = ble_advdata_search(p_adv_report->data.p_data, len, &ofs, BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA);
    if(res == 0) {
      NRF_LOG_DEBUG("manufdata not found.");
    } else {
      NRF_LOG_HEXDUMP_DEBUG(p_adv_report->data.p_data+ofs, res);
    }
    

    Memory dump of m_adv_data.scan_rsp_data.p_data

    m_adv_data.scan_rsp_data.p_data

Reply
  • No. data.len field of advertising report was zero (although the advertising packet was 26 octets long). bel_advdata_search also returned zero with the received advertising packet.

    Here are the modifications I made on central_long_range_demo_kit/main.c, and the content of m_adv_data.scan_rsp_data.p_data after calling ble_advdata_encode on the peripheral side.

    central_long_range_demo_kit/main.c:

    //NRF_LOG_HEXDUMP_DEBUG(p_adv_report->data.p_data, p_adv_report->data.len);
    uint16_t ofs;
    uint16_t res = ble_advdata_search(p_adv_report->data.p_data, len, &ofs, BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA);
    if(res == 0) {
      NRF_LOG_DEBUG("manufdata not found.");
    } else {
      NRF_LOG_HEXDUMP_DEBUG(p_adv_report->data.p_data+ofs, res);
    }
    

    Memory dump of m_adv_data.scan_rsp_data.p_data

    m_adv_data.scan_rsp_data.p_data

Children
Related