I'm writing a code for Beacon scanner using:CONTROLLER: nRf52832, SDK: nRF5_SDK_15.3.0_59ac345SOFTDEVICE: s132_nrf52_6.1.1_softdevice.hex
I'm using "ble_app_uart_c" code as a Beacon scanner.
On debugging, the code hits the function "nrf_ble_scan_on_ble_evt" in file "nrf_ble_scan.c" and i can see 31 byte of beacon data in *(&p_ble_evt->evt.gap_evt.params.adv_report.data.p_data[0 to 30]))
But the problem is my beacon device "MokoVeacon" transmit more than 31 bytes of data which includes Accelerometer data and also Txpower.
How to read more than 30 Bytes of Advertising data, i have changed various possible things to change ADVERTISING Data size, but failed.
Can some one please help me on this...
Please make sure the ble_gap_scan_params_t::active bit is gets set to '1' when you initialize the scanner (ble_gap_scan_params_t). This will make the scanner issue a scan request to receive the scan response packet, which probably contains the remaining sensor data.
This tutorial here explains a bit about how and why scan responses are used: https://devzone.nordicsemi.com/nordic/short-range-guides/b/bluetooth-low-energy/posts/ble-advertising-a-beginners-tutorial
Hi Vidar Berg,
Thanks for the replay. I have checked the "scan_init()" function, and the ble_gap_scan_params_t::active bitActually the active bit is set to 1, by default.
But still i'm not receiving more than 30 bytes of beacon data.
You're right. I forgot that the UART central example does active scanning by default. But since it's already enabled, you should be getting adv. report events with the ble_gap_adv_report_type_t::scan_response bit set as well. Can you check if you get any scan responses? Just remember that you cannot continue execution after hitting a breakpoint as that will likely cause the Softdevice to trigger an assertion.
Hi Vidar Berg,
I haven't put any break-points.
Actually i am printing first 50 byes of received data in J-link RTT viewer.
30 bytes i'm able to receive proper data, but after from 31 to 50th bytes, i'm receiving all zeros, which should be Accelerator data.
I have used "nRF connect" mobile app, in that i can be able to see the valid data from 31 to 50th bytes.
Is there any changes i need to make in "sdk_config.h" file like
#define NRF_BLE_SCAN_BUFFER 31
#define NRF_BLE_SCAN_NAME_MAX_LEN 31
#define NRF_BLE_SCAN_SHORT_NAME_MAX_LEN 31
I have changed this bytes to 50 but didn't received more than 30 bytes.
The scan response comes in a separate event, first, you get the data of the main adv. packet (max. 31 bytes), then you get the scan response. Please verify that you do you get scan response packets. One way you can to that is to check the scan response bit in your scanner callback as shown below.
static void scan_evt_handler(scan_evt_t const * p_scan_evt)
ble_gap_evt_adv_report_t const * adv_report;
adv_report = p_scan_evt->params.filter_match.p_adv_report;
__BKPT(0); //TODO: parse scan response packet
Have tested the scan response bit in scanner callback, it is hitting the break-point.
But how can i receive the remaining advertising data (i.e after 31st byte)
Even in scanner callback i can see only 31 byte of advertising data, also the packet length is 32 bytes
How to parse scan response packet? can you please help on this..
VIGNESH C said:But how can i receive the remaining advertising data (i.e after 31st byte)
It comes in two separate events. Max. payload for each event is 31 bytes.
VIGNESH C said:How to parse scan response packet? can you please help on this..
You can probably to in the same way as you did for the main advertisement packet. Can you post some code snippets so I can see how you have implemented this?
Now i'm able to receive entire advertising data. Has received the remaining advertising data in separate event.
Thanks for the help.