|
@ -175,6 +175,7 @@ static void scan_evt_handler(scan_evt_t const * p_scan_evt) |
|
|
|
|
|
|
|
|
/**@brief Function for initializing the scanning and setting the filters. |
|
|
/**@brief Function for initializing the scanning and setting the filters. |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
static char m_target_periph_name[20] = "iflytop_test"; /**< Name of the device we try to connect to. This name is searched in the scan report data*/ |
|
|
static void scan_init(void) |
|
|
static void scan_init(void) |
|
|
{ |
|
|
{ |
|
|
ret_code_t err_code; |
|
|
ret_code_t err_code; |
|
@ -188,11 +189,21 @@ static void scan_init(void) |
|
|
err_code = nrf_ble_scan_init(&m_scan, &init_scan, scan_evt_handler); |
|
|
err_code = nrf_ble_scan_init(&m_scan, &init_scan, scan_evt_handler); |
|
|
APP_ERROR_CHECK(err_code); |
|
|
APP_ERROR_CHECK(err_code); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_UUID_FILTER, &m_nus_uuid); |
|
|
err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_UUID_FILTER, &m_nus_uuid); |
|
|
APP_ERROR_CHECK(err_code); |
|
|
APP_ERROR_CHECK(err_code); |
|
|
|
|
|
|
|
|
err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_UUID_FILTER, false); |
|
|
|
|
|
|
|
|
err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_NAME_FILTER, m_target_periph_name); |
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_UUID_FILTER|NRF_BLE_SCAN_NAME_FILTER, false); |
|
|
APP_ERROR_CHECK(err_code); |
|
|
APP_ERROR_CHECK(err_code); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -693,7 +704,12 @@ int main(void) |
|
|
app_timer_create(&m_uart_send_tmr, APP_TIMER_MODE_REPEATED, uart_send_tmr_cb); |
|
|
app_timer_create(&m_uart_send_tmr, APP_TIMER_MODE_REPEATED, uart_send_tmr_cb); |
|
|
app_timer_start(m_uart_send_tmr, APP_TIMER_TICKS(2), NULL); |
|
|
app_timer_start(m_uart_send_tmr, APP_TIMER_TICKS(2), NULL); |
|
|
|
|
|
|
|
|
// app_uart_put(1); |
|
|
|
|
|
|
|
|
app_uart_put(1); |
|
|
|
|
|
app_uart_put(1); |
|
|
|
|
|
app_uart_put(1); |
|
|
|
|
|
app_uart_put(1); |
|
|
|
|
|
app_uart_put(1); |
|
|
|
|
|
app_uart_put(1); |
|
|
|
|
|
|
|
|
// Start execution. |
|
|
// Start execution. |
|
|
printf("BLE UART central example started.\r\n"); |
|
|
printf("BLE UART central example started.\r\n"); |
|
|