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

advertisement with whitelisting

Hi,

i am doing ble_app_beacon code on nrf 52832 with sdk 11 and s132. the packet, its advertising should only be received by the device whose bluetooth address we are providing in whitelist. After it reaches to sd_ble_gap_adv_start() in ble_advertising _start() function it goes to following piece of code with error code: 0x00000012

void app_error_handler_bare(ret_code_t error_code)

{
    error_info_t error_info =
    {
        .line_num    = 0,
        .p_file_name = NULL,
        .err_code    = error_code,
    };
    app_error_fault_handler(NRF_FAULT_ID_SDK_ERROR, 0, (uint32_t)(&error_info));

    UNUSED_VARIABLE(error_info);
}

here is my implementation of ble_advetising with whitelist.

static void advertising_init(void)
{
    uint32_t      err_code;
    ble_advdata_t advdata;
    uint8_t       flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;

    ble_advdata_manuf_data_t manuf_specific_data;

    manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER;

#if defined(USE_UICR_FOR_MAJ_MIN_VALUES)
    // If USE_UICR_FOR_MAJ_MIN_VALUES is defined, the major and minor values will be read from the
    // UICR instead of using the default values. The major and minor values obtained from the UICR
    // are encoded into advertising data in big endian order (MSB First).
    // To set the UICR used by this example to a desired value, write to the address 0x10001080
    // using the nrfjprog tool. The command to be used is as follows.
    // nrfjprog --snr <Segger-chip-Serial-Number> --memwr 0x10001080 --val <your major/minor value>
    // For example, for a major value and minor value of 0xabcd and 0x0102 respectively, the
    // the following command should be used.
    // nrfjprog --snr <Segger-chip-Serial-Number> --memwr 0x10001080 --val 0xabcd0102
    uint16_t major_value = ((*(uint32_t *)UICR_ADDRESS) & 0xFFFF0000) >> 16;
    uint16_t minor_value = ((*(uint32_t *)UICR_ADDRESS) & 0x0000FFFF);

    uint8_t index = MAJ_VAL_OFFSET_IN_BEACON_INFO;

    m_beacon_info[index++] = MSB_16(major_value);
    m_beacon_info[index++] = LSB_16(major_value);

    m_beacon_info[index++] = MSB_16(minor_value);
    m_beacon_info[index++] = LSB_16(minor_value);
#endif

    manuf_specific_data.data.p_data = (uint8_t *) m_beacon_info;
    manuf_specific_data.data.size   = APP_BEACON_INFO_LENGTH;

    // Build and set advertising data.
    memset(&advdata, 0, sizeof(advdata));

    advdata.name_type             = BLE_ADVDATA_NO_NAME;
    advdata.flags                 = flags;
    advdata.p_manuf_specific_data = &manuf_specific_data;

    err_code = ble_advdata_set(&advdata, NULL);
    APP_ERROR_CHECK(err_code);

    // Initialize advertising parameters (used when starting advertising).

ble_gap_addr_t   *p_whitelist_addr[1];
ble_gap_addr_t    whitelist_addr={ BLE_GAP_ADDR_TYPE_RANDOM_STATIC,{0x85,0x04,0x44,0x99,0x32,0xA0}} ;
ble_gap_whitelist_t  whitelist;
//uint8_t addr[6] = {0x85,0x04,0x44,0x99,0x32,0xA0};  
p_whitelist_addr[0]=&whitelist_addr;
    whitelist.pp_addrs =p_whitelist_addr; 
    whitelist.addr_count = 1;
    whitelist.irk_count = 0;
    whitelist.pp_irks = NULL;

//Configure the advertising parameter and whitelist
memset(&m_adv_params, 0, sizeof(m_adv_params));
m_adv_params.type        =  BLE_GAP_ADV_TYPE_ADV_IND;
m_adv_params.p_peer_addr = NULL;
m_adv_params.fp          = BLE_GAP_ADV_FP_FILTER_CONNREQ;
m_adv_params.interval    = 64;
m_adv_params.timeout     = 180;
m_adv_params.p_whitelist = &whitelist;

//p_whitelist_addr[0] = &whitelist_addr;
//whitelist.addr_count = 1;
//whitelist.pp_addrs   =  p_whitelist_addr;
//whitelist.pp_irks = NULL;
//whitelist.irk_count =0;

}


/**@brief Function for starting advertising.
 */
static void advertising_start(void)
{
uint32_t err_code;
    err_code = sd_ble_gap_adv_start(&m_adv_params);
    APP_ERROR_CHECK(err_code);

    err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
    APP_ERROR_CHECK(err_code);
}

What is the solution for this? how can i set whitelist so that the inteded device gets the packet? is there a need of implementing device manager?

Reply ASAP.

  • Hello anuja

    The whitelist only limits which devices the advertiser accepts connections/scan requests from, it does not prevent any observer/scanner from receiving the advertising packets.

    You do have something called directed advertising, in which the advertise-packet contains the address of one recipient. All recipients whose addresses does not match the transmitted address will ignore the advertisement. However you cannot have more than one recipient, and it is used to reconnect to the previous central if connection is lost. For more information on directed advertisement see this post

    The error you receive is because the beacon example is configured with 0 peripheral links (NRF_ERROR_CONN_COUNT), and you are using the BLE_GAP_ADV_TYPE_ADV_IND type, which means your device is connectable. The beacon example however is designed for a non-connectable device.

    Best regards

    Jørn Frøysa

Related