Skip to content

Commit

Permalink
feat: add more messages
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Nov 3, 2023
1 parent 1236c71 commit cab8fe7
Show file tree
Hide file tree
Showing 23 changed files with 856 additions and 69 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ The conformity to the rules is checked using the script
- The URN must have the prefix `urn:oma:lwm2m:x:`.
- The object version must be appended if it is not `1.0`
- All objects must define one timestamp property.
- Objects must be `Single` instance, and `Optional`
- Resources must be `Single` instance. `Multiple` could be useful in some cases,
e.g. IP addresses, but until it is really needed, we do not support it.
- `RangeEnumeration` is ignored
- `Objlnk` resource type is not supported
- `LWM2MVersion` must be `1.1`

The conformity to the rules is checked using the script
[`./lwm2m/check-lwm2m-rules.ts`](./lwm2m/check-lwm2m-rules.ts).
Expand Down
25 changes: 17 additions & 8 deletions generator/generateModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const generateModels = (
models: {
id: string
transforms: {
type: 'shadow' | 'messages'
type: 'reported' | 'desired' | 'messages'
match: string
transform: string
}[]
Expand Down Expand Up @@ -64,13 +64,22 @@ export const generateModels = (
// type
ts.factory.createPropertyAssignment(
ts.factory.createStringLiteral('type'),
transform.type === 'messages'
? ts.factory.createIdentifier(
'TransformerType.Messages',
)
: ts.factory.createIdentifier(
'TransformerType.Shadow',
),
((type) => {
switch (type) {
case 'messages':
return ts.factory.createIdentifier(
'TransformerType.Messages',
)
case 'reported':
return ts.factory.createIdentifier(
'TransformerType.ShadowReported',
)
default:
return ts.factory.createIdentifier(
'TransformerType.ShadowDesired',
)
}
})(transform.type),
),
// match
ts.factory.createPropertyAssignment(
Expand Down
2 changes: 1 addition & 1 deletion generator/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const loadModelTransforms = async (
model: string,
): Promise<
{
type: 'shadow' | 'messages'
type: 'reported' | 'desired' | 'messages'
match: string
transform: string
}[]
Expand Down
6 changes: 2 additions & 4 deletions lwm2m/14201.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
</Description1>
<ObjectID>14201</ObjectID>
<ObjectURN>urn:oma:lwm2m:x:14201</ObjectURN>
<LWM2MVersion>1.1</LWM2MVersion>
<ObjectVersion>1.1</ObjectVersion>
<MultipleInstances>Single</MultipleInstances>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Optional</Mandatory>
<Resources>
<Item ID="0">
Expand Down Expand Up @@ -85,7 +83,7 @@
<![CDATA[The angle of movement.]]>
</Description>
</Item>
<Item ID="9">
<Item ID="99">
<Name>Timestamp</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
Expand Down
101 changes: 101 additions & 0 deletions lwm2m/14202.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<LWM2M
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://openmobilealliance.org/tech/profiles/LWM2M-v1_1.xsd">
<Object ObjectType="MODefinition">
<Name>Battery</Name>
<Description1>
<![CDATA[Information about the battery and power status of the device.]]>
</Description1>
<ObjectID>14202</ObjectID>
<ObjectURN>urn:oma:lwm2m:x:14202</ObjectURN>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Optional</Mandatory>
<Resources>
<Item ID="0">
<Name>State of charge</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Mandatory</Mandatory>
<Type>Integer</Type>
<RangeEnumeration>0-100</RangeEnumeration>
<Units>%</Units>
<Description>
<![CDATA[State of charge in percent. Examples: 23, 1, 100.]]>
</Description>
</Item>
<Item ID="1">
<Name>Voltage</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Optional</Mandatory>
<Type>Float</Type>
<RangeEnumeration></RangeEnumeration>
<Units>V</Units>
<Description>
<![CDATA[Battery voltage in Volt. Examples: 2.754, 3.3.]]>
</Description>
</Item>
<Item ID="2">
<Name>Charge current</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Optional</Mandatory>
<Type>Float</Type>
<RangeEnumeration></RangeEnumeration>
<Units>mA</Units>
<Description>
<![CDATA[Charge current in mA. Examples: 429, -244.]]>
</Description>
</Item>
<Item ID="3">
<Name>Battery temperature</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Optional</Mandatory>
<Type>Float</Type>
<RangeEnumeration></RangeEnumeration>
<Units>C</Units>
<Description>
<![CDATA[Battery temperature in Celsius. Examples: 21.7, 23.123.]]>
</Description>
</Item>
<Item ID="4">
<Name>Time to full</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Optional</Mandatory>
<Type>Integer</Type>
<RangeEnumeration></RangeEnumeration>
<Units>s</Units>
<Description>
<![CDATA[Time to full in seconds. Examples: 4652.]]>
</Description>
</Item>
<Item ID="4">
<Name>Time to empty</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Optional</Mandatory>
<Type>Integer</Type>
<RangeEnumeration></RangeEnumeration>
<Units>s</Units>
<Description>
<![CDATA[Time to empty in seconds. Examples: 4652.]]>
</Description>
</Item>
<Item ID="99">
<Name>Timestamp</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Mandatory</Mandatory>
<Type>Time</Type>
<RangeEnumeration></RangeEnumeration>
<Units></Units>
<Description>
<![CDATA[The timestamp of when the measurement was performed.]]>
</Description>
</Item>
</Resources>
<Description2></Description2>
</Object>
</LWM2M>
125 changes: 125 additions & 0 deletions lwm2m/14203.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<LWM2M
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://openmobilealliance.org/tech/profiles/LWM2M-v1_1.xsd">
<Object ObjectType="MODefinition">
<Name>Connection information</Name>
<Description1>
<![CDATA[Details about the device's connection.]]>
</Description1>
<ObjectID>14203</ObjectID>
<ObjectURN>urn:oma:lwm2m:x:14203</ObjectURN>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Optional</Mandatory>
<Resources>
<Item ID="0">
<Name>Network mode</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Mandatory</Mandatory>
<Type>String</Type>
<RangeEnumeration></RangeEnumeration>
<Units></Units>
<Description>
<![CDATA[Examples: LTE-M, NB-IoT.]]>
</Description>
</Item>
<Item ID="1">
<Name>Band</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Mandatory</Mandatory>
<Type>Integer</Type>
<RangeEnumeration></RangeEnumeration>
<Units></Units>
<Description>
<![CDATA[E-UTRA Absolute Radio Frequency Channel Number (EARFCN) of the current cell where the EARFCN is as defined in 3GPP TS 36.101. LTE carrier channel number for unique identification of LTE band and carrier frequency. Examples: 262143]]>
</Description>
</Item>
<Item ID="2">
<Name>RSRP</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Mandatory</Mandatory>
<Type>Integer</Type>
<RangeEnumeration></RangeEnumeration>
<Units>dBm</Units>
<Description>
<![CDATA[Reference Signal Received Power (RSRP). The average power level in dBm received from a single reference signal in an LTE (Long-term Evolution) network. Typically this value ranges from -140 to -40 dBm. Examples: -97, -104.]]>
</Description>
</Item>
<Item ID="3">
<Name>Area</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Mandatory</Mandatory>
<Type>Integer</Type>
<RangeEnumeration></RangeEnumeration>
<Units></Units>
<Description>
<![CDATA[Area code. Examples: 12]]>
</Description>
</Item>
<Item ID="4">
<Name>Cell</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Mandatory</Mandatory>
<Type>Integer</Type>
<RangeEnumeration></RangeEnumeration>
<Units></Units>
<Description>
<![CDATA[The cell ID the User Equipment (UE) is camped on. 4-byte Evolved Terrestrial Radio Access Network (E-UTRAN) cell ID. Examples: 33703719]]>
</Description>
</Item>
<Item ID="5">
<Name>Mobile country code and mobile network code</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Mandatory</Mandatory>
<Type>Integer</Type>
<RangeEnumeration></RangeEnumeration>
<Units></Units>
<Description>
<![CDATA[Examples: 24202, 310410]]>
</Description>
</Item>
<Item ID="6">
<Name>IP address</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Mandatory</Mandatory>
<Type>String</Type>
<RangeEnumeration></RangeEnumeration>
<Units></Units>
<Description>
<![CDATA[Examples: 10.81.183.99, 2001:0db8:85a3:0000:0000:8a2e:0370:7334, 2001:db8:85a3::8a2e:370:7334]]>
</Description>
</Item>
<Item ID="11">
<Name>Energy Estimate</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Mandatory</Mandatory>
<Type>Integer</Type>
<RangeEnumeration></RangeEnumeration>
<Units></Units>
<Description>
<![CDATA[The %CONEVAL AT command returns amongst other data the energy estimate: Relative estimated energy consumption of data transmission compared to nominal consumption. A higher value means smaller energy consumption. 5: Difficulties in setting up connections. Maximum number of repetitions might be needed for data. 6: Poor conditions. Setting up a connection might require retries and a higher number of repetitions for data. 7: Normal conditions for cIoT device. No repetitions for data or only a few repetitions in the worst case. 8: Good conditions. Possibly very good conditions for small amounts of data. 9: Very good conditions. Efficient data transfer estimated also for larger amounts of data. Examples: 5, 7]]>
</Description>
</Item>
<Item ID="99">
<Name>Timestamp</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Mandatory</Mandatory>
<Type>Time</Type>
<RangeEnumeration></RangeEnumeration>
<Units></Units>
<Description>
<![CDATA[The timestamp of when the measurement was performed.]]>
</Description>
</Item>
</Resources>
<Description2></Description2>
</Object>
</LWM2M>
Loading

0 comments on commit cab8fe7

Please sign in to comment.