CANDY-LINE / node-red-contrib-lwm2m

Step-by-step tutorial is available at
http://candy-line.tumblr.com/post/166976363228/oma-lwm2m-node-red-node
Apache License 2.0
7 stars 3 forks source link

Question: Multiple instance resource #14

Closed djDuff closed 5 years ago

djDuff commented 5 years ago

@dbaba san, According to OMA spec, there are multiple instance resources. For example, in SmartObject "Connectivity Monitoring", resource "Ip Address" is Multiple Instance. It means, I need to send values as /4/0/4/0 = How can I do this using node-red-contrib-lwm2m ?

1. Define Object I need to define this object in Objects of Client Out node. How? i didn't find example in https://github.com/CANDY-LINE/node-red-contrib-lwm2m#management-object-json-format But there is

MULTIPLE_RESOURCE ... Resource Array Is this multiple resource instance?

Well, I was thinking about this format -> but this doesn't work

{
    "4": {
        "0": {
            "4": {
                "0": {
                    "type": "STRING",
                    "acl": "R",
                    "value": ""
                }
            }
        }
    },

1. Send data using Inject node I was thinking about using this format - is it correct way to send measurements for resource instance? image

Regards, Andrey

dbaba commented 5 years ago

Thank you for spotting the missing description regarding MULTIPLE_RESOURCE.

For the first question, here is how to define MULTIPLE_RESOURCE type value in JSON format: (will update README.md)


MULTIPLE_RESOURCE

The type is a collection having Resource Instance ID and Resource value pairs.

{
    "type": "MULTIPLE_RESOURCE",
    "value": {
        "100": 999,
        "101": true,
        "999": {
            "type": "FLOAT",
            "value": 987654.321
        }
    }
}

If the Resource Instance ID starts with "0" and its following IDs are 1,2,3... (increases by 1), you can provide a JSON Array like this.

{
    "type": "MULTIPLE_RESOURCE",
    "value": [
        123,
        false,
        {
            "type": "FLOAT",
            "value": 1234.567
        }
    ]
}

This is equivalent to:

{
    "type": "MULTIPLE_RESOURCE",
    "value": {
        "0": 123,
        "1": false,
        "2": {
            "type": "FLOAT",
            "value": 1234.567
        }
    }
}

And in terms of the second one, you cannot provide the string value in Payload as you showed. Instead, you need to use JSON format in Payload.

{
  "0": "10.29.8.45"
}

or

["10.29.8.45"]
/4/0/4

The Resource Instance ID (0) cannot be included in URI at all.

djDuff commented 5 years ago

@dbaba san, thank you! I tested: Part 1 - it is correct, Part 2 - only "array" format works correctly Inject node, topic /4/0/4

Payload returns error { "0": "10.29.8.45" }

image

"lwm2m error" in debug window: format is object image

["10.29.8.45"] works correctly:

image

all ok in Debug window, data is sent correctly. The only difference, format is array here image

dbaba commented 5 years ago

@djDuff My fault! Found the issue and will fix it soon. Thanks!

mukulele commented 1 week ago

How do I send measurements for a multiple ressource definition? Lets say I have /6/0 (location object) with ressource /0 (latitude) and /1 (longitude). msg.topic /6/0 and payload { "0" : 46.123 , "1": 9.345} dos not work.