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

Buffer JSON data and publish through MQTT nrf9160

Hi Dev Team,

I have an application wherein I am publishing my sensor data every hour through MQTT using a Thingy91. 

I am storing my sensor data value in a JSON format through cJSON library. I need to read this value every 10 mins, buffer it and send out all the values every hour.

So basically I need to store 6 values (values obtained every 10 mins through the hour) and send them out together every 1 hour.

I needed to know how could I buffer my sensor data and store it to send all of it together every hour.

I obtain my JSON format through this following code: 

void my_work_handler_1(struct k_work *work)
{

     char *desc2 = "BME680";
     char *id2 = "rH";
     char *type2 = "humidity";

     sensor1 = cJSON_CreateObject();

    cJSON_AddItemToObject(sensor1, "description", cJSON_CreateString(desc2));
    cJSON_AddItemToObject(sensor1, "Time", cJSON_CreateString(time_string));
    cJSON_AddItemToObject(sensor1, "value", cJSON_CreateNumber(testval2));
    cJSON_AddItemToObject(sensor1, "unit", cJSON_CreateString(id2));
    cJSON_AddItemToObject(sensor1, "type", cJSON_CreateString(type2));

       /* print everything */
        out1 = cJSON_Print(sensor1);
        printk("%s\n", out1);
        free(out1);
   /* free all objects under root and root itself */
        cJSON_Delete(sensor1);
        return;

}
K_WORK_DEFINE(my_work1, my_work_handler_1);

I save my json in the variable "out1" in the code. I wanted to know how I could buffer the output and store it in a variable, so I could publish that through MQTT every hour.

Regards,

Adeel.

  • Hi,

    Depending on your use case, it might be easier to store the raw data, than the encoded string.

    Where do you allocate memory for out1?

    The easiest way to save the data is probably to create a static array, either with pointers to heap-allocated strings (the allocation should happen in your work_handler, and the strings must be freed when you send them), or memcpy'ed strings directly into the array.

    You would also need a counter somewhere to keep track of which index you should write the next data point to.

    Alternatively, if you want a more fancy data structure, you can take a look at Zephyr's ring buffer or FIFO queue.

    Best regards,

    Didrik

  • Hi Didrik,

    The easiest way to save the data is probably to create a static array, either with pointers to heap-allocated strings (the allocation should happen in your work_handler, and the strings must be freed when you send them), or memcpy'ed strings directly into the array.

    Thanks for the advice on this and I moved along to create a static array to buffer the data. I was able to achieve my usage but I noticed that the code reboots when I try to publish my data for the 5th time. Its a bit strange and I tried to change the MQTT broker but the code reboots at exactly the same point again. 

    I am attaching the log file as well as the sample code I am using so you could reproduce it at your end. 

    2021-02-14T16:15:50.162Z INFO Application data folder: C:\Users\adeel\AppData\Roaming\nrfconnect\pc-nrfconnect-linkmonitor
    2021-02-14T16:15:50.177Z VERBOSE Could not fetch serial number for serial port at COM3
    2021-02-14T16:15:50.177Z VERBOSE Could not fetch serial number for serial port at COM1
    2021-02-14T16:15:50.234Z DEBUG App pc-nrfconnect-linkmonitor v1.1.10 official
    2021-02-14T16:15:50.234Z DEBUG App path: C:\Users\adeel\.nrfconnect-apps\node_modules\pc-nrfconnect-linkmonitor
    2021-02-14T16:15:50.234Z DEBUG nRFConnect 3.6.1 is supported by the app (^3.6.0)
    2021-02-14T16:15:50.234Z DEBUG nRFConnect path: C:\Users\adeel\AppData\Local\Programs\nrfconnect\resources\app.asar
    2021-02-14T16:15:50.234Z DEBUG HomeDir: C:\Users\adeel
    2021-02-14T16:15:50.234Z DEBUG TmpDir: C:\Users\adeel\AppData\Local\Temp
    2021-02-14T16:15:52.549Z INFO Modem port is opened
    2021-02-14T16:15:52.555Z DEBUG modem >> AT+CFUN?
    2021-02-14T16:15:57.271Z DEBUG modem << *** Booting Zephyr OS build v2.3.0-rc1-ncs1  ***
    2021-02-14T16:15:57.291Z DEBUG modem << Flash regionsDomainPermissions
    2021-02-14T16:15:57.294Z DEBUG modem << 00 00 0x00000 0x08000 Securerwxl
    2021-02-14T16:15:57.296Z DEBUG modem << 01 31 0x08000 0x100000 Non-Securerwxl
    2021-02-14T16:15:57.297Z DEBUG modem << Non-secure callable region 0 placed in flash region 0 with size 32.
    2021-02-14T16:15:57.566Z DEBUG modem << SRAM regionDomainPermissions
    2021-02-14T16:15:57.568Z DEBUG modem << 00 07 0x00000 0x10000 Securerwxl
    2021-02-14T16:15:57.569Z DEBUG modem << 08 31 0x10000 0x40000 Non-Securerwxl
    2021-02-14T16:15:57.571Z DEBUG modem << PeripheralDomainStatus
    2021-02-14T16:15:57.572Z DEBUG modem << 00 NRF_P0               Non-SecureOK
    2021-02-14T16:15:57.573Z DEBUG modem << 01 NRF_CLOCK            Non-SecureOK
    2021-02-14T16:15:57.574Z DEBUG modem << 02 NRF_RTC0             Non-SecureOK
    2021-02-14T16:15:57.575Z DEBUG modem << 03 NRF_RTC1             Non-SecureOK
    2021-02-14T16:15:57.577Z DEBUG modem << 04 NRF_NVMC             Non-SecureOK
    2021-02-14T16:15:57.578Z DEBUG modem << 05 NRF_UARTE1           Non-SecureOK
    2021-02-14T16:15:57.579Z DEBUG modem << 06 NRF_UARTE2           SecureSKIP
    2021-02-14T16:15:57.582Z DEBUG modem << 07 NRF_TWIM2            Non-SecureOK
    2021-02-14T16:15:57.585Z DEBUG modem << 08 NRF_SPIM3            Non-SecureOK
    2021-02-14T16:15:57.588Z DEBUG modem << 09 NRF_TIMER0           Non-SecureOK
    2021-02-14T16:15:57.589Z DEBUG modem << 10 NRF_TIMER1           Non-SecureOK
    2021-02-14T16:15:57.590Z DEBUG modem << 11 NRF_TIMER2           Non-SecureOK
    2021-02-14T16:15:57.592Z DEBUG modem << 12 NRF_SAADC            Non-SecureOK
    2021-02-14T16:15:57.593Z DEBUG modem << 13 NRF_PWM0             Non-SecureOK
    2021-02-14T16:15:57.594Z DEBUG modem << 14 NRF_PWM1             Non-SecureOK
    2021-02-14T16:15:57.595Z DEBUG modem << 15 NRF_PWM2             Non-SecureOK
    2021-02-14T16:15:57.596Z DEBUG modem << 16 NRF_PWM3             Non-SecureOK
    2021-02-14T16:15:57.597Z DEBUG modem << 17 NRF_WDT              Non-SecureOK
    2021-02-14T16:15:57.598Z DEBUG modem << 18 NRF_IPC              Non-SecureOK
    2021-02-14T16:15:57.599Z DEBUG modem << 19 NRF_VMC              Non-SecureOK
    2021-02-14T16:15:57.599Z DEBUG modem << 20 NRF_FPU              Non-SecureOK
    2021-02-14T16:15:57.600Z DEBUG modem << 21 NRF_EGU1             Non-SecureOK
    2021-02-14T16:15:57.601Z DEBUG modem << 22 NRF_EGU2             Non-SecureOK
    2021-02-14T16:15:57.601Z DEBUG modem << 23 NRF_DPPIC            Non-SecureOK
    2021-02-14T16:15:57.602Z DEBUG modem << 24 NRF_GPIOTE1          Non-SecureOK
    2021-02-14T16:15:57.603Z DEBUG modem << 25 NRF_REGULATORS       Non-SecureOK
    2021-02-14T16:15:57.604Z DEBUG modem << SPM: NS image at 0xc000
    2021-02-14T16:15:57.607Z DEBUG modem << SPM: NS MSP at 0x2002c010
    2021-02-14T16:15:57.607Z DEBUG modem << SPM: NS reset vector at 0xf651
    2021-02-14T16:15:57.608Z DEBUG modem << SPM: prepare to jump to Non-Secure image.
    2021-02-14T16:15:57.757Z DEBUG modem << *** Booting Zephyr OS build v2.3.0-rc1-ncs1  ***
    2021-02-14T16:15:57.764Z DEBUG modem << The MQTT simple sample started
    2021-02-14T16:15:57.765Z DEBUG modem << LTE Link Connecting ...
    2021-02-14T16:16:01.674Z DEBUG modem << +CEREG: 2,"5226","029E6004",7,0,0,"11100000","11100000"
    2021-02-14T16:16:01.728Z DEBUG modem << +CSCON: 1
    2021-02-14T16:16:02.994Z DEBUG modem << +CEREG: 5,"5226","029E6004",7,,,"11100000","00000110"
    2021-02-14T16:16:03.003Z DEBUG modem >> AT+COPS=3,2
    2021-02-14T16:16:03.006Z DEBUG modem << LTE Link Connected!
    2021-02-14T16:16:03.008Z DEBUG modem << AT send: AT%XDATAPRFL=0
    2021-02-14T16:16:03.009Z DEBUG modem << AT ret: OK
    2021-02-14T16:16:03.010Z DEBUG modem << AT send: AT+CEREG=5
    2021-02-14T16:16:03.012Z DEBUG modem << AT ret: OK
    2021-02-14T16:16:03.013Z DEBUG modem << AT send: AT%XSYSTEMMODE=1,0,0,0
    2021-02-14T16:16:03.013Z DEBUG modem << AT ret: 1
    2021-02-14T16:16:03.014Z DEBUG modem << AT send: AT%XVBAT
    2021-02-14T16:16:03.015Z DEBUG modem << AT recv:%XVBAT: 4378
    2021-02-14T16:16:03.015Z DEBUG modem << AT ret: OK
    2021-02-14T16:16:03.016Z DEBUG modem << AT send: AT+CFUN=1
    2021-02-14T16:16:03.016Z DEBUG modem << AT ret: OK
    2021-02-14T16:16:03.017Z DEBUG modem << connecting...
    2021-02-14T16:16:03.018Z DEBUG modem << connected
    2021-02-14T16:16:03.019Z DEBUG modem << AT send: AT+CEREG=5
    2021-02-14T16:16:03.021Z DEBUG modem << AT ret: OK
    2021-02-14T16:16:03.022Z DEBUG modem << AT send: AT+CEREG?
    2021-02-14T16:16:03.024Z DEBUG modem << AT recv:+CEREG: 5,5,"5226","029E6004",7,,,"11100000","00000110"
    2021-02-14T16:16:03.025Z DEBUG modem << AT ret: OK
    2021-02-14T16:16:03.026Z DEBUG modem << Busy-wait 10 s
    2021-02-14T16:16:14.933Z DEBUG modem << +CSCON: 0
    2021-02-14T16:16:17.612Z DEBUG modem << +CEREG: 5,"5226","029E6001",7,,,"11100000","00000110"
    2021-02-14T16:16:32.948Z DEBUG modem << Attempting to acquire time and date from date_time library...
    2021-02-14T16:16:32.953Z DEBUG modem << Time update:
    2021-02-14T16:16:32.955Z DEBUG modem <<   Unix time ms: 1613319392675
    2021-02-14T16:16:32.956Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:16:32
    2021-02-14T16:16:32.957Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:16:37.942Z DEBUG modem << Battery is : 0
    2021-02-14T16:16:42.934Z DEBUG modem << Counterdo value is : 0
    2021-02-14T16:17:02.943Z DEBUG modem << Time update:
    2021-02-14T16:17:02.944Z DEBUG modem <<   Unix time ms: 1613319422675
    2021-02-14T16:17:02.954Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:17:02
    2021-02-14T16:17:02.955Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:17:07.941Z DEBUG modem << Battery is : 0
    2021-02-14T16:17:12.933Z DEBUG modem << Counterdo value is : 1
    2021-02-14T16:17:32.942Z DEBUG modem << Time update:
    2021-02-14T16:17:32.943Z DEBUG modem <<   Unix time ms: 1613319452675
    2021-02-14T16:17:32.948Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:17:32
    2021-02-14T16:17:32.949Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:17:37.940Z DEBUG modem << Battery is : 0
    2021-02-14T16:17:42.932Z DEBUG modem << Counterdo value is : 2
    2021-02-14T16:18:02.941Z DEBUG modem << Time update:
    2021-02-14T16:18:02.942Z DEBUG modem <<   Unix time ms: 1613319482675
    2021-02-14T16:18:02.947Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:18:02
    2021-02-14T16:18:02.948Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:18:07.939Z DEBUG modem << Battery is : 0
    2021-02-14T16:18:12.931Z DEBUG modem << Counterdo value is : 3
    2021-02-14T16:18:32.940Z DEBUG modem << Time update:
    2021-02-14T16:18:32.941Z DEBUG modem <<   Unix time ms: 1613319512675
    2021-02-14T16:18:32.954Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:18:32
    2021-02-14T16:18:32.955Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:18:37.938Z DEBUG modem << Battery is : 0
    2021-02-14T16:18:42.930Z DEBUG modem << Counterdo value is : 4
    2021-02-14T16:19:02.939Z DEBUG modem << Time update:
    2021-02-14T16:19:02.940Z DEBUG modem <<   Unix time ms: 1613319542675
    2021-02-14T16:19:02.946Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:19:02
    2021-02-14T16:19:02.947Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:19:07.938Z DEBUG modem << Battery is : 0
    2021-02-14T16:19:12.930Z DEBUG modem << Counterdo value is : 5
    2021-02-14T16:19:18.214Z DEBUG modem << IPv4 Address found 3.120.61.0
    2021-02-14T16:19:18.448Z DEBUG modem << [mqtt_evt_handler:344] MQTT client connected!
    2021-02-14T16:19:18.454Z DEBUG modem << Subscribing to: my/send/message len 15
    2021-02-14T16:19:18.455Z DEBUG modem << Timer triggered, publishing MQTT message!!!!
    2021-02-14T16:19:18.456Z DEBUG modem << Publishing: 
    2021-02-14T16:19:18.457Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:19:18.458Z DEBUG modem << Publishing: {
    2021-02-14T16:19:18.458Z DEBUG modem << "description":"Battery",
    2021-02-14T16:19:18.459Z DEBUG modem << "Time":"2021-02-14 16:17:02",
    2021-02-14T16:19:18.459Z DEBUG modem << "value":0,
    2021-02-14T16:19:18.460Z DEBUG modem << "unit":"mV",
    2021-02-14T16:19:18.460Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:19:18.461Z DEBUG modem << }
    2021-02-14T16:19:18.464Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:19:18.465Z DEBUG modem << Publishing: {
    2021-02-14T16:19:18.466Z DEBUG modem << "description":"Battery",
    2021-02-14T16:19:18.467Z DEBUG modem << "Time":"2021-02-14 16:17:32",
    2021-02-14T16:19:18.468Z DEBUG modem << "value":0,
    2021-02-14T16:19:18.469Z DEBUG modem << "unit":"mV",
    2021-02-14T16:19:18.470Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:19:18.472Z DEBUG modem << }
    2021-02-14T16:19:18.473Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:19:18.474Z DEBUG modem << Publishing: {
    2021-02-14T16:19:18.475Z DEBUG modem << "description":"Battery",
    2021-02-14T16:19:18.477Z DEBUG modem << "Time":"2021-02-14 16:18:02",
    2021-02-14T16:19:18.478Z DEBUG modem << "value":0,
    2021-02-14T16:19:18.479Z DEBUG modem << "unit":"mV",
    2021-02-14T16:19:18.480Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:19:18.480Z DEBUG modem << }
    2021-02-14T16:19:18.481Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:19:18.481Z DEBUG modem << Publishing: {
    2021-02-14T16:19:18.482Z DEBUG modem << "description":"Battery",
    2021-02-14T16:19:18.482Z DEBUG modem << "Time":"2021-02-14 16:18:32",
    2021-02-14T16:19:18.492Z DEBUG modem << "value":0,
    2021-02-14T16:19:18.493Z DEBUG modem << "unit":"mV",
    2021-02-14T16:19:18.494Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:19:18.494Z DEBUG modem << }
    2021-02-14T16:19:18.495Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:19:18.495Z DEBUG modem << Publishing: {
    2021-02-14T16:19:18.495Z DEBUG modem << "description":"Battery",
    2021-02-14T16:19:18.496Z DEBUG modem << "Time":"2021-02-14 16:19:02",
    2021-02-14T16:19:18.496Z DEBUG modem << "value":0,
    2021-02-14T16:19:18.497Z DEBUG modem << "unit":"mV",
    2021-02-14T16:19:18.497Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:19:18.498Z DEBUG modem << }
    2021-02-14T16:19:18.498Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:19:20.474Z DEBUG modem << Disconnecting MQTT client...
    2021-02-14T16:19:20.493Z DEBUG modem << [mqtt_evt_handler:350] MQTT client disconnected 0
    2021-02-14T16:19:20.496Z DEBUG modem << ERROR: mqtt_live -128
    2021-02-14T16:19:20.498Z DEBUG modem << ERROR: mqtt_input -13
    2021-02-14T16:19:20.499Z DEBUG modem << +CSCON: 1
    2021-02-14T16:19:20.502Z DEBUG modem >> AT+COPS=3,2
    2021-02-14T16:19:32.145Z DEBUG modem << +CSCON: 0
    2021-02-14T16:19:32.938Z DEBUG modem << Time update:
    2021-02-14T16:19:32.939Z DEBUG modem <<   Unix time ms: 1613319572675
    2021-02-14T16:19:32.944Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:19:32
    2021-02-14T16:19:32.945Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:19:37.935Z DEBUG modem << Battery is : 0
    2021-02-14T16:19:42.928Z DEBUG modem << Counterdo value is : 0
    2021-02-14T16:20:02.937Z DEBUG modem << Time update:
    2021-02-14T16:20:02.938Z DEBUG modem <<   Unix time ms: 1613319602675
    2021-02-14T16:20:02.944Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:20:02
    2021-02-14T16:20:02.945Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:20:07.934Z DEBUG modem << Battery is : 0
    2021-02-14T16:20:12.928Z DEBUG modem << Counterdo value is : 1
    2021-02-14T16:20:32.936Z DEBUG modem << Time update:
    2021-02-14T16:20:32.937Z DEBUG modem <<   Unix time ms: 1613319632675
    2021-02-14T16:20:32.943Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:20:32
    2021-02-14T16:20:32.944Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:20:37.935Z DEBUG modem << Battery is : 0
    2021-02-14T16:20:42.927Z DEBUG modem << Counterdo value is : 2
    2021-02-14T16:21:02.936Z DEBUG modem << Time update:
    2021-02-14T16:21:02.937Z DEBUG modem <<   Unix time ms: 1613319662675
    2021-02-14T16:21:02.943Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:21:02
    2021-02-14T16:21:02.944Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:21:07.934Z DEBUG modem << Battery is : 0
    2021-02-14T16:21:12.926Z DEBUG modem << Counterdo value is : 3
    2021-02-14T16:21:32.935Z DEBUG modem << Time update:
    2021-02-14T16:21:32.936Z DEBUG modem <<   Unix time ms: 1613319692675
    2021-02-14T16:21:32.943Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:21:32
    2021-02-14T16:21:32.944Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:21:37.933Z DEBUG modem << Battery is : 0
    2021-02-14T16:21:42.925Z DEBUG modem << Counterdo value is : 4
    2021-02-14T16:22:02.934Z DEBUG modem << Time update:
    2021-02-14T16:22:02.935Z DEBUG modem <<   Unix time ms: 1613319722675
    2021-02-14T16:22:02.942Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:22:02
    2021-02-14T16:22:02.943Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:22:07.933Z DEBUG modem << Battery is : 0
    2021-02-14T16:22:12.924Z DEBUG modem << Counterdo value is : 5
    2021-02-14T16:22:18.141Z DEBUG modem << IPv4 Address found 3.120.61.0
    2021-02-14T16:22:18.524Z DEBUG modem << [mqtt_evt_handler:344] MQTT client connected!
    2021-02-14T16:22:18.534Z DEBUG modem << Subscribing to: my/send/message len 15
    2021-02-14T16:22:18.536Z DEBUG modem << Timer triggered, publishing MQTT message!!!!
    2021-02-14T16:22:18.537Z DEBUG modem << Publishing: {
    2021-02-14T16:22:18.537Z DEBUG modem << "description":"Battery",
    2021-02-14T16:22:18.538Z DEBUG modem << "Time":"2021-02-14 16:19:32",
    2021-02-14T16:22:18.539Z DEBUG modem << "value":0,
    2021-02-14T16:22:18.539Z DEBUG modem << "unit":"mV",
    2021-02-14T16:22:18.539Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:22:18.540Z DEBUG modem << }
    2021-02-14T16:22:18.540Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:22:18.541Z DEBUG modem << Publishing: {
    2021-02-14T16:22:18.541Z DEBUG modem << "description":"Battery",
    2021-02-14T16:22:18.541Z DEBUG modem << "Time":"2021-02-14 16:20:02",
    2021-02-14T16:22:18.542Z DEBUG modem << "value":0,
    2021-02-14T16:22:18.543Z DEBUG modem << "unit":"mV",
    2021-02-14T16:22:18.544Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:22:18.544Z DEBUG modem << }
    2021-02-14T16:22:18.545Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:22:18.545Z DEBUG modem << Publishing: {
    2021-02-14T16:22:18.545Z DEBUG modem << "description":"Battery",
    2021-02-14T16:22:18.546Z DEBUG modem << "Time":"2021-02-14 16:20:32",
    2021-02-14T16:22:18.546Z DEBUG modem << "value":0,
    2021-02-14T16:22:18.546Z DEBUG modem << "unit":"mV",
    2021-02-14T16:22:18.547Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:22:18.547Z DEBUG modem << }
    2021-02-14T16:22:18.573Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:22:18.574Z DEBUG modem << Publishing: {
    2021-02-14T16:22:18.575Z DEBUG modem << "description":"Battery",
    2021-02-14T16:22:18.576Z DEBUG modem << "Time":"2021-02-14 16:21:02",
    2021-02-14T16:22:18.576Z DEBUG modem << "value":0,
    2021-02-14T16:22:18.577Z DEBUG modem << "unit":"mV",
    2021-02-14T16:22:18.577Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:22:18.577Z DEBUG modem << }
    2021-02-14T16:22:18.578Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:22:18.578Z DEBUG modem << Publishing: {
    2021-02-14T16:22:18.579Z DEBUG modem << "description":"Battery",
    2021-02-14T16:22:18.580Z DEBUG modem << "Time":"2021-02-14 16:21:32",
    2021-02-14T16:22:18.580Z DEBUG modem << "value":0,
    2021-02-14T16:22:18.581Z DEBUG modem << "unit":"mV",
    2021-02-14T16:22:18.581Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:22:18.582Z DEBUG modem << }
    2021-02-14T16:22:18.582Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:22:18.582Z DEBUG modem << Publishing: {
    2021-02-14T16:22:18.583Z DEBUG modem << "description":"Battery",
    2021-02-14T16:22:18.583Z DEBUG modem << "Time":"2021-02-14 16:22:02",
    2021-02-14T16:22:18.584Z DEBUG modem << "value":0,
    2021-02-14T16:22:18.584Z DEBUG modem << "unit":"mV",
    2021-02-14T16:22:18.584Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:22:18.585Z DEBUG modem << }
    2021-02-14T16:22:18.586Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:22:20.587Z DEBUG modem << Disconnecting MQTT client...
    2021-02-14T16:22:20.603Z DEBUG modem << [mqtt_evt_handler:350] MQTT client disconnected 0
    2021-02-14T16:22:20.604Z DEBUG modem << ERROR: mqtt_live -128
    2021-02-14T16:22:20.605Z DEBUG modem << ERROR: mqtt_input -13
    2021-02-14T16:22:20.606Z DEBUG modem << +CSCON: 1
    2021-02-14T16:22:32.048Z DEBUG modem << +CSCON: 0
    2021-02-14T16:22:32.932Z DEBUG modem << Time update:
    2021-02-14T16:22:32.933Z DEBUG modem <<   Unix time ms: 1613319752675
    2021-02-14T16:22:32.941Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:22:32
    2021-02-14T16:22:32.942Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:22:37.931Z DEBUG modem << Battery is : 0
    2021-02-14T16:22:42.924Z DEBUG modem << Counterdo value is : 0
    2021-02-14T16:23:02.932Z DEBUG modem << Time update:
    2021-02-14T16:23:02.933Z DEBUG modem <<   Unix time ms: 1613319782675
    2021-02-14T16:23:02.942Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:23:02
    2021-02-14T16:23:02.943Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:23:07.930Z DEBUG modem << Battery is : 0
    2021-02-14T16:23:12.923Z DEBUG modem << Counterdo value is : 1
    2021-02-14T16:23:32.931Z DEBUG modem << Time update:
    2021-02-14T16:23:32.933Z DEBUG modem <<   Unix time ms: 1613319812675
    2021-02-14T16:23:32.940Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:23:32
    2021-02-14T16:23:32.941Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:23:37.921Z DEBUG modem << Battery is : 0
    2021-02-14T16:23:42.922Z DEBUG modem << Counterdo value is : 2
    2021-02-14T16:24:02.931Z DEBUG modem << Time update:
    2021-02-14T16:24:02.932Z DEBUG modem <<   Unix time ms: 1613319842675
    2021-02-14T16:24:02.942Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:24:02
    2021-02-14T16:24:02.943Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:24:07.929Z DEBUG modem << Battery is : 0
    2021-02-14T16:24:12.921Z DEBUG modem << Counterdo value is : 3
    2021-02-14T16:24:32.930Z DEBUG modem << Time update:
    2021-02-14T16:24:32.931Z DEBUG modem <<   Unix time ms: 1613319872675
    2021-02-14T16:24:32.939Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:24:32
    2021-02-14T16:24:32.940Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:24:37.928Z DEBUG modem << Battery is : 0
    2021-02-14T16:24:42.920Z DEBUG modem << Counterdo value is : 4
    2021-02-14T16:25:02.929Z DEBUG modem << Time update:
    2021-02-14T16:25:02.930Z DEBUG modem <<   Unix time ms: 1613319902675
    2021-02-14T16:25:02.937Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:25:02
    2021-02-14T16:25:02.938Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:25:07.927Z DEBUG modem << Battery is : 0
    2021-02-14T16:25:12.919Z DEBUG modem << Counterdo value is : 5
    2021-02-14T16:25:18.202Z DEBUG modem << IPv4 Address found 3.120.61.0
    2021-02-14T16:25:18.406Z DEBUG modem << [mqtt_evt_handler:344] MQTT client connected!
    2021-02-14T16:25:18.415Z DEBUG modem << Subscribing to: my/send/message len 15
    2021-02-14T16:25:18.416Z DEBUG modem << Timer triggered, publishing MQTT message!!!!
    2021-02-14T16:25:18.417Z DEBUG modem << Publishing: {
    2021-02-14T16:25:18.418Z DEBUG modem << "description":"Battery",
    2021-02-14T16:25:18.418Z DEBUG modem << "Time":"2021-02-14 16:22:32",
    2021-02-14T16:25:18.419Z DEBUG modem << "value":0,
    2021-02-14T16:25:18.420Z DEBUG modem << "unit":"mV",
    2021-02-14T16:25:18.421Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:25:18.422Z DEBUG modem << }
    2021-02-14T16:25:18.423Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:25:18.423Z DEBUG modem << Publishing: {
    2021-02-14T16:25:18.480Z DEBUG modem << "description":"Battery",
    2021-02-14T16:25:18.481Z DEBUG modem << "Time":"2021-02-14 16:23:02",
    2021-02-14T16:25:18.481Z DEBUG modem << "value":0,
    2021-02-14T16:25:18.483Z DEBUG modem << "unit":"mV",
    2021-02-14T16:25:18.484Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:25:18.485Z DEBUG modem << }
    2021-02-14T16:25:18.486Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:25:18.487Z DEBUG modem << Publishing: {
    2021-02-14T16:25:18.488Z DEBUG modem << "description":"Battery",
    2021-02-14T16:25:18.489Z DEBUG modem << "Time":"2021-02-14 16:23:32",
    2021-02-14T16:25:18.490Z DEBUG modem << "value":0,
    2021-02-14T16:25:18.490Z DEBUG modem << "unit":"mV",
    2021-02-14T16:25:18.491Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:25:18.491Z DEBUG modem << }
    2021-02-14T16:25:18.491Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:25:18.492Z DEBUG modem << Publishing: {
    2021-02-14T16:25:18.492Z DEBUG modem << "description":"Battery",
    2021-02-14T16:25:18.493Z DEBUG modem << "Time":"2021-02-14 16:24:02",
    2021-02-14T16:25:18.493Z DEBUG modem << "value":0,
    2021-02-14T16:25:18.494Z DEBUG modem << "unit":"mV",
    2021-02-14T16:25:18.494Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:25:18.494Z DEBUG modem << }
    2021-02-14T16:25:18.494Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:25:18.496Z DEBUG modem << Publishing: {
    2021-02-14T16:25:18.496Z DEBUG modem << "description":"Battery",
    2021-02-14T16:25:18.497Z DEBUG modem << "Time":"2021-02-14 16:24:32",
    2021-02-14T16:25:18.497Z DEBUG modem << "value":0,
    2021-02-14T16:25:18.497Z DEBUG modem << "unit":"mV",
    2021-02-14T16:25:18.497Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:25:18.498Z DEBUG modem << }
    2021-02-14T16:25:18.498Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:25:18.500Z DEBUG modem << Publishing: {
    2021-02-14T16:25:18.500Z DEBUG modem << "description":"Battery",
    2021-02-14T16:25:18.500Z DEBUG modem << "Time":"2021-02-14 16:25:02",
    2021-02-14T16:25:18.501Z DEBUG modem << "value":0,
    2021-02-14T16:25:18.501Z DEBUG modem << "unit":"mV",
    2021-02-14T16:25:18.501Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:25:18.502Z DEBUG modem << }
    2021-02-14T16:25:18.502Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:25:20.483Z DEBUG modem << Disconnecting MQTT client...
    2021-02-14T16:25:20.502Z DEBUG modem << [mqtt_evt_handler:350] MQTT client disconnected 0
    2021-02-14T16:25:20.504Z DEBUG modem << ERROR: mqtt_live -128
    2021-02-14T16:25:20.504Z DEBUG modem << ERROR: mqtt_input -13
    2021-02-14T16:25:20.505Z DEBUG modem << +CSCON: 1
    2021-02-14T16:25:32.198Z DEBUG modem << +CSCON: 0
    2021-02-14T16:25:32.927Z DEBUG modem << Time update:
    2021-02-14T16:25:32.928Z DEBUG modem <<   Unix time ms: 1613319932675
    2021-02-14T16:25:32.937Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:25:32
    2021-02-14T16:25:32.938Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:25:37.926Z DEBUG modem << Battery is : 0
    2021-02-14T16:25:42.918Z DEBUG modem << Counterdo value is : 0
    2021-02-14T16:26:02.927Z DEBUG modem << Time update:
    2021-02-14T16:26:02.928Z DEBUG modem <<   Unix time ms: 1613319962675
    2021-02-14T16:26:02.940Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:26:02
    2021-02-14T16:26:02.941Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:26:07.925Z DEBUG modem << Battery is : 0
    2021-02-14T16:26:12.917Z DEBUG modem << Counterdo value is : 1
    2021-02-14T16:26:32.925Z DEBUG modem << Time update:
    2021-02-14T16:26:32.928Z DEBUG modem <<   Unix time ms: 1613319992675
    2021-02-14T16:26:32.940Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:26:32
    2021-02-14T16:26:32.941Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:26:37.924Z DEBUG modem << Battery is : 0
    2021-02-14T16:26:42.917Z DEBUG modem << Counterdo value is : 2
    2021-02-14T16:27:02.925Z DEBUG modem << Time update:
    2021-02-14T16:27:02.926Z DEBUG modem <<   Unix time ms: 1613320022675
    2021-02-14T16:27:02.934Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:27:02
    2021-02-14T16:27:02.936Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:27:07.923Z DEBUG modem << Battery is : 0
    2021-02-14T16:27:12.916Z DEBUG modem << Counterdo value is : 3
    2021-02-14T16:27:32.924Z DEBUG modem << Time update:
    2021-02-14T16:27:32.925Z DEBUG modem <<   Unix time ms: 1613320052675
    2021-02-14T16:27:32.934Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:27:32
    2021-02-14T16:27:32.936Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:27:37.914Z DEBUG modem << Battery is : 0
    2021-02-14T16:27:42.915Z DEBUG modem << Counterdo value is : 4
    2021-02-14T16:28:02.924Z DEBUG modem << Time update:
    2021-02-14T16:28:02.925Z DEBUG modem <<   Unix time ms: 1613320082675
    2021-02-14T16:28:02.935Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:28:02
    2021-02-14T16:28:02.936Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:28:07.922Z DEBUG modem << Battery is : 0
    2021-02-14T16:28:12.914Z DEBUG modem << Counterdo value is : 5
    2021-02-14T16:28:18.201Z DEBUG modem << IPv4 Address found 3.120.61.0
    2021-02-14T16:28:18.394Z DEBUG modem << [mqtt_evt_handler:344] MQTT client connected!
    2021-02-14T16:28:18.492Z DEBUG modem << Subscribing to: my/send/message len 15
    2021-02-14T16:28:18.507Z DEBUG modem << Timer triggered, publishing MQTT message!!!!
    2021-02-14T16:28:18.508Z DEBUG modem << Publishing: {
    2021-02-14T16:28:18.509Z DEBUG modem << "description":"Battery",
    2021-02-14T16:28:18.510Z DEBUG modem << "Time":"2021-02-14 16:25:32",
    2021-02-14T16:28:18.511Z DEBUG modem << "value":0,
    2021-02-14T16:28:18.512Z DEBUG modem << "unit":"mV",
    2021-02-14T16:28:18.512Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:28:18.512Z DEBUG modem << }
    2021-02-14T16:28:18.512Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:28:18.513Z DEBUG modem << Publishing: {
    2021-02-14T16:28:18.514Z DEBUG modem << "description":"Battery",
    2021-02-14T16:28:18.514Z DEBUG modem << "Time":"2021-02-14 16:26:02",
    2021-02-14T16:28:18.514Z DEBUG modem << "value":0,
    2021-02-14T16:28:18.515Z DEBUG modem << "unit":"mV",
    2021-02-14T16:28:18.515Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:28:18.515Z DEBUG modem << }
    2021-02-14T16:28:18.516Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:28:18.516Z DEBUG modem << Publishing: {
    2021-02-14T16:28:18.516Z DEBUG modem << "description":"Battery",
    2021-02-14T16:28:18.517Z DEBUG modem << "Time":"2021-02-14 16:26:32",
    2021-02-14T16:28:18.517Z DEBUG modem << "value":0,
    2021-02-14T16:28:18.517Z DEBUG modem << "unit":"mV",
    2021-02-14T16:28:18.517Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:28:18.518Z DEBUG modem << }
    2021-02-14T16:28:18.518Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:28:18.518Z DEBUG modem << Publishing: {
    2021-02-14T16:28:18.519Z DEBUG modem << "description":"Battery",
    2021-02-14T16:28:18.519Z DEBUG modem << "Time":"2021-02-14 16:27:02",
    2021-02-14T16:28:18.519Z DEBUG modem << "value":0,
    2021-02-14T16:28:18.520Z DEBUG modem << "unit":"mV",
    2021-02-14T16:28:18.521Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:28:18.522Z DEBUG modem << }
    2021-02-14T16:28:18.522Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:28:18.523Z DEBUG modem << Publishing: {
    2021-02-14T16:28:18.523Z DEBUG modem << "description":"Battery",
    2021-02-14T16:28:18.524Z DEBUG modem << "Time":"2021-02-14 16:27:32",
    2021-02-14T16:28:18.524Z DEBUG modem << "value":0,
    2021-02-14T16:28:18.524Z DEBUG modem << "unit":"mV",
    2021-02-14T16:28:18.525Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:28:18.525Z DEBUG modem << }
    2021-02-14T16:28:18.525Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:28:18.526Z DEBUG modem << Publishing: {
    2021-02-14T16:28:18.526Z DEBUG modem << "description":"Battery",
    2021-02-14T16:28:18.526Z DEBUG modem << "Time":"2021-02-14 16:28:02",
    2021-02-14T16:28:18.526Z DEBUG modem << "value":0,
    2021-02-14T16:28:18.527Z DEBUG modem << "unit":"mV",
    2021-02-14T16:28:18.529Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:28:18.529Z DEBUG modem << }
    2021-02-14T16:28:18.530Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:28:20.496Z DEBUG modem << Disconnecting MQTT client...
    2021-02-14T16:28:20.513Z DEBUG modem << [mqtt_evt_handler:350] MQTT client disconnected 0
    2021-02-14T16:28:20.515Z DEBUG modem << ERROR: mqtt_live -128
    2021-02-14T16:28:20.516Z DEBUG modem << ERROR: mqtt_input -13
    2021-02-14T16:28:20.516Z DEBUG modem << +CSCON: 1
    2021-02-14T16:28:32.043Z DEBUG modem << +CSCON: 0
    2021-02-14T16:28:32.922Z DEBUG modem << Time update:
    2021-02-14T16:28:32.923Z DEBUG modem <<   Unix time ms: 1613320112675
    2021-02-14T16:28:32.934Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:28:32
    2021-02-14T16:28:32.936Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:28:37.921Z DEBUG modem << Battery is : 0
    2021-02-14T16:28:42.913Z DEBUG modem << Counterdo value is : 0
    2021-02-14T16:29:02.922Z DEBUG modem << Time update:
    2021-02-14T16:29:02.923Z DEBUG modem <<   Unix time ms: 1613320142675
    2021-02-14T16:29:02.933Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:29:02
    2021-02-14T16:29:02.934Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:29:07.920Z DEBUG modem << Battery is : 0
    2021-02-14T16:29:12.912Z DEBUG modem << Counterdo value is : 1
    2021-02-14T16:29:32.920Z DEBUG modem << Time update:
    2021-02-14T16:29:32.921Z DEBUG modem <<   Unix time ms: 1613320172675
    2021-02-14T16:29:32.933Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:29:32
    2021-02-14T16:29:32.934Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:29:37.919Z DEBUG modem << Battery is : 0
    2021-02-14T16:29:42.912Z DEBUG modem << Counterdo value is : 2
    2021-02-14T16:30:02.920Z DEBUG modem << Time update:
    2021-02-14T16:30:02.921Z DEBUG modem <<   Unix time ms: 1613320202675
    2021-02-14T16:30:02.932Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:30:02
    2021-02-14T16:30:02.933Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:30:07.918Z DEBUG modem << Battery is : 0
    2021-02-14T16:30:12.911Z DEBUG modem << Counterdo value is : 3
    2021-02-14T16:30:32.918Z DEBUG modem << Time update:
    2021-02-14T16:30:32.919Z DEBUG modem <<   Unix time ms: 1613320232675
    2021-02-14T16:30:32.929Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:30:32
    2021-02-14T16:30:32.930Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:30:37.917Z DEBUG modem << Battery is : 0
    2021-02-14T16:30:42.909Z DEBUG modem << Counterdo value is : 4
    2021-02-14T16:31:02.918Z DEBUG modem << Time update:
    2021-02-14T16:31:02.919Z DEBUG modem <<   Unix time ms: 1613320262675
    2021-02-14T16:31:02.929Z DEBUG modem <<   Scheduler starts at local time: 2021-02-14 16:31:02
    2021-02-14T16:31:02.930Z DEBUG modem <<   Time Value is :537026650 
    2021-02-14T16:31:07.917Z DEBUG modem << Battery is : 0
    2021-02-14T16:31:12.908Z DEBUG modem << Counterdo value is : 5
    2021-02-14T16:31:18.202Z DEBUG modem << IPv4 Address found 18.184.63.203
    2021-02-14T16:31:18.463Z DEBUG modem << [mqtt_evt_handler:344] MQTT client connected!
    2021-02-14T16:31:18.475Z DEBUG modem << Subscribing to: my/send/message len 15
    2021-02-14T16:31:18.476Z DEBUG modem << Timer triggered, publishing MQTT message!!!!
    2021-02-14T16:31:18.476Z DEBUG modem << Publishing: {
    2021-02-14T16:31:18.476Z DEBUG modem << "description":"Battery",
    2021-02-14T16:31:18.477Z DEBUG modem << "Time":"2021-02-14 16:28:32",
    2021-02-14T16:31:18.477Z DEBUG modem << "value":0,
    2021-02-14T16:31:18.477Z DEBUG modem << "unit":"mV",
    2021-02-14T16:31:18.478Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:31:18.478Z DEBUG modem << }
    2021-02-14T16:31:18.478Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:31:18.479Z DEBUG modem << Publishing: {
    2021-02-14T16:31:18.479Z DEBUG modem << "description":"Battery",
    2021-02-14T16:31:18.479Z DEBUG modem << "Time":"2021-02-14 16:29:02",
    2021-02-14T16:31:18.480Z DEBUG modem << "value":0,
    2021-02-14T16:31:18.481Z DEBUG modem << "unit":"mV",
    2021-02-14T16:31:18.482Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:31:18.482Z DEBUG modem << }
    2021-02-14T16:31:18.482Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:31:18.483Z DEBUG modem << Publishing: {
    2021-02-14T16:31:18.483Z DEBUG modem << "description":"Battery",
    2021-02-14T16:31:18.483Z DEBUG modem << "Time":"2021-02-14 16:29:32",
    2021-02-14T16:31:18.483Z DEBUG modem << "value":0,
    2021-02-14T16:31:18.484Z DEBUG modem << "unit":"mV",
    2021-02-14T16:31:18.484Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:31:18.484Z DEBUG modem << }
    2021-02-14T16:31:18.485Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:31:18.486Z DEBUG modem << Publishing: {
    2021-02-14T16:31:18.486Z DEBUG modem << "description":"Battery",
    2021-02-14T16:31:18.486Z DEBUG modem << "Time":"2021-02-14 16:30:02",
    2021-02-14T16:31:18.487Z DEBUG modem << "value":0,
    2021-02-14T16:31:18.487Z DEBUG modem << "unit":"mV",
    2021-02-14T16:31:18.487Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:31:18.488Z DEBUG modem << }
    2021-02-14T16:31:18.489Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:31:18.489Z DEBUG modem << Publishing: {
    2021-02-14T16:31:18.489Z DEBUG modem << "description":"Battery",
    2021-02-14T16:31:18.490Z DEBUG modem << "Time":"2021-02-14 16:30:32",
    2021-02-14T16:31:18.490Z DEBUG modem << "value":0,
    2021-02-14T16:31:18.490Z DEBUG modem << "unit":"mV",
    2021-02-14T16:31:18.491Z DEBUG modem << "type":"Voltage"
    2021-02-14T16:31:18.491Z DEBUG modem << }
    2021-02-14T16:31:18.491Z DEBUG modem << to topic: my/listen/message len: 17
    2021-02-14T16:31:18.492Z DEBUG modem << *** Booting Zephyr OS build v2.3.0-rc1-ncs1  ***
    2021-02-14T16:31:18.493Z DEBUG modem << Flash regionsDomainPermissions
    2021-02-14T16:31:18.494Z DEBUG modem << 00 00 0x00000 0x08000 Securerwxl
    2021-02-14T16:31:18.494Z DEBUG modem << 01 31 0x08000 0x100000 Non-Securerwxl
    2021-02-14T16:31:18.494Z DEBUG modem << Non-secure callable region 0 placed in flash region 0 with size 32.
    2021-02-14T16:31:18.699Z DEBUG modem << SRAM regionDomainPermissions
    2021-02-14T16:31:18.712Z DEBUG modem << 00 07 0x00000 0x10000 Securerwxl
    2021-02-14T16:31:18.713Z DEBUG modem << 08 31 0x10000 0x40000 Non-Securerwxl
    2021-02-14T16:31:18.714Z DEBUG modem << PeripheralDomainStatus
    2021-02-14T16:31:18.715Z DEBUG modem << 00 NRF_P0               Non-SecureOK
    2021-02-14T16:31:18.715Z DEBUG modem << 01 NRF_CLOCK            Non-SecureOK
    2021-02-14T16:31:18.716Z DEBUG modem << 02 NRF_RTC0             Non-SecureOK
    2021-02-14T16:31:18.716Z DEBUG modem << 03 NRF_RTC1             Non-SecureOK
    2021-02-14T16:31:18.716Z DEBUG modem << 04 NRF_NVMC             Non-SecureOK
    2021-02-14T16:31:18.717Z DEBUG modem << 05 NRF_UARTE1           Non-SecureOK
    2021-02-14T16:31:18.718Z DEBUG modem << 06 NRF_UARTE2           SecureSKIP
    2021-02-14T16:31:18.719Z DEBUG modem << 07 NRF_TWIM2            Non-SecureOK
    2021-02-14T16:31:18.720Z DEBUG modem << 08 NRF_SPIM3            Non-SecureOK
    2021-02-14T16:31:18.721Z DEBUG modem << 09 NRF_TIMER0           Non-SecureOK
    2021-02-14T16:31:18.722Z DEBUG modem << 10 NRF_TIMER1           Non-SecureOK
    2021-02-14T16:31:18.722Z DEBUG modem << 11 NRF_TIMER2           Non-SecureOK
    2021-02-14T16:31:18.758Z DEBUG modem << 12 NRF_SAADC            Non-SecureOK
    2021-02-14T16:31:18.759Z DEBUG modem << 13 NRF_PWM0             Non-SecureOK
    2021-02-14T16:31:18.760Z DEBUG modem << 14 NRF_PWM1             Non-SecureOK
    2021-02-14T16:31:18.761Z DEBUG modem << 15 NRF_PWM2             Non-SecureOK
    2021-02-14T16:31:18.762Z DEBUG modem << 16 NRF_PWM3             Non-SecureOK
    2021-02-14T16:31:18.762Z DEBUG modem << 17 NRF_WDT              Non-SecureOK
    2021-02-14T16:31:18.762Z DEBUG modem << 18 NRF_IPC              Non-SecureOK
    2021-02-14T16:31:18.763Z DEBUG modem << 19 NRF_VMC              Non-SecureOK
    2021-02-14T16:31:18.763Z DEBUG modem << 20 NRF_FPU              Non-SecureOK
    2021-02-14T16:31:18.763Z DEBUG modem << 21 NRF_EGU1             Non-SecureOK
    2021-02-14T16:31:18.764Z DEBUG modem << 22 NRF_EGU2             Non-SecureOK
    2021-02-14T16:31:18.764Z DEBUG modem << 23 NRF_DPPIC            Non-SecureOK
    2021-02-14T16:31:18.764Z DEBUG modem << 24 NRF_GPIOTE1          Non-SecureOK
    2021-02-14T16:31:18.778Z DEBUG modem << 25 NRF_REGULATORS       Non-SecureOK
    2021-02-14T16:31:18.781Z DEBUG modem << SPM: NS image at 0xc000
    2021-02-14T16:31:18.782Z DEBUG modem << SPM: NS MSP at 0x2002c010
    2021-02-14T16:31:18.783Z DEBUG modem << SPM: NS reset vector at 0xf651
    2021-02-14T16:31:18.783Z DEBUG modem << SPM: prepare to jump to Non-Secure image.
    2021-02-14T16:31:18.949Z DEBUG modem << *** Booting Zephyr OS build v2.3.0-rc1-ncs1  ***
    2021-02-14T16:31:18.973Z DEBUG modem << The MQTT simple sample started
    2021-02-14T16:31:18.974Z DEBUG modem << LTE Link Connecting ...
    2021-02-14T16:31:23.206Z DEBUG modem << +CEREG: 2,"5226","029E6001",7,0,0,"11100000","11100000"
    2021-02-14T16:31:23.260Z DEBUG modem << +CSCON: 1
    2021-02-14T16:31:24.553Z DEBUG modem << +CEREG: 5,"5226","029E6001",7,,,"11100000","00000110"
    2021-02-14T16:31:24.570Z DEBUG modem >> AT+COPS=3,2
    2021-02-14T16:31:24.571Z DEBUG modem << LTE Link Connected!
    2021-02-14T16:31:24.573Z DEBUG modem << AT send: AT%XDATAPRFL=0
    2021-02-14T16:31:24.574Z DEBUG modem << AT ret: OK
    2021-02-14T16:31:24.576Z DEBUG modem << AT send: AT+CEREG=5
    2021-02-14T16:31:24.577Z DEBUG modem << AT ret: OK
    2021-02-14T16:31:24.578Z DEBUG modem << AT send: AT%XSYSTEMMODE=1,0,0,0
    2021-02-14T16:31:24.579Z DEBUG modem << AT ret: 1
    2021-02-14T16:31:24.580Z DEBUG modem << AT send: AT%XVBAT
    2021-02-14T16:31:24.581Z DEBUG modem << AT recv:%XVBAT: 4375
    2021-02-14T16:31:24.582Z DEBUG modem << AT ret: OK
    2021-02-14T16:31:24.583Z DEBUG modem << AT send: AT+CFUN=1
    2021-02-14T16:31:24.584Z DEBUG modem << AT ret: OK
    2021-02-14T16:31:24.585Z DEBUG modem << connecting...
    2021-02-14T16:31:24.585Z DEBUG modem << connected
    2021-02-14T16:31:24.586Z DEBUG modem << AT send: AT+CEREG=5
    2021-02-14T16:31:24.586Z DEBUG modem << AT ret: OK
    2021-02-14T16:31:24.587Z DEBUG modem << AT send: AT+CEREG?
    2021-02-14T16:31:24.587Z DEBUG modem << AT recv:+CEREG: 5,5,"5226","029E6001",7,,,"11100000","00000110"
    2021-02-14T16:31:24.587Z DEBUG modem << AT ret: OK
    2021-02-14T16:31:24.588Z DEBUG modem << Busy-wait 10 s
    2021-02-14T16:31:39.509Z DEBUG modem << +CSCON: 0
    
    mqtt_buffer_test.rar

    To test it quickly, I have each timers working at 30 seconds for now, I try to get the data every 30 seconds and then send out the data when I have buffered 6 messages. 

    It always happens that the code works perfectly as I need it for the first 4 times while publishing every 180 seconds for now, but at the 5th time, the code reboots without any error update.

    I tried to understand it based on the memory issue, and increased my memory space to : 

    # Main thread
    CONFIG_MAIN_STACK_SIZE=32768

    CONFIG_HEAP_MEM_POOL_SIZE=65536

    and now the reboot happens after the 15th time.

    I guess I am not freeing up my memory correctly that I need to, and I am not sure how to do that properly.

    Could you try to reproduce this code at your end and see what the issue could be with this. It would be of great help Slight smile.

    Regards,

    Adeel.

  • You need to free sensor6 each time my_work_handler_6 runs, otherwise you will leak the memory allocated by cJSON_CreateObject().

    If you move the call to cJSON_Delete() out of the for loop

  • Hi Didrik,

    Thanks for the suggestion. I tried it and it worked. I had just one more question to ask you regarding the 2 configurations in prj.conf file .

    I have it like this in my sample.

    CONFIG_MAIN_STACK_SIZE=32768

    CONFIG_HEAP_MEM_POOL_SIZE=65536

    What can be the maximum value of these configurations ? and how do they effect the memory ?

    Regards,

    Adeel.

  • Adeel said:
    What can be the maximum value of these configurations ? and how do they effect the memory ?

     You are obviously limited by the amount of RAM in the system.

    CONFIG_MAIN_STACK_SIZE sets the stack size for the main thread, but there are often other threads as well. The sum of all the stack sizes, and the heap size should not be more than the amount of RAM in the system.

    However, you might be able to set higher numbers, as long as you don't use too much RAM. If a stack or the heap starts to grow into a different area, weird things can happen (but porbably you just get a crash. Regardless, don't do that).

    When it comes to the heap, the memory allocation algorithm will also be a consideration. Depending on the algorithm, increasing the heap size might not let you allocate more items, just bigger items.

Related