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

Update expected output #25

Closed MLopezJ closed 1 year ago

MLopezJ commented 1 year ago

As part of the complete flow of the integration between Thingy:91 and nRF Asset Tracker, there are multiple steps. Those are described here.

Input received in this repo is composed by objects, those can be LwM2M defined objects and custom defined objects. This specific step (current repo) is about taking that input, check if the object is defined in LwM2M and if it is, transform it in LwM2M format.

The next step after this one is to check if the LwM2M definition of the objects transformed are actually the correct or not. And in order to make this process easier it is convenience to create a data struct that allows that validation the faster way possible.

Current expected output

{
  "6": { "0": -43.5723, "1": 153.2176, "2": 2, "6": 5 },
  "3347:1.1": [
    {
      "5500": false,
      "5501": 0,
      "5750": "Button 0",
    },
  ],
  "3420": [{ "1": "#000000" }],
  "10256": [{ "0": 428, "2": 6300, "3": 52, "4": 14, "5": 0 }],
  "50001": {
    "0": 5,
    "1": 128,
    "7": 403,
  },
  "50009": {
    "0": true,
    "2": 120,
    "3": 600,
    "4": 7200,
    "1": 120,
    "5": 8.5,
    "8": 2.5,
    "9": 0.5,
  },
}

New expected output

{
    "LwM2M": {
        "6": { "0": -43.5723, "1": 153.2176, "2": 2, "6": 5 },
        "3347:1.1": [
            {
            "5500": false,
            "5501": 0,
            "5750": "Button 0",
            },
        ],
        "3420": [{ "1": "#000000" }],
        "10256": [{ "0": 428, "2": 6300, "3": 52, "4": 14, "5": 0 }],
    },
    "customObjects": { 
        "50001": {
            "0": 5,
            "1": 128,
            "7": 403,
        },
        "50009": {
            "0": true,
            "2": 120,
            "3": 600,
            "4": 7200,
            "1": 120,
            "5": 8.5,
            "8": 2.5,
            "9": 0.5,
        }
    }
}