This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

add uart peripheral into client example returns "app_error_weak.c, 105, Mesh assert at 0x0002C8B0 (:0)"

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

Parents Reply Children
  • Hi Hung,

    Thank you for your quick reply.

    Sorry, the link was missed.

    I had a look at the serial and the serial_cmd.h where all opcodes are defined. I found that more difficult than using two UARTs. isn't it?

    I am looking for the most simple method.

    Br,

    Sama 

  • Hi Sama, 
    I don't think using 2 UART would help much here. You would need to have 2 cables connected to PC. One for UART0 and one for UART1. 
    If that OK for you you can follow what I suggested in the case to implement. But I do think that you can just edit the serial library in mesh to add your own opcode it's much more simpler. 

  • Hi,

    There is no problem with the two cables. So there are two ways:

    1. using two UARTs

    What is the pin map of UARTE1? Can I use the nRF USB MicroUSB connector on the board? 

    2. using usbd_cdc_acm

    I have added the usbd_cdc_acm to the client codes. I am facing the problem with app_timer2 and app_timer_mesh. There are many definitions common in both files. I exclusive the app_timer2 and drv_rtc leading to mesh error 8.

    After that, I added two files and I tried to comment out the common definitions and change the name of app_timer_init in the app_timer2 and main. the codes were built without any compiler error. However, this returned "app_error_weak.c,  115, Mesh error 133 at 0x00000000"

    any solution?

    Br,

    Sama

  • Hi Sama, 
    1. Please tell how you plan to use UARTE1 ? Are you using the nrf_drv_uart or you are using the serial_uart from mesh SDK ? 
    The nrf_drv_uart use the configuration when you call APP_UART_FIFO_INIT() you can choose the pin their. You would need to select the APP_UART_DRIVER_INSTANCE to 1. See here.

    2. You may want to debug the mesh application and tell where the error is. 

    I really think that you are complicated thing up. It can be much easier if you follow what I suggested. Just add you own opcode in the serial.h file and you can do your own communication with the same UART as for DFU or serial mesh. Let me know if there is anything you don't understand on that. 

  • Hi Hung,

    Thank you for your reply. 

    We have our protocol and we want to separate the DFU transferring port from the command port.

    I am trying to use the nRF USB port to send our commands. Is this the correct way?

    What makes me confused is this example. If I want to use the UARTE1 independent from UART0 what should I do?

    Br,

    Sama

Related