@hello.nrfcloud.com/proto-map 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/LICENSE +29 -0
  2. package/README.md +122 -0
  3. package/dist/generator/addDocBlock.js +5 -0
  4. package/dist/generator/generateLwM2MDefinitions.js +82 -0
  5. package/dist/generator/generateLwM2MDefinitions.spec.js +91 -0
  6. package/dist/generator/generateLwm2mTimestampResources.js +69 -0
  7. package/dist/generator/generateModels.js +142 -0
  8. package/dist/generator/generateType.js +90 -0
  9. package/dist/generator/generateValidator.js +132 -0
  10. package/dist/generator/generateValidators.js +63 -0
  11. package/dist/generator/isDir.js +163 -0
  12. package/dist/generator/isDir.spec.js +212 -0
  13. package/dist/generator/lwm2m.js +106 -0
  14. package/dist/generator/models.js +306 -0
  15. package/dist/generator/printNode.js +8 -0
  16. package/dist/generator/tokenizeName.js +5 -0
  17. package/dist/generator/tokenizeName.spec.js +98 -0
  18. package/dist/generator/types.js +140 -0
  19. package/dist/lwm2m/LWM2MObjectDefinition.js +88 -0
  20. package/dist/lwm2m/LWM2MObjectInfo.js +9 -0
  21. package/dist/lwm2m/LwM2MObject.d.js +1 -0
  22. package/dist/lwm2m/LwM2MObjectID.js +57 -0
  23. package/dist/lwm2m/ParsedLwM2MObjectDefinition.js +1 -0
  24. package/dist/lwm2m/check-lwm2m-rules.js +480 -0
  25. package/dist/lwm2m/definitions.js +596 -0
  26. package/dist/lwm2m/fromXML2JSON.js +194 -0
  27. package/dist/lwm2m/instanceTs.js +9 -0
  28. package/dist/lwm2m/instanceTs.spec.js +16 -0
  29. package/dist/lwm2m/isRegisteredLwM2MObject.js +3 -0
  30. package/dist/lwm2m/isRegisteredLwM2MObject.spec.js +45 -0
  31. package/dist/lwm2m/object/14201.d.js +5 -0
  32. package/dist/lwm2m/object/14202.d.js +5 -0
  33. package/dist/lwm2m/object/14203.d.js +5 -0
  34. package/dist/lwm2m/object/14204.d.js +5 -0
  35. package/dist/lwm2m/object/14205.d.js +5 -0
  36. package/dist/lwm2m/object/14210.d.js +5 -0
  37. package/dist/lwm2m/object/14220.d.js +5 -0
  38. package/dist/lwm2m/object/14230.d.js +5 -0
  39. package/dist/lwm2m/object/validate14201.js +18 -0
  40. package/dist/lwm2m/object/validate14202.js +17 -0
  41. package/dist/lwm2m/object/validate14203.js +19 -0
  42. package/dist/lwm2m/object/validate14204.js +17 -0
  43. package/dist/lwm2m/object/validate14205.js +15 -0
  44. package/dist/lwm2m/object/validate14210.js +13 -0
  45. package/dist/lwm2m/object/validate14220.js +12 -0
  46. package/dist/lwm2m/object/validate14230.js +13 -0
  47. package/dist/lwm2m/objects.js +8 -0
  48. package/dist/lwm2m/parseRangeEnumeration.js +20 -0
  49. package/dist/lwm2m/parseRangeEnumeration.spec.js +27 -0
  50. package/dist/lwm2m/resourceType.js +12 -0
  51. package/dist/lwm2m/timestampResources.js +12 -0
  52. package/dist/lwm2m/unwrapNestedArray.js +114 -0
  53. package/dist/lwm2m/unwrapNestedArray.spec.js +374 -0
  54. package/dist/lwm2m/validate.js +14 -0
  55. package/dist/lwm2m/validation.js +146 -0
  56. package/dist/lwm2m/validators.js +20 -0
  57. package/dist/markdown/getCodeBlock.js +74 -0
  58. package/dist/markdown/getFrontMatter.js +15 -0
  59. package/dist/markdown/parseREADME.js +19 -0
  60. package/dist/models/asset_tracker_v2+AWS/examples/examples.spec.js +489 -0
  61. package/dist/models/check-model-rules.js +137 -0
  62. package/dist/models/models.js +137 -0
  63. package/dist/models/types.js +13 -0
  64. package/dist/senml/SenMLSchema.js +79 -0
  65. package/dist/senml/SenMLSchema.spec.js +23 -0
  66. package/dist/senml/hasValue.js +8 -0
  67. package/dist/senml/hasValue.spec.js +103 -0
  68. package/dist/senml/lwm2mToSenML.js +137 -0
  69. package/dist/senml/lwm2mToSenML.spec.js +104 -0
  70. package/dist/senml/parseResourceId.js +58 -0
  71. package/dist/senml/parseResourceId.spec.js +13 -0
  72. package/dist/senml/senMLtoLwM2M.js +126 -0
  73. package/dist/senml/senMLtoLwM2M.spec.js +226 -0
  74. package/dist/senml/validateSenML.js +6 -0
  75. package/dist/senml/validateSenML.spec.js +31 -0
  76. package/export.js +13 -0
  77. package/index.d.ts +14 -0
  78. package/lwm2m/14201.xml +94 -0
  79. package/lwm2m/14202.xml +84 -0
  80. package/lwm2m/14203.xml +104 -0
  81. package/lwm2m/14204.xml +84 -0
  82. package/lwm2m/14205.xml +64 -0
  83. package/lwm2m/14210.xml +44 -0
  84. package/lwm2m/14220.xml +34 -0
  85. package/lwm2m/14230.xml +44 -0
  86. package/lwm2m/LWM2M-v1_1.xsd +168 -0
  87. package/lwm2m/LWM2MObjectDefinition.ts +84 -0
  88. package/lwm2m/LWM2MObjectInfo.ts +42 -0
  89. package/lwm2m/LwM2MObject.d.ts +19 -0
  90. package/lwm2m/LwM2MObjectID.ts +73 -0
  91. package/lwm2m/ParsedLwM2MObjectDefinition.ts +28 -0
  92. package/lwm2m/check-lwm2m-rules.ts +160 -0
  93. package/lwm2m/definitions.ts +278 -0
  94. package/lwm2m/format.sh +3 -0
  95. package/lwm2m/fromXML2JSON.ts +44 -0
  96. package/lwm2m/instanceTs.spec.ts +19 -0
  97. package/lwm2m/instanceTs.ts +10 -0
  98. package/lwm2m/isRegisteredLwM2MObject.spec.ts +48 -0
  99. package/lwm2m/isRegisteredLwM2MObject.ts +4 -0
  100. package/lwm2m/object/14201.d.ts +73 -0
  101. package/lwm2m/object/14202.d.ts +59 -0
  102. package/lwm2m/object/14203.d.ts +67 -0
  103. package/lwm2m/object/14204.d.ts +55 -0
  104. package/lwm2m/object/14205.d.ts +43 -0
  105. package/lwm2m/object/14210.d.ts +31 -0
  106. package/lwm2m/object/14220.d.ts +25 -0
  107. package/lwm2m/object/14230.d.ts +31 -0
  108. package/lwm2m/object/validate14201.ts +10 -0
  109. package/lwm2m/object/validate14202.ts +10 -0
  110. package/lwm2m/object/validate14203.ts +10 -0
  111. package/lwm2m/object/validate14204.ts +10 -0
  112. package/lwm2m/object/validate14205.ts +10 -0
  113. package/lwm2m/object/validate14210.ts +10 -0
  114. package/lwm2m/object/validate14220.ts +10 -0
  115. package/lwm2m/object/validate14230.ts +10 -0
  116. package/lwm2m/objects.ts +16 -0
  117. package/lwm2m/parseRangeEnumeration.spec.ts +34 -0
  118. package/lwm2m/parseRangeEnumeration.ts +29 -0
  119. package/lwm2m/resourceType.ts +11 -0
  120. package/lwm2m/timestampResources.ts +4 -0
  121. package/lwm2m/unwrapNestedArray.spec.ts +241 -0
  122. package/lwm2m/unwrapNestedArray.ts +27 -0
  123. package/lwm2m/validate.ts +30 -0
  124. package/lwm2m/validation.ts +120 -0
  125. package/lwm2m/validators.ts +21 -0
  126. package/models/PCA20035+solar/README.md +10 -0
  127. package/models/PCA20035+solar/transforms/airQuality.md +48 -0
  128. package/models/PCA20035+solar/transforms/battery.md +46 -0
  129. package/models/PCA20035+solar/transforms/button.md +45 -0
  130. package/models/PCA20035+solar/transforms/deviceInfo.md +72 -0
  131. package/models/PCA20035+solar/transforms/gain.md +45 -0
  132. package/models/PCA20035+solar/transforms/geolocationFromGroundfix.md +67 -0
  133. package/models/PCA20035+solar/transforms/geolocationFromMessage.md +80 -0
  134. package/models/PCA20035+solar/transforms/humidity.md +43 -0
  135. package/models/PCA20035+solar/transforms/networkInfo.md +84 -0
  136. package/models/PCA20035+solar/transforms/pressure.md +43 -0
  137. package/models/PCA20035+solar/transforms/temperature.md +43 -0
  138. package/models/README.md +10 -0
  139. package/models/asset_tracker_v2+AWS/README.md +6 -0
  140. package/models/asset_tracker_v2+AWS/examples/examples.spec.ts +229 -0
  141. package/models/asset_tracker_v2+AWS/examples/shadow/example-1.json +24 -0
  142. package/models/asset_tracker_v2+AWS/examples/shadow/example-2.json +30 -0
  143. package/models/asset_tracker_v2+AWS/examples/shadow/example-3.json +37 -0
  144. package/models/asset_tracker_v2+AWS/examples/shadow/example-4.json +48 -0
  145. package/models/asset_tracker_v2+AWS/examples/shadow/example-5.json +43 -0
  146. package/models/asset_tracker_v2+AWS/transforms/GNSS.md +66 -0
  147. package/models/asset_tracker_v2+AWS/transforms/battery-voltage.md +50 -0
  148. package/models/asset_tracker_v2+AWS/transforms/device-info.md +61 -0
  149. package/models/asset_tracker_v2+AWS/transforms/env.md +69 -0
  150. package/models/asset_tracker_v2+AWS/transforms/fuel-gauge.md +62 -0
  151. package/models/asset_tracker_v2+AWS/transforms/roam.md +100 -0
  152. package/models/asset_tracker_v2+AWS/transforms/solar.md +58 -0
  153. package/models/check-model-rules.ts +125 -0
  154. package/models/kartverket-vasstandsdata/README.md +13 -0
  155. package/models/models.ts +36 -0
  156. package/models/types.ts +17 -0
  157. package/package.json +111 -0
  158. package/senml/SenMLSchema.spec.ts +21 -0
  159. package/senml/SenMLSchema.ts +74 -0
  160. package/senml/hasValue.spec.ts +19 -0
  161. package/senml/hasValue.ts +12 -0
  162. package/senml/lwm2mToSenML.spec.ts +74 -0
  163. package/senml/lwm2mToSenML.ts +62 -0
  164. package/senml/parseResourceId.spec.ts +13 -0
  165. package/senml/parseResourceId.ts +23 -0
  166. package/senml/senMLtoLwM2M.spec.ts +181 -0
  167. package/senml/senMLtoLwM2M.ts +121 -0
  168. package/senml/validateSenML.spec.ts +16 -0
  169. package/senml/validateSenML.ts +8 -0
@@ -0,0 +1,10 @@
1
+ import type { LwM2MObjectInstance } from '../senml/senMLtoLwM2M.js'
2
+ import { definitions } from './definitions.js'
3
+ import { timestampResources } from './timestampResources.js'
4
+
5
+ export const instanceTs = (instance: LwM2MObjectInstance): Date => {
6
+ const definition = definitions[instance.ObjectID]
7
+ const tsResourceId = timestampResources[definition.ObjectID] as number // All registered objects must have a timestamp resource
8
+ const ts = instance.Resources[tsResourceId] as string
9
+ return new Date(ts)
10
+ }
@@ -0,0 +1,48 @@
1
+ import { describe, it } from 'node:test'
2
+ import assert from 'node:assert/strict'
3
+ import { isRegisteredLwM2MObject } from './isRegisteredLwM2MObject.js'
4
+
5
+ void describe('isRegisteredLwM2MObject()', () => {
6
+ void it('should validate a LwM2M object', () => {
7
+ const o = {
8
+ ObjectID: 14201,
9
+ ObjectVersion: '1.0',
10
+ Resources: {
11
+ 0: 33.98771459323253,
12
+ 1: -84.50632147267358,
13
+ 2: 241.9342498779297,
14
+ 3: 11.317643165588379,
15
+ 4: 0.03478508070111275,
16
+ 5: 90.31222534179688,
17
+ 6: 'GNSS',
18
+ 99: new Date(1699049744000),
19
+ },
20
+ }
21
+ assert.equal(isRegisteredLwM2MObject(o), true)
22
+ })
23
+
24
+ void it('should validate a LwM2M object with optional resources', () => {
25
+ const o = {
26
+ ObjectID: 14201,
27
+ ObjectVersion: '1.0',
28
+ Resources: {
29
+ 0: 33.98771459323253,
30
+ 1: -84.50632147267358,
31
+ 6: 'GNSS',
32
+ 99: new Date(1699049744000),
33
+ },
34
+ }
35
+ assert.equal(isRegisteredLwM2MObject(o), true)
36
+ })
37
+
38
+ void it('should not validate an unknown LwM2M object', () => {
39
+ const o = {
40
+ ObjectID: 666,
41
+ ObjectVersion: '1.0',
42
+ Resources: {
43
+ 0: 42,
44
+ },
45
+ }
46
+ assert.equal(isRegisteredLwM2MObject(o), false)
47
+ })
48
+ })
@@ -0,0 +1,4 @@
1
+ import { validators } from './validators.js'
2
+ import { validate } from './validate.js'
3
+
4
+ export const isRegisteredLwM2MObject = validate(validators)
@@ -0,0 +1,73 @@
1
+ import type { LwM2MObject } from "../LwM2MObject.js";
2
+ import { LwM2MObjectID } from "../LwM2MObjectID.js";
3
+ /**
4
+ * Geolocation (14201)
5
+ *
6
+ * Describes the geo location of a device
7
+ */
8
+ export type Geolocation_14201 = LwM2MObject<{
9
+ ObjectID: LwM2MObjectID.Geolocation_14201;
10
+ ObjectVersion: "1.0";
11
+ Resources: {
12
+ /**
13
+ * Latitude (°)
14
+ *
15
+ * The decimal notation of latitude in degrees, e.g. -43.5723 [World Geodetic System 1984].
16
+ */
17
+ /**
18
+ * Minimum: -90
19
+ * Maximum: 90
20
+ */
21
+ 0: number;
22
+ /**
23
+ * Longitude (°)
24
+ *
25
+ * The decimal notation of longitude in degrees, e.g. 153.21760 [World Geodetic System 1984].
26
+ */
27
+ /**
28
+ * Minimum: -180
29
+ * Maximum: 180
30
+ */
31
+ 1: number;
32
+ /**
33
+ * Source
34
+ *
35
+ * The source of the geo location, e.g. GNSS, SCELL, MCELL, WIFI.
36
+ */
37
+ 6: string;
38
+ /**
39
+ * Timestamp
40
+ *
41
+ * The timestamp of when the location measurement was performed.
42
+ */
43
+ 99: Date;
44
+ /**
45
+ * Altitude (m)
46
+ *
47
+ * The decimal notation of altitude in meters above sea level.
48
+ */
49
+ 2?: number;
50
+ /**
51
+ * Radius (m)
52
+ *
53
+ * The value in this resource indicates the radius of a circular area in meters. The circular area is used to describe uncertainty about a point for coordinates in a two-dimensional coordinate reference systems (CRS). The center point of a circular area is specified by using the Latitude and the Longitude Resources.
54
+ */
55
+ 3?: number;
56
+ /**
57
+ * Speed (m/s)
58
+ *
59
+ * Speed is the time rate of change in position.
60
+ */
61
+ 4?: number;
62
+ /**
63
+ * Heading (°)
64
+ *
65
+ * The angle of movement in degrees.
66
+ */
67
+ /**
68
+ * Minimum: 0
69
+ * Maximum: 360
70
+ */
71
+ 5?: number;
72
+ };
73
+ }>;
@@ -0,0 +1,59 @@
1
+ import type { LwM2MObject } from "../LwM2MObject.js";
2
+ import { LwM2MObjectID } from "../LwM2MObjectID.js";
3
+ /**
4
+ * Battery and Power (14202)
5
+ *
6
+ * Information about the battery and power status of the device.
7
+ */
8
+ export type BatteryAndPower_14202 = LwM2MObject<{
9
+ ObjectID: LwM2MObjectID.BatteryAndPower_14202;
10
+ ObjectVersion: "1.0";
11
+ Resources: {
12
+ /**
13
+ * Timestamp
14
+ *
15
+ * The timestamp of when the measurement was performed.
16
+ */
17
+ 99: Date;
18
+ /**
19
+ * State of charge (%)
20
+ *
21
+ * State of charge in percent. Examples: 23, 1, 100.
22
+ */
23
+ /**
24
+ * Minimum: 0
25
+ * Maximum: 100
26
+ */
27
+ 0?: number;
28
+ /**
29
+ * Voltage (V)
30
+ *
31
+ * Battery voltage in Volt. Examples: 2.754, 3.3.
32
+ */
33
+ 1?: number;
34
+ /**
35
+ * Charge current (mA)
36
+ *
37
+ * Charge current in mA. Examples: 429, -244.
38
+ */
39
+ 2?: number;
40
+ /**
41
+ * Battery temperature (C)
42
+ *
43
+ * Battery temperature in Celsius. Examples: 21.7, 23.123.
44
+ */
45
+ 3?: number;
46
+ /**
47
+ * Time to full (s)
48
+ *
49
+ * Time to full in seconds. Examples: 4652.
50
+ */
51
+ 4?: number;
52
+ /**
53
+ * Time to empty (s)
54
+ *
55
+ * Time to empty in seconds. Examples: 4652.
56
+ */
57
+ 5?: number;
58
+ };
59
+ }>;
@@ -0,0 +1,67 @@
1
+ import type { LwM2MObject } from "../LwM2MObject.js";
2
+ import { LwM2MObjectID } from "../LwM2MObjectID.js";
3
+ /**
4
+ * Connection information (14203)
5
+ *
6
+ * Details about the device's connection.
7
+ */
8
+ export type ConnectionInformation_14203 = LwM2MObject<{
9
+ ObjectID: LwM2MObjectID.ConnectionInformation_14203;
10
+ ObjectVersion: "1.0";
11
+ Resources: {
12
+ /**
13
+ * Timestamp
14
+ *
15
+ * The timestamp of when the measurement was performed.
16
+ */
17
+ 99: Date;
18
+ /**
19
+ * Network mode
20
+ *
21
+ * Examples: LTE-M, NB-IoT.
22
+ */
23
+ 0?: string;
24
+ /**
25
+ * Band
26
+ *
27
+ * 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
28
+ */
29
+ 1?: number;
30
+ /**
31
+ * RSRP (dBm)
32
+ *
33
+ * 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.
34
+ */
35
+ 2?: number;
36
+ /**
37
+ * Area
38
+ *
39
+ * Area code. Examples: 12
40
+ */
41
+ 3?: number;
42
+ /**
43
+ * Cell
44
+ *
45
+ * The cell ID the User Equipment (UE) is camped on. 4-byte Evolved Terrestrial Radio Access Network (E-UTRAN) cell ID. Examples: 33703719
46
+ */
47
+ 4?: number;
48
+ /**
49
+ * Mobile country code and mobile network code
50
+ *
51
+ * Examples: 24202, 310410
52
+ */
53
+ 5?: number;
54
+ /**
55
+ * IP address
56
+ *
57
+ * Examples: 10.81.183.99, 2001:0db8:85a3:0000:0000:8a2e:0370:7334, 2001:db8:85a3::8a2e:370:7334
58
+ */
59
+ 6?: string;
60
+ /**
61
+ * Energy Estimate
62
+ *
63
+ * 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
64
+ */
65
+ 11?: number;
66
+ };
67
+ }>;
@@ -0,0 +1,55 @@
1
+ import type { LwM2MObject } from "../LwM2MObject.js";
2
+ import { LwM2MObjectID } from "../LwM2MObjectID.js";
3
+ /**
4
+ * Device information (14204)
5
+ *
6
+ * Details about the device's connection.
7
+ */
8
+ export type DeviceInformation_14204 = LwM2MObject<{
9
+ ObjectID: LwM2MObjectID.DeviceInformation_14204;
10
+ ObjectVersion: "1.0";
11
+ Resources: {
12
+ /**
13
+ * IMEI
14
+ *
15
+ * Board IMEI. Examples: 352656106111232.
16
+ */
17
+ 0: string;
18
+ /**
19
+ * Modem firmware version
20
+ *
21
+ * Examples: mfw_nrf9160_1.0.0.
22
+ */
23
+ 2: string;
24
+ /**
25
+ * Application firmware version
26
+ *
27
+ * Examples: v1.0.0-rc1-327-g6fc8c16b239f.
28
+ */
29
+ 3: string;
30
+ /**
31
+ * Board version
32
+ *
33
+ * Examples: thingy91_nrf9160.
34
+ */
35
+ 4: string;
36
+ /**
37
+ * Timestamp
38
+ *
39
+ * The timestamp of when the measurement was performed.
40
+ */
41
+ 99: Date;
42
+ /**
43
+ * SIM ICCID
44
+ *
45
+ * Examples: 89450421180216216095.
46
+ */
47
+ 1?: string;
48
+ /**
49
+ * Battery model
50
+ *
51
+ * Examples: LP302535, LP502540, LP803035.
52
+ */
53
+ 5?: string;
54
+ };
55
+ }>;
@@ -0,0 +1,43 @@
1
+ import type { LwM2MObject } from "../LwM2MObject.js";
2
+ import { LwM2MObjectID } from "../LwM2MObjectID.js";
3
+ /**
4
+ * Environment (14205)
5
+ *
6
+ * Environment information.
7
+ */
8
+ export type Environment_14205 = LwM2MObject<{
9
+ ObjectID: LwM2MObjectID.Environment_14205;
10
+ ObjectVersion: "1.0";
11
+ Resources: {
12
+ /**
13
+ * Timestamp
14
+ *
15
+ * The timestamp of when the measurement was performed.
16
+ */
17
+ 99: Date;
18
+ /**
19
+ * Temperature (°C)
20
+ *
21
+ * Environmental temperature in Celsius. Examples: 23.5, -10.2.
22
+ */
23
+ 0?: number;
24
+ /**
25
+ * Humidity (%)
26
+ *
27
+ * Environmental humidity in percent. Examples: 44.2, 72.
28
+ */
29
+ 1?: number;
30
+ /**
31
+ * Atmospheric pressure (Pa)
32
+ *
33
+ * Atmospheric pressure in pascal. Examples: 1003.6, 977.
34
+ */
35
+ 2?: number;
36
+ /**
37
+ * Air Quality Index
38
+ *
39
+ * The Bosch BME680 sensor calculates an Air Quality Index. See https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bme680-ds001.pdf
40
+ */
41
+ 10?: number;
42
+ };
43
+ }>;
@@ -0,0 +1,31 @@
1
+ import type { LwM2MObject } from "../LwM2MObject.js";
2
+ import { LwM2MObjectID } from "../LwM2MObjectID.js";
3
+ /**
4
+ * Solar charge (14210)
5
+ *
6
+ * Measurements from the solar shield.
7
+ */
8
+ export type SolarCharge_14210 = LwM2MObject<{
9
+ ObjectID: LwM2MObjectID.SolarCharge_14210;
10
+ ObjectVersion: "1.0";
11
+ Resources: {
12
+ /**
13
+ * Gain (mA)
14
+ *
15
+ * The current gain from the solar shield, measured in mA. Example: 3.123, -0.0032.
16
+ */
17
+ 0: number;
18
+ /**
19
+ * Timestamp
20
+ *
21
+ * The timestamp of when the measurement was performed.
22
+ */
23
+ 99: Date;
24
+ /**
25
+ * Voltage (V)
26
+ *
27
+ * Battery voltage in Volt. Examples: 2.754, 3.3.
28
+ */
29
+ 1?: number;
30
+ };
31
+ }>;
@@ -0,0 +1,25 @@
1
+ import type { LwM2MObject } from "../LwM2MObject.js";
2
+ import { LwM2MObjectID } from "../LwM2MObjectID.js";
3
+ /**
4
+ * Button press (14220)
5
+ *
6
+ * Describes a button press event.
7
+ */
8
+ export type ButtonPress_14220 = LwM2MObject<{
9
+ ObjectID: LwM2MObjectID.ButtonPress_14220;
10
+ ObjectVersion: "1.0";
11
+ Resources: {
12
+ /**
13
+ * Button ID
14
+ *
15
+ * The ID of the button that was pressed. Examples: 1, 2.
16
+ */
17
+ 0: number;
18
+ /**
19
+ * Timestamp
20
+ *
21
+ * The timestamp of when the button was pressed.
22
+ */
23
+ 99: Date;
24
+ };
25
+ }>;
@@ -0,0 +1,31 @@
1
+ import type { LwM2MObject } from "../LwM2MObject.js";
2
+ import { LwM2MObjectID } from "../LwM2MObjectID.js";
3
+ /**
4
+ * Sea Water Level (14230)
5
+ *
6
+ * Describes observed sea water level.
7
+ */
8
+ export type SeaWaterLevel_14230 = LwM2MObject<{
9
+ ObjectID: LwM2MObjectID.SeaWaterLevel_14230;
10
+ ObjectVersion: "1.0";
11
+ Resources: {
12
+ /**
13
+ * Sea Water Level (cm)
14
+ *
15
+ * The observed sea water level relative the the sea level elevation of the sea map. Examples: 134.2, 104.5.
16
+ */
17
+ 0: number;
18
+ /**
19
+ * Station code
20
+ *
21
+ * The code of the observation station. Examples: TRD, SVG.
22
+ */
23
+ 1: string;
24
+ /**
25
+ * Timestamp
26
+ *
27
+ * The timestamp of when the observation was made.
28
+ */
29
+ 99: Date;
30
+ };
31
+ }>;
@@ -0,0 +1,10 @@
1
+ import type { LwM2MObject } from "../LwM2MObject.js";
2
+ import { NumberResource, StringResource, DateResource, OptionalResource, validate } from "../validation.js";
3
+ import type { Geolocation_14201 } from "../objects.js";
4
+ import { LwM2MObjectID } from "../LwM2MObjectID.js";
5
+ /**
6
+ * Validate Geolocation (14201)
7
+ *
8
+ * Ensures the given object is an LwM2M object according to the schema 14201.xml.
9
+ */
10
+ export const validate14201 = (o: unknown, onError?: (error: Error) => void): o is LwM2MObject<Geolocation_14201> => validate(LwM2MObjectID.Geolocation_14201, "1.0", { 0: NumberResource, 1: NumberResource, 6: StringResource, 99: DateResource, 2: OptionalResource(NumberResource), 3: OptionalResource(NumberResource), 4: OptionalResource(NumberResource), 5: OptionalResource(NumberResource) })(o, onError);
@@ -0,0 +1,10 @@
1
+ import type { LwM2MObject } from "../LwM2MObject.js";
2
+ import { DateResource, NumberResource, OptionalResource, validate } from "../validation.js";
3
+ import type { BatteryAndPower_14202 } from "../objects.js";
4
+ import { LwM2MObjectID } from "../LwM2MObjectID.js";
5
+ /**
6
+ * Validate Battery and Power (14202)
7
+ *
8
+ * Ensures the given object is an LwM2M object according to the schema 14202.xml.
9
+ */
10
+ export const validate14202 = (o: unknown, onError?: (error: Error) => void): o is LwM2MObject<BatteryAndPower_14202> => validate(LwM2MObjectID.BatteryAndPower_14202, "1.0", { 99: DateResource, 0: OptionalResource(NumberResource), 1: OptionalResource(NumberResource), 2: OptionalResource(NumberResource), 3: OptionalResource(NumberResource), 4: OptionalResource(NumberResource), 5: OptionalResource(NumberResource) })(o, onError);
@@ -0,0 +1,10 @@
1
+ import type { LwM2MObject } from "../LwM2MObject.js";
2
+ import { DateResource, StringResource, OptionalResource, NumberResource, validate } from "../validation.js";
3
+ import type { ConnectionInformation_14203 } from "../objects.js";
4
+ import { LwM2MObjectID } from "../LwM2MObjectID.js";
5
+ /**
6
+ * Validate Connection information (14203)
7
+ *
8
+ * Ensures the given object is an LwM2M object according to the schema 14203.xml.
9
+ */
10
+ export const validate14203 = (o: unknown, onError?: (error: Error) => void): o is LwM2MObject<ConnectionInformation_14203> => validate(LwM2MObjectID.ConnectionInformation_14203, "1.0", { 99: DateResource, 0: OptionalResource(StringResource), 1: OptionalResource(NumberResource), 2: OptionalResource(NumberResource), 3: OptionalResource(NumberResource), 4: OptionalResource(NumberResource), 5: OptionalResource(NumberResource), 6: OptionalResource(StringResource), 11: OptionalResource(NumberResource) })(o, onError);
@@ -0,0 +1,10 @@
1
+ import type { LwM2MObject } from "../LwM2MObject.js";
2
+ import { StringResource, DateResource, OptionalResource, validate } from "../validation.js";
3
+ import type { DeviceInformation_14204 } from "../objects.js";
4
+ import { LwM2MObjectID } from "../LwM2MObjectID.js";
5
+ /**
6
+ * Validate Device information (14204)
7
+ *
8
+ * Ensures the given object is an LwM2M object according to the schema 14204.xml.
9
+ */
10
+ export const validate14204 = (o: unknown, onError?: (error: Error) => void): o is LwM2MObject<DeviceInformation_14204> => validate(LwM2MObjectID.DeviceInformation_14204, "1.0", { 0: StringResource, 2: StringResource, 3: StringResource, 4: StringResource, 99: DateResource, 1: OptionalResource(StringResource), 5: OptionalResource(StringResource) })(o, onError);
@@ -0,0 +1,10 @@
1
+ import type { LwM2MObject } from "../LwM2MObject.js";
2
+ import { DateResource, NumberResource, OptionalResource, validate } from "../validation.js";
3
+ import type { Environment_14205 } from "../objects.js";
4
+ import { LwM2MObjectID } from "../LwM2MObjectID.js";
5
+ /**
6
+ * Validate Environment (14205)
7
+ *
8
+ * Ensures the given object is an LwM2M object according to the schema 14205.xml.
9
+ */
10
+ export const validate14205 = (o: unknown, onError?: (error: Error) => void): o is LwM2MObject<Environment_14205> => validate(LwM2MObjectID.Environment_14205, "1.0", { 99: DateResource, 0: OptionalResource(NumberResource), 1: OptionalResource(NumberResource), 2: OptionalResource(NumberResource), 10: OptionalResource(NumberResource) })(o, onError);
@@ -0,0 +1,10 @@
1
+ import type { LwM2MObject } from "../LwM2MObject.js";
2
+ import { NumberResource, DateResource, OptionalResource, validate } from "../validation.js";
3
+ import type { SolarCharge_14210 } from "../objects.js";
4
+ import { LwM2MObjectID } from "../LwM2MObjectID.js";
5
+ /**
6
+ * Validate Solar charge (14210)
7
+ *
8
+ * Ensures the given object is an LwM2M object according to the schema 14210.xml.
9
+ */
10
+ export const validate14210 = (o: unknown, onError?: (error: Error) => void): o is LwM2MObject<SolarCharge_14210> => validate(LwM2MObjectID.SolarCharge_14210, "1.0", { 0: NumberResource, 99: DateResource, 1: OptionalResource(NumberResource) })(o, onError);
@@ -0,0 +1,10 @@
1
+ import type { LwM2MObject } from "../LwM2MObject.js";
2
+ import { NumberResource, DateResource, validate } from "../validation.js";
3
+ import type { ButtonPress_14220 } from "../objects.js";
4
+ import { LwM2MObjectID } from "../LwM2MObjectID.js";
5
+ /**
6
+ * Validate Button press (14220)
7
+ *
8
+ * Ensures the given object is an LwM2M object according to the schema 14220.xml.
9
+ */
10
+ export const validate14220 = (o: unknown, onError?: (error: Error) => void): o is LwM2MObject<ButtonPress_14220> => validate(LwM2MObjectID.ButtonPress_14220, "1.0", { 0: NumberResource, 99: DateResource })(o, onError);
@@ -0,0 +1,10 @@
1
+ import type { LwM2MObject } from "../LwM2MObject.js";
2
+ import { NumberResource, StringResource, DateResource, validate } from "../validation.js";
3
+ import type { SeaWaterLevel_14230 } from "../objects.js";
4
+ import { LwM2MObjectID } from "../LwM2MObjectID.js";
5
+ /**
6
+ * Validate Sea Water Level (14230)
7
+ *
8
+ * Ensures the given object is an LwM2M object according to the schema 14230.xml.
9
+ */
10
+ export const validate14230 = (o: unknown, onError?: (error: Error) => void): o is LwM2MObject<SeaWaterLevel_14230> => validate(LwM2MObjectID.SeaWaterLevel_14230, "1.0", { 0: NumberResource, 1: StringResource, 99: DateResource })(o, onError);
@@ -0,0 +1,16 @@
1
+ export type { Geolocation_14201 } from "./object/14201";
2
+ export { validate14201 } from "./object/validate14201.js";
3
+ export type { BatteryAndPower_14202 } from "./object/14202";
4
+ export { validate14202 } from "./object/validate14202.js";
5
+ export type { ConnectionInformation_14203 } from "./object/14203";
6
+ export { validate14203 } from "./object/validate14203.js";
7
+ export type { DeviceInformation_14204 } from "./object/14204";
8
+ export { validate14204 } from "./object/validate14204.js";
9
+ export type { Environment_14205 } from "./object/14205";
10
+ export { validate14205 } from "./object/validate14205.js";
11
+ export type { SolarCharge_14210 } from "./object/14210";
12
+ export { validate14210 } from "./object/validate14210.js";
13
+ export type { ButtonPress_14220 } from "./object/14220";
14
+ export { validate14220 } from "./object/validate14220.js";
15
+ export type { SeaWaterLevel_14230 } from "./object/14230";
16
+ export { validate14230 } from "./object/validate14230.js";
@@ -0,0 +1,34 @@
1
+ import { describe, it } from 'node:test'
2
+ import assert from 'node:assert/strict'
3
+ import { parseRangeEnumeration } from './parseRangeEnumeration.js'
4
+ import { RangeEnumerationRegExp } from './LWM2MObjectDefinition.js'
5
+
6
+ void describe('parseRangeEnumeration()', () => {
7
+ void it('should parse valid range enumeration', () => {
8
+ const result = parseRangeEnumeration('1..10')
9
+ assert.deepEqual(result, {
10
+ range: {
11
+ min: 1,
12
+ max: 10,
13
+ },
14
+ })
15
+ })
16
+
17
+ void it('should handle invalid range enumeration', () => {
18
+ const result = parseRangeEnumeration('10..1')
19
+ assert.deepEqual(result, {
20
+ error: new Error(
21
+ `'min' must be smaller than 'max' in RangeEnumeration '10..1'!`,
22
+ ),
23
+ })
24
+ })
25
+
26
+ void it('should handle invalid input', () => {
27
+ const result = parseRangeEnumeration('invalid')
28
+ assert.deepEqual(result, {
29
+ error: new Error(
30
+ `Could not match 'invalid' against ${RangeEnumerationRegExp}!`,
31
+ ),
32
+ })
33
+ })
34
+ })
@@ -0,0 +1,29 @@
1
+ import { RangeEnumerationRegExp } from './LWM2MObjectDefinition.js'
2
+ import type { Range } from './LWM2MObjectInfo.js'
3
+
4
+ export const parseRangeEnumeration = (
5
+ re: string,
6
+ ): { range: Range } | { error: Error } => {
7
+ const match = RangeEnumerationRegExp.exec(re)
8
+ if (match === null)
9
+ return {
10
+ error: new Error(
11
+ `Could not match '${re}' against ${RangeEnumerationRegExp}!`,
12
+ ),
13
+ }
14
+ const { min: minS, max: maxS } = match.groups ?? {}
15
+ const min = parseFloat(minS as string)
16
+ const max = parseFloat(maxS as string)
17
+ if (min > max)
18
+ return {
19
+ error: new Error(
20
+ `'min' must be smaller than 'max' in RangeEnumeration '${re}'!`,
21
+ ),
22
+ }
23
+ return {
24
+ range: {
25
+ min,
26
+ max,
27
+ },
28
+ }
29
+ }
@@ -0,0 +1,11 @@
1
+ export enum LwM2MType {
2
+ Boolean = 'Boolean',
3
+ Float = 'Float',
4
+ Integer = 'Integer',
5
+ UnsignedInteger = 'Unsigned Integer',
6
+ Objlnk = 'Objlnk',
7
+ Corelnk = 'Corelnk',
8
+ Opaque = 'Opaque',
9
+ String = 'String',
10
+ Time = 'Time',
11
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Contains the ID of the resource that defines the timestamp for each LwM2M object definition
3
+ */
4
+ export const timestampResources: Readonly<Record<number, number>> = { 14201: 99, 14202: 99, 14203: 99, 14204: 99, 14205: 99, 14210: 99, 14220: 99, 14230: 99 };