My phone is like beacon that transmit service data. (I checked service data in different phone.)
So, I want to recieve service data, service UUID with PCA10040(nRF52832) observer(central) mode.
I use SDK13.0.0 examples\ble_cnetral\ble_app_uart_c and softdevice 4.0.2.
First, I remove ble connection function in on_ble_evt()
All except BLE_GAP_EVT_ADV_REPORT was cleared.
Second, PCA10040 transmit service data, service UUID with UART.
But, I don't konw that where store service data and service UUID.
below is on_ble_evt function for using observer mode.
please, tell me my problem.
///////////////////////////////////////////////////////////////////////
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
ret_code_t err_code;
const ble_gap_evt_t * p_gap_evt = &p_ble_evt->evt.gap_evt;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_ADV_REPORT:
{
const ble_gap_evt_adv_report_t * p_adv_report = &p_gap_evt->params.adv_report;
if (is_uuid_present(&m_nus_uuid, p_adv_report))
{
#if 0
err_code = sd_ble_gap_connect(&p_adv_report->peer_addr,
&m_scan_params,
&m_connection_param,
CONN_CFG_TAG);
#endif
#if 1
app_uart_put(p_adv_report->peer_addr.addr[0]);
app_uart_put(p_adv_report->peer_addr.addr[1]);
app_uart_put(p_adv_report->peer_addr.addr[2]);
app_uart_put(p_adv_report->peer_addr.addr[3]);
app_uart_put(p_adv_report->peer_addr.addr[4]);
app_uart_put(p_adv_report->peer_addr.addr[5]);
#endif
#if 0
for(int8_t i=0;i<BLE_GAP_ADV_MAX_SIZE;i++)
{
app_uart_put(p_adv_report->data[i]);
}
#endif
if (err_code == NRF_SUCCESS)
{
// scan is automatically stopped by the connect
err_code = bsp_indication_set(BSP_INDICATE_IDLE);
APP_ERROR_CHECK(err_code);
NRF_LOG_INFO("Connecting to target %02x%02x%02x%02x%02x%02x\r\n",
p_adv_report->peer_addr.addr[0],
p_adv_report->peer_addr.addr[1],
p_adv_report->peer_addr.addr[2],
p_adv_report->peer_addr.addr[3],
p_adv_report->peer_addr.addr[4],
p_adv_report->peer_addr.addr[5]
);
}
}
}break; // BLE_GAP_EVT_ADV_REPORT
#if 0
case BLE_GAP_EVT_CONNECTED:
NRF_LOG_INFO("Connected to target\r\n");
err_code = ble_nus_c_handles_assign(&m_ble_nus_c, p_ble_evt->evt.gap_evt.conn_handle, NULL);
APP_ERROR_CHECK(err_code);
err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
APP_ERROR_CHECK(err_code);
// start discovery of services. The NUS Client waits for a discovery result
err_code = ble_db_discovery_start(&m_ble_db_discovery, p_ble_evt->evt.gap_evt.conn_handle);
APP_ERROR_CHECK(err_code);
break; // BLE_GAP_EVT_CONNECTED
case BLE_GAP_EVT_TIMEOUT:
if (p_gap_evt->params.timeout.src == BLE_GAP_TIMEOUT_SRC_SCAN)
{
NRF_LOG_INFO("Scan timed out.\r\n");
scan_start();
}
else if (p_gap_evt->params.timeout.src == BLE_GAP_TIMEOUT_SRC_CONN)
{
NRF_LOG_INFO("Connection Request timed out.\r\n");
}
break; // BLE_GAP_EVT_TIMEOUT
case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
// Pairing not supported
err_code = sd_ble_gap_sec_params_reply(p_ble_evt->evt.gap_evt.conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
APP_ERROR_CHECK(err_code);
break; // BLE_GAP_EVT_SEC_PARAMS_REQUEST
case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST:
// Accepting parameters requested by peer.
err_code = sd_ble_gap_conn_param_update(p_gap_evt->conn_handle,
&p_gap_evt->params.conn_param_update_request.conn_params);
APP_ERROR_CHECK(err_code);
break; // BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST
case BLE_GATTC_EVT_TIMEOUT:
// Disconnect on GATT Client timeout event.
NRF_LOG_DEBUG("GATT Client Timeout.\r\n");
err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gattc_evt.conn_handle,
BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
APP_ERROR_CHECK(err_code);
break; // BLE_GATTC_EVT_TIMEOUT
case BLE_GATTS_EVT_TIMEOUT:
// Disconnect on GATT Server timeout event.
NRF_LOG_DEBUG("GATT Server Timeout.\r\n");
err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gatts_evt.conn_handle,
BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
APP_ERROR_CHECK(err_code);
break; // BLE_GATTS_EVT_TIMEOUT
#endif
default:
break;
}
}