Hi Support
I created a BLE beacon using example Ble_barebone. using the following configuration-
static const struct advertise_configuration user_adv_conf = {
.addr_src = GAPM_PUBLIC_ADDR,//GAPM_PUBLIC_ADDR,
.renew_dur = 0,
.intv_min = 800,//值* 0.625ms = MS
.intv_max = 800, // value*0.625ms=ms
.channel_map = 0x7,
.mode = GAP_GEN_DISCOVERABLE,
。adv_filt_policy = adv_allow_scan_any_con_any,
.peer_addr = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6},
.peer_addr_type = 0,
};
With the above configuration the beacon is scanned by every scanner successfully.
But now I want it to be scanned by my specific scanner only(I don't want to reveal my beacon to everyone) . I don't know what configuration I will have to make at scanner and advertiser end. Please help.
Device:
still waiting for DA Support Team
Hi abhikalitra,
You will have to be patient, when asking question over the forum. You are not going to be able to do something like that, since you act as a beacon and I suppose that you wish to send data when advertising. According to the BLE specification you can advertise and be scanned by a specific device (if you are aware of the bd address of the scanner) if you use directed advertising but you will not be able to fit data in a directed advertising PDU. In direct advertising the PCU incudes only the bd address of the devices and it consumes quite some power.
Thanks, PM_Dialog
Hi PM_Dialog,
Thank you for the reply. Can I get any code example of directed advertising.
Hi abhikalitra,
你应该添加的中心地址.peer_addr_type of the user_adv_config structure in the user_config.h file. Then, use the app_easy_gap_directed_advertise_start() instead of app_easy_gap_undirected_advertise_get_active() in the user_app_adv_start() with a proper bd address to field mentioned above. As mentioned in the previous post, be aware that in direct advertising the PCU incudes only the bd address of the device.
Thanks, PM_Dialog
Dear PM_Dialog,
I got it. But I think it will not solve my problem. Could you please tell me how to set whitelist at advertiser side. so that it will accept connection request from whitelist addresses only.
i am doing like this-
in file user_config.h
static const struct advertise_configuration user_adv_conf = {
.addr_src = GAPM_PUBLIC_ADDR,//GAPM_PUBLIC_ADDR,
/// Duration of resolvable address before regenerate it.
.renew_dur = 0,
/// Minimum interval for advertising
.intv_min = 800,//(8000+((MAC_ID_B0%10)*800)),//ADV_MAX, // value*0.625ms=ms
///广告的最大时间间隔
.intv_max = 800,//(8000+((MAC_ID_B0%10)*800)),//ADV_MIN, // value*0.625ms=ms
/// Advertising channel map
.channel_map = 0x7,
.mode = GAP_GEN_DISCOVERABLE,//GAP_GEN_DISCOVERABLE,
.adv_filt_policy = ADV_ALLOW_SCAN_WLST_CON_WLST,
///直接地址信息(Gapm_adv_direct)
.peer_addr ={0x1, 0x2, 0x3, 0x4, 0x5, 0x6}
/// Address type of the device 0=public/1=private random
.peer_addr_type = 0,
};
void user_app_adv_start(void)
{
manage_white_list();
// Schedule the next advertising data update
app_adv_data_update_timer_used = app_easy_timer(APP_ADV_DATA_UPDATE_TO, adv_data_update_timer_cb);
// struct gapm_start_advertise_cmd* cmd;
cmd =app_easy_gap_undirected_advertise_get_active();
app_add_ad_struct(cmd, &mnf_data, sizeof(struct mnf_specific_data_ad_structure));
app_easy_gap_undirected_advertise_start();
}
in file user_barebone.c
static void manage_white_list(void)
{
uint8_t wht_lst1[6]={ 0x20, 0x33, 0x32, 0xCA, 0xEA, 0x80 };//BD_Address of my central device
struct gapm_white_list_mgt_cmd *cmd = KE_MSG_ALLOC_DYN(GAPM_WHITE_LIST_MGT_CMD,
TASK_GAPM,
TASK_APP,
gapm_white_list_mgt_cmd,
sizeof(struct gap_bdaddr));
cmd->operation = GAPM_ADD_DEV_IN_WLIST;
cmd->nb = 1;
memcpy((void *) &cmd->devices[0].addr, (void *)wht_lst1, BD_ADDR_LEN);
cmd->devices[0].addr_type=0;
ke_msg_send(cmd);
}
Please see and check whether it will work or not?
Hi abhikalitra,
I am not able to find something wrong in your code snippet. What The ADV_ALLOW_SCAN_WLST_CON_WLST is filter policy applied only on a peripheral to accept scan or connection requests from a device in the white list.
Thanks, PM_Dialog