Hi,
I am facing an issue while integrating BLE with the rest of my code. The code crashes when I try to start BLE outside of main()
.
Currently, I have placed the BLE initialization at the beginning of main()
, and it starts and advertises successfully. However, the code crashes during the bonding process.
- I am using two threads in my application.
I am using nrf5340, 2.6.1 SDK and 2.6.1 toolchain manager.
This are my configuration.
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Enable the UART driver
CONFIG_UART_ASYNC_API=y
# CONFIG_NRFX_UARTE0=y
# CONFIG_SERIAL=y
# Enable GPIO
CONFIG_GPIO=y
CONFIG_LOG_DEFAULT_LEVEL=4
# Configure printk to use UART console
# CONFIG_CONSOLE=y
# CONFIG_UART_CONSOLE=y
# Configure heap memory
CONFIG_HEAP_MEM_POOL_SIZE=8192
# Bluetooth configuration
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="XXXXXXXXXX"
CONFIG_BT_MAX_CONN=1
this is BLE start code
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int BLE_Start()
{
int err;
err = bt_enable(NULL);
if (err) {
LOG_ERR("Bluetooth initialization failed (err: %d)", err);
return err;
}
LOG_INF("Bluetooth initialized");
err = bt_nus_init(&nus_cb);
if (err) {
LOG_ERR("Failed to initialize NUS service (err: %d)", err);
return err;
}
LOG_INF("NUS service initialized");
bt_conn_cb_register(&connection_callbacks);
bt_conn_auth_cb_register(&conn_auth_callbacks);
bt_conn_auth_info_cb_register(&conn_auth_callbacks_info);
Please help me resolve this issue, as I am in the final stage of my project completion!