New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lwm2m-id

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lwm2m-id - npm Package Compare versions

Comparing version 0.0.9 to 1.0.0

2

package.json
{
"name": "lwm2m-id",
"version": "0.0.9",
"version": "1.0.0",
"description": "lwm2m-id is a module that implements a dictionary of ip-based smart object(IPSO) identifiers defined by lwm2m spec.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -10,3 +10,2 @@ lwm2m-id

4. [APIs](#APIs)
5. [Custom Definitions](#Custom)
6. [Table of Identifiers](#Identifiers)

@@ -18,3 +17,3 @@ <br />

**lwm2m-id** is a dictionary of identifiers defined by [OMA LightweightM2M(v1.0)](http://technical.openmobilealliance.org/Technical/technical-information/release-program/current-releases/oma-lightweightm2m-v1-0) and IPSO SmartObject Guideline([Smart Objects Starter Pack1.0](http://www.ipso-alliance.org/smart-object-guidelines/)). If you want more information about what lwm2m and IPSO are doing, you can take a look at their websites.
**lwm2m-id** is a dictionary of identifiers defined by [OMA LightweightM2M(v1.0)](http://technical.openmobilealliance.org/Technical/technical-information/release-program/current-releases/oma-lightweightm2m-v1-0) and IPSO SmartObject Guideline([Smart Objects Starter Pack1.0](http://www.ipso-alliance.org/smart-object-guidelines/)). Please visit their websites for more information.

@@ -30,3 +29,3 @@ <a name="Installation"></a>

**lwm2m-id** provides you with two getters to get the key-value pair of the identifier. This two getter are `getOid()` and `getRid()`. The item, returned from the getter, has properties `'key'` and `'value'` in string and number, respectively. Let me show you some example.
**lwm2m-id** provides you with two getters, i.e. `getOid()` and `getRid()`, to get the key-value pair of an Object and a Resource identifier. The getter returns an item which has properties of `'key'` and `'value'`, or returns `undefined` if not found. In the returned item, `item.key` is the idetifier in string and `item.value` is the identifier in number. Let me show you some examples.

@@ -37,23 +36,30 @@ ```js

// get Object Id
var oidItem1 = m2mid.getOid(oid); // { key: 'xxx', value: 1234 }
var oidItem2 = m2mid.getOid(oid); // undefined
var oidItem1 = m2mid.getOid('device'); // { key: 'device', value: 3 }
var oidItem2 = m2mid.getOid(3); // { key: 'device', value: 3 }
var oidItem3 = m2mid.getOid('3'); // { key: 'device', value: 3 }
var oidItem4 = m2mid.getOid(999); // undefined
var oidItem5 = m2mid.getOid('noSuchId'); // undefined
var oidKey = m2mid.getOid(oid).key; // 'xxx'
var oidId = m2mid.getOid(oid).value; // 1234
var oidKey = m2mid.getOid(3).key; // 'device'
var oidId = m2mid.getOid('device').value; // 3
// get Resource Id
// (1) The rid is specific to an Object
var ridItem1 = m2mid.getRid('lightCtrl', 'onOff'); // { key: 'onOff', value: 5850 }
var ridItem2 = m2mid.getRid(3311, 'onOff'); // { key: 'onOff', value: 5850 }
var ridItem3 = m2mid.getRid(3311, 5850); // { key: 'onOff', value: 5850 }
var ridItem4 = m2mid.getRid('3311', '5850'); // { key: 'onOff', value: 5850 }
var ridItem5 = m2mid.getOid('lightCtrl', 'noSuchId'); // undefined
var ridItem6 = m2mid.getOid('noSuchId', 5850); // undefined
var ridItem1 = m2mid.getRid(oid, rid); // { key: 'xxx', value: 1234 }
var ridItem2 = m2mid.getOid(oid, rid); // undefined
var ridKey = m2mid.getRid('lightCtrl', 5850).key; // 'onOff'
var ridId = m2mid.getRid(3311, 'onOff').value; // 5850
var ridKey = m2mid.getRid(oid, rid).key; // 'xxx'
var ridId = m2mid.getRid(oid, rid).value; // 1234
// (2) The rid is an unique id
var ridItem7 = m2mid.getRid('sensorValue'); // { key: 'sensorValue', value: 5700 }
var ridItem8 = m2mid.getRid(5700); // { key: 'sensorValue', value: 5700 }
var ridItem8 = m2mid.getRid('5700'); // { key: 'sensorValue', value: 5700 }
var ridItem3 = m2mid.getRid(rid); // { key: 'xxx', value: 1234 }
var ridKey = m2mid.getRid(rid).key; // 'xxx'
var ridId = m2mid.getRid(rid).value; // 1234
var ridKey = m2mid.getRid(5700).key; // 'sensorValue'
var ridId = m2mid.getRid('sensorValue').value; // 5700
```

@@ -64,222 +70,66 @@

**lwm2m-id*** provides two kinds of APIs:
* [.getOid()](#API_getOid)
* [.getRid()](#API_getRid)
<a name="close"></a>
********************************************
<a name="API_getOid"></a>
### .getOid(oid)
> This method returns the enumerable item.
> Returns an item of the Object identifier.
**Arguments**
- oid (*String|Number*)
* oid (*String|Number*): `oid` can be given with a string or a number. Notice that a numbered string will be recognized as a number, e.g. '128' is equal to 128.
**Example**
**Returns:**
* (_Object_ | _Undefined_) Returns an item of `{ key: 'sampleId', value: 1234 }`, otherwise returns `undefined` if not found.
lwm2mid.getOid('tempSensor');
lwm2mid.getOid('3303');
lwm2mid.getOid(3303);
// these all calls will return { key: 'tempSensor', value: 3303 }
lwm2mid.getOid('xxxx'); // return undefined
lwm2mid.getOid('9999'); // return undefined
lwm2mid.getOid(9999); // return undefined
lwm2mid.getOid('tempSensor').key; // return 'tempSensor'
lwm2mid.getOid('3303').key; // return 'tempSensor'
lwm2mid.getOid(3303).key; // return 'tempSensor'
lwm2mid.getOid('tempSensor').value; // return 3303
lwm2mid.getOid('3303').value; // return 3303
lwm2mid.getOid(3303).value; // return 3303
<br>
<a name="close"></a>
### .addOid(items)
> This method will close the opened serial port.
**Arguments**
- callback(err)
- `'err'` (*Error*) - [Error Message](#errcodes)
**Example**
```javascript
ccBnp.close(function (err) {
if (err) console.log(err);
});
```
<br>
<a name="close"></a>
### .getRid(oid, rid)
> This method will close the opened serial port.
```js
lwm2mid.getOid('tempSensor'); // { key: 'tempSensor', value: 3303 }
lwm2mid.getOid(3303); // { key: 'tempSensor', value: 3303 }
lwm2mid.getOid('3303'); // { key: 'tempSensor', value: 3303 }
**Arguments**
- callback(err)
- `'err'` (*Error*) - [Error Message](#errcodes)
**Example**
```javascript
ccBnp.close(function (err) {
if (err) console.log(err);
});
lwm2mid.getOid('xxxx'); // undefined
lwm2mid.getOid('9999'); // undefined
lwm2mid.getOid(9999); // undefined
```
<br>
********************************************
<br />
<a name="API_getRid"></a>
### .getRid([oid,] rid)
> Returns an item of the Resource identifier.
>
> There are two kinds of Resource id, the **Resource id specific to an Object** and the **unique Resource id**. In the former case, the meaning of a Resource is specific to an Object that holds it. An **unique Resource id** indicates that the Resouce id is a reusable one and its id number is always constant and unique across Objects. In addition, an Object can use both of these two kinds of Resource id to define its characteristic.
>
> To query a **Resource id specific to an Object**, both `oid` and `rid` should be given.
> To query an **unique Resource id**, only the single argument `rid` is needed.
<a name="close"></a>
### .addUniqueRid(items)
> This method will close the opened serial port.
**Arguments**
**Arguments**
- oid (*String|Number*, optional): `oid` can be given with a string or a number. Notice that a numbered string will be recognized as a number, e.g. '128' is equal to 128.
- rid (*String|Number*): `rid` can be given with a string or a number. Notice that a numbered string will be recognized as a number, e.g. '128' is equal to 128.
- callback(err)
- `'err'` (*Error*) - [Error Message](#errcodes)
**Example**
```javascript
ccBnp.close(function (err) {
if (err) console.log(err);
});
```
<br>
**Example**
<a name="close"></a>
### .addSpecificRid(oid, items)
> This method will close the opened serial port.
```js
// get a Resource id specific to an Object
lwm2mid.getRid('tempSensor', 'sensorValue'); // { key: 'sensorValue', value: 5700 }
lwm2mid.getRid(3303, 5700); // { key: 'sensorValue', value: 5700 }
lwm2mid.getRid('tempSensor', '5700'); // { key: 'sensorValue', value: 5700 }
**Arguments**
// get an unqiue Resource id
lwm2mid.getRid('appType'); // { key: 'appType', value: 5750 }
lwm2mid.getRid(5750); // { key: 'appType', value: 5700 }
lwm2mid.getRid('5750'); // { key: 'appType', value: 5750 }
- callback(err)
- `'err'` (*Error*) - [Error Message](#errcodes)
**Example**
```javascript
ccBnp.close(function (err) {
if (err) console.log(err);
});
```
<br>
<a name="close"></a>
### .getSpecificResrcChar(oid, rid)
> This method will close the opened serial port.
**Arguments**
- callback(err)
- `'err'` (*Error*) - [Error Message](#errcodes)
**Example**
```javascript
ccBnp.close(function (err) {
if (err) console.log(err);
});
```
<br>
<a name="close"></a>
### .addSpecificResrcChar(oid, chars)
> This method will close the opened serial port.
**Arguments**
- callback(err)
- `'err'` (*Error*) - [Error Message](#errcodes)
**Example**
```javascript
ccBnp.close(function (err) {
if (err) console.log(err);
});
```
********************************************
<br />
<a name="Custom"></a>
## 5. Custom Definitions
**lwm2m-id** allows you to add the custom-defined idetifiers with `.addUniqueRid()`, `.addSpecificRid()`. You can also use `.addSpecificResrcChar()` to assign the resource characteritics of access control to the dictionary at runtime. If you want to add some definition statically, you can modify the JSON file lies in `defs/defs.json`.
The lwm2m v1.0 defines many unique object id (oid) for different purpose. Such as `"device"` object that contains many optional resources. Each resource has an unique id within that object. For those reusable unique resources ids, they are under the `"uniqueRid"` namespace. For those resources subject to a specific object, are defined under the namespace `"specificRid"`. In `"specificRid"`, the rids are categories by the object id. For example, if you got a an object with id `"tempSensor"`, and it can contains the rids of `"sensorValue"`, `"units"`, .etc.
defs/defs.json
{
"oid": {
"lwm2mSecurity": 0,
"lwm2mServer": 1,
"accessControl": 2,
"device": 3,
"connMonitor": 4,
"firmware": 5,
// ...
"illumSensor": 3301,
"presenceSensor": 3302,
"tempSensor": 3303,
"humidSensor": 3304,
// ...
},
"uniqueRid": {
"objectInstanceHandle": 4000,
"objectVersion": 4001,
"dInState": 5500,
"counter": 5501,
// ...
"onOff": 5850,
"dimmer": 5851,
"onTime": 5852,
// ...
},
"specificRid": {
// ...
"device": {
"manuf": 0,
"model": 1,
"serial": 2,
"firmware": 3,
// ...
},
// ...
"tempSensor": {
"sensorValue": 5700,
"units": 5701,
"minMeaValue": 5601,
"maxMeaValue": 5602,
"minRangeValue": 5603,
"maxRangeValue": 5604,
"resetMinMaxMeaValues": 5605
},
"humidSensor": {
"sensorValue": 5700,
"units": 5701,
"minMeaValue": 5601,
"maxMeaValue": 5602,
"minRangeValue": 5603,
"maxRangeValue": 5604,
"resetMinMaxMeaValues": 5605
},
// ...
},
"specificResrcChar": {
// ...
"device": {
"manuf": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "my company" },
"model": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "machine-gun" },
"serial": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "fb-0000-0001" },
"firmware": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "0.0.1" },
// ...
},
// ...
"humidSensor": {
"sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 },
"units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "%" },
"minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 },
"maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 },
"minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 },
"maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 },
"resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }
},
// ...
}
<a name="Identifiers"></a>

@@ -402,27 +252,358 @@ ## 5. Table of Identifiers

* IPSO/OMA-LWM2M specified Resource ids (this class of ids is specified with Objects)
- oid = lwm2mSecurity
```js
{
"lwm2mServerURI": 0,
"bootstrapServer": 1,
"securityMode": 2,
"pubKeyId": 3,
"serverPubKeyId": 4,
"secretKey": 5,
"smsSecurityMode": 6,
"smsBindingKeyParam": 7,
"smsBindingSecretKey": 8,
"lwm2mServerSmsNum": 9,
"shortServerId": 10,
"clientHoldOffTime": 11
}
```
- oid = lwm2mServer
```js
{
"shortServerId": 0,
"lifetime": 1,
"defaultMinPeriod": 2,
"defaultMaxPeriod": 3,
"disable": 4,
"disableTimeout": 5,
"notificationStoring": 6,
"binding": 7,
"regUpdateTrigger": 8
}
```
- oid = accessControl
```js
{
"objectId": 0,
"objectInstanceId": 1,
"ACL": 2,
"ACLOwner": 3
}
```
- oid = device
```js
"manuf": 0,
"model": 1,
"serial": 2,
"firmware": 3,
"reboot": 4,
"factoryReset": 5,
"availPwrSrc": 6,
"pwrSrcVoltage": 7,
"pwrSrcCurrent": 8,
"battLevel": 9,
"memFree": 10,
"errCode": 11,
"resetErrCode": 12,
"currTime": 13,
"UTCOffset": 14,
"timezone": 15,
"suppBindAndMode": 16,
"devType": 17,
"hwVer": 18,
"swVer": 19,
"battStatus": 20,
"memTotal": 21
```
- oid = connMonitor
```js
{
"nwkBearer": 0,
"availNwkBearer": 1,
"radioSS": 2,
"linkQuality": 3,
"ip": 4,
"routeIp": 5,
"linkUtil": 6,
"APN": 7,
"cellId": 8,
"SMNC": 9,
"SMCC": 10
}
```
- oid = firmware
```js
{
"package": 0,
"packageURI": 1,
"update": 2,
"state": 3,
"updateSuppObjects": 4,
"updateResult": 5,
"pkgName": 6,
"pkgVer": 7
}
```
- oid = location
```js
{
"lat": 0,
"lon": 1,
"alt": 2,
"uncertainty": 3,
"velocity": 4,
"timestamp": 5
}
```
- oid = connStatistics
```js
{
"SMSTxCounter": 0,
"SMSRxCounter": 1,
"txData": 2,
"rxData": 3,
"maxMsgSize": 4,
"avgMsgSize": 5,
"startOrReset": 6
}
```
- oid = digitalInput
```js
{
"dInState": 5500,
"counter": 5501,
"dInPolarity": 5502,
"debouncePeriod": 5503,
"edgeSelection": 5504,
"counterReset": 5505,
"appType": 5750,
"sensorType": 5751
}
```
- oid = digitalOutput
```js
{
"dOutState": 5550,
"dOutpolarity": 5551,
"appType": 5750
}
```
- oid = analogInput
```js
{
"aInCurrValue": 5600,
"minMeaValue": 5601,
"maxMeaValue": 5602,
"minRangeValue": 5603,
"maxRangeValue": 5604,
"resetMinMaxMeaValues": 5605,
"appType": 5750,
"sensorType": 5751
}
```
- oid = analogOutput
```js
{
"aOutCurrValue": 5650,
"minRangeValue": 5603,
"maxRangeValue": 5604,
"appType": 5750
}
```
- oid = genericSensor
```js
{
"sensorValue": 5700,
"units": 5701,
"minMeaValue": 5601,
"maxMeaValue": 5602,
"minRangeValue": 5603,
"maxRangeValue": 5604,
"resetMinMaxMeaValues": 5605,
"appType": 5750,
"sensorType": 5751
}
```
- oid = illumSensor
```js
{
"sensorValue": 5700,
"units": 5701,
"minMeaValue": 5601,
"maxMeaValue": 5602,
"minRangeValue": 5603,
"maxRangeValue": 5604,
"resetMinMaxMeaValues": 5605
}
```
- oid = presenceSensor
```js
{
"dInState": 5500,
"counter": 5501,
"counterReset": 5505,
"sensorType": 5751,
"busyToClearDelay": 5903,
"clearToBusyDelay": 5904
}
```
- oid = tempSensor
```js
{
"sensorValue": 5700,
"units": 5701,
"minMeaValue": 5601,
"maxMeaValue": 5602,
"minRangeValue": 5603,
"maxRangeValue": 5604,
"resetMinMaxMeaValues": 5605
}
```
- oid = humidSensor
```js
{
"sensorValue": 5700,
"units": 5701,
"minMeaValue": 5601,
"maxMeaValue": 5602,
"minRangeValue": 5603,
"maxRangeValue": 5604,
"resetMinMaxMeaValues": 5605
}
```
- oid = pwrMea
```js
{
"instActivePwr": 5800,
"minMeaActivePwr": 5801,
"maxMeaActivePwr": 5802,
"minRangeActivePwr": 5803,
"maxRangeActivePwr": 5804,
"cumulActivePwr": 5805,
"activePwrCal": 5806,
"instReactivePwr": 5810,
"minMeaReactivePwr": 5811,
"maxMeaReactivePwr": 5812,
"minRangeReactivePwr": 5813,
"maxRangeReactivePwr": 5814,
"resetMinMaxMeaValues": 5605,
"cumulReactivePwr": 5815,
"reactivePwrCal": 5816,
"pwrFactor": 5820,
"currCal": 5821,
"resetCumulEnergy": 5822
}
```
- oid = actuation
```js
{
"onOff": 5850,
"dimmer": 5851,
"onTime": 5852,
"mstateOut": 5853,
"appType": 5750
}
```
- oid = setPoint
```js
{
"setPointValue": 5900,
"colour": 5706,
"units": 5701,
"appType": 5750
}
```
- oid = loadCtrl
```js
{
"eventId": 5823,
"startTime": 5824,
"durationInMin": 5825,
"criticalLevel": 5826,
"avgLoadAdjPct": 5827,
"dutyCycle": 5828
}
```
- oid = lightCtrl
```js
{
"onOff": 5850,
"dimmer": 5851,
"colour": 5706,
"units": 5701,
"onTime": 5852,
"cumulActivePwr": 5805,
"pwrFactor": 5820
}
```
- oid = pwrCtrl
```js
{
"onOff": 5850,
"dimmer": 5851,
"onTime": 5852,
"cumulActivePwr": 5805,
"pwrFactor": 5820
}
```
- oid = accelerometer
```js
{
"units": 5701,
"xValue": 5702,
"yValue": 5703,
"zValue": 5704,
"minRangeValue": 5603,
"maxRangeValue": 5604
}
```
- oid = magnetometer
```js
{
"units": 5701,
"xValue": 5702,
"yValue": 5703,
"zValue": 5704,
"compassDir": 5705
}
```
- oid = barometer
```js
{
"sensorValue": 5700,
"units": 5701,
"minMeaValue": 5601,
"maxMeaValue": 5602,
"minRangeValue": 5603,
"maxRangeValue": 5604,
"resetMinMaxMeaValues": 5605
}
```
<br />
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc