Hello,
I am a beginner student and I think this is the kind of misunderstanding on my part. I program on the Thingy 1.4.0 with the SDK 1.4.2. I create my own project to learn a little more about the embedded world. In this project I have several threads (Collect sensor values, connect to NB-IoT, connect to MQTT, LED and Button, send MQTT data).
I currently have a problem with my MQTT thread because the CONNACK events don't seem to be triggered. I receive the error MQTT disconnect -57. I can't find the origin of the problem. Do you have an idea to share? I have tested the simple MQTT and I use a lot of the functions and the one I modified were tested in a simple project without thread and it works. I think it has a link but I don't know how to solve it.
Thank you.
I attach my project here and the log:
2021-03-10T15:42:32.061Z INFO Application data folder: C:\Users\tgasser\AppData\Roaming\nrfconnect\pc-nrfconnect-linkmonitor 2021-03-10T15:42:32.105Z DEBUG App pc-nrfconnect-linkmonitor v1.1.10 official 2021-03-10T15:42:32.106Z DEBUG App path: C:\Users\tgasser\.nrfconnect-apps\node_modules\pc-nrfconnect-linkmonitor 2021-03-10T15:42:32.106Z DEBUG nRFConnect 3.6.1 is supported by the app (^3.6.0) 2021-03-10T15:42:32.106Z DEBUG nRFConnect path: C:\Users\tgasser\AppData\Local\Programs\nrfconnect\resources\app.asar 2021-03-10T15:42:32.107Z DEBUG HomeDir: C:\Users\tgasser 2021-03-10T15:42:32.107Z DEBUG TmpDir: C:\Users\tgasser\AppData\Local\Temp 2021-03-10T15:42:40.959Z INFO Modem port is opened 2021-03-10T15:42:40.968Z DEBUG modem >> AT+CFUN? 2021-03-10T15:42:50.734Z DEBUG modem << *** Booting Zephyr OS build v2.4.0-ncs2 *** 2021-03-10T15:42:51.453Z DEBUG modem << ð*** Booting Zephyr OS build v2.4.0-ncs2 *** 2021-03-10T15:42:51.476Z DEBUG modem << Flash regionsDomainPermissions 2021-03-10T15:42:51.481Z DEBUG modem << 00 00 0x00000 0x08000 Securerwxl 2021-03-10T15:42:51.485Z DEBUG modem << 01 31 0x08000 0x100000 Non-Securerwxl 2021-03-10T15:42:51.488Z DEBUG modem << Non-secure callable region 0 placed in flash region 0 with size 32. 2021-03-10T15:42:51.760Z DEBUG modem << SRAM regionDomainPermissions 2021-03-10T15:42:51.768Z DEBUG modem << 00 07 0x00000 0x10000 Securerwxl 2021-03-10T15:42:51.774Z DEBUG modem << 08 31 0x10000 0x40000 Non-Securerwxl 2021-03-10T15:42:51.779Z DEBUG modem << PeripheralDomainStatus 2021-03-10T15:42:51.784Z DEBUG modem << 00 NRF_P0 Non-SecureOK 2021-03-10T15:42:51.789Z DEBUG modem << 01 NRF_CLOCK Non-SecureOK 2021-03-10T15:42:51.794Z DEBUG modem << 02 NRF_RTC0 Non-SecureOK 2021-03-10T15:42:51.805Z DEBUG modem << 03 NRF_RTC1 Non-SecureOK 2021-03-10T15:42:51.807Z DEBUG modem << 04 NRF_NVMC Non-SecureOK 2021-03-10T15:42:51.809Z DEBUG modem << 05 NRF_UARTE1 Non-SecureOK 2021-03-10T15:42:51.811Z DEBUG modem << 06 NRF_UARTE2 SecureSKIP 2021-03-10T15:42:51.813Z DEBUG modem << 07 NRF_TWIM2 Non-SecureOK 2021-03-10T15:42:51.817Z DEBUG modem << 08 NRF_SPIM3 Non-SecureOK 2021-03-10T15:42:51.820Z DEBUG modem << 09 NRF_TIMER0 Non-SecureOK 2021-03-10T15:42:51.822Z DEBUG modem << 10 NRF_TIMER1 Non-SecureOK 2021-03-10T15:42:51.826Z DEBUG modem << 11 NRF_TIMER2 Non-SecureOK 2021-03-10T15:42:51.830Z DEBUG modem << 12 NRF_SAADC Non-SecureOK 2021-03-10T15:42:51.833Z DEBUG modem << 13 NRF_PWM0 Non-SecureOK 2021-03-10T15:42:51.836Z DEBUG modem << 14 NRF_PWM1 Non-SecureOK 2021-03-10T15:42:51.837Z DEBUG modem << 15 NRF_PWM2 Non-SecureOK 2021-03-10T15:42:51.838Z DEBUG modem << 16 NRF_PWM3 Non-SecureOK 2021-03-10T15:42:51.839Z DEBUG modem << 17 NRF_WDT Non-SecureOK 2021-03-10T15:42:51.841Z DEBUG modem << 18 NRF_IPC Non-SecureOK 2021-03-10T15:42:51.842Z DEBUG modem << 19 NRF_VMC Non-SecureOK 2021-03-10T15:42:51.843Z DEBUG modem << 20 NRF_FPU Non-SecureOK 2021-03-10T15:42:51.844Z DEBUG modem << 21 NRF_EGU1 Non-SecureOK 2021-03-10T15:42:51.845Z DEBUG modem << 22 NRF_EGU2 Non-SecureOK 2021-03-10T15:42:51.846Z DEBUG modem << 23 NRF_DPPIC Non-SecureOK 2021-03-10T15:42:51.847Z DEBUG modem << 24 NRF_GPIOTE1 Non-SecureOK 2021-03-10T15:42:51.851Z DEBUG modem << 25 NRF_REGULATORS Non-SecureOK 2021-03-10T15:42:51.853Z DEBUG modem << SPM: NS image at 0xc000 2021-03-10T15:42:51.855Z DEBUG modem << SPM: NS MSP at 0x2002b9a8 2021-03-10T15:42:51.857Z DEBUG modem << SPM: NS reset vector at 0x117d9 2021-03-10T15:42:51.858Z DEBUG modem << SPM: prepare to jump to Non-Secure image. 2021-03-10T15:42:52.974Z DEBUG modem << *** Booting Zephyr OS build v2.4.0-ncs2 *** 2021-03-10T15:42:53.000Z DEBUG modem << Waiting for network.. 2021-03-10T15:42:54.014Z DEBUG modem << [00:00:01.242,156] [1;33m<wrn> at_notif: Already initialized. Nothing to do[0m 2021-03-10T15:42:54.020Z DEBUG modem << [00:00:01.258,361] [0m<inf> lte_lc: PDP Context: AT+CGDCONT=0,"IP","iot.1nce.net"[0m 2021-03-10T15:43:08.183Z DEBUG modem << LTE Link Connected! 2021-03-10T15:43:08.189Z DEBUG modem << Time to connect: 15 seconds 2021-03-10T15:43:18.193Z DEBUG modem << [Info] Operator: 26201 2021-03-10T15:43:19.449Z DEBUG modem << IPv4 Address found 137.135.83.217 2021-03-10T15:43:20.459Z DEBUG modem << [00:00:27.693,634] [0m<dbg> net_mqtt_sock_tcp.mqtt_client_tcp_connect: (0x20020948): Created socket 1[0m 2021-03-10T15:43:21.637Z DEBUG modem << [00:00:29.686,645] [0m<dbg> net_mqtt_sock_tcp.mqtt_client_tcp_connect: (0x20020948): Connect completed[0m 2021-03-10T15:43:21.646Z DEBUG modem << [00:00:29.686,676] [0m<dbg> net_mqtt_enc.connect_request_encode: (0x20020948): Encoding Protocol Description. Str:MQTT Size:00000004.[0m 2021-03-10T15:43:21.650Z DEBUG modem << [00:00:29.686,706] [0m<dbg> net_mqtt_enc.pack_utf8_str: (0x20020948): >> str_size:00000006 cur:0x2002359c, end:0x20023617[0m 2021-03-10T15:43:21.653Z DEBUG modem << [00:00:29.686,706] [0m<dbg> net_mqtt_enc.pack_uint16: (0x20020948): >> val:0004 cur:0x2002359c, end:0x20023617[0m 2021-03-10T15:43:21.656Z DEBUG modem << [00:00:29.686,737] [0m<dbg> net_mqtt_enc.connect_request_encode: (0x20020948): Encoding Protocol Version 04.[0m 2021-03-10T15:43:21.658Z DEBUG modem << [00:00:29.686,737] [0m<dbg> net_mqtt_enc.pack_uint8: (0x20020948): >> val:04 cur:0x200235a2, end:0x20023617[0m 2021-03-10T15:43:21.660Z DEBUG modem << [00:00:29.686,767] [0m<dbg> net_mqtt_enc.pack_uint8: (0x20020948): >> val:00 cur:0x200235a3, end:0x20023617[0m 2021-03-10T15:43:21.662Z DEBUG modem << [00:00:29.686,767] [0m<dbg> net_mqtt_enc.connect_request_encode: (0x20020948): Encoding Keep Alive Time 003c.[0m 2021-03-10T15:43:21.664Z DEBUG modem << [00:00:29.686,798] [0m<dbg> net_mqtt_enc.pack_uint16: (0x20020948): >> val:003c cur:0x200235a4, end:0x20023617[0m 2021-03-10T15:43:21.666Z DEBUG modem << [00:00:29.686,798] [0m<dbg> net_mqtt_enc.connect_request_encode: (0x20020948): Encoding Client Id. Str:Thingy_Client Size:0000000d.[0m 2021-03-10T15:43:21.673Z DEBUG modem << [00:00:29.686,859] [0m<dbg> net_mqtt_enc.pack_utf8_str: (0x20020948): >> str_size:0000000f cur:0x200235a6, end:0x20023617[0m 2021-03-10T15:43:21.675Z DEBUG modem << [00:00:29.686,859] [0m<dbg> net_mqtt_enc.pack_uint16: (0x20020948): >> val:000d cur:0x200235a6, end:0x20023617[0m 2021-03-10T15:43:21.677Z DEBUG modem << [00:00:29.686,889] [0m<dbg> net_mqtt_enc.mqtt_encode_fixed_header: (0x20020948): << msg type:0x10 length:0x00000019[0m 2021-03-10T15:43:21.679Z DEBUG modem << [00:00:29.686,889] [0m<dbg> net_mqtt_enc.packet_length_encode: (0x20020948): >> length:0x00000019 cur:0x00000000, end:0x00000000[0m 2021-03-10T15:43:21.680Z DEBUG modem << [00:00:29.686,920] [0m<dbg> net_mqtt_enc.mqtt_encode_fixed_header: (0x20020948): Fixed header length = 02[0m 2021-03-10T15:43:21.682Z DEBUG modem << [00:00:29.686,920] [0m<dbg> net_mqtt_enc.pack_uint8: (0x20020948): >> val:10 cur:0x2002359a, end:0x20023617[0m 2021-03-10T15:43:21.685Z DEBUG modem << [00:00:29.686,950] [0m<dbg> net_mqtt_enc.packet_length_encode: (0x20020948): >> length:0x00000019 cur:0x2002359b, end:0x20023617[0m 2021-03-10T15:43:21.722Z DEBUG modem << [00:00:29.687,255] [0m<dbg> net_mqtt.client_connect: (0x20020948): Connect completed[0m 2021-03-10T15:44:21.446Z DEBUG modem << ERROR: mqtt_live -57 2021-03-10T15:44:21.450Z DEBUG modem << Disconnecting MQTT client... 2021-03-10T15:44:21.960Z DEBUG modem << Could not disconnect MQTT client. Error: -57