SDK Environment: nRF Connect SDK v1.7.1
Target: Decawave DWM1001-DEV. This uses the nRF52832
Simon posted in this discussion an example of adding a custom service to the sample peripheral_dis
When I ran this example I did not get a notification. my_service_send is not called.
I added the following to the end of main()
uint32_t number = 0;
for (;;) {
// Main loop
my_service_send(my_connection, (uint8_t *)&number, sizeof(number));
number++;
k_sleep(K_MSEC(1000)); // 1000ms
}
This still did not send the notification, so I added CONFIG_ASSERT=y to proj.conf. When run I got an assertion fault.
I then removed the first BT_GATT_CC in BT_GATT_SERVICE_DEFINE
I also changed the index in the line const struct bt_gatt_attr *attr = &my_service.attrs[4]; from 4 to 2; This seemed to better match the comments above in the code, as well as this tutorial. I am still getting an assertion fault when run.
I have added my complete project in the attached zip file.
I initially built this with west build -b decawave_dwm1001_dev2 -d build2 -- -DBOARD_ROOT=\ncs\myapps\peripheral_dis_test1
When run I get the following:
*** Booting Zephyr OS build v2.6.99-ncs1-1 ***
[00:00:00.001,098] <inf> sdc_hci_driver: SoftDevice Controller build revision:
3f 47 70 8e 81 95 4e 86 9d d3 a2 95 88 f6 30 0a |?Gp...N. ......0.
7f 53 49 fd |.SI.
[00:00:00.006,195] <inf> bt_hci_core: No ID address. App must call settings_load()
[00:00:00.009,918] <err> bt_gatt: Failed to save Database Hash (err -2)
Bluetooth initialized
Advertising successfully started
ASSERTION FAIL [conn] @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/gatt.c:2653
invalid parameter
[00:00:00.012,420] <err> os: r0/a1: 0x00000004 r1/a2: 0x00000a5d r2/a3: 0x00000008
[00:00:00.012,420] <err> os: r3/a4: 0x00000000 r12/ip: 0x00000000 r14/lr: 0x0001aebb
[00:00:00.012,451] <err> os: xpsr: 0x41000000
[00:00:00.012,451] <err> os: Faulting instruction address (r15/pc): 0x00024400
[00:00:00.012,451] <err> os: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
[00:00:00.012,481] <err> os: Current thread: 0x20001e40 (main)
[00:00:01.732,971] <err> fatal_error: Resetting system
I have posted a separate query about the line [00:00:00.009,918] <err> bt_gatt: Failed to save Database Hash (err -2). I don't know if this is related or not.
The assertion fail happens when bt_gatt_is_subscribed is called.