Thingy91 lwm2m FOTA update

Good day 

I am trying pull an update from our own server using lwm2m and have attempted to follow the steps accordingly.  The sample I'm using is the standard lwm2m client sample.  I seem to  be getting an error which is documented as a connection timeout.  Any ideas on what I need to do ?

2023-04-17T10:51:55.817Z DEBUG modem << [m[1;32muart:~$ [m[8D[J*** Booting Zephyr OS build v3.2.99-ncs2 ***
2023-04-17T10:51:55.822Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:01.507,812] [0m<inf> app_lwm2m_client: Run LWM2M client[0m
2023-04-17T10:51:55.826Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:01.507,812] [0m<inf> app_lwm2m_client: Initializing modem.[0m
2023-04-17T10:51:55.829Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:01.509,918] [0m<inf> BH1749: BH1749 initialized[0m
2023-04-17T10:51:55.833Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:01.524,810] [0m<inf> app_lwm2m_client: endpoint: urn:imei:******[0m
2023-04-17T10:51:55.836Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:01.571,014] [0m<dbg> app_lwm2m: buzzer_intensity_cb: Intensity: 100[0m
2023-04-17T10:51:57.900Z DEBUG modem << [1;32muart:~$ [m[8D[J[1;32muart:~$ [m[8D[J[00:00:03.572,448] [0m<inf> app_sensors: Finished accelerometer calibration[0m
2023-04-17T10:51:57.905Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:03.572,753] [0m<dbg> app_sensors: colour_sensor_create: Created IPSO Colour Sensor instance: 0[0m
2023-04-17T10:51:57.908Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:03.572,906] [0m<dbg> app_sensors: colour_sensor_create: Created IPSO Colour Sensor instance: 1[0m
2023-04-17T10:51:57.912Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:03.573,059] [0m<inf> lwm2m_lte_notification: Registering ncell notification handler[0m
2023-04-17T10:51:57.915Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:03.573,150] [0m<inf> lwm2m_firmware: Image is confirmed OK[0m
2023-04-17T10:51:57.919Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:03.582,031] [0m<inf> app_lwm2m_client: PSM mode requested[0m
2023-04-17T10:51:57.922Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:03.582,031] [0m<inf> app_lwm2m_client: Connecting to network.[0m
2023-04-17T10:51:57.925Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:03.582,061] [0m<inf> app_lwm2m_client: This may take several minutes.[0m
2023-04-17T10:52:00.799Z DEBUG modem << [1;32muart:~$ [m[8D[J[1;32muart:~$ [m[8D[J[00:00:06.542,358] [0m<dbg> app_lwm2m_client: lwm2m_lte_reg_handler_notify: LTE NW status: 2[0m
2023-04-17T10:52:03.020Z DEBUG modem << [1;32muart:~$ [m[8D[J[1;32muart:~$ [m[8D[J[00:00:08.711,151] [0m<dbg> app_lwm2m_client: lwm2m_lte_reg_handler_notify: LTE NW status: 1[0m
2023-04-17T10:52:03.024Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:08.712,036] [0m<inf> app_lwm2m_client: Connected to NB-IoT network[0m
2023-04-17T10:52:03.027Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:08.712,432] [1;31m<err> gnss_module: Failed to set GNSS use case (-13)[0m
2023-04-17T10:52:03.030Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:08.712,554] [0m<inf> app_lwm2m_client: Client connect to server[0m
2023-04-17T10:52:03.033Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:08.712,615] [0m<inf> 3: Start LWM2M Client: urn:*************[0m
2023-04-17T10:52:03.036Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:09.508,758] [0m<inf> 3: RD Client started with endpoint '********' with client lifetime 43200[0m
2023-04-17T10:52:05.311Z DEBUG modem << [1;32muart:~$ [m[8D[J[1;32muart:~$ [m[8D[J[00:00:11.032,226] [0m<inf> lwm2m_security: Need to write credentials, requesting LTE and GNSS offline...[0m
2023-04-17T10:52:05.316Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:11.573,089] [0m<dbg> app_lwm2m_client: lwm2m_lte_reg_handler_notify: LTE NW status: 0[0m
2023-04-17T10:52:05.319Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:11.573,242] [0m<inf> app_lwm2m_client: LwM2M is connecting to server[0m
2023-04-17T10:52:06.424Z DEBUG modem << [1;32muart:~$ [m[8D[J[1;32muart:~$ [m[8D[J[00:00:12.168,334] [0m<inf> lwm2m_security: Requesting LTE and GNSS online[0m
2023-04-17T10:52:09.417Z DEBUG modem << [1;32muart:~$ [m[8D[J[1;32muart:~$ [m[8D[J[00:00:15.161,254] [0m<dbg> app_lwm2m_client: lwm2m_lte_reg_handler_notify: LTE NW status: 2[0m
2023-04-17T10:52:10.843Z DEBUG modem << [1;32muart:~$ [m[8D[J[1;32muart:~$ [m[8D[J[00:00:16.567,321] [0m<inf> lwm2m_security: Modem connection restored[0m
2023-04-17T10:52:10.849Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:16.767,120] [0m<dbg> app_lwm2m_client: lwm2m_lte_reg_handler_notify: LTE NW status: 1[0m
2023-04-17T10:52:10.866Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:16.767,425] [0m<inf> app_lwm2m_client: LwM2M is connecting to server[0m
2023-04-17T10:52:12.263Z DEBUG modem << [1;32muart:~$ [m[8D[J[1;32muart:~$ [m[8D[J[00:00:17.969,573] [0m<inf> net_lwm2m_engine: Connected, sock id 0[0m
2023-04-17T10:52:12.267Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:18.547,973] [0m<dbg> app_lwm2m_client: rd_client_event: Registration complete[0m
2023-04-17T10:52:12.270Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:18.548,034] [0m<inf> 3: Registration Done (EP='9CjKyTlser')[0m
2023-04-17T10:52:12.273Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:18.548,339] [0m<inf> app_lwm2m_client: LwM2M is connected to server[0m
2023-04-17T10:52:12.277Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:18.548,431] [0m<inf> app_lwm2m_client: Obtained date-time from modem[0m
2023-04-17T10:52:19.743Z DEBUG modem << [1;32muart:~$ [m[8D[J[1;32muart:~$ [m[8D[J[00:00:25.425,445] [0m<inf> download_client: Setting up TLS credentials, tag 16842753[0m
2023-04-17T10:52:19.748Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:25.425,567] [0m<inf> download_client: Connecting to https://download.*redacted*.com[0m
2023-04-17T10:52:19.751Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:25.682,983] [1;31m<err> download_client: Unable to connect, errno 116[0m
2023-04-17T10:52:19.754Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:25.683,380] [1;31m<err> lwm2m_firmware: fota_download_start() failed, return code -116[0m
2023-04-17T10:52:19.757Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:25.684,783] [1;33m<wrn> fota_download: fota_download_cancel invalid state[0m
2023-04-17T10:52:19.760Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:25.684,814] [1;31m<err> lwm2m_firmware: Unsupported Image type 0[0m
2023-04-17T10:52:19.763Z DEBUG modem << [1;32muart:~$ [m[8D[J[00:00:25.684,814] [1;31m<err> lwm2m_firmware: Failed to reset DFU target, err: -13[0m
2023-04-17T10:52:49.241Z DEBUG modem << [1;32muart:~$ [m[8D[J[1;32muart:~$ [m[8D[J[00:00:54.987,121] [0m<dbg> app_lwm2m_client: rd_client_event: Queue mode RX window closed[0m

  • # General config
    CONFIG_NEWLIB_LIBC=y
    CONFIG_ASSERT=y
    CONFIG_REBOOT=y
    
    # Network
    CONFIG_NETWORKING=y
    CONFIG_NET_NATIVE=n
    CONFIG_NET_IPV6=n
    CONFIG_NET_IPV4=y
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_SOCKETS_OFFLOAD=y
    
    # Sensors
    CONFIG_I2C=y
    CONFIG_SPI=y
    CONFIG_SENSOR=y
    
    # LwM2M and IPSO
    CONFIG_LWM2M=y
    CONFIG_LWM2M_COAP_BLOCK_SIZE=512
    CONFIG_LWM2M_COAP_MAX_MSG_SIZE=1280
    CONFIG_LWM2M_ENGINE_MAX_OBSERVER=15
    CONFIG_LWM2M_ENGINE_MAX_MESSAGES=15
    CONFIG_LWM2M_ENGINE_MAX_PENDING=15
    CONFIG_LWM2M_ENGINE_MAX_REPLIES=15
    CONFIG_LWM2M_DNS_SUPPORT=y
    CONFIG_LWM2M_RW_JSON_SUPPORT=n
    CONFIG_LWM2M_SERVER_DEFAULT_PMIN=1
    CONFIG_LWM2M_SERVER_DEFAULT_PMAX=300
    CONFIG_LWM2M_CLIENT_UTILS=y
    CONFIG_LWM2M_CLIENT_UTILS_LOCATION_OBJ_SUPPORT=n
    CONFIG_LWM2M_IPSO_SUPPORT=y
    
    # DTLS settings
    CONFIG_LWM2M_DTLS_SUPPORT=y
    
    # nRF9160 helper libraries
    CONFIG_MODEM_KEY_MGMT=y
    
    # Default app to debug logging
    CONFIG_LOG=y
    CONFIG_APP_LOG_LEVEL_DBG=y
    
    # Support HEX style PSK values (double the size + NULL char)
    CONFIG_LWM2M_SECURITY_KEY_SIZE=33
    
    # extend CoAP retry timing to 4 seconds for LTE/LTE-M
    CONFIG_COAP_INIT_ACK_TIMEOUT_MS=4000
    
    # Enable CoAP extended option length
    CONFIG_COAP_EXTENDED_OPTIONS_LEN=y
    CONFIG_COAP_EXTENDED_OPTIONS_LEN_VALUE=40
    
    # Enable settings storage
    CONFIG_SETTINGS=y
    CONFIG_FCB=y
    CONFIG_SETTINGS_FCB=y
    
    # LTE link control
    CONFIG_LTE_LINK_CONTROL=y
    CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
    CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y
    
    # Modem library
    CONFIG_NRF_MODEM_LIB=y
    
    # Modem info
    CONFIG_MODEM_INFO=y
    CONFIG_MODEM_INFO_ADD_DATE_TIME=n
    
    # Enable shell
    CONFIG_LWM2M_SHELL=y
    
    # Heap and stacks
    CONFIG_HEAP_MEM_POOL_SIZE=16384
    CONFIG_MAIN_STACK_SIZE=4096
    CONFIG_LWM2M_ENGINE_STACK_SIZE=3072
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    # Allow FOTA downloads using download-client
    CONFIG_DOWNLOAD_CLIENT=y
    CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096
    CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE_1024=y
    CONFIG_FOTA_DOWNLOAD=y
    CONFIG_LWM2M_FIRMWARE_UPDATE_PULL_SUPPORT=y
    
    
    # Application version
    CONFIG_MCUBOOT_IMAGE_VERSION="1.0.0"
    
    # Set LwM2M Server IP address here
    CONFIG_LWM2M_CLIENT_UTILS_SERVER="coaps://leshan.eclipseprojects.io:5684"
    
    # Application Event Manager
    CONFIG_APP_EVENT_MANAGER=y
    
    # Date-Time library
    CONFIG_DATE_TIME=y
    CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=86400
    
    # Enable LwM2M Queue Mode
    CONFIG_LWM2M_QUEUE_MODE_ENABLED=n
    
    # Enable TLS session caching to prevent doing a full TLS handshake for every send.
    CONFIG_LWM2M_TLS_SESSION_CACHING=y
    
    # Socket close is skipped at RX off idle state which optimize power consumption
    # Socket close call will enable RCC connection for send Alert message to server
    # Alert is now send right before opening a new connection.
    CONFIG_LWM2M_RD_CLIENT_SUSPEND_SOCKET_AT_IDLE=y
    
    # Sets the duration that the lwm2m engine will be polling for data after transmission before
    # the socket is closed.
    # Adjust so that we can detach from network in 30 seconds
    CONFIG_LWM2M_QUEUE_MODE_UPTIME=30
    
    # Set lifetime of 12 hours
    CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME=43200
    
    # Do registration update after 5400 seconds (90 minutes)
    CONFIG_LWM2M_SECONDS_TO_UPDATE_EARLY=37800
    
    # Configure PSM mode
    # Request periodic TAU of 3600 seconds (60 minutes)
    CONFIG_LTE_PSM_REQ_RPTAU="00000110"
    
    # Set Requested Active Time (RAT) to 30 seconds. Preferably a little bit longer than the
    # configured LWM2M_QUEUE_MODE_UPTIME. Due to NAT/firewall UDP connections are usually
    # closed within 30-60 seconds so there is in general no point in setting a longer
    # Queue mode uptime / LTE PSM active time.
    CONFIG_LTE_PSM_REQ_RAT="00001111"
    
    # Request eDRX mode
    CONFIG_LTE_EDRX_REQ=y
    
    # Request eDRX cycle length of 10.24 seconds for LTE-M
    CONFIG_LTE_EDRX_REQ_VALUE_LTE_M="0001"
    
    # Request eDRX cycle length of 20.48 seconds for NB-IoT
    CONFIG_LTE_EDRX_REQ_VALUE_NBIOT="0010"
    
    # Request Paging time window of 1.28 seconds for LTE-M
    CONFIG_LTE_PTW_VALUE_LTE_M="0000"
    
    # Request Paging time window of 2.56 seconds for NB-IoT
    CONFIG_LTE_PTW_VALUE_NBIOT="0000"
    
    # Get notification before Tracking Area Update (TAU). Notification triggers registration
    # update and TAU will be sent with the update which decreases power consumption.
    CONFIG_LTE_LC_TAU_PRE_WARNING_NOTIFICATIONS=y
    
    # NBIOT
    
    CONFIG_LTE_NETWORK_MODE_NBIOT=y
    CONFIG_PDN=y
    CONFIG_PDN_DEFAULTS_OVERRIDE=y
    CONFIG_PDN_DEFAULT_APN="nbiot.*******"
    
    CONFIG_LWM2M_CLIENT_UTILS_SERVER="coaps://leshan.eclipseprojects.io:5684"
    CONFIG_APP_LWM2M_PSK="000102030405060708090a0b0c0d0e0f"
    CONFIG_BOOTLOADER_MCUBOOT=y
    
    CONFIG_DOWNLOAD_CLIENT=y
    CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096
    CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE_1024=y
    CONFIG_FOTA_DOWNLOAD=y
    CONFIG_LWM2M_FIRMWARE_UPDATE_OBJ_SUPPORT=y
    CONFIG_DFU_TARGET=y
    
    

    Would like to add that all did was configure NBIOT for my device.  Thank you !

    Kind regards,

    Hassan

  • Hello,

    have you checked that the certificates are correct?

  • Hi !

    Are you talking about certificates for the website(where i'm pulling from) or for the device? not quite understanding.  The website does not use any security at the moment 

  • I can see from the log that you are trying to connect to a HTTPS host where I assume the FOTA image is hosted. So I would imagine that will require that you have the necessary certificates provisioned on your device.

  • Thank you !  WIll definitely try this.  Does the client distinguish when to use TLS and when not to strictly with http or https?  Or can it be configured later on?

    Kind regards

    Hassan

Related