MLopezJ / LWM2M-JSONSchema

LWM2M protocol From XML to JSON Schema
0 stars 0 forks source link

Implement multiple instance in LwM2M definition #11

Closed MLopezJ closed 1 year ago

MLopezJ commented 1 year ago

Every LwM2M registry contain a MultipleInstances param with 2 possible values: Single or Multiple.

<LWM2M xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.openmobilealliance.org/tech/profiles/LWM2M-v1_1.xsd">
  <Object ObjectType="MODefinition">
        <Name>...</Name>
        <Description1>....</Description1>
        <ObjectID>1</ObjectID>
        <ObjectURN>urn:oma:lwm2m:oma:1:1.2</ObjectURN>
        <LWM2MVersion>1.2</LWM2MVersion>
        <ObjectVersion>1.2</ObjectVersion>
        <MultipleInstances>Multiple</MultipleInstances>
        <Mandatory>Mandatory</Mandatory>
        <Resources>
            <Item ID="0">
                <Name>Short Server ID</Name>
                <Operations>R</Operations>
                <MultipleInstances>Single</MultipleInstances>
                <Mandatory>Mandatory</Mandatory>
                <Type>Integer</Type>
                <RangeEnumeration>1..65534</RangeEnumeration>
                <Units></Units>
                <Description><![CDATA[Used as link to associate server Object Instance.]]></Description>
            </Item>
    </Object>
</LWM2M>

More information about it here: https://github.com/MLopezJ/LWM2M-JSONSchema/issues/10

The multiple instance value should be reflected somehow in the LwM2M object definition.

MLopezJ commented 1 year ago

// in this hypothetical example 0 is multiple instance and 1 is single instance
export const LwM2MType = Type.Object({
     _0 : _0: Type.Union([_0, Type.Array(_0)]), // _0 | _0 [ ]
     _1 : _1 // _1
})
MLopezJ commented 1 year ago

The mandatory property from the registry should be considered in the type definition of the LwM2M object.