Hi,
I'm using the S132 v6.0 and SDK v15.0 to work with nRF52832. I found the it just get the advertising data. If the device put some data into the scan response, when I use 52832 to scan, how to get the scan response data? Thanks.
Hi,
I'm using the S132 v6.0 and SDK v15.0 to work with nRF52832. I found the it just get the advertising data. If the device put some data into the scan response, when I use 52832 to scan, how to get the scan response data? Thanks.
static void advertising_init(void) { uint32_t err_code; ble_advertising_init_t init; uint8_t m_addl_adv_manuf_data[19] = {0xaa,0xbb,0x00,0x00,0xC4,0xF1,0x00,0x0b,0x03,0x01}; memset(&init, 0, sizeof(init)); ble_advdata_manuf_data_t manuf_data; manuf_data.data.size = sizeof(m_addl_adv_manuf_data); manuf_data.data.p_data = &m_addl_adv_manuf_data[2]; init.advdata.p_manuf_specific_data = &manuf_data; init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE; init.srdata.name_type = BLE_ADVDATA_FULL_NAME; init.srdata.include_appearance = false; init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]); init.srdata.uuids_complete.p_uuids = m_adv_uuids; init.config.ble_adv_fast_enabled = true; init.config.ble_adv_fast_interval = APP_ADV_INTERVAL; init.config.ble_adv_fast_timeout = APP_ADV_DURATION; err_code = ble_advertising_init(&m_advertising, &init); APP_ERROR_CHECK(err_code); ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG); } ble_gap_scan_params_t const m_scan_params = { .active = 1, .interval = SCAN_INTERVAL, .window = SCAN_WINDOW, .timeout = SCAN_DURATION, .scan_phys = BLE_GAP_PHY_1MBPS, .filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL, }; void on_adv_report(ble_gap_evt_adv_report_t const * p_adv_report) { printf("scan_response=%04x\r\n",p_adv_report->type); printf("%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]); if(p_adv_report->peer_addr.addr[5]==0xDE&&p_adv_report->peer_addr.addr[4]==0x88) { printf("ADV data:\r\n"); for(uint8_t i=0;i<p_adv_report->data.len;i++) printf("%02x ",p_adv_report->data.p_data[i]); printf("\r\n"); } uint32_t ret = sd_ble_gap_scan_start(&m_scan_params, &m_scan_buffer); }
This is the code for the ble_advertising_init and the scan report.
I don't see any problems with your code, neither the scanner nor the advertiser.
For reference (and if you would like to test with a known working example), I stripped down a central project to only do active scanning and logging whether an advertisement packet or scan response packet was received. The two relevant functions are here:
static void scan_start(void) { ret_code_t ret; m_scan_param.active = 1; m_scan_param.interval = SCAN_INTERVAL; m_scan_param.window = SCAN_WINDOW; m_scan_param.timeout = SCAN_DURATION; m_scan_param.scan_phys = BLE_GAP_PHY_1MBPS; m_scan_param.filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL; ret = sd_ble_gap_scan_start(&m_scan_param, &m_scan_buffer); APP_ERROR_CHECK(ret); }
static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) { ret_code_t err_code; ble_gap_evt_adv_report_t const * p_adv_report = &p_ble_evt->evt.gap_evt.params.adv_report; switch (p_ble_evt->header.evt_id) { case BLE_GAP_EVT_ADV_REPORT: if (p_adv_report->type.scan_response) { if (p_adv_report->data.len > 0) { NRF_LOG_INFO("Scan response received:"); NRF_LOG_RAW_HEXDUMP_INFO(p_adv_report->data.p_data, p_adv_report->data.len); } else { NRF_LOG_INFO("Empty scan response received."); } } else { NRF_LOG_INFO("Advertising packet received:"); NRF_LOG_RAW_HEXDUMP_INFO(p_adv_report->data.p_data, p_adv_report->data.len); } // Continue scanning. sd_ble_gap_scan_start(NULL, &m_scan_buffer); break; default: break; } }
Here are full projects for SDK 15.0 (ble_active_scanner_sdk_15.0.zip) and SDK 15.2 (ble_active_scanner_sdk__15.2.zip).
I use the scanner to work on sdk15.2 and S132v6.1, I could get the scan response data. However, I if I use the same way to make the scanner to work on sdk 15.0 and S132v6.0,then scan the same advertiser, I could see that the bit scan_response of ble_gap_adv_report_type_t is 1, but I just get the advertising data, I couldn't get the scan_response data.
Is there any problem with s132v6.0? Could you help me have a try? Thanks
Hi,
S132 version 6.0 and version 6.1 should behave the same in this regard, and both work as they should on my desk. I have updated my previous post to print data and included example projects for both SDK 15.0.0 and SDK 15.2.0 so that you can test both.
Note that a BLE peripheral will typically reply with an empty scan response if no scan response has been configured. So empty scan responses are expected (though not from a peripheral you know has scan response data). Perhaps you could log the BLE address of the advertiser to verify whether the empty scan responses come from your peripheral (where there should be scan response data) or not? You could for example do something like this:
NRF_LOG_INFO("Peer addr: %02x:%02x:%02x:%02x:%02x:%02x.", 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]);