Hello Nordic Engineer,
I used SDK17.1.0 and ble_app_multirole_lesc, So, we need to discuss scan_init() and advertising_init().
Assuming there are three devices, A, B, and C. Both B and C are advertising the same UUID, but I only want A and B to establish a connection.
Additionally, I would like the advertising name to be '#define DEVICE_NAME "Hello123"'. This is not my actual product name, so please disregard this issue. What I want to emphasize is that the advertising name must be the full name.
So I want to use two filtering methods to achieve my goal. The third parameter set to true indicates that both requirements must be met simultaneously to establish a connection.
nrf_ble_scan_filters_enable(&m_scan, TYPE | NRF_BLE_SCAN_UUID_FILTER, true);
TYPE = NRF_BLE_SCAN_APPEARANCE_FILTER or NRF_BLE_SCAN_SHORT_NAME_FILTER
As long as the goal can be achieved, I won't specify a particular type.
Let's discuss APPEARANCE first:
《sdk_config.h》
#define NRF_BLE_SCAN_APPEARANCE_CNT 1
《main.c》
static void scan_init(void)
{
...
uint16_t mAppearance;
...
nrf_ble_scan_init(&m_scan, &init_scan, scan_evt_handler);
...
nrf_ble_scan_filter_set(&m_scan, SCAN_APPEARANCE_FILTER, &mAppearance);
...
nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_APPEARANCE_FILTER | NRF_BLE_SCAN_UUID_FILTER, true);
}
static void advertising_init(void)
{
...
init.advdata.include_appearance = true;
...
ble_advertising_init(&m_advertising, &init);
ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
}
I have two question:
【1】I don't know how to set mAppearance.
【2】Do I have any other parts that need to be set?
Let's discuss the short name next:
《sdk_config.h》
#define NRF_BLE_SCAN_SHORT_NAME_CNT 1
《main.c》
nrf_ble_scan_short_name_t m_short_name =
{
.p_short_name = "Hello",
.short_name_min_len = 5
};
static void scan_init(void)
{
nrf_ble_scan_filter_set(&m_scan, SCAN_SHORT_NAME_FILTER, &m_short_name);
nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_SHORT_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER, true);
}
static void advertising_init(void)
{
init.advdata.name_type = BLE_ADVDATA_SHORT_NAME;
init.advdata.short_name_len = m_short_name.short_name_min_len;
}
I have a question. If the device name is 'Hello123' and I set a short name filter, can I establish a connection by setting 'Hello' with the shortest length set to 5? (Even though my test failed, is my idea correct?)
Thanks
