Hi,
I’m currently working with the nRF52840 DK configured as a BLE Central device.
The peripheral device is a Flutter-based mobile application acting as a BLE Peripheral.
We're encountering an issue where, during service discovery, the discover_callback function is invoked but the attr parameter is NULL.
However, when testing with the nRF Connect mobile application, the app is able to discover and display services and characteristics correctly from the same Flutter peripheral.
Why does the nRF52840 DK receive a NULL attr in the callback, while the nRF Connect app works as expected?
Below is the implementation of our discover_callback function for reference:
static uint8_t
discover_cb (struct bt_conn *conn, const struct bt_gatt_attr *attr,
struct bt_gatt_discover_params *params)
{
static struct bt_uuid_128 uuid = BT_UUID_INIT_128(0);
uint8_t slot = MAX_BEACONS_SUPPORTED;
printk("Discovery callback - Type: %d, Start: 0x%04x, End: 0x%04x\n",
params->type, params->start_handle, params->end_handle);
if (!attr) {
// This could be normal completion, not necessarily an error
printk("Discovery completed for type %d, UUID: ", params->type);
return BT_GATT_ITER_STOP;
}
else {
printk("Found attr at handle 0x%04x, value handle: 0x%04x\n",
attr->handle, bt_gatt_attr_value_handle(attr));
// Rest of the discovery logic
}
return BT_GATT_ITER_STOP;
}