How to change the NRF9160 Simple MQTT to send UART – the old example by Simon mqtt_w_uart does not compile – Nordic Q&A – Nordic DevZone

Hi there

We are trying to modify the MQTT_Simple example to be able to send more info than the status of pressing a button and having a button pressed notification go back up to the cloud.  There was an attempt by Simon from 2 years ago to help someone and called mqtt_w_uart, however there are a number of odd things about the code (zephyr deprecated type u8_t which I changed to uint8_t for example – but there were more serious problems like trying to compile and having problems with other dependencies.  Now using the 1.7.0 environment.)  Trying to pull the special additional mqtt_w_uart code into the current version of MQTT_simple (which uses LOG_INF and LOG_ERR instead of printf or whatever, and also you need to #import <drivers/uart.h> instead of just <uart.h> and a few other fun changes that arent obvious) is fine until the main function in main.c has the line  uart_irq_callback_set(uart_gb, uart_cb)  or the line  uart_irq_rx_enable(uart_gb)  plunked into it.  Once this is tried, it DOES compile, however the program keeps resetting and this is what the log shows over and over:

[0m<inf> mqtt_simple: The MQTT simple sample started
[1;31m<err> os: Exception occurred in Secure State
[1;31m<err> os: ***** HARD FAULT *****
[1;31m<err> os:   Fault escalation (see below)
[1;31m<err> os: ***** BUS FAULT *****
[1;31m<err> os:   Precise data bus error
[1;31m<err> os:   BFAR Address: 0x50008158
[1;31m<err> os: r0/a1:  0x00000000  r1/a2:  0x000249a4  r2/a3:  0x00000055
[1;31m<err> os: r3/a4:  0x00000047 r12/ip:  0x2001455c r14/lr:  0x0001c9f5
[1;31m<err> os:  xpsr:  0x61000000
[1;31m<err> os: Faulting instruction address (r15/pc): 0x0001179c
[1;31m<err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
[1;31m<err> os: Current thread: 0x20014e30 (unknown)
[1;31m<err> fatal_error: Resetting system

Read more here: Source link