lwm2m client thingy91

Good day

I have used the previous versions of thngy91 built in sensor(BME680) successfully .  However, I have found that the latest version of the sample doesn't use the same read callback method.  As a result, when a read is performed, the value reflects fine but any request after that doesn't update the variable.  Just thought that it would be worthwhile to look into.

Thank you !

Hassan

Parents
  • Hi,

     

    Which version of ncs is non-working in your scenario?

    Is this an issue that you see with a simpler project, like this one as well?

    https://github.com/nrfconnect/sdk-zephyr/blob/v3.1.99-ncs1-2/samples/sensor/bme680/src/main.c

     

    Kind regards,

    Håkon

  • Hi Håkon

    The lwm2m_client sample has BME680 implemented for the thingy91.  The latest zephyr sample has shown this issue but all previous versions seem to be working fine.  I have used the method described in the above code and the temperature collection works fine! I assume that the issue exists in dealing with the button push.

    Kind regards,

    Hassan

  • Hi,

     

    Hkhan7861 said:
    The latest zephyr sample has shown this issue but all previous versions seem to be working fine.

    Could you share specific version(s) where this issue is present?

    Hkhan7861 said:
    I have used the method described in the above code and the temperature collection works fine! I assume that the issue exists in dealing with the button push.

    Have you done any changes to the original sample? If so, can you share those?

    Kind regards,

    Håkon

  • Good day 

    The sample is the one described here:

    nrf/samples/nrf9160/lwm2m_client

    In SDK v2.2.0, the temperature doesn't update every button push while in SDK v2.1.3 it does.  

    I did not change my main.c file at all.  Alll I changed was my prj file as I am using NBIOT. 

    # 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
    
    # UI
    CONFIG_UI_LOG_LEVEL_DBG=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_ENGINE_DEFAULT_LIFETIME=30
    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
    
    # Expand logging memory to avoid log_strdup() errors
    
    # 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
    
    # 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
    
    
    # NBIOT
    
    CONFIG_LTE_NETWORK_MODE_NBIOT=y
    CONFIG_PDN=y
    CONFIG_PDN_DEFAULTS_OVERRIDE=y
    CONFIG_PDN_DEFAULT_APN="nbiot.vodacom.za"
    
    # Set LwM2M Server IP address here
    CONFIG_LWM2M_CLIENT_UTILS_SERVER="coaps://leshan.eclipseprojects.io:5684"
    CONFIG_APP_LWM2M_PSK="000102030405060708090a0b0c0d0e0f"

Reply
  • Good day 

    The sample is the one described here:

    nrf/samples/nrf9160/lwm2m_client

    In SDK v2.2.0, the temperature doesn't update every button push while in SDK v2.1.3 it does.  

    I did not change my main.c file at all.  Alll I changed was my prj file as I am using NBIOT. 

    # 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
    
    # UI
    CONFIG_UI_LOG_LEVEL_DBG=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_ENGINE_DEFAULT_LIFETIME=30
    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
    
    # Expand logging memory to avoid log_strdup() errors
    
    # 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
    
    # 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
    
    
    # NBIOT
    
    CONFIG_LTE_NETWORK_MODE_NBIOT=y
    CONFIG_PDN=y
    CONFIG_PDN_DEFAULTS_OVERRIDE=y
    CONFIG_PDN_DEFAULT_APN="nbiot.vodacom.za"
    
    # Set LwM2M Server IP address here
    CONFIG_LWM2M_CLIENT_UTILS_SERVER="coaps://leshan.eclipseprojects.io:5684"
    CONFIG_APP_LWM2M_PSK="000102030405060708090a0b0c0d0e0f"

Children
  • Could you share details and logs of what actually does not work as expected?

    Here's a log from ncs v2.1.0:

    uart:~$ *** Booting Zephyr OS build v3.1.99-ncs1  ***
    [00:00:01.458,374] <inf> BH1749: BH1749 initialized
    [00:00:01.460,296] <inf> app_lwm2m_client: Run LWM2M client
    [00:00:01.460,693] <inf> app_lwm2m_client: Initializing modem.
    [00:00:01.477,264] <inf> app_lwm2m_client: endpoint: urn:imei:352656106121406
    [00:00:01.479,217] <dbg> app_lwm2m_buzzer: buzzer_intensity_cb: Intensity: 0
    [00:00:03.480,651] <inf> accelerometer: Finished accelerometer calibration
    [00:00:03.481,323] <inf> lwm2m_neighbour_cell: Registering ncell notification handler
    [00:00:03.481,384] <inf> lwm2m_firmware: Update Counter: current 0, update 0
    [00:00:03.481,414] <inf> lwm2m_firmware: Image is not confirmed OK
    [00:00:03.481,445] <inf> lwm2m_firmware: Marked image as OK
    [00:00:03.481,567] <inf> lwm2m_firmware: Update Counter updated
    [00:00:03.481,597] <inf> lwm2m_firmware: Firmware updated successfully
    [00:00:03.481,628] <inf> app_lwm2m_client: Connecting to LTE network.
    [00:00:03.481,658] <inf> app_lwm2m_client: This may take several minutes.
    [00:00:16.252,075] <inf> app_lwm2m_client: Connected to LTE network
    [00:00:16.256,225] <inf> lwm2m_connmon: Updating modem data on connmon
    [00:00:16.257,507] <inf> net_lwm2m_rd_client: Start LWM2M Client: urn:imei:352656106121406
    [00:00:16.963,073] <inf> net_lwm2m_rd_client: RD Client started with endpoint 'urn:imei:352656106121406' with client lifetime 0
    [00:00:17.107,604] <inf> lwm2m_security: Need to write credentials, requesting LTE and GNSS offline...
    [00:00:17.257,537] <inf> lwm2m_neighbour_cell: RRC connected, measure when idle
    [00:00:20.331,726] <inf> lwm2m_security: Requesting LTE and GNSS online
    [00:00:22.495,025] <inf> lwm2m_security: Modem connection restored
    [00:00:22.857,360] <inf> net_lwm2m_engine: Connected, sock id 0
    [00:00:22.940,643] <dbg> app_lwm2m_client: rd_client_event: Registration complete
    [00:00:22.940,795] <inf> app_lwm2m_client: Obtained date-time from modem
    [00:00:22.942,077] <dbg> gnss_module: gnss_event_handler: A-GPS data request not supported.
    [00:00:22.942,108] <dbg> gnss_module: start_gnss: Started GNSS scan
    [00:00:22.942,138] <inf> net_lwm2m_rd_client: Registration Done (EP='LpDLrYgv57')
    [00:00:48.317,321] <inf> net_lwm2m_rd_client: Update callback (code:2.4)
    [00:00:48.317,352] <dbg> app_lwm2m_client: rd_client_event: Registration update complete
    [00:00:48.317,382] <inf> net_lwm2m_rd_client: Update Done
    [00:01:13.421,020] <inf> net_lwm2m_rd_client: Update callback (code:2.4)
    [00:01:13.421,081] <dbg> app_lwm2m_client: rd_client_event: Registration update complete
    [00:01:13.421,081] <inf> net_lwm2m_rd_client: Update Done
    [00:01:38.709,747] <inf> net_lwm2m_rd_client: Update callback (code:2.4)
    [00:01:38.709,777] <dbg> app_lwm2m_client: rd_client_event: Registration update complete
    [00:01:38.709,808] <inf> net_lwm2m_rd_client: Update Done
    [00:02:03.910,430] <inf> net_lwm2m_rd_client: Update callback (code:2.4)
    [00:02:03.910,491] <dbg> app_lwm2m_client: rd_client_event: Registration update complete
    [00:02:03.910,491] <inf> net_lwm2m_rd_client: Update Done
    [00:02:29.417,175] <inf> net_lwm2m_rd_client: Update callback (code:2.4)
    [00:02:29.417,205] <dbg> app_lwm2m_client: rd_client_event: Registration update complete
    [00:02:29.417,236] <inf> net_lwm2m_rd_client: Update Done
    [00:02:48.725,097] <dbg> app_lwm2m_push_button: app_event_handler: Button 1 changed state to 1.
    [00:02:48.896,636] <dbg> app_lwm2m_push_button: app_event_handler: Button 1 changed state to 0.
    [00:02:52.730,590] <dbg> app_lwm2m_push_button: app_event_handler: Button 1 changed state to 1.
    [00:02:54.230,865] <inf> net_lwm2m_rd_client: Update callback (code:2.4)
    [00:02:54.230,895] <dbg> app_lwm2m_client: rd_client_event: Registration update complete
    [00:02:54.230,926] <inf> net_lwm2m_rd_client: Update Done
    [00:02:56.235,565] <dbg> app_lwm2m_push_button: app_event_handler: Button 1 changed state to 0.
    [00:03:19.513,580] <inf> net_lwm2m_rd_client: Update callback (code:2.4)
    [00:03:19.513,610] <dbg> app_lwm2m_client: rd_client_event: Registration update complete
    [00:03:19.513,641] <inf> net_lwm2m_rd_client: Update Done
    [00:03:44.873,291] <inf> net_lwm2m_rd_client: Update callback (code:2.4)
    [00:03:44.873,321] <dbg> app_lwm2m_client: rd_client_event: Registration update complete
    [00:03:44.873,352] <inf> net_lwm2m_rd_client: Update Done
    [00:04:09.833,984] <inf> net_lwm2m_rd_client: Update callback (code:2.4)
    [00:04:09.834,045] <dbg> app_lwm2m_client: rd_client_event: Registration update complete
    [00:04:09.834,075] <inf> net_lwm2m_rd_client: Update Done
    [00:04:34.795,715] <inf> net_lwm2m_rd_client: Update callback (code:2.4)
    [00:04:34.795,745] <dbg> app_lwm2m_client: rd_client_event: Registration update complete
    [00:04:34.795,776] <inf> net_lwm2m_rd_client: Update Done
    uart:~$ 

    and ncs v2.2.0:

    
    uart:~$ *** Booting Zephyr OS build v3.2.99-ncs1 ***
    [00:00:01.458,374] <inf> BH1749: BH1749 initialized
    [00:00:01.460,601] <inf> app_lwm2m_client: Run LWM2M client
    [00:00:01.460,632] <inf> app_lwm2m_client: Initializing modem.
    [00:00:01.477,142] <inf> app_lwm2m_client: endpoint: urn:imei:352656106121406
    [00:00:01.480,621] <dbg> app_lwm2m_buzzer: buzzer_intensity_cb: Intensity: 100
    [00:00:03.482,086] <inf> accelerometer: Finished accelerometer calibration
    [00:00:03.482,727] <inf> lwm2m_firmware: Image is not confirmed OK
    [00:00:03.482,788] <inf> lwm2m_firmware: Marked image as OK
    [00:00:03.482,788] <inf> app_lwm2m_client: Connecting to network.
    [00:00:03.482,818] <inf> app_lwm2m_client: This may take several minutes.
    [00:00:12.824,279] <dbg> app_lwm2m_client: lwm2m_lte_reg_handler_notify: LTE NW status: 2
    [00:00:15.676,574] <dbg> app_lwm2m_client: lwm2m_lte_reg_handler_notify: LTE NW status: 5
    [00:00:15.677,307] <inf> app_lwm2m_client: Connected to LTE network
    [00:00:15.681,671] <inf> app_lwm2m_client: Client connect to server
    [00:00:15.681,793] <inf> net_lwm2m_rd_client: Start LWM2M Client: urn:imei:352656106121406
    [00:00:16.022,460] <dbg> app_lwm2m_accel: app_event_handler: Accelerometer sensor event received:x = 0.-205940, y = 0.362846, 4
    [00:00:16.022,644] <dbg> app_lwm2m_temp_sensor: app_event_handler: Temperature sensor event received: val1 = 000031, val2 = 540
    [00:00:16.022,857] <dbg> app_lwm2m_press_sensor: app_event_handler: Pressure sensor event received: val1 = 000101, val2 = 77500
    [00:00:16.023,101] <dbg> app_lwm2m_humid_sensor: app_event_handler: Humidity sensor event received: val1 = 000013, val2 = 78500
    [00:00:16.463,470] <inf> net_lwm2m_rd_client: RD Client started with endpoint 'urn:imei:352656106121406' with client lifetime 0
    [00:00:16.901,611] <inf> lwm2m_security: Need to write credentials, requesting LTE and GNSS offline...
    [00:00:16.972,167] <dbg> app_lwm2m_client: lwm2m_lte_reg_handler_notify: LTE NW status: 0
    [00:00:16.972,351] <inf> app_lwm2m_client: LwM2M is connecting to server
    [00:00:20.095,611] <inf> lwm2m_security: Requesting LTE and GNSS online
    [00:00:21.025,238] <dbg> app_lwm2m_client: lwm2m_lte_reg_handler_notify: LTE NW status: 2
    [00:00:23.024,597] <inf> lwm2m_security: Modem connection restored
    [00:00:23.025,238] <dbg> app_lwm2m_client: lwm2m_lte_reg_handler_notify: LTE NW status: 5
    [00:00:23.025,421] <inf> app_lwm2m_client: LwM2M is connecting to server
    [00:00:23.782,043] <inf> net_lwm2m_engine: Connected, sock id 0
    [00:00:24.268,920] <dbg> app_lwm2m_client: rd_client_event: Registration complete
    [00:00:24.269,012] <inf> net_lwm2m_rd_client: Registration Done (EP='8VEVZMHGp0')
    [00:00:24.269,348] <inf> app_lwm2m_client: LwM2M is connected to server
    [00:00:24.269,439] <inf> app_lwm2m_client: Obtained date-time from modem
    [00:00:49.291,870] <dbg> app_lwm2m_push_button: app_event_handler: Button 1 changed state to 1.
    [00:00:49.332,977] <inf> net_lwm2m_rd_client: Update callback (code:2.4)
    [00:00:49.333,007] <dbg> app_lwm2m_client: rd_client_event: Registration update complete
    [00:00:49.333,038] <inf> net_lwm2m_rd_client: Update Done
    [00:00:53.483,734] <dbg> app_lwm2m_push_button: app_event_handler: Button 1 changed state to 0.
    

     

    They both behave as expected on my side. Please note that the button 1 is only accessible on the thingy91:

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/nrf9160/lwm2m_client/sample_description.html#user-interface

     

    Kind regards,

    Håkon

  • Hi Håkon

    Apologies, I think you may be misunderstanding me.  I am referring to 'Read' button for the temperature that is pressed on the server.  Not on the thingy91 itself.  When you press 'read' on the temperature object, the temperature is displayed.  However, when you press it again, instead of refreshing the temperature, the old value is displayed.

  • Hi,

     

    This is expected, as the sensor handling was changed from v2.1.x to v2.2.x.

    The sensors are now polled in an interval, by default 2 minutes:

    https://github.com/nrfconnect/sdk-nrf/blob/v2.2.0/samples/nrf9160/lwm2m_client/src/modules/sensor_module.c#L39

     

    Here's the pull-request with the changes to the behavior:

    https://github.com/nrfconnect/sdk-nrf/pull/9127

     

    Kind regards,

    Håkon

  • Hi Håkon

    Thank you for the update! I see the interval now.

    Kind regards,

    Hassan

Related