I'm using the nrf52840 with connectivity firmware and S140 SoftDevice, accessed through pc-ble-driver version 4.1.1, with NRF_SD_BLE_API=6
Occasionally pc-ble-driver fails to decode an advertisement event, and notifies my application with a status callback with PKT_DECODE_ERROR and message “Failed to decode event, error code is 14/0xe”. Error code 14 is NRF_ERROR_NULL. I have tracked down the cause of the NRF_ERROR_NULL.
I’ve debugged enough to find out what event is received over the virtual serial port – hex dumps of a sample invalid event are below.
In “ble_data_t_dec” this decodes to a ‘buf_id’ of zero, and it then calls “app_ble_gap_adv_buf_unregister” with zero, which returns a nullptr. That nullptr passed to ‘SER_PULL_len16data’ is invalid and causes it to return NRF_ERROR_NULL, which is the error reported to my application.
So pc-ble-driver expects that the connectivity firmware will never give it an advertisement with this “buf_id” of zero. What is causing this?
Hex dump of invalid event (62 bytes):
1d 00 ff ff 03 00 04 68 ce e3 b1 14 7d fe 00 00
00 00 00 00 01 ff 7f e3 27 ff 00 00 00 00 00 00
18 00 01 02 01 1a 14 ff 4c 00 01 00 00 00 00 00
00 40 00 00 00 00 00 00 00 00 00 09 03 03
Numbering the bytes starting from zero, the “buffer id” is bytes 27-31 (decimal)