Good afternoon.
I have 2 boards NRF51:
-
One as beacon (SDK 9), use example code "nRF51_SDK_9.0.0\examples\ble_peripheral\ble_app_beacon".
-
The other as central (SDK10, softdevice s130), use example code "nRF5_SDK_10.0.0\examples\ble_central\ble_app_uart_c" to read beacons messages.
I have modified central code to be able to read messages:
/**@brief Function for handling the Application's BLE Stack events.
*
* @param[in] p_ble_evt Bluetooth stack event.
*/
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code;
const ble_gap_evt_t * p_gap_evt = &p_ble_evt->evt.gap_evt;
const ble_gap_evt_adv_report_t *p_adv_report = &p_gap_evt->params.adv_report;
//is_uuid_present(&m_nus_uuid, p_adv_report);
switch (p_ble_evt->header.evt_id){
case BLE_GAP_EVT_ADV_REPORT:
if(p_adv_report->type == 3){
printf("rssi: %d, scan_rsp: %d, type: %d, long: %d, ", p_adv_report->rssi, p_adv_report->scan_rsp, p_adv_report->type, p_adv_report->dlen);
printf("dir: %02x:%02x:%02x:%02x:%02x:%02x \r\n", p_adv_report->peer_addr.addr[5], p_adv_report->peer_addr.addr[4], p_adv_report->peer_addr.addr[3],
p_adv_report->peer_addr.addr[2], p_adv_report->peer_addr.addr[1], p_adv_report->peer_addr.addr[0]);
for(int i = 0; i < p_adv_report->dlen; i++){
printf("%x", p_adv_report->data[i]);
}
printf("\r\n");
printf("------------------------------------------\r\n\n");
}
break;
...............
}
}
Three questions:
- Point 1. I want beacon sends a string (ex: hello) and the level of battery to, how could I implement this.
- Point 2. If beacon sends the string and lvl of battery, could I read this with my "on_ble_evt" code or I have to modified it? and this way to read messages is good or there is someone better.
- Point 3. Should I use the news SDK?
All help is wellcome.
Thank you.