I am using sdk for mesh v.5 (s140.7.2.0) and nrf52840 DK and want to add uart peripheral into the client in the light switch mesh example and then trigger button 1 once a sting data is received.
I added drivers and libraries c.files of the art peripheral, paths, headers, and finally added these functions in the main.c file.
void uart_error_handle(app_uart_evt_t * p_event)
void uart_event_handle(app_uart_evt_t * p_event)
void uart_init(void)
And with an "if" I checked a string received from uart and then I trigger buttun1 by call the "button_event_handler(button_number)" function.
and I added the "uart_init()" function in the main () function .
When I press the button 1 it works fine, although when I write the "string" on the uart, it returns:
<t: 0>, main.c, 573, ----- BLE Mesh Light Switch Client Demo -----
<t: 12650>, main.c, 412, Initializing and adding models
<t: 12702>, main.c, 209, Node Address: 0x0004
<t: 12704>, mesh_app_utils.c, 66, Device UUID (raw): 137FF47B11294702B381A62F60654E45
<t: 12708>, mesh_app_utils.c, 67, Device UUID : 137FF47B-1129-4702-B381-A62F60654E45
<t: 12731>, main.c, 625,
------------------------------------------------------------------------------------
Button/RTT 1) Send a message to the odd group (address: 0xC003) to turn on LED 1.
Button/RTT 2) Send a message to the odd group (address: 0xC003) to turn off LED 1.
Button/RTT 3) Send a message to the even group (address: 0xC002) to turn on LED 1.
Button/RTT 4) Send a message to the even group (address: 0xC002) to turn off LED 1.
------------------------------------------------------------------------------------
<t: 483794>, main.c, 489, Data is Successfully Received
<t: 483797>, main.c, 312, Button 1 pressed
<t: 483799>, main.c, 335, Sending msg: ONOFF SET 1
<t: 483809>, app_error_weak.c, 105, Mesh assert at 0x0002C8B0 (:0)
I searched my problem and found this case.
So I tried to add app_scheduler in my codes based on this tutorial.
#include "app_scheduler.h"
static void button_event_handler_app_sched(void * p_event_data, uint16_t event_size)
{
uint8_t * button_number = (uint8_t *) p_event_data;
NRF_MESH_ASSERT(event_size == 1);
button_event_handler(*button_number);
}
static void button_event_handler_irq(uint32_t button_number)
{
static uint8_t bt_num;
bt_num = button_number;
app_sched_event_put((void *)&bt_num, sizeof(bt_num), button_event_handler_app_sched);
}
static void initialize(void)
{
.
.
#if BUTTON_BOARD
ERROR_CHECK(hal_buttons_init(button_event_handler_irq));
#endif
.
.
.
}
int main(void)
{
///////////////////////add by Sama
/*scheduler*/
APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);
app_sched_execute();
/*UART_Interface*/
uart_init();
///////////////////////end by Sama
initialize();
start();
for (;;)
{
/*scheduler*/
//(void)sd_app_evt_wait();
bool done = nrf_mesh_process();
if (done)
{
sd_app_evt_wait();
}
}
}
However, it does not work. Here is the log file:
t: 0>, main.c, 594, ----- BLE Mesh Light Switch Client Demo -----
<t: 12031>, app_error_weak.c, 115, Mesh error 8 at 0x0002846B (D:\Behine Niroo\Nordic\NRF Mesh\nrf5_SDK_for_Mesh_v5.0.0_src\examples\common\src\simple_hal.c:244)
Could you please advise me?
Thank you in advance.
Br,
Sama

