Hello,
I have use the BLE Multi-link Example as a central. For the priripheral I have use BLE Blinky Application and UART/Serial Port Emulation over BLE (<InstallFolder>\examples\ble_peripheral\ble_app_uart).
The need is to have the possibility for the central to manage this two type of peripheral.
First step : define the filter :#define NUS_SERVICE_UUID_TYPE BLE_UUID_TYPE_VENDOR_BEGIN /**< UUID type for the Nordic UART Service (vendor specific). */
/**@brief NUS UUID. */
static ble_uuid_t const m_nus_uuid =
{
.uuid = BLE_UUID_NUS_SERVICE,
.type = NUS_SERVICE_UUID_TYPE
};
static void scan_init(void)
{
ret_code_t err_code;
nrf_ble_scan_init_t init_scan;
memset(&init_scan, 0, sizeof(init_scan));
init_scan.connect_if_match = true;
init_scan.conn_cfg_tag = APP_BLE_CONN_CFG_TAG;
err_code = nrf_ble_scan_init(&m_scan, &init_scan, scan_evt_handler);
APP_ERROR_CHECK(err_code);
err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_NAME_FILTER, m_target_periph_name);
APP_ERROR_CHECK(err_code);
switch (2)
{
case (1):
{ // marche pas filtre non effecfif !!
err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_UUID_FILTER, &m_nus_uuid);
APP_ERROR_CHECK(err_code);
err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER, false);
APP_ERROR_CHECK(err_code);
break;
}
case (2):
{
err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_NAME_FILTER, m_target_periph_name2);
APP_ERROR_CHECK(err_code);
err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_NAME_FILTER, false);
APP_ERROR_CHECK(err_code);
break;
}
default:
err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_NAME_FILTER, false);
APP_ERROR_CHECK(err_code);
break;
}
}
try one : use two time the SCAN_NAME_FILTER, the central detecte the advertising of the 2 peripheral and go in ble_evt_handler() event BLE_GAP_EVT_CONNECTED => OK it's working
try two : use SCAN_NAME_FILTER for BLE blinky and NRF_BLE_SCAN_UUID_FILTER for the "Serial over BLE peripheral" (see code when you put 1 in the case)
in this case, the filter NRF_BLE_SCAN_UUID_FILTER doesn't work and the software doesn't go in the ble_evt_handler() event BLE_GAP_EVT_CONNECTED. Did you have an idea ? the filter seems to be be define correcly?
Question 2 :
When the filter is working using the two SCAN_NAME_FILTER, How can you know in the ble_evt_handler() function event BLE_GAP_EVT_CONNECTED which type of pheripheral generate this event?The information give by the p_gap_evt->params.connected give me not this information.
Thanks in advance
Stephane