Asset Tracker v2 - How to monitor the On/Off state of the sliding switches: sw1 and sw2 reported every minute from the nRF9160DK device to a topic of the AWS IoT Core?

I have built and run the application: Asset Tracker v2 using Segger IDE with nRF Connect SDK 1.8.0 , and my nRF9160DK device communicates with the  AWS IoT Core topics.

I can see the battery voltage data (with its time stamp) reported every minute from my nRF9160DK device to the shadow topics of the AWS IoT Core and I can also see the button-pressed data reported (when a button is pressed) from my nRF9160DK device to the AWS IoT Core topic: <IMEI>/messages.

As a next step, I would like to see the On/Off state of the sliding switches: sw1 and sw2 reported every minute from my nRF9160DK device to a topic on the AWS IoT Core.

How can this be done? 

Parents
  • Hi,

    When I tried to introduce some changes to the "Asset Tracker v2" application's src files, I saw the following error message on the LTE Link Monitor, when I tried to run this application:

    "[1,31m<err> aws-iot: Cloud MQTT input error: -16", shown line after line, as can be seen on the attached LTE Link Monitor log file: "LTE Link Monitor log 2022-01-27".

    I then removed from the src files for "Asset Tracker v2" app all changes that I introduced recently but the problem still persisted and the above mentioned error message kept coming on the LTE Link Monitor when I tried to run this application.

    I then tried to build and run the sample "aws_iot" and it seemed to work OK as per the attached LTE Link Monitor log file: "log_file_for_aws_iot_sample_27_01_2022".

    How can I rectify the error "aws-iot: Cloud MQTT input error: -16" that keeps coming on the LTE Link Monitor when I try to run the "Asset Tracker v2" app ?

    Regards,

    JM

    LTE Link Monitor log 2022-01-27.txt

    2022-01-27T08:23:28.558Z INFO Application data folder: C:\Users\Administrator\AppData\Roaming\nrfconnect\pc-nrfconnect-linkmonitor
    2022-01-27T08:23:29.178Z DEBUG App pc-nrfconnect-linkmonitor v2.0.0 official
    2022-01-27T08:23:29.179Z DEBUG App path: C:\Users\Administrator\.nrfconnect-apps\node_modules\pc-nrfconnect-linkmonitor
    2022-01-27T08:23:29.179Z DEBUG nRFConnect 3.9.3, required by the app is (^3.8.0)
    2022-01-27T08:23:29.179Z DEBUG nRFConnect path: C:\Users\Administrator\AppData\Local\Programs\nrfconnect\resources\app.asar
    2022-01-27T08:23:29.179Z DEBUG HomeDir: C:\Users\Administrator
    2022-01-27T08:23:29.179Z DEBUG TmpDir: C:\Users\ADMINI~1\AppData\Local\Temp
    2022-01-27T08:23:34.829Z INFO Modem port is opened
    2022-01-27T08:23:34.855Z DEBUG modem >> AT+CFUN?
    2022-01-27T08:23:34.960Z DEBUG modem << CFUN: 1
    2022-01-27T08:23:34.963Z DEBUG modem << OK
    2022-01-27T08:23:52.122Z DEBUG modem << *** Booting Zephyr OS build v2.7.0-ncs1  ***
    2022-01-27T08:23:52.134Z DEBUG modem << I: Starting bootloader
    2022-01-27T08:23:52.152Z DEBUG modem << I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    2022-01-27T08:23:52.165Z DEBUG modem << I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    2022-01-27T08:23:52.172Z DEBUG modem << I: Boot source: none
    2022-01-27T08:23:52.176Z DEBUG modem << I: Swap type: none
    2022-01-27T08:23:52.210Z DEBUG modem << I: Bootloader chainload address offset: 0x10000
    2022-01-27T08:23:52.219Z DEBUG modem << I: Jumping to the first image slot
    2022-01-27T08:23:52.437Z DEBUG modem << *** Booting Zephyr OS build v2.7.0-ncs1  ***
    2022-01-27T08:23:52.470Z DEBUG modem << Flash regionsDomainPermissions
    2022-01-27T08:23:52.480Z DEBUG modem << 00 03 0x00000 0x20000 Securerwxl
    2022-01-27T08:23:52.487Z DEBUG modem << 04 31 0x20000 0x100000 Non-Securerwxl
    2022-01-27T08:23:52.493Z DEBUG modem << Non-secure callable region 0 placed in flash region 3 with size 32.
    2022-01-27T08:23:52.508Z DEBUG modem << SRAM regionDomainPermissions
    2022-01-27T08:23:52.518Z DEBUG modem << 00 07 0x00000 0x10000 Securerwxl
    2022-01-27T08:23:52.528Z DEBUG modem << 08 31 0x10000 0x40000 Non-Securerwxl
    2022-01-27T08:23:52.531Z DEBUG modem << PeripheralDomainStatus
    2022-01-27T08:23:52.536Z DEBUG modem << 00 NRF_P0               Non-SecureOK
    2022-01-27T08:23:52.548Z DEBUG modem << 01 NRF_CLOCK            Non-SecureOK
    2022-01-27T08:23:52.556Z DEBUG modem << 02 NRF_RTC0             Non-SecureOK
    2022-01-27T08:23:52.560Z DEBUG modem << 03 NRF_RTC1             Non-SecureOK
    2022-01-27T08:23:52.562Z DEBUG modem << 04 NRF_NVMC             Non-SecureOK
    2022-01-27T08:23:52.565Z DEBUG modem << 05 NRF_UARTE1           Non-SecureOK
    2022-01-27T08:23:52.567Z DEBUG modem << 06 NRF_UARTE2           SecureSKIP
    2022-01-27T08:23:52.572Z DEBUG modem << 07 NRF_TWIM2            Non-SecureOK
    2022-01-27T08:23:52.576Z DEBUG modem << 08 NRF_SPIM3            Non-SecureOK
    2022-01-27T08:23:52.588Z DEBUG modem << 09 NRF_TIMER0           Non-SecureOK
    2022-01-27T08:23:52.598Z DEBUG modem << 10 NRF_TIMER1           Non-SecureOK
    2022-01-27T08:23:52.602Z DEBUG modem << 11 NRF_TIMER2           Non-SecureOK
    2022-01-27T08:23:52.605Z DEBUG modem << 12 NRF_SAADC            Non-SecureOK
    2022-01-27T08:23:52.610Z DEBUG modem << 13 NRF_PWM0             Non-SecureOK
    2022-01-27T08:23:52.612Z DEBUG modem << 14 NRF_PWM1             Non-SecureOK
    2022-01-27T08:23:52.615Z DEBUG modem << 15 NRF_PWM2             Non-SecureOK
    2022-01-27T08:23:52.618Z DEBUG modem << 16 NRF_PWM3             Non-SecureOK
    2022-01-27T08:23:52.619Z DEBUG modem << 17 NRF_WDT              Non-SecureOK
    2022-01-27T08:23:52.621Z DEBUG modem << 18 NRF_IPC              Non-SecureOK
    2022-01-27T08:23:52.623Z DEBUG modem << 19 NRF_VMC              Non-SecureOK
    2022-01-27T08:23:52.626Z DEBUG modem << 20 NRF_FPU              Non-SecureOK
    2022-01-27T08:23:52.637Z DEBUG modem << 21 NRF_EGU0             Non-SecureOK
    2022-01-27T08:23:52.641Z DEBUG modem << 22 NRF_EGU1             Non-SecureOK
    2022-01-27T08:23:52.643Z DEBUG modem << 23 NRF_EGU2             Non-SecureOK
    2022-01-27T08:23:52.645Z DEBUG modem << 24 NRF_EGU3             Non-SecureOK
    2022-01-27T08:23:52.646Z DEBUG modem << 25 NRF_EGU4             Non-SecureOK
    2022-01-27T08:23:52.649Z DEBUG modem << 26 NRF_EGU5             Non-SecureOK
    2022-01-27T08:23:52.651Z DEBUG modem << 27 NRF_DPPIC            Non-SecureOK
    2022-01-27T08:23:52.654Z DEBUG modem << 28 NRF_REGULATORS       Non-SecureOK
    2022-01-27T08:23:52.655Z DEBUG modem << 29 NRF_PDM              Non-SecureOK
    2022-01-27T08:23:52.656Z DEBUG modem << 30 NRF_I2S              Non-SecureOK
    2022-01-27T08:23:52.658Z DEBUG modem << 31 NRF_GPIOTE1          Non-SecureOK
    2022-01-27T08:23:52.659Z DEBUG modem << SPM: NS image at 0x20200
    2022-01-27T08:23:52.660Z DEBUG modem << SPM: NS MSP at 0x2001dbd8
    2022-01-27T08:23:52.661Z DEBUG modem << SPM: NS reset vector at 0x25855
    2022-01-27T08:23:52.669Z DEBUG modem << SPM: prepare to jump to Non-Secure image.
    2022-01-27T08:23:52.839Z DEBUG modem << *** Booting Zephyr OS build v2.7.0-ncs1  ***
    2022-01-27T08:23:52.856Z DEBUG modem << W: Already initialized. Nothing to do
    2022-01-27T08:23:52.873Z DEBUG modem << The AWS IoT sample started, version: v1.0.0
    2022-01-27T08:23:54.364Z DEBUG modem << LTE cell changed: Cell ID: 161454349, Tracking area: 21001
    2022-01-27T08:23:54.938Z DEBUG modem << RRC mode: Connected
    2022-01-27T08:23:56.561Z DEBUG modem << RRC mode: Idle
    2022-01-27T08:24:07.099Z DEBUG modem << RRC mode: Connected
    2022-01-27T08:24:08.739Z DEBUG modem << Network registration status: Connected - home network
    2022-01-27T08:24:08.760Z DEBUG modem << PSM parameter update: TAU: 3600, Active time: -1
    2022-01-27T08:24:08.765Z DEBUG modem << Next connection retry in 30 seconds
    2022-01-27T08:24:08.771Z DEBUG modem << AWS_IOT_EVT_CONNECTING
    2022-01-27T08:24:08.800Z DEBUG modem << DATE_TIME_OBTAINED_MODEM
    2022-01-27T08:24:09.723Z DEBUG modem << DATE_TIME_OBTAINED_NTP
    2022-01-27T08:24:09.736Z DEBUG modem << DATE_TIME_OBTAINED_NTP
    2022-01-27T08:24:18.046Z DEBUG modem << AWS_IOT_EVT_CONNECTED
    2022-01-27T08:24:18.063Z DEBUG modem << Persistent session enabled
    2022-01-27T08:24:18.069Z DEBUG modem << Publishing: {
    2022-01-27T08:24:18.075Z DEBUG modem << "state":{
    2022-01-27T08:24:18.098Z DEBUG modem << "reported":{
    2022-01-27T08:24:18.101Z DEBUG modem << "app_version":"v1.0.0",
    2022-01-27T08:24:18.105Z DEBUG modem << "batv":5078,
    2022-01-27T08:24:18.107Z DEBUG modem << "ts":1643271893326
    2022-01-27T08:24:18.110Z DEBUG modem << }
    2022-01-27T08:24:18.111Z DEBUG modem << }
    2022-01-27T08:24:18.112Z DEBUG modem << } to AWS IoT broker
    2022-01-27T08:24:18.114Z DEBUG modem << AWS_IOT_EVT_READY
    2022-01-27T08:24:18.206Z DEBUG modem << PSM parameter update: TAU: 1800, Active time: 60
    2022-01-27T08:24:20.573Z DEBUG modem << AWS_IOT_EVT_DATA_RECEIVED
    2022-01-27T08:25:18.047Z DEBUG modem << cJSON Parse failurePublishing: {
    2022-01-27T08:25:18.069Z DEBUG modem << "state":{
    2022-01-27T08:25:18.093Z DEBUG modem << "reported":{
    2022-01-27T08:25:18.099Z DEBUG modem << "batv":5089,
    2022-01-27T08:25:18.105Z DEBUG modem << "ts":1643271953326
    2022-01-27T08:25:18.110Z DEBUG modem << }
    2022-01-27T08:25:18.115Z DEBUG modem << }
    2022-01-27T08:25:18.118Z DEBUG modem << } to AWS IoT broker
    2022-01-27T08:25:18.129Z DEBUG modem << Next data publication in 60 seconds
    2022-01-27T08:26:18.059Z DEBUG modem << Publishing: {
    2022-01-27T08:26:18.076Z DEBUG modem << "state":{
    2022-01-27T08:26:18.092Z DEBUG modem << "reported":{
    2022-01-27T08:26:18.101Z DEBUG modem << "batv":5085,
    2022-01-27T08:26:18.108Z DEBUG modem << "ts":1643272013344
    2022-01-27T08:26:18.114Z DEBUG modem << }
    2022-01-27T08:26:18.121Z DEBUG modem << }
    2022-01-27T08:26:18.126Z DEBUG modem << } to AWS IoT broker
    2022-01-27T08:26:18.129Z DEBUG modem << Next data publication in 60 seconds
    2022-01-27T08:27:18.075Z DEBUG modem << Publishing: {
    2022-01-27T08:27:18.082Z DEBUG modem << "state":{
    2022-01-27T08:27:18.089Z DEBUG modem << "reported":{
    2022-01-27T08:27:18.093Z DEBUG modem << "batv":5074,
    2022-01-27T08:27:18.098Z DEBUG modem << "ts":1643272073362
    2022-01-27T08:27:18.103Z DEBUG modem << }
    2022-01-27T08:27:18.107Z DEBUG modem << }
    2022-01-27T08:27:18.113Z DEBUG modem << } to AWS IoT broker
    2022-01-27T08:27:18.116Z DEBUG modem << Next data publication in 60 seconds
    2022-01-27T08:28:18.088Z DEBUG modem << Publishing: {
    2022-01-27T08:28:18.093Z DEBUG modem << "state":{
    2022-01-27T08:28:18.100Z DEBUG modem << "reported":{
    2022-01-27T08:28:18.105Z DEBUG modem << "batv":5078,
    2022-01-27T08:28:18.110Z DEBUG modem << "ts":1643272133380
    2022-01-27T08:28:18.114Z DEBUG modem << }
    2022-01-27T08:28:18.118Z DEBUG modem << }
    2022-01-27T08:28:18.122Z DEBUG modem << } to AWS IoT broker
    2022-01-27T08:28:18.128Z DEBUG modem << Next data publication in 60 seconds
    2022-01-27T08:29:18.101Z DEBUG modem << Publishing: {
    2022-01-27T08:29:18.110Z DEBUG modem << "state":{
    2022-01-27T08:29:18.118Z DEBUG modem << "reported":{
    2022-01-27T08:29:18.125Z DEBUG modem << "batv":5078,
    2022-01-27T08:29:18.136Z DEBUG modem << "ts":1643272193398
    2022-01-27T08:29:18.140Z DEBUG modem << }
    2022-01-27T08:29:18.143Z DEBUG modem << }
    2022-01-27T08:29:18.145Z DEBUG modem << } to AWS IoT broker
    2022-01-27T08:29:18.148Z DEBUG modem << Next data publication in 60 seconds
    2022-01-27T08:30:18.116Z DEBUG modem << Publishing: {
    2022-01-27T08:30:18.121Z DEBUG modem << "state":{
    2022-01-27T08:30:18.127Z DEBUG modem << "reported":{
    2022-01-27T08:30:18.132Z DEBUG modem << "batv":5082,
    2022-01-27T08:30:18.136Z DEBUG modem << "ts":1643272253416
    2022-01-27T08:30:18.141Z DEBUG modem << }
    2022-01-27T08:30:18.147Z DEBUG modem << }
    2022-01-27T08:30:18.154Z DEBUG modem << } to AWS IoT broker
    2022-01-27T08:30:18.157Z DEBUG modem << Next data publication in 60 seconds
    2022-01-27T08:31:18.130Z DEBUG modem << Publishing: {
    2022-01-27T08:31:18.136Z DEBUG modem << "state":{
    2022-01-27T08:31:18.143Z DEBUG modem << "reported":{
    2022-01-27T08:31:18.148Z DEBUG modem << "batv":5078,
    2022-01-27T08:31:18.152Z DEBUG modem << "ts":1643272313434
    2022-01-27T08:31:18.159Z DEBUG modem << }
    2022-01-27T08:31:18.163Z DEBUG modem << }
    2022-01-27T08:31:18.167Z DEBUG modem << } to AWS IoT broker
    2022-01-27T08:31:18.171Z DEBUG modem << Next data publication in 60 seconds
    2022-01-27T08:32:18.142Z DEBUG modem << Publishing: {
    2022-01-27T08:32:18.148Z DEBUG modem << "state":{
    2022-01-27T08:32:18.157Z DEBUG modem << "reported":{
    2022-01-27T08:32:18.160Z DEBUG modem << "batv":5074,
    2022-01-27T08:32:18.163Z DEBUG modem << "ts":1643272373452
    2022-01-27T08:32:18.167Z DEBUG modem << }
    2022-01-27T08:32:18.170Z DEBUG modem << }
    2022-01-27T08:32:18.172Z DEBUG modem << } to AWS IoT broker
    2022-01-27T08:32:18.174Z DEBUG modem << Next data publication in 60 seconds
    2022-01-27T08:33:18.154Z DEBUG modem << Publishing: {
    2022-01-27T08:33:18.157Z DEBUG modem << "state":{
    2022-01-27T08:33:18.159Z DEBUG modem << "reported":{
    2022-01-27T08:33:18.162Z DEBUG modem << "batv":5062,
    2022-01-27T08:33:18.164Z DEBUG modem << "ts":1643272433470
    2022-01-27T08:33:18.166Z DEBUG modem << }
    2022-01-27T08:33:18.168Z DEBUG modem << }
    2022-01-27T08:33:18.170Z DEBUG modem << } to AWS IoT broker
    2022-01-27T08:33:18.173Z DEBUG modem << Next data publication in 60 seconds
    2022-01-27T08:34:18.170Z DEBUG modem << Publishing: {
    2022-01-27T08:34:18.178Z DEBUG modem << "state":{
    2022-01-27T08:34:18.185Z DEBUG modem << "reported":{
    2022-01-27T08:34:18.190Z DEBUG modem << "batv":5082,
    2022-01-27T08:34:18.194Z DEBUG modem << "ts":1643272493488
    2022-01-27T08:34:18.196Z DEBUG modem << }
    2022-01-27T08:34:18.198Z DEBUG modem << }
    2022-01-27T08:34:18.202Z DEBUG modem << } to AWS IoT broker
    2022-01-27T08:34:18.206Z DEBUG modem << Next data publication in 60 seconds
    2022-01-27T08:35:18.183Z DEBUG modem << Publishing: {
    2022-01-27T08:35:18.191Z DEBUG modem << "state":{
    2022-01-27T08:35:18.195Z DEBUG modem << "reported":{
    2022-01-27T08:35:18.200Z DEBUG modem << "batv":5078,
    2022-01-27T08:35:18.204Z DEBUG modem << "ts":1643272553506
    2022-01-27T08:35:18.213Z DEBUG modem << }
    2022-01-27T08:35:18.217Z DEBUG modem << }
    2022-01-27T08:35:18.223Z DEBUG modem << } to AWS IoT broker
    2022-01-27T08:35:18.227Z DEBUG modem << Next data publication in 60 seconds
    2022-01-27T08:36:18.197Z DEBUG modem << Publishing: {
    2022-01-27T08:36:18.206Z DEBUG modem << "state":{
    2022-01-27T08:36:18.211Z DEBUG modem << "reported":{
    2022-01-27T08:36:18.213Z DEBUG modem << "batv":5078,
    2022-01-27T08:36:18.215Z DEBUG modem << "ts":1643272613523
    2022-01-27T08:36:18.217Z DEBUG modem << }
    2022-01-27T08:36:18.218Z DEBUG modem << }
    2022-01-27T08:36:18.220Z DEBUG modem << } to AWS IoT broker
    2022-01-27T08:36:18.223Z DEBUG modem << Next data publication in 60 seconds
    2022-01-27T08:37:18.210Z DEBUG modem << Publishing: {
    2022-01-27T08:37:18.218Z DEBUG modem << "state":{
    2022-01-27T08:37:18.224Z DEBUG modem << "reported":{
    2022-01-27T08:37:18.230Z DEBUG modem << "batv":5078,
    2022-01-27T08:37:18.232Z DEBUG modem << "ts":1643272673541
    2022-01-27T08:37:18.234Z DEBUG modem << }
    2022-01-27T08:37:18.236Z DEBUG modem << }
    2022-01-27T08:37:18.239Z DEBUG modem << } to AWS IoT broker
    2022-01-27T08:37:18.242Z DEBUG modem << Next data publication in 60 seconds
    2022-01-27T08:38:18.225Z DEBUG modem << Publishing: {
    2022-01-27T08:38:18.230Z DEBUG modem << "state":{
    2022-01-27T08:38:18.258Z DEBUG modem << "reported":{
    2022-01-27T08:38:18.269Z DEBUG modem << "batv":5062,
    2022-01-27T08:38:18.272Z DEBUG modem << "ts":1643272733559
    2022-01-27T08:38:18.276Z DEBUG modem << }
    2022-01-27T08:38:18.278Z DEBUG modem << }
    2022-01-27T08:38:18.281Z DEBUG modem << } to AWS IoT broker
    2022-01-27T08:38:18.286Z DEBUG modem << Next data publication in 60 seconds
    

  • Hi,

     

    Jacek Majda said:

    How can I rectify the error "aws-iot: Cloud MQTT input error: -16" that keeps coming on the LTE Link Monitor when I try to run the "Asset Tracker v2" app ?

    -16 is EBUSY:

    mqtt_input -> client_read, which returns EBUSY when the socket is still writing (ie. uploading) data:

    https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.0-ncs1/subsys/net/lib/mqtt/mqtt.c#L117

     

    Before the above error is printed, you are seeing:

    2022-01-27T08:06:19.469Z DEBUG modem << [00:00:29.372,650] [1;31m<err> aws_iot: Incoming MQTT message too large for payload buffer[0m
    2022-01-27T08:06:19.495Z DEBUG modem << [00:00:29.381,072] [1;31m<err> aws_iot: publish_get_payload, error: -122

    How large is the payload you're sending?

     

    Kind regards,

    Håkon

Reply Children
No Data
Related