BT central sample has the following code
-------------------------
BT central sample has the following code
Update
1. Calling bt_enable from a thread crashes the program - is this expected?
2.Enabled logging, called from main thread, see this message after bt_enable
[00:01:03.757,263] <inf> sdc_hci_driver: SoftDevice Controller build revision:
0e e7 c5 66 67 18 3c ac b3 d2 cc 81 a3 dc f1 c0 |...fg.<. ........
c0 36 02 22 |.6."
[00:01:03.763,702] <inf> bt_hci_core: No ID address. App must call settings_load()
Perhaps this is a clue.
Any ideas?
Thanks
Update 2
1.Calling settings_load() fixed the scan_start problem. Now scanning works
Apparently this is a requirement if CONGFIG_BT_SETTINGS is enabled ( it is )
Wish documentation was more clear on that
2. Calling bt_enable from a thread other than main,crashes the app with the following error
[00:00:00.009,918] <err> os: ***** MPU FAULT *****
[00:00:00.010,314] <err> os: Stacking error (context area might be not valid)
[00:00:00.010,803] <err> os: Data Access Violation
[00:00:00.011,199] <err> os: MMFAR Address: 0x20005230
[00:00:00.011,657] <err> os: r0/a1: 0xfc71651f r1/a2: 0x72c7d345 r2/a3: 0x263cb4d2
[00:00:00.012,268] <err> os: r3/a4: 0xa56dccb0 r12/ip: 0x4d7daa1a r14/lr: 0x271198f7
[00:00:00.012,908] <err> os: xpsr: 0x61000000
[00:00:00.013,305] <err> os: Faulting instruction address (r15/pc): 0x0002e228
[00:00:00.013,854] <err> os: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
[00:00:00.014,404] <err> os: Current thread: 0x20001e98 (comm_task)
[00:00:00.019,897] [1;31m<err> fatal_error: Resetting system[0m]
Hi Andy,
Could you show how you define the thread that you call bt_enable() ?
As far as I know it should be fine to call it from thread with positive priority (and not from a interrupt handler)
If you enable CONFIG_SETTINGS, settings_load() should be called. I'm a little bit unsure why not calling it causing the scan problem though.
One side question, I assume you are doing mesh at the same time as doing central scanning ? If true this could potentially reduce mesh performance.
Thread was defined as follows
Hi Andy,
Could you provide a simplified example that we can test here ?
I tried with the ble_peripheral_lbs_coex and didn't see the issue.
I replaced main() function with this:
#define STACKSIZE 1024 void ble_write_thread(void) { int err; printk("Thread..\n"); err = bt_enable(bt_ready); if (err) { printk("Bluetooth init failed (err %d)\n", err); } } void blink_LED(void) { for (;;) { printk("LED\n"); k_sleep(K_MSEC(1000)); } } K_THREAD_DEFINE(ble_write_thread_id, STACKSIZE, ble_write_thread, NULL, NULL, NULL, 7, 0, 0); K_THREAD_DEFINE(blink_LED_id, STACKSIZE, blink_LED, NULL, NULL, NULL, 7, 0, 0);