MLopezJ / asset-tracker-cloud-coiote-azure-converter-js

Convert the LwM2M JSON encoding written by AVSystem's Coiote Azure integration to nRF Asset Tracker's LwM2M JSON encoding.
0 stars 0 forks source link

Device Location can not be shown #3

Closed MLopezJ closed 1 year ago

MLopezJ commented 1 year ago

TL;DR

The approach that follows the AV System tutorial is using this LwM2M Anjay client. So, data is only sent to the Coiote Dashboard if client is running and the client is hosted in the computer. Computer is indoors and indoors is not possible to reach out GNSS data.

Not sure if the last justification is what actually happened but when I removed the Anjay Client and uses LwM2M-client firmware example from Nordic, Location data was sent. Data in general was sent (indoors and outdoors) even when the device was not connected to the computer, which didnt happen with last approach.

There are still some open questions that will be addressed in new issues:

Ticket discussion

After make the integration of Thingy:91 - Coiote - Azure, the Location object is not shown neither in the Coiote dashboard and IoT hub Device twin.

Questions

~How to know if Location data is been sent from Thingy:91 to Coiote?~ How can I see the data sent from Thingy:91? In particular interested in LwM2M data but would be good to see all as well.

MLopezJ commented 1 year ago

How can I see the data sent from Thingy:91? In particular interested in LwM2M data but would be good to see all as well.

With Trace Collector V2.

Update the firmware KConfig option to CONFIG_NRF_MODEM_LIB_TRACE=y, this will enable modem tracing and then the Trace Collector V2 from nRF Connect for Desktop app can be used to do the modem tracing.

MLopezJ commented 1 year ago

Walk arround with Thingy

GNSS technology does not work indoors.

MLopezJ commented 1 year ago

Walk arround with Thingy

Small walk around office did not return any value related to Location.

Next try will be changing the read frequency time parameter from Coiote Dashboard

MLopezJ commented 1 year ago

GNSS

-- investigate about gnss --

MLopezJ commented 1 year ago

Whit Max helps, modem tracing was tried. WireShark and Trace Collector V2 were used. var CONFIG_NRF_MODEM_LIB_TRACE=y was created in prj.conf from "home/zephyrproject/Anjay-zephyr-client/demo" folder.

As a result, data can not be shown because protocol DTLS is encrypted.

MLopezJ commented 1 year ago

An alternative to solve this situation is to create a simulator.

Do by software what I'm expecting from the hardware.

Here are others examples of simulator:

MLopezJ commented 1 year ago

simulator.

  • Is there any LwM2M lib for node?
  1. lwm2m-node-lib
  2. node-lwm2m
  3. node-red-contrib-lwm2m
MLopezJ commented 1 year ago

As a result, data can not be shown because protocol DTLS is encrypted.

There is an option to decrypt DTLS messages but comparing the benefices the simulator approach can return, it is desired to invest time and effort on this approach first than the decrypt one.

MLopezJ commented 1 year ago

Small walk around office did not return any value related to Location.

Next try will be changing the read frequency time parameter from Coiote Dashboard

Havent trying another walk with the thingy but I did an observation: Actually no new data was returned in the small walk. Data is not sent to Coiote if the thingy is not connected to the Anjay console.

Context:

The set up was done following this tutorial. In the tutorial, the thingy is connected to Coiote using LwM2M Anjay Client. And this is the reason why data is not send to Coiote Dashboard if the thingy is not connected to the Anjay console. Because Anjay is the client!!! It takes the data from the Thingy but the Thingy does not set any data, Anjay does.

Situation

Anjay is sending the data to Coiote. The Anjay client is running on my desktop computer and it is indoors. GNSS only works outdoors, so no Location data is reported on Coiote Dasboard. When I went outdoors with the thingy, no data was sending to Dashboard because there was not connection to the Anjay client.

This LwM2M Anjay client looks pretty much as how the simulator should looks like.

Solution

I would like to connect the Thingy with Coiote directly. without using an LwM2M client. And once it is connected to Coiote, make the integration between Azure and Coiote.

With this approach I would like to test if it is possible to make this integration process using Asset Tracker firmware, and this way be able to send the config object to Coiote.

MLopezJ commented 1 year ago

Solution

Set up:

Description:

Firmware build was done with nRF Connect Visual Studio Code Extension and following the Nordic tutorial. The nrf/samples/nrf9160 folder was used as Aplication, and build configuration was modified.

the board used was nrf9160dk_nrf9160_ns, configuration was prj.conf and kconfig frangments were: overlay-avsystem.conf and overlay-assist-cell.conf.

Minicom was used to see the logs:

minicom --device /dev/ttyACM0 --baudrate 115200

A new device was created in Coiote:

Device was connected to Azure using previous configuration.

Connection with nRF Cloud was made with Gound Fix Service key because Service Evaluation Token already expired.

Result

Here: https://github.com/MLopezJ/asset-tracker-cloud-coiote-azure-converter-js/issues/3#issuecomment-1446034462

Conclusion

Integration was successful. Location is present in the device twin. But there is no object related to Pressure or Barometer neither Config

next steps

MLopezJ commented 1 year ago

Result

{
  deviceId: "urn:imei:351358811128922",
  etag: "AAAAAAAAAAE=",
  deviceEtag: "MTA0MjIyNzMyOQ==",
  status: "enabled",
  statusUpdateTime: "0001-01-01T00:00:00Z",
  connectionState: "Connected",
  lastActivityTime: "0001-01-01T00:00:00Z",
  cloudToDeviceMessageCount: 0,
  authenticationType: "sas",
  x509Thumbprint: {
    primaryThumbprint: null,
    secondaryThumbprint: null,
  },
  modelId: "",
  version: 4,
  properties: {
    desired: {
      $metadata: {
        $lastUpdated: "2023-02-24T14:30:23.8793971Z",
      },
      $version: 1,
    },
    reported: {
      lwm2m: {
        1: {
          0: {
            0: {
              value: 101,
            },
            1: {
              value: 30,
            },
            2: {
              value: 1,
            },
            3: {
              value: 300,
            },
            5: {
              value: 86400,
            },
            6: {
              value: false,
            },
            7: {
              value: "U",
            },
            10: {},
            11: {},
            12: {},
            13: {},
            14: {},
            15: {},
            16: {},
            17: {},
            18: {},
            19: {},
            20: {},
            21: {},
            22: {},
            23: {
              value: false,
            },
          },
        },
        3: {
          0: {
            0: {
              value: "Nordic Semiconductor ASA",
            },
            1: {
              value: "nrf9160dk_nrf9160",
            },
            2: {
              value: "351358811128922",
            },
            3: {
              value: "mfw_nrf9160_1.3.1",
            },
            6: {
              0: {
                value: 1,
              },
              1: {
                value: 5,
              },
              attributes: {
                dim: "2",
              },
            },
            7: {
              0: {
                value: 3800,
              },
              1: {
                value: 5000,
              },
              attributes: {
                dim: "2",
              },
            },
            8: {
              0: {
                value: 125,
              },
              1: {
                value: 900,
              },
              attributes: {
                dim: "2",
              },
            },
            9: {},
            10: {},
            11: {
              0: {
                value: 0,
              },
              attributes: {
                dim: "1",
              },
            },
            13: {
              value: 1677249309000,
            },
            14: {
              value: "",
            },
            15: {
              value: "",
            },
            16: {
              value: "U",
            },
            17: {
              value: "OMA-LWM2M Client",
            },
            18: {
              value: "nRF9160_SICA",
            },
            19: {
              value: "2.0.2",
            },
            20: {
              value: 1,
            },
            21: {
              value: 448,
            },
            22: {
              attributes: {
                dim: "0",
              },
            },
          },
          attributes: {
            ver: "1.0",
          },
        },
        4: {
          0: {
            0: {
              value: 6,
            },
            1: {
              0: {
                value: 6,
              },
              1: {
                value: 7,
              },
              attributes: {
                dim: "2",
              },
            },
            2: {
              value: -83,
            },
            3: {
              value: 0,
            },
            4: {
              0: {
                value: "10.160.81.145",
              },
              attributes: {
                dim: "1",
              },
            },
            5: {
              attributes: {
                dim: "0",
              },
            },
            7: {
              0: {
                value: "ibasis.iot",
              },
              attributes: {
                dim: "1",
              },
            },
            8: {
              value: 21627653,
            },
            9: {
              value: 1,
            },
            10: {
              value: 242,
            },
            11: {
              value: 0,
            },
          },
          attributes: {
            ver: "1.2",
          },
        },
        5: {
          0: {
            0: {},
            1: {
              value: "",
            },
            3: {
              value: 0,
            },
            5: {
              value: 1,
            },
            6: {},
            7: {},
            8: {
              attributes: {
                dim: "0",
              },
            },
            9: {
              value: 2,
            },
          },
          attributes: {
            ver: "1.0",
          },
        },
        6: {
          0: {
            0: {
              value: 0,
            },
            1: {
              value: 0,
            },
            2: {
              value: 0,
            },
            3: {
              value: 0,
            },
            4: {},
            5: {
              value: 0,
            },
            6: {
              value: 0,
            },
          },
          attributes: {
            ver: "1.0",
          },
        },
        3303: {
          0: {
            5601: {
              value: 20.75098,
            },
            5602: {
              value: 20.75098,
            },
            5603: {
              value: -40,
            },
            5604: {
              value: 85,
            },
            5700: {
              value: 20.75098,
            },
            5701: {
              value: "°C",
            },
            5750: {
              value: "Simulated Temperature Sensor",
            },
          },
          attributes: {
            ver: "1.1",
          },
        },
        3304: {
          0: {
            5601: {
              value: 52.2809,
            },
            5602: {
              value: 52.2809,
            },
            5603: {
              value: 0,
            },
            5604: {
              value: 100,
            },
            5700: {
              value: 52.2809,
            },
            5701: {
              value: "%",
            },
            5750: {
              value: "Simulated Humidity Sensor",
            },
          },
          attributes: {
            ver: "1.1",
          },
        },
        3313: {
          0: {
            5603: {
              value: -19.6133,
            },
            5604: {
              value: 19.6133,
            },
            5701: {
              value: "m/s^2",
            },
            5702: {
              value: -19.999994,
            },
            5703: {
              value: -19.999985,
            },
            5704: {
              value: -19.999964,
            },
            5750: {
              value: "Simulated Accelerometer",
            },
          },
          attributes: {
            ver: "1.1",
          },
        },
        3347: {
          0: {
            5500: {
              value: false,
            },
            5501: {
              value: 0,
            },
            5750: {
              value: "Push button 1",
            },
          },
          attributes: {
            ver: "1.1",
          },
        },
        10256: {
          0: {
            0: {
              value: 0,
            },
            1: {
              value: 0,
            },
            2: {
              value: 0,
            },
            3: {
              value: 0,
            },
            4: {
              value: 0,
            },
            5: {
              value: 0,
            },
          },
        },
        50001: {
          0: {
            0: {
              value: 4,
            },
            1: {
              value: 0,
            },
            2: {
              value: 0,
            },
            3: {
              value: 0,
            },
            4: {
              value: 0,
            },
            5: {
              value: 0,
            },
            7: {},
            8: {},
            9: {},
            10: {},
            11: {},
          },
        },
      },
      $metadata: {},
      $version: 3,
    },
  },
  capabilities: {
    iotEdge: false,
  },
};
MLopezJ commented 1 year ago

next steps

  • Make integration using Thingy:91 board
  • Uses Asset Tracker firmware

I tried both at the same time and it failed.

new approach

Make integration as described here

Firmware build was done with nRF Connect Visual Studio Code Extension and following the Nordic tutorial. The nrf/samples/nrf9160 folder was used as Aplication, and build configuration was modified.

the board used was nrf9160dk_nrf9160_ns, configuration was prj.conf and kconfig frangments were: overlay-avsystem.conf and overlay-assist-cell.conf.

But using Thingy:91 board instead.

Process

Thinggy91 credentials:

Modifications done in prj.conf

CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=120
CONFIG_DATE_TIME_TOO_OLD_SECONDS=120

Result

Thingy:91 is connected to Coiote. Data is been sending from the device to the dashboard and make sense. Took the device outdoors and value about temperature and push button was related to the conditions. Location data was not updated. In Coiote Dashboard, no cell location was shown.

In Azure, the device was created after the integration. Data in device twin was not the expected and it was not updated with the values shown in Coiote Dashabort.

{
    "deviceId": "urn:imei:351358815340515",
    "etag": "AAAAAAAAAAE=",
    "deviceEtag": "MTU3MDQyODA1",
    "status": "enabled",
    "statusUpdateTime": "0001-01-01T00:00:00Z",
    "connectionState": "Disconnected",
    "lastActivityTime": "0001-01-01T00:00:00Z",
    "cloudToDeviceMessageCount": 0,
    "authenticationType": "sas",
    "x509Thumbprint": {
        "primaryThumbprint": null,
        "secondaryThumbprint": null
    },
    "modelId": "",
    "version": 2,
    "properties": {
        "desired": {
            "$metadata": {
                "$lastUpdated": "2023-02-27T11:56:04.1648972Z"
            },
            "$version": 1
        },
        "reported": {
            "$metadata": {
                "$lastUpdated": "2023-02-27T11:56:04.1648972Z"
            },
            "$version": 1
        }
    },
    "capabilities": {
        "iotEdge": false
    }
}