├── .gitignore ├── .travis.yml ├── LICENSE ├── Makefile ├── README.md ├── defs └── defs.json ├── index.js ├── package.json └── test ├── argumentType.test.js ├── getter.test.js └── setter.test.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # node-waf configuration 20 | .lock-wscript 21 | 22 | # Compiled binary addons (http://nodejs.org/api/addons.html) 23 | build/Release 24 | 25 | # Dependency directory 26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 27 | node_modules 28 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.12.10" 4 | - "4.1.0" 5 | - "6.9.2" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Simen Li 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | test-all: 2 | @./node_modules/.bin/mocha -u bdd --reporter spec 3 | 4 | .PHONY: test-all -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # lwm2m-id 2 | A dictionary of ip-based smart object(IPSO) identifiers defined by lwm2m spec. 3 | 4 | [![NPM](https://nodei.co/npm/lwm2m-id.png?downloads=true)](https://nodei.co/npm/lwm2m-id/) 5 | 6 | [![Travis branch](https://img.shields.io/travis/simenkid/lwm2m-id/master.svg?maxAge=2592000)](https://travis-ci.org/simenkid/lwm2m-id) 7 | [![npm](https://img.shields.io/npm/v/lwm2m-id.svg?maxAge=2592000)](https://www.npmjs.com/package/lwm2m-id) 8 | [![npm](https://img.shields.io/npm/l/lwm2m-id.svg?maxAge=2592000)](https://www.npmjs.com/package/lwm2m-id) 9 | 10 |
11 | 12 | ## Documentation 13 | 14 | Please visit the [Wiki](https://github.com/simenkid/lwm2m-id/wiki). 15 | 16 | ## Overview 17 | 18 | **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), IPSO SmartObject Guideline([Smart Objects Starter Pack1.0](http://www.ipso-alliance.org/smart-object-guidelines/) and [Smart Objects Expansion Pack](http://www.ipso-alliance.org/so-expansion-pack/)). Please visit their websites for more information. 19 | 20 | ## Installation 21 | 22 | > $ npm install lwm2m-id --save 23 | 24 | ## Usage 25 | 26 | See [Usage](https://github.com/simenkid/lwm2m-id/wiki#Usage) on the Wiki. 27 | 28 | ## License 29 | 30 | Licensed under [MIT](https://github.com/simenkid/lwm2m-id/blob/master/LICENSE). 31 | -------------------------------------------------------------------------------- /defs/defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "rspCode": { 3 | "OK": 200, 4 | "Created": 201, 5 | "Deleted": 202, 6 | "Changed": 204, 7 | "Content": 205, 8 | "BadRequest": 400, 9 | "Unauthorized": 401, 10 | "Forbidden": 403, 11 | "NotFound": 404, 12 | "MethodNotAllowed": 405, 13 | "Timeout": 408, 14 | "Conflict": 409, 15 | "InternalServerError": 500 16 | }, 17 | "cmdId": { 18 | "read": 0, 19 | "write": 1, 20 | "discover": 2, 21 | "writeAttrs": 3, 22 | "execute": 4, 23 | "observe": 5, 24 | "notify": 6, 25 | "ping": 7, 26 | "unknown": 255 27 | }, 28 | "oid": { 29 | "lwm2mSecurity": 0, 30 | "lwm2mServer": 1, 31 | "accessCtrl": 2, 32 | "device": 3, 33 | "connMonitor": 4, 34 | "firmware": 5, 35 | "location": 6, 36 | "connStatistics": 7, 37 | "lockAndWipe": 8, 38 | "swUpdate": 9, 39 | "cellularConn": 10, 40 | "apnConnProfile": 11, 41 | "wlanConn": 12, 42 | "bearerSelection": 13, 43 | "devCapMgmt": 15, 44 | "cmdhPolicy": 2048, 45 | "activeCmdhPolicy": 2049, 46 | "cmdhDefaults": 2050, 47 | "cmdhDefEcValues": 2051, 48 | "cmdhDefEcParamsValues": 2052, 49 | "cmdhLimits": 2053, 50 | "cmdhNetworkAccessRules": 2054, 51 | "cmdhNwAccessRule": 2055, 52 | "cmdhBuffer": 2056, 53 | "dIn": 3200, 54 | "dOut": 3201, 55 | "aIn": 3202, 56 | "aOut": 3203, 57 | "generic": 3300, 58 | "illuminance": 3301, 59 | "presence": 3302, 60 | "temperature": 3303, 61 | "humidity": 3304, 62 | "pwrMea": 3305, 63 | "actuation": 3306, 64 | "setPoint": 3308, 65 | "loadCtrl": 3310, 66 | "lightCtrl": 3311, 67 | "pwrCtrl": 3312, 68 | "accelerometer": 3313, 69 | "magnetometer": 3314, 70 | "barometer": 3315, 71 | "voltage": 3316, 72 | "current": 3317, 73 | "frequency": 3318, 74 | "depth": 3319, 75 | "percentage": 3320, 76 | "altitude": 3321, 77 | "load": 3322, 78 | "pressure": 3323, 79 | "loudness": 3324, 80 | "concentration": 3325, 81 | "acidity": 3326, 82 | "conductivity": 3327, 83 | "power": 3328, 84 | "powerFactor": 3329, 85 | "distance": 3330, 86 | "energy": 3331, 87 | "direction": 3332, 88 | "time": 3333, 89 | "gyrometer": 3334, 90 | "colour": 3335, 91 | "gpsLocation": 3336, 92 | "positioner": 3337, 93 | "buzzer": 3338, 94 | "audioClip": 3339, 95 | "timer": 3340, 96 | "addressableTextDisplay": 3341, 97 | "onOffSwitch": 3342, 98 | "levelControl": 3343, 99 | "upDownControl": 3344, 100 | "multipleAxisJoystick": 3345, 101 | "rate": 3346, 102 | "pushButton": 3347, 103 | "multistateSelector": 3348 104 | }, 105 | "uniqueRid": { 106 | "objectInstanceHandle": 4000, 107 | "objectVersion": 4001, 108 | "dInState": 5500, 109 | "counter": 5501, 110 | "dInPolarity": 5502, 111 | "debouncePeriod": 5503, 112 | "edgeSelection": 5504, 113 | "counterReset": 5505, 114 | "currentTime": 5506, 115 | "fracTime": 5507, 116 | "minXValue": 5508, 117 | "maxXValue": 5509, 118 | "minYValue": 5510, 119 | "maxYValue": 5511, 120 | "minZValue": 5512, 121 | "latitude": 5514, 122 | "longitude": 5515, 123 | "uncertainty": 5516, 124 | "velocity": 5517, 125 | "timestamp": 5518, 126 | "minLimit": 5519, 127 | "maxLimit": 5520, 128 | "timeDuration": 5521, 129 | "clip": 5522, 130 | "trigger": 5523, 131 | "soundDuration": 5524, 132 | "minOffTime": 5525, 133 | "mode": 5526, 134 | "text": 5527, 135 | "xCoord": 5528, 136 | "yCoord": 5529, 137 | "clearDisplay": 5530, 138 | "contrast": 5531, 139 | "incInputState": 5532, 140 | "decInputState": 5533, 141 | "eventCounter": 5534, 142 | "calOffset": 5535, 143 | "currentPos": 5536, 144 | "transTime": 5537, 145 | "remainTime": 5538, 146 | "displayMaxXCoord": 5539, 147 | "displayMaxYCoord": 5540, 148 | "upCounter": 5541, 149 | "downCounter": 5542, 150 | "digitalState": 5543, 151 | "cumulTime": 5544, 152 | "maxXCoord": 5545, 153 | "maxYCoord": 5546, 154 | "mStateIn": 5547, 155 | "level": 5548, 156 | "dOutState": 5550, 157 | "dOutPolarity": 5551, 158 | "aInCurrValue": 5600, 159 | "minMeaValue": 5601, 160 | "maxMeaValue": 5602, 161 | "minRangeValue": 5603, 162 | "maxRangeValue": 5604, 163 | "resetMinMaxMeaValues": 5605, 164 | "aOutCurrValue": 5650, 165 | "sensorValue": 5700, 166 | "units": 5701, 167 | "xValue": 5702, 168 | "yValue": 5703, 169 | "zValue": 5704, 170 | "compassDir": 5705, 171 | "colour": 5706, 172 | "appType": 5750, 173 | "sensorType": 5751, 174 | "instActivePwr": 5800, 175 | "minMeaActivePwr": 5801, 176 | "maxMeaActivePwr": 5802, 177 | "minRangeActivePwr": 5803, 178 | "maxRangeActivePwr": 5804, 179 | "cumulActivePwr": 5805, 180 | "activePwrCal": 5806, 181 | "instReactivePwr": 5810, 182 | "minMeaReactivePwr": 5811, 183 | "maxMeaReactivePwr": 5812, 184 | "minRangeReactivePwr": 5813, 185 | "maxRangeReactivePwr": 5814, 186 | "cumulReactivePwr": 5815, 187 | "reactivePwrCal": 5816, 188 | "pwrFactor": 5820, 189 | "currCal": 5821, 190 | "resetCumulEnergy": 5822, 191 | "eventId": 5823, 192 | "startTime": 5824, 193 | "durationInMin": 5825, 194 | "criticalLevel": 5826, 195 | "avgLoadAdjPct": 5827, 196 | "dutyCycle": 5828, 197 | "onOff": 5850, 198 | "dimmer": 5851, 199 | "onTime": 5852, 200 | "mStateOut": 5853, 201 | "offTime": 5854, 202 | "setPointValue": 5900, 203 | "busyToClearDelay": 5903, 204 | "clearToBusyDelay": 5904, 205 | "hostDeviceManuf": 5905, 206 | "hostDeviceMdl": 5906, 207 | "hostDeviceUID": 5907, 208 | "hostDeviceSwVer": 5908 209 | }, 210 | "specificRid": { 211 | "lwm2mSecurity": { 212 | "lwm2mServerURI": 0, 213 | "bootstrapServer": 1, 214 | "securityMode": 2, 215 | "pubKeyId": 3, 216 | "serverPubKeyId": 4, 217 | "secretKey": 5, 218 | "smsSecurityMode": 6, 219 | "smsBindingKeyParam": 7, 220 | "smsBindingSecretKey": 8, 221 | "lwm2mServerSmsNum": 9, 222 | "shortServerId": 10, 223 | "clientHoldOffTime": 11 224 | }, 225 | "lwm2mServer": { 226 | "shortServerId": 0, 227 | "lifetime": 1, 228 | "defaultMinPeriod": 2, 229 | "defaultMaxPeriod": 3, 230 | "disable": 4, 231 | "disableTimeout": 5, 232 | "notificationStoring": 6, 233 | "binding": 7, 234 | "regUpdateTrigger": 8 235 | }, 236 | "accessCtrl": { 237 | "objectId": 0, 238 | "objectInstanceId": 1, 239 | "ACL": 2, 240 | "ACLOwner": 3 241 | }, 242 | "device": { 243 | "manuf": 0, 244 | "model": 1, 245 | "serial": 2, 246 | "firmware": 3, 247 | "reboot": 4, 248 | "factoryReset": 5, 249 | "availPwrSrc": 6, 250 | "pwrSrcVoltage": 7, 251 | "pwrSrcCurrent": 8, 252 | "battLevel": 9, 253 | "memFree": 10, 254 | "errCode": 11, 255 | "resetErrCode": 12, 256 | "currTime": 13, 257 | "UTCOffset": 14, 258 | "timezone": 15, 259 | "bindAndModes": 16, 260 | "devType": 17, 261 | "hwVer": 18, 262 | "swVer": 19, 263 | "battStatus": 20, 264 | "memTotal": 21 265 | }, 266 | "connMonitor": { 267 | "nwkBearer": 0, 268 | "availNwkBearer": 1, 269 | "radioStrength": 2, 270 | "linkQuality": 3, 271 | "ip": 4, 272 | "routeIp": 5, 273 | "linkUtil": 6, 274 | "APN": 7, 275 | "cellId": 8, 276 | "SMNC": 9, 277 | "SMCC": 10 278 | }, 279 | "firmware": { 280 | "package": 0, 281 | "packageURI": 1, 282 | "update": 2, 283 | "state": 3, 284 | "updateSuppObjects": 4, 285 | "updateResult": 5, 286 | "pkgName": 6, 287 | "pkgVer": 7 288 | }, 289 | "location": { 290 | "lat": 0, 291 | "lon": 1, 292 | "alt": 2, 293 | "radius": 3, 294 | "velocity": 4, 295 | "timestamp": 5, 296 | "speed": 6 297 | }, 298 | "connStatistics": { 299 | "SMSTxCounter": 0, 300 | "SMSRxCounter": 1, 301 | "txData": 2, 302 | "rxData": 3, 303 | "maxMsgSize": 4, 304 | "avgMsgSize": 5, 305 | "startOrReset": 6 306 | }, 307 | "dIn": { 308 | "dInState": 5500, 309 | "counter": 5501, 310 | "dInPolarity": 5502, 311 | "debouncePeriod": 5503, 312 | "edgeSelection": 5504, 313 | "counterReset": 5505, 314 | "appType": 5750, 315 | "sensorType": 5751 316 | }, 317 | "dOut": { 318 | "dOutState": 5550, 319 | "dOutPolarity": 5551, 320 | "appType": 5750 321 | }, 322 | "aIn": { 323 | "aInCurrValue": 5600, 324 | "minMeaValue": 5601, 325 | "maxMeaValue": 5602, 326 | "minRangeValue": 5603, 327 | "maxRangeValue": 5604, 328 | "resetMinMaxMeaValues": 5605, 329 | "appType": 5750, 330 | "sensorType": 5751 331 | }, 332 | "aOut": { 333 | "aOutCurrValue": 5650, 334 | "minRangeValue": 5603, 335 | "maxRangeValue": 5604, 336 | "appType": 5750 337 | }, 338 | "generic": { 339 | "sensorValue": 5700, 340 | "units": 5701, 341 | "minMeaValue": 5601, 342 | "maxMeaValue": 5602, 343 | "minRangeValue": 5603, 344 | "maxRangeValue": 5604, 345 | "resetMinMaxMeaValues": 5605, 346 | "appType": 5750, 347 | "sensorType": 5751 348 | }, 349 | "illuminance": { 350 | "sensorValue": 5700, 351 | "units": 5701, 352 | "minMeaValue": 5601, 353 | "maxMeaValue": 5602, 354 | "minRangeValue": 5603, 355 | "maxRangeValue": 5604, 356 | "resetMinMaxMeaValues": 5605 357 | }, 358 | "presence": { 359 | "dInState": 5500, 360 | "counter": 5501, 361 | "counterReset": 5505, 362 | "sensorType": 5751, 363 | "busyToClearDelay": 5903, 364 | "clearToBusyDelay": 5904 365 | }, 366 | "temperature": { 367 | "sensorValue": 5700, 368 | "units": 5701, 369 | "minMeaValue": 5601, 370 | "maxMeaValue": 5602, 371 | "minRangeValue": 5603, 372 | "maxRangeValue": 5604, 373 | "resetMinMaxMeaValues": 5605 374 | }, 375 | "humidity": { 376 | "sensorValue": 5700, 377 | "units": 5701, 378 | "minMeaValue": 5601, 379 | "maxMeaValue": 5602, 380 | "minRangeValue": 5603, 381 | "maxRangeValue": 5604, 382 | "resetMinMaxMeaValues": 5605 383 | }, 384 | "pwrMea": { 385 | "instActivePwr": 5800, 386 | "minMeaActivePwr": 5801, 387 | "maxMeaActivePwr": 5802, 388 | "minRangeActivePwr": 5803, 389 | "maxRangeActivePwr": 5804, 390 | "cumulActivePwr": 5805, 391 | "activePwrCal": 5806, 392 | "instReactivePwr": 5810, 393 | "minMeaReactivePwr": 5811, 394 | "maxMeaReactivePwr": 5812, 395 | "minRangeReactivePwr": 5813, 396 | "maxRangeReactivePwr": 5814, 397 | "resetMinMaxMeaValues": 5605, 398 | "cumulReactivePwr": 5815, 399 | "reactivePwrCal": 5816, 400 | "pwrFactor": 5820, 401 | "currCal": 5821, 402 | "resetCumulEnergy": 5822 403 | }, 404 | "actuation": { 405 | "onOff": 5850, 406 | "dimmer": 5851, 407 | "onTime": 5852, 408 | "mStateOut": 5853, 409 | "appType": 5750 410 | }, 411 | "setPoint": { 412 | "setPointValue": 5900, 413 | "colour": 5706, 414 | "units": 5701, 415 | "appType": 5750 416 | }, 417 | "loadCtrl": { 418 | "eventId": 5823, 419 | "startTime": 5824, 420 | "durationInMin": 5825, 421 | "criticalLevel": 5826, 422 | "avgLoadAdjPct": 5827, 423 | "dutyCycle": 5828 424 | }, 425 | "lightCtrl": { 426 | "onOff": 5850, 427 | "dimmer": 5851, 428 | "colour": 5706, 429 | "units": 5701, 430 | "onTime": 5852, 431 | "cumulActivePwr": 5805, 432 | "pwrFactor": 5820 433 | }, 434 | "pwrCtrl": { 435 | "onOff": 5850, 436 | "dimmer": 5851, 437 | "onTime": 5852, 438 | "cumulActivePwr": 5805, 439 | "pwrFactor": 5820 440 | }, 441 | "accelerometer": { 442 | "units": 5701, 443 | "xValue": 5702, 444 | "yValue": 5703, 445 | "zValue": 5704, 446 | "minRangeValue": 5603, 447 | "maxRangeValue": 5604 448 | }, 449 | "magnetometer": { 450 | "units": 5701, 451 | "xValue": 5702, 452 | "yValue": 5703, 453 | "zValue": 5704, 454 | "compassDir": 5705 455 | }, 456 | "barometer": { 457 | "sensorValue": 5700, 458 | "units": 5701, 459 | "minMeaValue": 5601, 460 | "maxMeaValue": 5602, 461 | "minRangeValue": 5603, 462 | "maxRangeValue": 5604, 463 | "resetMinMaxMeaValues": 5605 464 | }, 465 | "voltage": { 466 | "sensorValue": 5700, 467 | "units": 5701, 468 | "minMeaValue": 5601, 469 | "maxMeaValue": 5602, 470 | "minRangeValue": 5603, 471 | "maxRangeValue": 5604, 472 | "resetMinMaxMeaValues": 5605, 473 | "calOffset": 5535, 474 | "appType": 5750 475 | }, 476 | "current": { 477 | "sensorValue": 5700, 478 | "units": 5701, 479 | "minMeaValue": 5601, 480 | "maxMeaValue": 5602, 481 | "minRangeValue": 5603, 482 | "maxRangeValue": 5604, 483 | "resetMinMaxMeaValues": 5605, 484 | "calOffset": 5535, 485 | "appType": 5750 486 | }, 487 | "frequency": { 488 | "sensorValue": 5700, 489 | "units": 5701, 490 | "minMeaValue": 5601, 491 | "maxMeaValue": 5602, 492 | "minRangeValue": 5603, 493 | "maxRangeValue": 5604, 494 | "resetMinMaxMeaValues": 5605, 495 | "calOffset": 5535, 496 | "appType": 5750 497 | }, 498 | "depth": { 499 | "sensorValue": 5700, 500 | "units": 5701, 501 | "minMeaValue": 5601, 502 | "maxMeaValue": 5602, 503 | "minRangeValue": 5603, 504 | "maxRangeValue": 5604, 505 | "resetMinMaxMeaValues": 5605, 506 | "calOffset": 5535, 507 | "appType": 5750 508 | }, 509 | "percentage": { 510 | "sensorValue": 5700, 511 | "units": 5701, 512 | "minMeaValue": 5601, 513 | "maxMeaValue": 5602, 514 | "minRangeValue": 5603, 515 | "maxRangeValue": 5604, 516 | "resetMinMaxMeaValues": 5605, 517 | "calOffset": 5535, 518 | "appType": 5750 519 | }, 520 | "altitude": { 521 | "sensorValue": 5700, 522 | "units": 5701, 523 | "minMeaValue": 5601, 524 | "maxMeaValue": 5602, 525 | "minRangeValue": 5603, 526 | "maxRangeValue": 5604, 527 | "resetMinMaxMeaValues": 5605, 528 | "calOffset": 5535, 529 | "appType": 5750 530 | }, 531 | "load": { 532 | "sensorValue": 5700, 533 | "units": 5701, 534 | "minMeaValue": 5601, 535 | "maxMeaValue": 5602, 536 | "minRangeValue": 5603, 537 | "maxRangeValue": 5604, 538 | "resetMinMaxMeaValues": 5605, 539 | "calOffset": 5535, 540 | "appType": 5750 541 | }, 542 | "pressure": { 543 | "sensorValue": 5700, 544 | "units": 5701, 545 | "minMeaValue": 5601, 546 | "maxMeaValue": 5602, 547 | "minRangeValue": 5603, 548 | "maxRangeValue": 5604, 549 | "resetMinMaxMeaValues": 5605, 550 | "calOffset": 5535, 551 | "appType": 5750 552 | }, 553 | "loudness": { 554 | "sensorValue": 5700, 555 | "units": 5701, 556 | "minMeaValue": 5601, 557 | "maxMeaValue": 5602, 558 | "minRangeValue": 5603, 559 | "maxRangeValue": 5604, 560 | "resetMinMaxMeaValues": 5605, 561 | "calOffset": 5535, 562 | "appType": 5750 563 | }, 564 | "concentration": { 565 | "sensorValue": 5700, 566 | "units": 5701, 567 | "minMeaValue": 5601, 568 | "maxMeaValue": 5602, 569 | "minRangeValue": 5603, 570 | "maxRangeValue": 5604, 571 | "resetMinMaxMeaValues": 5605, 572 | "calOffset": 5535, 573 | "appType": 5750 574 | }, 575 | "acidity": { 576 | "sensorValue": 5700, 577 | "units": 5701, 578 | "minMeaValue": 5601, 579 | "maxMeaValue": 5602, 580 | "minRangeValue": 5603, 581 | "maxRangeValue": 5604, 582 | "resetMinMaxMeaValues": 5605, 583 | "calOffset": 5535, 584 | "appType": 5750 585 | }, 586 | "conductivity": { 587 | "sensorValue": 5700, 588 | "units": 5701, 589 | "minMeaValue": 5601, 590 | "maxMeaValue": 5602, 591 | "minRangeValue": 5603, 592 | "maxRangeValue": 5604, 593 | "resetMinMaxMeaValues": 5605, 594 | "calOffset": 5535, 595 | "appType": 5750 596 | }, 597 | "power": { 598 | "sensorValue": 5700, 599 | "units": 5701, 600 | "minMeaValue": 5601, 601 | "maxMeaValue": 5602, 602 | "minRangeValue": 5603, 603 | "maxRangeValue": 5604, 604 | "resetMinMaxMeaValues": 5605, 605 | "calOffset": 5535, 606 | "appType": 5750 607 | }, 608 | "powerFactor": { 609 | "sensorValue": 5700, 610 | "units": 5701, 611 | "minMeaValue": 5601, 612 | "maxMeaValue": 5602, 613 | "minRangeValue": 5603, 614 | "maxRangeValue": 5604, 615 | "resetMinMaxMeaValues": 5605, 616 | "calOffset": 5535, 617 | "appType": 5750 618 | }, 619 | "distance": { 620 | "sensorValue": 5700, 621 | "units": 5701, 622 | "minMeaValue": 5601, 623 | "maxMeaValue": 5602, 624 | "minRangeValue": 5603, 625 | "maxRangeValue": 5604, 626 | "resetMinMaxMeaValues": 5605, 627 | "calOffset": 5535, 628 | "appType": 5750 629 | }, 630 | "energy": { 631 | "cumulActivePwr": 5805, 632 | "units": 5701, 633 | "resetCumulEnergy": 5822, 634 | "appType": 5750 635 | }, 636 | "direction": { 637 | "compassDir": 5705, 638 | "minMeaValue": 5601, 639 | "maxMeaValue": 5602, 640 | "resetMinMaxMeaValues": 5605, 641 | "appType": 5750 642 | }, 643 | "time": { 644 | "currentTime": 5506, 645 | "fracTime": 5507, 646 | "appType": 5750 647 | }, 648 | "gyrometer": { 649 | "units": 5701, 650 | "xValue": 5702, 651 | "yValue": 5703, 652 | "zValue": 5704, 653 | "minRangeValue": 5603, 654 | "maxRangeValue": 5604, 655 | "minXValue": 5508, 656 | "maxXValue": 5509, 657 | "minYValue": 5510, 658 | "maxYValue": 5511, 659 | "minZValue": 5512, 660 | "maxZValue": 5513, 661 | "resetMinMaxMeaValues": 5605, 662 | "appType": 5750 663 | }, 664 | "colour": { 665 | "colour": 5706, 666 | "units": 5701, 667 | "appType": 5750 668 | }, 669 | "gpsLocation": { 670 | "latitude": 5514, 671 | "longitude": 5515, 672 | "uncertainty": 5516, 673 | "compassDir": 5705, 674 | "velocity": 5517, 675 | "timestamp": 5518, 676 | "appType": 5750 677 | }, 678 | "positioner": { 679 | "currentPos": 5536, 680 | "transTime": 5537, 681 | "remainTime": 5538, 682 | "minMeaValue": 5601, 683 | "maxMeaValue": 5602, 684 | "resetMinMaxMeaValues": 5605, 685 | "minLimit": 5519, 686 | "maxLimit": 5520, 687 | "appType": 5750 688 | }, 689 | "buzzer": { 690 | "onOff": 5850, 691 | "level": 5548, 692 | "timeDuration": 5521, 693 | "minOffTime": 5525, 694 | "appType": 5750 695 | }, 696 | "audioClip": { 697 | "clip": 5522, 698 | "trigger": 5523, 699 | "level": 5548, 700 | "soundDuration": 5524, 701 | "appType": 5750 702 | }, 703 | "timer": { 704 | "timeDuration": 5521, 705 | "remainTime": 5538, 706 | "minOffTime": 5525, 707 | "trigger": 5523, 708 | "onOff": 5850, 709 | "counter": 5501, 710 | "cumulTime": 5544, 711 | "digitalState": 5543, 712 | "eventCounter": 5534, 713 | "mode": 5526, 714 | "appType": 5750 715 | }, 716 | "addressableTextDisplay": { 717 | "text": 5527, 718 | "xCoord": 5528, 719 | "yCoord": 5529, 720 | "maxXCoord": 5545, 721 | "maxYCoord": 5546, 722 | "clearDisplay": 5530, 723 | "contrast": 5531, 724 | "level": 5548, 725 | "appType": 5750 726 | }, 727 | "onOffSwitch": { 728 | "dInState": 5500, 729 | "counter": 5501, 730 | "onTime": 5852, 731 | "offTime": 5854, 732 | "appType": 5750 733 | }, 734 | "levelControl": { 735 | "level": 5548, 736 | "onTime": 5852, 737 | "offTime": 5854, 738 | "appType": 5750 739 | }, 740 | "upDownControl": { 741 | "incInputState": 5532, 742 | "decInputState": 5533, 743 | "upCounter": 5541, 744 | "downCounter": 5542, 745 | "appType": 5750 746 | }, 747 | "multipleAxisJoystick": { 748 | "dInState": 5500, 749 | "counter": 5501, 750 | "xValue": 5702, 751 | "yValue": 5703, 752 | "zValue": 5704, 753 | "appType": 5750 754 | }, 755 | "rate": { 756 | "sensorValue": 5700, 757 | "units": 5701, 758 | "minMeaValue": 5601, 759 | "maxMeaValue": 5602, 760 | "minRangeValue": 5603, 761 | "maxRangeValue": 5604, 762 | "resetMinMaxMeaValues": 5605, 763 | "calOffset": 5535, 764 | "appType": 5750 765 | }, 766 | "pushButton": { 767 | "dInState": 5500, 768 | "counter": 5501, 769 | "appType": 5750 770 | }, 771 | "multistateSelector": { 772 | "mStateIn": 5547, 773 | "appType": 5750 774 | } 775 | }, 776 | "objectSpec": { 777 | "lwm2mSecurity": { "multi": true, "mand": true }, 778 | "lwm2mServer": { "multi": true, "mand": true }, 779 | "accessCtrl": { "multi": true, "mand": false }, 780 | "device": { "multi": false, "mand": true }, 781 | "connMonitor": { "multi": false, "mand": false }, 782 | "firmware": { "multi": false, "mand": false }, 783 | "location": { "multi": false, "mand": false }, 784 | "connStatistics": { "multi": false, "mand": false } 785 | }, 786 | "specificResrcChar": { 787 | "lwm2mSecurity": { 788 | "lwm2mServerURI": { "access": null, "multi": false, "mand": true, "type": "string", "range": 255, "init": "" }, 789 | "bootstrapServer": { "access": null, "multi": false, "mand": true, "type": "boolean", "range": null, "init": false }, 790 | "securityMode": { "access": null, "multi": false, "mand": true, "type": "integer", "range": 3, "init": false }, 791 | "pubKeyId": { "access": null, "multi": false, "mand": true, "type": "opaque", "range": null, "init": 0 }, 792 | "serverPubKeyId": { "access": null, "multi": false, "mand": true, "type": "opaque", "range": null, "init": 0 }, 793 | "secretKey": { "access": null, "multi": false, "mand": true, "type": "opaque", "range": null, "init": 0 }, 794 | "smsSecurityMode": { "access": null, "multi": false, "mand": false, "type": "integer", "range": 255, "init": 3 }, 795 | "smsBindingKeyParam": { "access": null, "multi": false, "mand": false, "type": "opaque", "range": 6, "init": 0 }, 796 | "smsBindingSecretKey": { "access": null, "multi": false, "mand": false, "type": "opaque", "range": 48, "init": 0 }, 797 | "lwm2mServerSmsNum": { "access": null, "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 798 | "shortServerId": { "access": null, "multi": false, "mand": false, "type": "integer", "range": 65535, "init": 1 }, 799 | "clientHoldOffTime": { "access": null, "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 } 800 | }, 801 | "lwm2mServer": { 802 | "shortServerId": { "access": "R", "multi": false, "mand": true, "type": "integer", "range": 65535, "init": 1 }, 803 | "lifetime": { "access": "RW", "multi": false, "mand": true, "type": "integer", "range": null, "init": 86400 }, 804 | "defaultMinPeriod": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": null, "init": 1 }, 805 | "defaultMaxPeriod": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": null, "init": 60 }, 806 | "disable": { "access": "E", "multi": false, "mand": false, "type": "execute", "range": null, "init": null }, 807 | "disableTimeout": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": null, "init": 86400 }, 808 | "notificationStoring": { "access": "RW", "multi": false, "mand": true, "type": "boolean", "range": null, "init": true }, 809 | "binding": { "access": "RW", "multi": false, "mand": true, "type": "string", "range": null, "init": "TCP" }, 810 | "regUpdateTrigger": { "access": "E", "multi": false, "mand": true, "type": "execute", "range": null, "init": null } 811 | }, 812 | "accessCtrl": { 813 | "objectId": { "access": "R", "multi": false, "mand": true, "type": "integer", "range": 65534, "init": 1 }, 814 | "objectInstanceId": { "access": "R", "multi": false, "mand": true, "type": "integer", "range": 65535, "init": 0 }, 815 | "ACL": { "access": "RW", "multi": true, "mand": false, "type": "integer", "range": 65535, "init": 0 }, 816 | "ACLOwner": { "access": "RW", "multi": false, "mand": true, "type": "integer", "range": 65535, "init": 0 } 817 | }, 818 | "device": { 819 | "manuf": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "freebird" }, 820 | "model": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "freebird-smarthing-v1" }, 821 | "serial": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "fb-0000-0001" }, 822 | "firmware": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "0.0.1" }, 823 | "reboot": { "access": "E", "multi": false, "mand": true, "type": "execute", "range": null, "init": null }, 824 | "factoryReset": { "access": "E", "multi": false, "mand": false, "type": "execute", "range": null, "init": null }, 825 | "availPwrSrc": { "access": "R", "multi": true, "mand": false, "type": "integer", "range": 7, "init": 0 }, 826 | "pwrSrcVoltage": { "access": "R", "multi": true, "mand": false, "type": "integer", "range": null, "init": 3300 }, 827 | "pwrSrcCurrent": { "access": "R", "multi": true, "mand": false, "type": "integer", "range": null, "init": 0 }, 828 | "battLevel": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": 100, "init": 100 }, 829 | "memFree": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 830 | "errCode": { "access": "R", "multi": true, "mand": true, "type": "integer", "range": 8, "init": 0 }, 831 | "resetErrCode": { "access": "E", "multi": true, "mand": false, "type": "execute", "range": null, "init": null }, 832 | "currTime": { "access": "RW", "multi": false, "mand": false, "type": "time", "range": null, "init": 0 }, 833 | "UTCOffset": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "UTC+08:00" }, 834 | "timezone": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "Asia/Taipei" }, 835 | "bindAndModes": { "access": "R", "multi": false, "mand": true, "type": "string", "range": null, "init": "TCP" }, 836 | "devType": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "mqtt-smarthing" }, 837 | "hwVer": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "0.0.1" }, 838 | "swVer": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "0.0.1" }, 839 | "battStatus": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": 6, "init": 0 }, 840 | "memTotal": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 } 841 | }, 842 | "connMonitor": { 843 | "nwkBearer": { "access": "R", "multi": false, "mand": true, "type": "integer", "range": null, "init": 21 }, 844 | "availNwkBearer": { "access": "R", "multi": true, "mand": true, "type": "integer", "range": null, "init": 21 }, 845 | "radioStrength": { "access": "R", "multi": false, "mand": true, "type": "integer", "range": null, "init": 64 }, 846 | "linkQuality": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 100 }, 847 | "ip": { "access": "R", "multi": true, "mand": true, "type": "string", "range": null, "init": "" }, 848 | "routeIp": { "access": "R", "multi": true, "mand": false, "type": "string", "range": null, "init": "" }, 849 | "linkUtil": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": 100, "init": 50 }, 850 | "APN": { "access": "R", "multi": true, "mand": false, "type": "string", "range": null, "init": "" }, 851 | "cellId": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 1 }, 852 | "SMNC": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 853 | "SMCC": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 } 854 | }, 855 | "firmware": { 856 | "package": { "access": "W", "multi": false, "mand": true, "type": "opaque", "range": null, "init": 0 }, 857 | "packageURI": { "access": "W", "multi": false, "mand": true, "type": "string", "range": 255, "init": "" }, 858 | "update": { "access": "E", "multi": false, "mand": true, "type": "execute", "range": null, "init": null }, 859 | "state": { "access": "R", "multi": false, "mand": true, "type": "integer", "range": 3, "init": 1 }, 860 | "updateSuppObjects": { "access": "RW", "multi": false, "mand": false, "type": "boolean", "range": null, "init": false }, 861 | "updateResult": { "access": "R", "multi": false, "mand": true, "type": "integer", "range": 6, "init": 0 }, 862 | "pkgName": { "access": "R", "multi": false, "mand": false, "type": "string", "range": 255, "init": "" }, 863 | "pkgVer": { "access": "R", "multi": false, "mand": false, "type": "string", "range": 255, "init": "" } 864 | }, 865 | "location": { 866 | "lat": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 867 | "lon": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 868 | "alt": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 869 | "radius": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 870 | "velocity": { "access": "R", "multi": false, "mand": false, "type": "opaque", "range": null, "init": 0 }, 871 | "timestamp": { "access": "R", "multi": false, "mand": true, "type": "time", "range": null, "init": 0 }, 872 | "speed": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 } 873 | }, 874 | "connStatistics": { 875 | "SMSTxCounter": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 876 | "SMSRxCounter": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 877 | "txData": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 878 | "rxData": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 879 | "maxMsgSize": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 880 | "avgMsgSize": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 881 | "startOrReset": { "access": "E", "multi": false, "mand": true, "type": "execute", "range": null, "init": null } 882 | }, 883 | "dIn": { 884 | "dInState": { "access": "R", "multi": false, "mand": true, "type": "boolean", "range": null, "init": false }, 885 | "counter": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 886 | "dInPolarity": { "access": "RW", "multi": false, "mand": false, "type": "boolean", "range": null, "init": false }, 887 | "debouncePeriod": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 888 | "edgeSelection": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": 3, "init": 2 }, 889 | "counterReset": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 890 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "Digital Input" }, 891 | "sensorType": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "Digital" } 892 | }, 893 | "dOut": { 894 | "dOutState": { "access": "RW", "multi": false, "mand": true, "type": "boolean", "range": null, "init": false }, 895 | "dOutPolarity": { "access": "RW", "multi": false, "mand": false, "type": "boolean", "range": null, "init": false }, 896 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "Digital Output" } 897 | }, 898 | "aIn": { 899 | "aInCurrValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 900 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 901 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 902 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 903 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 904 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 905 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "Analog Input" }, 906 | "sensorType": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "Analog" } 907 | }, 908 | "aOut": { 909 | "aOutCurrValue": { "access": "RW", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 910 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 911 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 912 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "Analog Output" } 913 | }, 914 | "generic": { 915 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 916 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 917 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 918 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 919 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 920 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 921 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 922 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "Generic Sensor" }, 923 | "sensorType": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "Generic" } 924 | }, 925 | "illuminance": { 926 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 927 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "lux" }, 928 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 929 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 930 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 931 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 932 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null } 933 | }, 934 | "presence": { 935 | "dInState": { "access": "R", "multi": false, "mand": true, "type": "boolean", "range": null, "init": false }, 936 | "counter": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 937 | "counterReset": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 938 | "sensorType": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "Presence" }, 939 | "busyToClearDelay": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 940 | "clearToBusyDelay": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 } 941 | }, 942 | "temperature": { 943 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 944 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "Cel" }, 945 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 946 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 947 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 948 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 949 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null } 950 | }, 951 | "humidity": { 952 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 953 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "%" }, 954 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 955 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 956 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 957 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 958 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null } 959 | }, 960 | "pwrMea": { 961 | "instActivePwr": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 962 | "minMeaActivePwr": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 963 | "maxMeaActivePwr": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 964 | "minRangeActivePwr": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 965 | "maxRangeActivePwr": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 966 | "cumulActivePwr": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 967 | "activePwrCal": { "access": "W", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 968 | "instReactivePwr": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 969 | "minMeaReactivePwr": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 970 | "maxMeaReactivePwr": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 971 | "minRangeReactivePwr": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 972 | "maxRangeReactivePwr": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 973 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 974 | "cumulReactivePwr": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 975 | "reactivePwrCal": { "access": "W", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 976 | "pwrFactor": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 977 | "currCal": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 978 | "resetCumulEnergy": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null } 979 | }, 980 | "actuation": { 981 | "onOff": { "access": "RW", "multi": false, "mand": true, "type": "boolean", "range": null, "init": false }, 982 | "dimmer": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": 100, "init": 0 }, 983 | "onTime": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": 100, "init": 0 }, 984 | "mStateOut": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "Pilot Wire" }, 985 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "Actuator" } 986 | }, 987 | "setPoint": { 988 | "setPointValue": { "access": "RW", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 989 | "colour": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": 100, "init": "#fff" }, 990 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 991 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "Set Point" } 992 | }, 993 | "loadCtrl": { 994 | "eventId": { "access": "RW", "multi": false, "mand": true, "type": "string", "range": null, "init": "evt01" }, 995 | "startTime": { "access": "RW", "multi": false, "mand": true, "type": "time", "range": null, "init": 0 }, 996 | "durationInMin": { "access": "RW", "multi": false, "mand": true, "type": "integer", "range": null, "init": 0 }, 997 | "criticalLevel": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": 3, "init": 0 }, 998 | "avgLoadAdjPct": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": 100, "init": 0 }, 999 | "dutyCycle": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": 100, "init": 0 } 1000 | }, 1001 | "lightCtrl": { 1002 | "onOff": { "access": "RW", "multi": false, "mand": true, "type": "boolean", "range": null, "init": false }, 1003 | "dimmer": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": 100, "init": 0 }, 1004 | "colour": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": 100, "init": "#fff" }, 1005 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1006 | "onTime": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": 100, "init": 0 }, 1007 | "cumulActivePwr": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1008 | "pwrFactor": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 } 1009 | }, 1010 | "pwrCtrl": { 1011 | "onOff": { "access": "RW", "multi": false, "mand": true, "type": "boolean", "range": null, "init": false }, 1012 | "dimmer": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": 100, "init": 0 }, 1013 | "onTime": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": 100, "init": 0 }, 1014 | "cumulActivePwr": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1015 | "pwrFactor": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 } 1016 | }, 1017 | "accelerometer": { 1018 | "xValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1019 | "yValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1020 | "zValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1021 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1022 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1023 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 } 1024 | }, 1025 | "magnetometer": { 1026 | "xValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1027 | "yValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1028 | "zValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1029 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1030 | "compassDir": { "access": "R", "multi": false, "mand": false, "type": "float", "range": 360, "init": 0 } 1031 | }, 1032 | "barometer": { 1033 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1034 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1035 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1036 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1037 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1038 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1039 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null } 1040 | }, 1041 | "voltage": { 1042 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1043 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1044 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1045 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1046 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1047 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1048 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1049 | "calOffset": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": null }, 1050 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "voltage" } 1051 | }, 1052 | "current": { 1053 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1054 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1055 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1056 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1057 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1058 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1059 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1060 | "calOffset": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": null }, 1061 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "current" } 1062 | }, 1063 | "frequency": { 1064 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1065 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1066 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1067 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1068 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1069 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1070 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1071 | "calOffset": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": null }, 1072 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "frequency" } 1073 | }, 1074 | "depth": { 1075 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1076 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1077 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1078 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1079 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1080 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1081 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1082 | "calOffset": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": null }, 1083 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "depth" } 1084 | }, 1085 | "percentage": { 1086 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1087 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1088 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1089 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1090 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1091 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1092 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1093 | "calOffset": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": null }, 1094 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "percentage" } 1095 | }, 1096 | "altitude": { 1097 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1098 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1099 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1100 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1101 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1102 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1103 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1104 | "calOffset": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": null }, 1105 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "altitude" } 1106 | }, 1107 | "load": { 1108 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1109 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1110 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1111 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1112 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1113 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1114 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1115 | "calOffset": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": null }, 1116 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "load" } 1117 | }, 1118 | "pressure": { 1119 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1120 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1121 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1122 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1123 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1124 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1125 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1126 | "calOffset": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": null }, 1127 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "pressure" } 1128 | }, 1129 | "loudness": { 1130 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1131 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1132 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1133 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1134 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1135 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1136 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1137 | "calOffset": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": null }, 1138 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "loudness" } 1139 | }, 1140 | "concentration": { 1141 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1142 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1143 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1144 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1145 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1146 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1147 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1148 | "calOffset": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": null }, 1149 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "concentration" } 1150 | }, 1151 | "acidity": { 1152 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1153 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1154 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1155 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1156 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1157 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1158 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1159 | "calOffset": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": null }, 1160 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "acidity" } 1161 | }, 1162 | "conductivity": { 1163 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1164 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1165 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1166 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1167 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1168 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1169 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1170 | "calOffset": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": null }, 1171 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "conductivity" } 1172 | }, 1173 | "power": { 1174 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1175 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1176 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1177 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1178 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1179 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1180 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1181 | "calOffset": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": null }, 1182 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "power" } 1183 | }, 1184 | "powerFactor": { 1185 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1186 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1187 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1188 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1189 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1190 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1191 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1192 | "calOffset": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": null }, 1193 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "powerFactor" } 1194 | }, 1195 | "distance": { 1196 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1197 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1198 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1199 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1200 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1201 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1202 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1203 | "calOffset": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": null }, 1204 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "distance" } 1205 | }, 1206 | "energy": { 1207 | "cumulActivePwr": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1208 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1209 | "resetCumulEnergy": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1210 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "energy" } 1211 | }, 1212 | "direction": { 1213 | "compassDir": { "access": "R", "multi": false, "mand": true, "type": "float", "range": 360, "init": 0 }, 1214 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1215 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1216 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1217 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "direction" } 1218 | }, 1219 | "time": { 1220 | "currentTime": { "access": "RW", "multi": false, "mand": true, "type": "time", "range": null, "init": 0 }, 1221 | "fracTime": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": 1, "init": 0 }, 1222 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "time" } 1223 | }, 1224 | "gyrometer": { 1225 | "xValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1226 | "yValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1227 | "zValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1228 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1229 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1230 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1231 | "minXValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1232 | "maxXValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1233 | "minYValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1234 | "maxYValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1235 | "minZValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1236 | "maxZValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1237 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1238 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "gyrometer" } 1239 | }, 1240 | "colour": { 1241 | "colour": { "access": "RW", "multi": false, "mand": true, "type": "string", "range": 100, "init": "#fff" }, 1242 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1243 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "colour" } 1244 | }, 1245 | "gpsLocation": { 1246 | "latitude": { "access": "R", "multi": false, "mand": true, "type": "string", "range": null, "init": "0.00" }, 1247 | "longitude": { "access": "R", "multi": false, "mand": true, "type": "string", "range": null, "init": "0.00" }, 1248 | "uncertainty": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "0.00" }, 1249 | "compassDir": { "access": "R", "multi": false, "mand": false, "type": "float", "range": 360, "init": 0 }, 1250 | "velocity": { "access": "R", "multi": false, "mand": false, "type": "opaque", "range": null, "init": 0 }, 1251 | "timestamp": { "access": "R", "multi": false, "mand": false, "type": "time", "range": null, "init": 0 }, 1252 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "gpsLocation" } 1253 | }, 1254 | "positioner": { 1255 | "currentPos": { "access": "RW", "multi": false, "mand": true, "type": "float", "range": 100, "init": 0 }, 1256 | "transTime": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1257 | "remainTime": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1258 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1259 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1260 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1261 | "minLimit": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1262 | "maxLimit": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1263 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "positioner" } 1264 | }, 1265 | "buzzer": { 1266 | "onOff": { "access": "RW", "multi": false, "mand": true, "type": "boolean", "range": null, "init": false }, 1267 | "level": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": 100, "init": 0 }, 1268 | "timeDuration": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1269 | "minOffTime": { "access": "RW", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1270 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "buzzer" } 1271 | }, 1272 | "audioClip": { 1273 | "clip": { "access": "RW", "multi": false, "mand": true, "type": "opaque", "range": null, "init": null }, 1274 | "trigger": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1275 | "level": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": 100, "init": 0 }, 1276 | "soundDuration": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1277 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "audioClip" } 1278 | }, 1279 | "timer": { 1280 | "timeDuration": { "access": "RW", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1281 | "remainTime": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1282 | "minOffTime": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1283 | "trigger": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1284 | "onOff": { "access": "RW", "multi": false, "mand": false, "type": "boolean", "range": null, "init": false }, 1285 | "counter": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 1286 | "cumulTime": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1287 | "digitalState": { "access": "R", "multi": false, "mand": false, "type": "boolean", "range": null, "init": false }, 1288 | "eventCounter": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 1289 | "mode": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": 4, "init": 0 }, 1290 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "timer" } 1291 | }, 1292 | "addressableTextDisplay": { 1293 | "text": { "access": "RW", "multi": false, "mand": true, "type": "string", "range": null, "init": "defaut text" }, 1294 | "xCoord": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 1295 | "yCoord": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 1296 | "maxXCoord": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 1297 | "maxYCoord": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 1298 | "clearDisplay": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1299 | "contrast": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": 100, "init": 0 }, 1300 | "level": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": 100, "init": 0 }, 1301 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "addressableTextDisplay" } 1302 | }, 1303 | "onOffSwitch": { 1304 | "dInState": { "access": "R", "multi": false, "mand": true, "type": "boolean", "range": null, "init": false }, 1305 | "counter": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 1306 | "onTime": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 1307 | "offTime": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 1308 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "onOffSwitch" } 1309 | }, 1310 | "levelControl": { 1311 | "level": { "access": "RW", "multi": false, "mand": true, "type": "float", "range": 100, "init": 0 }, 1312 | "onTime": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 1313 | "offTime": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 1314 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "levelControl" } 1315 | }, 1316 | "upDownControl": { 1317 | "incInputState": { "access": "R", "multi": false, "mand": true, "type": "boolean", "range": null, "init": false }, 1318 | "decInputState": { "access": "R", "multi": false, "mand": true, "type": "boolean", "range": null, "init": false }, 1319 | "upCounter": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 1320 | "downCounter": { "access": "RW", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 1321 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "upDownControl" } 1322 | }, 1323 | "multipleAxisJoystick": { 1324 | "dInState": { "access": "R", "multi": false, "mand": true, "type": "boolean", "range": null, "init": false }, 1325 | "counter": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 1326 | "xValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": 100, "init": 0 }, 1327 | "yValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": 100, "init": 0 }, 1328 | "zValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": 100, "init": 0 }, 1329 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "multipleAxisJoystick" } 1330 | }, 1331 | "rate": { 1332 | "sensorValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 1333 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 1334 | "minMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1335 | "maxMeaValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1336 | "minRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1337 | "maxRangeValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 1338 | "resetMinMaxMeaValues": { "access": "E", "multi": false, "mand": false, "type": "opaque", "range": null, "init": null }, 1339 | "calOffset": { "access": "RW", "multi": false, "mand": false, "type": "float", "range": null, "init": null }, 1340 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "rate" } 1341 | }, 1342 | "pushButton": { 1343 | "dInState": { "access": "R", "multi": false, "mand": true, "type": "boolean", "range": null, "init": false }, 1344 | "counter": { "access": "R", "multi": false, "mand": false, "type": "integer", "range": null, "init": 0 }, 1345 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "pushButton" } 1346 | }, 1347 | "multistateSelector": { 1348 | "mStateIn": { "access": "R", "multi": false, "mand": true, "type": "integer", "range": null, "init": 0 }, 1349 | "appType": { "access": "RW", "multi": false, "mand": false, "type": "string", "range": null, "init": "multistateSelector" } 1350 | } 1351 | } 1352 | } 1353 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Enum = require('enum'), 4 | _defs = require('./defs/defs.json'), 5 | _specificRid = _defs.specificRid, 6 | DEFS = { 7 | _Enum: Enum, 8 | _defs: _defs, 9 | RspCode: null, 10 | Cmd: null, 11 | Oid: null, 12 | UniqueRid: null, 13 | SpecificRid: {}, 14 | SpecificResrcChar: _defs.specificResrcChar, 15 | objectSpec: _defs.objectSpec 16 | }; 17 | 18 | /*************************************************************************************************/ 19 | /*** Loading Enumerations ***/ 20 | /*************************************************************************************************/ 21 | DEFS.RspCode = new Enum(_defs.rspCode); 22 | DEFS.Cmd = new Enum(_defs.cmdId); 23 | DEFS.Oid = new Enum(_defs.oid); 24 | DEFS.UniqueRid = new Enum(_defs.uniqueRid); 25 | 26 | for (var key in _specificRid) { 27 | if (_specificRid.hasOwnProperty(key)) 28 | DEFS.SpecificRid[key] = new Enum(_specificRid[key]); 29 | } 30 | 31 | function isValidArgType(param) { 32 | var isValid = true; 33 | 34 | if (typeof param !== 'number' && typeof param !== 'string') { 35 | isValid = false; 36 | } else if (typeof param === 'number') { 37 | isValid = !isNaN(param); 38 | } 39 | 40 | return isValid; 41 | } 42 | 43 | /*************************************************************************************************/ 44 | /*** DEFS Methods ***/ 45 | /*************************************************************************************************/ 46 | DEFS.getCmd = function (cmdId) { 47 | if (!isValidArgType(cmdId)) 48 | throw new TypeError('cmdId should be type of string or number.'); 49 | 50 | return DEFS.Cmd.get(cmdId); 51 | }; 52 | 53 | DEFS.getRspCode = function (code) { 54 | if (!isValidArgType(code)) 55 | throw new TypeError('code should be a type of string or number.'); 56 | 57 | return DEFS.RspCode.get(code); 58 | }; 59 | 60 | DEFS.getOid = function (oid) { 61 | if (!isValidArgType(oid)) 62 | throw new TypeError('oid should be a number or a string.'); 63 | 64 | var oidNumber = parseInt(oid), 65 | oidItem; 66 | 67 | if (!isNaN(oidNumber)) 68 | oid = oidNumber; 69 | 70 | oidItem = DEFS.Oid.get(oid); 71 | 72 | return oidItem; 73 | }; 74 | 75 | DEFS.addOid = function (items) { 76 | var _oid = DEFS._defs.oid; 77 | 78 | if (typeof items !== 'object' || items === null || Array.isArray(items)) 79 | throw new TypeError('items should be a plain object.'); 80 | 81 | for (var key in items) { 82 | if (DEFS.getOid(key)) 83 | throw new Error('oid: ' + key + ' name conflicts.'); 84 | else if (DEFS.getOid(items[key])) 85 | throw new Error('oid: ' + key + ' value conflicts.'); 86 | else 87 | _oid[key] = items[key]; 88 | } 89 | 90 | DEFS.Oid = null; 91 | DEFS.Oid = new Enum(_oid); 92 | 93 | return DEFS; 94 | }; 95 | 96 | DEFS.getRid = function (oid, rid) { 97 | var oidItem = DEFS.getOid(oid), 98 | ridNumber, 99 | ridItem, 100 | oidKey; 101 | 102 | if (typeof rid === 'undefined') { 103 | if (typeof oid === 'undefined') 104 | throw new TypeError('Bad arguments'); 105 | 106 | rid = oid; 107 | oid = undefined; 108 | if (!isValidArgType(rid)) 109 | throw new TypeError('rid should be a number or a string.'); 110 | } 111 | 112 | ridNumber = parseInt(rid); 113 | if (!isNaN(ridNumber)) 114 | rid = ridNumber; 115 | 116 | if (typeof oid !== 'undefined') { // searching in MDEFS.RIDOFOID 117 | if (!isValidArgType(oid)) 118 | throw new TypeError('rid should be a number or a string.'); 119 | 120 | if (typeof rid === 'undefined') 121 | throw new TypeError('rid should be given'); 122 | 123 | if (!isValidArgType(rid)) 124 | throw new TypeError('rid should be a number or a string.'); 125 | 126 | oidKey = oidItem ? oidItem.key : oid.toString(); 127 | 128 | if (DEFS.SpecificRid[oidKey] instanceof Enum) 129 | ridItem = DEFS.SpecificRid[oidKey].get(rid); 130 | } else { 131 | ridItem = DEFS.UniqueRid.get(rid); 132 | } 133 | 134 | return ridItem; 135 | }; 136 | 137 | DEFS.addUniqueRid = function (items) { 138 | var _uRid = DEFS._defs.uniqueRid; 139 | 140 | if (typeof items !== 'object' || items === null || Array.isArray(items)) 141 | throw new TypeError('items should be a plain object.'); 142 | 143 | for (var key in items) { 144 | if (DEFS.getRid(key)) 145 | throw new Error('unique rid: ' + key + ' name conflicts.'); 146 | else if (DEFS.getRid(items[key])) 147 | throw new Error('unique rid: ' + key + ' value conflicts.'); 148 | else 149 | _uRid[key] = items[key]; 150 | } 151 | 152 | DEFS.UniqueRid = null; 153 | DEFS.UniqueRid = new Enum(_uRid); 154 | 155 | return DEFS; 156 | }; 157 | 158 | DEFS.addSpecificRid = function (oid, items) { 159 | var oidItem = DEFS.getOid(oid), 160 | oidKey, 161 | _spfRid = DEFS._defs.specificRid; 162 | 163 | if (!oidItem) 164 | throw new Error('oid: ' + oid + ' does not exist. Please do addOid() first.'); 165 | 166 | oidKey = oidItem.key; 167 | 168 | _spfRid[oidKey] = _spfRid[oidKey] || {}; 169 | 170 | if (typeof items !== 'object' || items === null || Array.isArray(items)) 171 | throw new TypeError('items should be a plain object.'); 172 | 173 | for (var key in items) { 174 | if (typeof _spfRid[oidKey][key] !== 'undefined') { 175 | throw new Error('rid: ' + key + ' within oid: ' + oidKey + ' conflicts.'); 176 | } 177 | 178 | _spfRid[oidKey][key] = items[key]; 179 | } 180 | 181 | DEFS.SpecificRid[oidKey] = null; 182 | DEFS.SpecificRid[oidKey] = new Enum(_spfRid[oidKey]); 183 | 184 | return DEFS; 185 | }; 186 | 187 | DEFS.addObjectSpec = function (oid, items) { 188 | var oidItem = DEFS.getOid(oid), 189 | oidKey, 190 | _objSpec = DEFS._defs.objectSpec; 191 | 192 | if (!oidItem) 193 | throw new Error('oid: ' + oid + ' does not exist. Please do addOid() first.'); 194 | 195 | oidKey = oidItem.key; 196 | 197 | _objSpec[oidKey] = _objSpec[oidKey] || {}; 198 | 199 | if (typeof items !== 'object' || items === null || Array.isArray(items)) 200 | throw new TypeError('items should be a plain object.'); 201 | 202 | for (var key in items) { 203 | if (typeof _objSpec[oidKey][key] !== 'undefined') { 204 | throw new Error('objectSpec: ' + key + ' within oid: ' + oidKey + ' conflicts.'); 205 | } 206 | 207 | _objSpec[oidKey][key] = items[key]; 208 | } 209 | 210 | return DEFS; 211 | }; 212 | 213 | DEFS.getOdef = function (oid) { 214 | var oidItem = DEFS.getOid(oid), 215 | spec; 216 | 217 | if (!oidItem) 218 | return; 219 | 220 | spec = DEFS.objectSpec[oidItem.key]; 221 | 222 | // 3200-3400: defined by starter and expansion pack 223 | if (!spec && oidItem.value >= 3200 && oidItem.value <= 3400) 224 | spec = { multi: true, mand: false }; 225 | 226 | return spec; 227 | }; // undefined / Object spec. 228 | 229 | DEFS.getSpecificResrcChar = function (oid, rid) { 230 | var oidItem = DEFS.getOid(oid), 231 | ridItem = DEFS.getRid(oid, rid), 232 | characteristic; 233 | 234 | if (!ridItem) 235 | return; 236 | 237 | if (oidItem && ridItem) { 238 | characteristic = DEFS.SpecificResrcChar[oidItem.key]; 239 | characteristic = characteristic[ridItem.key]; 240 | } 241 | 242 | return characteristic; 243 | }; // undefined / resrc characteristic 244 | 245 | DEFS.getRdef = DEFS.getSpecificResrcChar; 246 | 247 | DEFS.addSpecificResrcChar = function (oid, chars) { 248 | var _rChar = DEFS._defs.specificResrcChar, 249 | oidItem = DEFS.getOid(oid), 250 | ridItem, 251 | pass = _checkCharFormat(chars); 252 | 253 | if (!oidItem) 254 | throw new Error('oid: ' + oid + ' does not exist. Please do addOid() first.'); 255 | 256 | _rChar[oidItem.key] = _rChar[oidItem.key] || {}; 257 | _rChar = _rChar[oidItem.key]; 258 | 259 | if (typeof chars !== 'object' || chars === null || Array.isArray(chars)) 260 | throw new TypeError('chars should be a plain object.'); 261 | 262 | for (var rid in chars) { 263 | ridItem = DEFS.getRid(oid, rid); 264 | if (!ridItem) 265 | throw new Error('rid: ' + rid + ' does not exist. Please do addSpecificRid() first.'); 266 | 267 | if (_rChar[ridItem.key]) { 268 | throw new Error('rid: ' + rid + ' conflicts in oid: ' + oid); 269 | } else { 270 | if (!_checkCharFormat(chars[rid])) 271 | throw new Error('Invalid characteristic format within rid: ' + rid); 272 | 273 | _rChar[ridItem.key] = chars[rid]; 274 | } 275 | } 276 | 277 | return DEFS; 278 | }; 279 | 280 | /*************************************************************************************************/ 281 | /*** Private Functions ***/ 282 | /*************************************************************************************************/ 283 | function _checkCharFormat(charItem) { 284 | var keysChecked = { 285 | access: false, 286 | multi: false, 287 | mand: false, 288 | type: false, 289 | range: false, 290 | init: false 291 | }, 292 | pass = true; 293 | 294 | if (typeof charItem !== 'object') 295 | throw new TypeError('Resource characteristic should be an object.'); 296 | 297 | for (var key in charItem) { 298 | if (keysChecked.hasOwnProperty(key)) 299 | keysChecked[key] = true; 300 | } 301 | 302 | for (var k in keysChecked) { 303 | pass = pass & keysChecked[k]; 304 | } 305 | 306 | return pass; 307 | } 308 | 309 | module.exports = DEFS; 310 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lwm2m-id", 3 | "version": "1.6.4", 4 | "description": "A dictionary of ip-based smart object(IPSO) identifiers defined by lwm2m spec.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "make test-all" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/simenkid/lwm2m-id.git" 12 | }, 13 | "keywords": [ 14 | "ipso", 15 | "lwm2m" 16 | ], 17 | "author": "Simen Li", 18 | "license": "MIT", 19 | "bugs": { 20 | "url": "https://github.com/simenkid/lwm2m-id/issues" 21 | }, 22 | "homepage": "https://github.com/simenkid/lwm2m-id", 23 | "dependencies": { 24 | "enum": "^2.3.0" 25 | }, 26 | "devDependencies": { 27 | "chai": "^3.5.0", 28 | "mocha": "^2.5.3" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/argumentType.test.js: -------------------------------------------------------------------------------- 1 | var Enum = require('enum'), 2 | expect = require('chai').expect, 3 | lwm2mid = require('../index.js'); // lwm2m-id module 4 | 5 | describe('Enum Instance Check', function() { 6 | describe('#._defs', function() { 7 | it('is not an object of Enum', function () { 8 | expect(lwm2mid._defs instanceof Enum).to.be.false; 9 | }); 10 | }); 11 | 12 | describe('#.RspCode', function() { 13 | it('is an object of Enum', function () { 14 | expect(lwm2mid.RspCode instanceof Enum).to.be.true; 15 | }); 16 | }); 17 | 18 | describe('#.Cmd', function() { 19 | it('is an object of Enum', function () { 20 | expect(lwm2mid.Cmd instanceof Enum).to.be.true; 21 | }); 22 | }); 23 | 24 | describe('#.Cmd', function() { 25 | it('is an object of Enum', function () { 26 | expect(lwm2mid.Cmd instanceof Enum).to.be.true; 27 | }); 28 | }); 29 | 30 | describe('#.Oid', function() { 31 | it('is an object of Enum', function () { 32 | expect(lwm2mid.Oid instanceof Enum).to.be.true; 33 | }); 34 | }); 35 | 36 | describe('#.UniqueRid', function() { 37 | it('is an object of Enum', function () { 38 | expect(lwm2mid.UniqueRid instanceof Enum).to.be.true; 39 | }); 40 | }); 41 | 42 | describe('#.SpecificRid', function() { 43 | it('are objects of Enum', function () { 44 | var pass = true; 45 | for (var oid in lwm2mid.SpecificRid) { 46 | pass = pass && (lwm2mid.SpecificRid[oid] instanceof Enum); 47 | } 48 | expect(pass).to.be.true; 49 | }); 50 | 51 | }); 52 | 53 | describe('#.specificResrcChar', function() { 54 | it('is not an object of Enum', function () { 55 | expect(lwm2mid.specificResrcChar instanceof Enum).to.be.false; 56 | }); 57 | }); 58 | }); 59 | 60 | describe('APIs Arguments Check for Throwing Errors', function() { 61 | 62 | describe('#.getCmd', function() { 63 | it('should be a function', function () { 64 | expect(lwm2mid.getCmd).to.be.a('function'); 65 | }); 66 | 67 | it('should throw TypeError if input cmdId is not a number and not a string', function () { 68 | expect(function () { return lwm2mid.getCmd(); }).to.throw(TypeError); 69 | expect(function () { return lwm2mid.getCmd(undefined); }).to.throw(TypeError); 70 | expect(function () { return lwm2mid.getCmd(null); }).to.throw(TypeError); 71 | expect(function () { return lwm2mid.getCmd(NaN); }).to.throw(TypeError); 72 | expect(function () { return lwm2mid.getCmd([]); }).to.throw(TypeError); 73 | expect(function () { return lwm2mid.getCmd({}); }).to.throw(TypeError); 74 | expect(function () { return lwm2mid.getCmd(true); }).to.throw(TypeError); 75 | expect(function () { return lwm2mid.getCmd(new Date()); }).to.throw(TypeError); 76 | expect(function () { return lwm2mid.getCmd(function () {}); }).to.throw(TypeError); 77 | 78 | expect(function () { return lwm2mid.getCmd(3); }).not.to.throw(Error); 79 | expect(function () { return lwm2mid.getCmd('3'); }).not.to.throw(Error); 80 | expect(function () { return lwm2mid.getCmd('xx'); }).not.to.throw(Error); 81 | }); 82 | }); 83 | 84 | describe('#.getRspCode', function() { 85 | it('should be a function', function () { 86 | expect(lwm2mid.getRspCode).to.be.a('function'); 87 | }); 88 | 89 | it('should throw TypeError if input code is not a number and not a string', function () { 90 | expect(function () { return lwm2mid.getRspCode(); }).to.throw(TypeError); 91 | expect(function () { return lwm2mid.getRspCode(undefined); }).to.throw(TypeError); 92 | expect(function () { return lwm2mid.getRspCode(null); }).to.throw(TypeError); 93 | expect(function () { return lwm2mid.getRspCode(NaN); }).to.throw(TypeError); 94 | expect(function () { return lwm2mid.getRspCode([]); }).to.throw(TypeError); 95 | expect(function () { return lwm2mid.getRspCode({}); }).to.throw(TypeError); 96 | expect(function () { return lwm2mid.getRspCode(true); }).to.throw(TypeError); 97 | expect(function () { return lwm2mid.getRspCode(new Date()); }).to.throw(TypeError); 98 | expect(function () { return lwm2mid.getRspCode(function () {}); }).to.throw(TypeError); 99 | 100 | expect(function () { return lwm2mid.getRspCode(3); }).not.to.throw(Error); 101 | expect(function () { return lwm2mid.getRspCode('3'); }).not.to.throw(Error); 102 | expect(function () { return lwm2mid.getRspCode('xx'); }).not.to.throw(Error); 103 | }); 104 | }); 105 | 106 | describe('#.getOid', function() { 107 | it('should be a function', function () { 108 | expect(lwm2mid.getOid).to.be.a('function'); 109 | }); 110 | 111 | it('should throw TypeError if input oid is not a number and not a string', function () { 112 | expect(function () { return lwm2mid.getOid(); }).to.throw(TypeError); 113 | expect(function () { return lwm2mid.getOid(undefined); }).to.throw(TypeError); 114 | expect(function () { return lwm2mid.getOid(null); }).to.throw(TypeError); 115 | expect(function () { return lwm2mid.getOid(NaN); }).to.throw(TypeError); 116 | expect(function () { return lwm2mid.getOid([]); }).to.throw(TypeError); 117 | expect(function () { return lwm2mid.getOid({}); }).to.throw(TypeError); 118 | expect(function () { return lwm2mid.getOid(true); }).to.throw(TypeError); 119 | expect(function () { return lwm2mid.getOid(new Date()); }).to.throw(TypeError); 120 | expect(function () { return lwm2mid.getOid(function () {}); }).to.throw(TypeError); 121 | 122 | expect(function () { return lwm2mid.getOid(3); }).not.to.throw(Error); 123 | expect(function () { return lwm2mid.getOid('3'); }).not.to.throw(Error); 124 | expect(function () { return lwm2mid.getOid('xx'); }).not.to.throw(Error); 125 | }); 126 | }); 127 | 128 | describe('#.getRid', function() { 129 | it('should be a function', function () { 130 | expect(lwm2mid.getRid).to.be.a('function'); 131 | }); 132 | 133 | it('should throw TypeError if input oid is not a number and not a string', function () { 134 | expect(function () { return lwm2mid.getRid(undefined, 3); }).to.throw(TypeError); 135 | expect(function () { return lwm2mid.getRid(undefined, 3); }).to.throw(TypeError); 136 | expect(function () { return lwm2mid.getRid(null, 3); }).to.throw(TypeError); 137 | expect(function () { return lwm2mid.getRid(NaN, 3); }).to.throw(TypeError); 138 | expect(function () { return lwm2mid.getRid([], 3); }).to.throw(TypeError); 139 | expect(function () { return lwm2mid.getRid({}, 3); }).to.throw(TypeError); 140 | expect(function () { return lwm2mid.getRid(true, 3); }).to.throw(TypeError); 141 | expect(function () { return lwm2mid.getRid(new Date(), 3); }).to.throw(TypeError); 142 | expect(function () { return lwm2mid.getRid(function () {}, 3); }).to.throw(TypeError); 143 | 144 | expect(function () { return lwm2mid.getRid(undefined, '3'); }).to.throw(TypeError); 145 | expect(function () { return lwm2mid.getRid(undefined, '3'); }).to.throw(TypeError); 146 | expect(function () { return lwm2mid.getRid(null, '3'); }).to.throw(TypeError); 147 | expect(function () { return lwm2mid.getRid(NaN, '3'); }).to.throw(TypeError); 148 | expect(function () { return lwm2mid.getRid([], '3'); }).to.throw(TypeError); 149 | expect(function () { return lwm2mid.getRid({}, '3'); }).to.throw(TypeError); 150 | expect(function () { return lwm2mid.getRid(true, '3'); }).to.throw(TypeError); 151 | expect(function () { return lwm2mid.getRid(new Date(), '3'); }).to.throw(TypeError); 152 | expect(function () { return lwm2mid.getRid(function () {}, '3'); }).to.throw(TypeError); 153 | 154 | expect(function () { return lwm2mid.getRid(undefined, 'xx'); }).to.throw(TypeError); 155 | expect(function () { return lwm2mid.getRid(undefined, 'xx'); }).to.throw(TypeError); 156 | expect(function () { return lwm2mid.getRid(null, 'xx'); }).to.throw(TypeError); 157 | expect(function () { return lwm2mid.getRid(NaN, 'xx'); }).to.throw(TypeError); 158 | expect(function () { return lwm2mid.getRid([], 'xx'); }).to.throw(TypeError); 159 | expect(function () { return lwm2mid.getRid({}, 'xx'); }).to.throw(TypeError); 160 | expect(function () { return lwm2mid.getRid(true, 'xx'); }).to.throw(TypeError); 161 | expect(function () { return lwm2mid.getRid(new Date(), 'xx'); }).to.throw(TypeError); 162 | expect(function () { return lwm2mid.getRid(function () {}, 'xx'); }).to.throw(TypeError); 163 | 164 | expect(function () { return lwm2mid.getRid(3, 3); }).not.to.throw(Error); 165 | expect(function () { return lwm2mid.getRid('3', 3); }).not.to.throw(Error); 166 | expect(function () { return lwm2mid.getRid('xx', 3); }).not.to.throw(Error); 167 | 168 | expect(function () { return lwm2mid.getRid(3, '3'); }).not.to.throw(Error); 169 | expect(function () { return lwm2mid.getRid('3', '3'); }).not.to.throw(Error); 170 | expect(function () { return lwm2mid.getRid('xx', 'xx'); }).not.to.throw(Error); 171 | }); 172 | 173 | it('should throw TypeError if input rid is not a number and not a string', function () { 174 | expect(function () { return lwm2mid.getRid(3, null); }).to.throw(TypeError); 175 | expect(function () { return lwm2mid.getRid(3, NaN); }).to.throw(TypeError); 176 | expect(function () { return lwm2mid.getRid(3, []); }).to.throw(TypeError); 177 | expect(function () { return lwm2mid.getRid(3, {}); }).to.throw(TypeError); 178 | expect(function () { return lwm2mid.getRid(3, true); }).to.throw(TypeError); 179 | expect(function () { return lwm2mid.getRid(3, new Date()); }).to.throw(TypeError); 180 | expect(function () { return lwm2mid.getRid(3, function () {}); }).to.throw(TypeError); 181 | 182 | expect(function () { return lwm2mid.getRid('3', null); }).to.throw(TypeError); 183 | expect(function () { return lwm2mid.getRid('3', NaN); }).to.throw(TypeError); 184 | expect(function () { return lwm2mid.getRid('3', []); }).to.throw(TypeError); 185 | expect(function () { return lwm2mid.getRid('3', {}); }).to.throw(TypeError); 186 | expect(function () { return lwm2mid.getRid('3', true); }).to.throw(TypeError); 187 | expect(function () { return lwm2mid.getRid('3', new Date()); }).to.throw(TypeError); 188 | expect(function () { return lwm2mid.getRid('3', function () {}); }).to.throw(TypeError); 189 | 190 | expect(function () { return lwm2mid.getRid('xx', null); }).to.throw(TypeError); 191 | expect(function () { return lwm2mid.getRid('xx', NaN); }).to.throw(TypeError); 192 | expect(function () { return lwm2mid.getRid('xx', []); }).to.throw(TypeError); 193 | expect(function () { return lwm2mid.getRid('xx', {}); }).to.throw(TypeError); 194 | expect(function () { return lwm2mid.getRid('xx', true); }).to.throw(TypeError); 195 | expect(function () { return lwm2mid.getRid('xx', new Date()); }).to.throw(TypeError); 196 | expect(function () { return lwm2mid.getRid('xx', function () {}); }).to.throw(TypeError); 197 | 198 | expect(function () { return lwm2mid.getRid(3); }).not.to.throw(TypeError); 199 | expect(function () { return lwm2mid.getRid('3'); }).not.to.throw(TypeError); 200 | expect(function () { return lwm2mid.getRid(3, 3); }).not.to.throw(Error); 201 | expect(function () { return lwm2mid.getRid(3, '3'); }).not.to.throw(Error); 202 | expect(function () { return lwm2mid.getRid(3, 'xx'); }).not.to.throw(Error); 203 | expect(function () { return lwm2mid.getRid('xx'); }).not.to.throw(TypeError); 204 | expect(function () { return lwm2mid.getRid('3', 3); }).not.to.throw(Error); 205 | expect(function () { return lwm2mid.getRid('3', '3'); }).not.to.throw(Error); 206 | expect(function () { return lwm2mid.getRid('xx', 'xx'); }).not.to.throw(Error); 207 | }); 208 | }); 209 | 210 | describe('#.getSpecificResrcChar', function() { 211 | it('should be a function', function () { 212 | expect(lwm2mid.getSpecificResrcChar).to.be.a('function'); 213 | }); 214 | 215 | it('should throw TypeError if input oid is not a number and not a string', function () { 216 | expect(function () { return lwm2mid.getSpecificResrcChar(undefined, 3); }).to.throw(TypeError); 217 | expect(function () { return lwm2mid.getSpecificResrcChar(undefined, 3); }).to.throw(TypeError); 218 | expect(function () { return lwm2mid.getSpecificResrcChar(null, 3); }).to.throw(TypeError); 219 | expect(function () { return lwm2mid.getSpecificResrcChar(NaN, 3); }).to.throw(TypeError); 220 | expect(function () { return lwm2mid.getSpecificResrcChar([], 3); }).to.throw(TypeError); 221 | expect(function () { return lwm2mid.getSpecificResrcChar({}, 3); }).to.throw(TypeError); 222 | expect(function () { return lwm2mid.getSpecificResrcChar(true, 3); }).to.throw(TypeError); 223 | expect(function () { return lwm2mid.getSpecificResrcChar(new Date(), 3); }).to.throw(TypeError); 224 | expect(function () { return lwm2mid.getSpecificResrcChar(function () {}, 3); }).to.throw(TypeError); 225 | 226 | expect(function () { return lwm2mid.getSpecificResrcChar(undefined, '3'); }).to.throw(TypeError); 227 | expect(function () { return lwm2mid.getSpecificResrcChar(undefined, '3'); }).to.throw(TypeError); 228 | expect(function () { return lwm2mid.getSpecificResrcChar(null, '3'); }).to.throw(TypeError); 229 | expect(function () { return lwm2mid.getSpecificResrcChar(NaN, '3'); }).to.throw(TypeError); 230 | expect(function () { return lwm2mid.getSpecificResrcChar([], '3'); }).to.throw(TypeError); 231 | expect(function () { return lwm2mid.getSpecificResrcChar({}, '3'); }).to.throw(TypeError); 232 | expect(function () { return lwm2mid.getSpecificResrcChar(true, '3'); }).to.throw(TypeError); 233 | expect(function () { return lwm2mid.getSpecificResrcChar(new Date(), '3'); }).to.throw(TypeError); 234 | expect(function () { return lwm2mid.getSpecificResrcChar(function () {}, '3'); }).to.throw(TypeError); 235 | 236 | expect(function () { return lwm2mid.getSpecificResrcChar(undefined, 'xx'); }).to.throw(TypeError); 237 | expect(function () { return lwm2mid.getSpecificResrcChar(undefined, 'xx'); }).to.throw(TypeError); 238 | expect(function () { return lwm2mid.getSpecificResrcChar(null, 'xx'); }).to.throw(TypeError); 239 | expect(function () { return lwm2mid.getSpecificResrcChar(NaN, 'xx'); }).to.throw(TypeError); 240 | expect(function () { return lwm2mid.getSpecificResrcChar([], 'xx'); }).to.throw(TypeError); 241 | expect(function () { return lwm2mid.getSpecificResrcChar({}, 'xx'); }).to.throw(TypeError); 242 | expect(function () { return lwm2mid.getSpecificResrcChar(true, 'xx'); }).to.throw(TypeError); 243 | expect(function () { return lwm2mid.getSpecificResrcChar(new Date(), 'xx'); }).to.throw(TypeError); 244 | expect(function () { return lwm2mid.getSpecificResrcChar(function () {}, 'xx'); }).to.throw(TypeError); 245 | 246 | expect(function () { return lwm2mid.getSpecificResrcChar(3, 3); }).not.to.throw(Error); 247 | expect(function () { return lwm2mid.getSpecificResrcChar('3', 3); }).not.to.throw(Error); 248 | expect(function () { return lwm2mid.getSpecificResrcChar('xx', 3); }).not.to.throw(Error); 249 | 250 | expect(function () { return lwm2mid.getSpecificResrcChar(3, '3'); }).not.to.throw(Error); 251 | expect(function () { return lwm2mid.getSpecificResrcChar('3', '3'); }).not.to.throw(Error); 252 | expect(function () { return lwm2mid.getSpecificResrcChar('xx', 'xx'); }).not.to.throw(Error); 253 | }); 254 | 255 | it('should throw TypeError if input rid is not a number and not a string', function () { 256 | expect(function () { return lwm2mid.getSpecificResrcChar(3, null); }).to.throw(TypeError); 257 | expect(function () { return lwm2mid.getSpecificResrcChar(3, NaN); }).to.throw(TypeError); 258 | expect(function () { return lwm2mid.getSpecificResrcChar(3, []); }).to.throw(TypeError); 259 | expect(function () { return lwm2mid.getSpecificResrcChar(3, {}); }).to.throw(TypeError); 260 | expect(function () { return lwm2mid.getSpecificResrcChar(3, true); }).to.throw(TypeError); 261 | expect(function () { return lwm2mid.getSpecificResrcChar(3, new Date()); }).to.throw(TypeError); 262 | expect(function () { return lwm2mid.getSpecificResrcChar(3, function () {}); }).to.throw(TypeError); 263 | 264 | expect(function () { return lwm2mid.getSpecificResrcChar('3', null); }).to.throw(TypeError); 265 | expect(function () { return lwm2mid.getSpecificResrcChar('3', NaN); }).to.throw(TypeError); 266 | expect(function () { return lwm2mid.getSpecificResrcChar('3', []); }).to.throw(TypeError); 267 | expect(function () { return lwm2mid.getSpecificResrcChar('3', {}); }).to.throw(TypeError); 268 | expect(function () { return lwm2mid.getSpecificResrcChar('3', true); }).to.throw(TypeError); 269 | expect(function () { return lwm2mid.getSpecificResrcChar('3', new Date()); }).to.throw(TypeError); 270 | expect(function () { return lwm2mid.getSpecificResrcChar('3', function () {}); }).to.throw(TypeError); 271 | 272 | expect(function () { return lwm2mid.getSpecificResrcChar('xx', null); }).to.throw(TypeError); 273 | expect(function () { return lwm2mid.getSpecificResrcChar('xx', NaN); }).to.throw(TypeError); 274 | expect(function () { return lwm2mid.getSpecificResrcChar('xx', []); }).to.throw(TypeError); 275 | expect(function () { return lwm2mid.getSpecificResrcChar('xx', {}); }).to.throw(TypeError); 276 | expect(function () { return lwm2mid.getSpecificResrcChar('xx', true); }).to.throw(TypeError); 277 | expect(function () { return lwm2mid.getSpecificResrcChar('xx', new Date()); }).to.throw(TypeError); 278 | expect(function () { return lwm2mid.getSpecificResrcChar('xx', function () {}); }).to.throw(TypeError); 279 | 280 | expect(function () { return lwm2mid.getSpecificResrcChar(3); }).not.to.throw(TypeError); 281 | expect(function () { return lwm2mid.getSpecificResrcChar('3'); }).not.to.throw(TypeError); 282 | expect(function () { return lwm2mid.getSpecificResrcChar(3, 3); }).not.to.throw(Error); 283 | expect(function () { return lwm2mid.getSpecificResrcChar(3, '3'); }).not.to.throw(Error); 284 | expect(function () { return lwm2mid.getSpecificResrcChar(3, 'xx'); }).not.to.throw(Error); 285 | expect(function () { return lwm2mid.getSpecificResrcChar('xx'); }).not.to.throw(TypeError); 286 | expect(function () { return lwm2mid.getSpecificResrcChar('3', 3); }).not.to.throw(Error); 287 | expect(function () { return lwm2mid.getSpecificResrcChar('3', '3'); }).not.to.throw(Error); 288 | expect(function () { return lwm2mid.getSpecificResrcChar('xx', 'xx'); }).not.to.throw(Error); 289 | }); 290 | }); 291 | 292 | describe('#.getOdef', function() { 293 | it('should be a function', function () { 294 | expect(lwm2mid.getOdef).to.be.a('function'); 295 | }); 296 | 297 | it('should throw TypeError if input oid is not a number and not a string', function () { 298 | expect(function () { return lwm2mid.getOdef(); }).to.throw(TypeError); 299 | expect(function () { return lwm2mid.getOdef(undefined); }).to.throw(TypeError); 300 | expect(function () { return lwm2mid.getOdef(null); }).to.throw(TypeError); 301 | expect(function () { return lwm2mid.getOdef(NaN); }).to.throw(TypeError); 302 | expect(function () { return lwm2mid.getOdef([]); }).to.throw(TypeError); 303 | expect(function () { return lwm2mid.getOdef({}); }).to.throw(TypeError); 304 | expect(function () { return lwm2mid.getOdef(true); }).to.throw(TypeError); 305 | expect(function () { return lwm2mid.getOdef(new Date()); }).to.throw(TypeError); 306 | expect(function () { return lwm2mid.getOdef(function () {}); }).to.throw(TypeError); 307 | 308 | expect(function () { return lwm2mid.getOdef(3); }).not.to.throw(Error); 309 | expect(function () { return lwm2mid.getOdef('3'); }).not.to.throw(Error); 310 | expect(function () { return lwm2mid.getOdef('xx'); }).not.to.throw(Error); 311 | }); 312 | }); 313 | 314 | describe('#.getRdef', function() { 315 | it('should be a function', function () { 316 | expect(lwm2mid.getRdef).to.be.a('function'); 317 | }); 318 | 319 | it('should throw TypeError if input oid is not a number and not a string', function () { 320 | expect(function () { return lwm2mid.getRdef(undefined, 3); }).to.throw(TypeError); 321 | expect(function () { return lwm2mid.getRdef(undefined, 3); }).to.throw(TypeError); 322 | expect(function () { return lwm2mid.getRdef(null, 3); }).to.throw(TypeError); 323 | expect(function () { return lwm2mid.getRdef(NaN, 3); }).to.throw(TypeError); 324 | expect(function () { return lwm2mid.getRdef([], 3); }).to.throw(TypeError); 325 | expect(function () { return lwm2mid.getRdef({}, 3); }).to.throw(TypeError); 326 | expect(function () { return lwm2mid.getRdef(true, 3); }).to.throw(TypeError); 327 | expect(function () { return lwm2mid.getRdef(new Date(), 3); }).to.throw(TypeError); 328 | expect(function () { return lwm2mid.getRdef(function () {}, 3); }).to.throw(TypeError); 329 | 330 | expect(function () { return lwm2mid.getRdef(undefined, '3'); }).to.throw(TypeError); 331 | expect(function () { return lwm2mid.getRdef(undefined, '3'); }).to.throw(TypeError); 332 | expect(function () { return lwm2mid.getRdef(null, '3'); }).to.throw(TypeError); 333 | expect(function () { return lwm2mid.getRdef(NaN, '3'); }).to.throw(TypeError); 334 | expect(function () { return lwm2mid.getRdef([], '3'); }).to.throw(TypeError); 335 | expect(function () { return lwm2mid.getRdef({}, '3'); }).to.throw(TypeError); 336 | expect(function () { return lwm2mid.getRdef(true, '3'); }).to.throw(TypeError); 337 | expect(function () { return lwm2mid.getRdef(new Date(), '3'); }).to.throw(TypeError); 338 | expect(function () { return lwm2mid.getRdef(function () {}, '3'); }).to.throw(TypeError); 339 | 340 | expect(function () { return lwm2mid.getRdef(undefined, 'xx'); }).to.throw(TypeError); 341 | expect(function () { return lwm2mid.getRdef(undefined, 'xx'); }).to.throw(TypeError); 342 | expect(function () { return lwm2mid.getRdef(null, 'xx'); }).to.throw(TypeError); 343 | expect(function () { return lwm2mid.getRdef(NaN, 'xx'); }).to.throw(TypeError); 344 | expect(function () { return lwm2mid.getRdef([], 'xx'); }).to.throw(TypeError); 345 | expect(function () { return lwm2mid.getRdef({}, 'xx'); }).to.throw(TypeError); 346 | expect(function () { return lwm2mid.getRdef(true, 'xx'); }).to.throw(TypeError); 347 | expect(function () { return lwm2mid.getRdef(new Date(), 'xx'); }).to.throw(TypeError); 348 | expect(function () { return lwm2mid.getRdef(function () {}, 'xx'); }).to.throw(TypeError); 349 | 350 | expect(function () { return lwm2mid.getRdef(3, 3); }).not.to.throw(Error); 351 | expect(function () { return lwm2mid.getRdef('3', 3); }).not.to.throw(Error); 352 | expect(function () { return lwm2mid.getRdef('xx', 3); }).not.to.throw(Error); 353 | 354 | expect(function () { return lwm2mid.getRdef(3, '3'); }).not.to.throw(Error); 355 | expect(function () { return lwm2mid.getRdef('3', '3'); }).not.to.throw(Error); 356 | expect(function () { return lwm2mid.getRdef('xx', 'xx'); }).not.to.throw(Error); 357 | }); 358 | 359 | it('should throw TypeError if input rid is not a number and not a string', function () { 360 | expect(function () { return lwm2mid.getRdef(3, null); }).to.throw(TypeError); 361 | expect(function () { return lwm2mid.getRdef(3, NaN); }).to.throw(TypeError); 362 | expect(function () { return lwm2mid.getRdef(3, []); }).to.throw(TypeError); 363 | expect(function () { return lwm2mid.getRdef(3, {}); }).to.throw(TypeError); 364 | expect(function () { return lwm2mid.getRdef(3, true); }).to.throw(TypeError); 365 | expect(function () { return lwm2mid.getRdef(3, new Date()); }).to.throw(TypeError); 366 | expect(function () { return lwm2mid.getRdef(3, function () {}); }).to.throw(TypeError); 367 | 368 | expect(function () { return lwm2mid.getRdef('3', null); }).to.throw(TypeError); 369 | expect(function () { return lwm2mid.getRdef('3', NaN); }).to.throw(TypeError); 370 | expect(function () { return lwm2mid.getRdef('3', []); }).to.throw(TypeError); 371 | expect(function () { return lwm2mid.getRdef('3', {}); }).to.throw(TypeError); 372 | expect(function () { return lwm2mid.getRdef('3', true); }).to.throw(TypeError); 373 | expect(function () { return lwm2mid.getRdef('3', new Date()); }).to.throw(TypeError); 374 | expect(function () { return lwm2mid.getRdef('3', function () {}); }).to.throw(TypeError); 375 | 376 | expect(function () { return lwm2mid.getRdef('xx', null); }).to.throw(TypeError); 377 | expect(function () { return lwm2mid.getRdef('xx', NaN); }).to.throw(TypeError); 378 | expect(function () { return lwm2mid.getRdef('xx', []); }).to.throw(TypeError); 379 | expect(function () { return lwm2mid.getRdef('xx', {}); }).to.throw(TypeError); 380 | expect(function () { return lwm2mid.getRdef('xx', true); }).to.throw(TypeError); 381 | expect(function () { return lwm2mid.getRdef('xx', new Date()); }).to.throw(TypeError); 382 | expect(function () { return lwm2mid.getRdef('xx', function () {}); }).to.throw(TypeError); 383 | 384 | expect(function () { return lwm2mid.getRdef(3); }).not.to.throw(TypeError); 385 | expect(function () { return lwm2mid.getRdef('3'); }).not.to.throw(TypeError); 386 | expect(function () { return lwm2mid.getRdef(3, 3); }).not.to.throw(Error); 387 | expect(function () { return lwm2mid.getRdef(3, '3'); }).not.to.throw(Error); 388 | expect(function () { return lwm2mid.getRdef(3, 'xx'); }).not.to.throw(Error); 389 | expect(function () { return lwm2mid.getRdef('xx'); }).not.to.throw(TypeError); 390 | expect(function () { return lwm2mid.getRdef('3', 3); }).not.to.throw(Error); 391 | expect(function () { return lwm2mid.getRdef('3', '3'); }).not.to.throw(Error); 392 | expect(function () { return lwm2mid.getRdef('xx', 'xx'); }).not.to.throw(Error); 393 | }); 394 | }); 395 | 396 | describe('#.addOid', function() { 397 | it('should be a function', function () { 398 | expect(lwm2mid.addOid).to.be.a('function'); 399 | }); 400 | 401 | it('should throw TypeError if input oid is not a number and not a string', function () { 402 | expect(function () { return lwm2mid.addOid(); }).to.throw(TypeError); 403 | expect(function () { return lwm2mid.addOid(undefined); }).to.throw(TypeError); 404 | expect(function () { return lwm2mid.addOid(null); }).to.throw(TypeError); 405 | expect(function () { return lwm2mid.addOid(NaN); }).to.throw(TypeError); 406 | expect(function () { return lwm2mid.addOid([]); }).to.throw(TypeError); 407 | expect(function () { return lwm2mid.addOid(true); }).to.throw(TypeError); 408 | expect(function () { return lwm2mid.addOid(function () {}); }).to.throw(TypeError); 409 | expect(function () { return lwm2mid.addOid(3); }).to.throw(Error); 410 | expect(function () { return lwm2mid.addOid('3'); }).to.throw(Error); 411 | expect(function () { return lwm2mid.addOid('xx'); }).to.throw(Error); 412 | 413 | expect(function () { return lwm2mid.addOid({}); }).not.to.throw(TypeError); 414 | }); 415 | }); 416 | 417 | describe('#.addUniqueRid', function() { 418 | it('should be a function', function () { 419 | expect(lwm2mid.addUniqueRid).to.be.a('function'); 420 | }); 421 | 422 | 423 | it('should throw TypeError if input oid is not a number and not a string', function () { 424 | expect(function () { return lwm2mid.addUniqueRid(); }).to.throw(TypeError); 425 | expect(function () { return lwm2mid.addUniqueRid(undefined); }).to.throw(TypeError); 426 | expect(function () { return lwm2mid.addUniqueRid(null); }).to.throw(TypeError); 427 | expect(function () { return lwm2mid.addUniqueRid(NaN); }).to.throw(TypeError); 428 | expect(function () { return lwm2mid.addUniqueRid([]); }).to.throw(TypeError); 429 | expect(function () { return lwm2mid.addUniqueRid(true); }).to.throw(TypeError); 430 | expect(function () { return lwm2mid.addUniqueRid(function () {}); }).to.throw(TypeError); 431 | expect(function () { return lwm2mid.addUniqueRid(3); }).to.throw(Error); 432 | expect(function () { return lwm2mid.addUniqueRid('3'); }).to.throw(Error); 433 | expect(function () { return lwm2mid.addUniqueRid('xx'); }).to.throw(Error); 434 | 435 | expect(function () { return lwm2mid.addUniqueRid({}); }).not.to.throw(TypeError); 436 | }); 437 | }); 438 | 439 | describe('#.addSpecificRid', function() { 440 | it('should be a function', function () { 441 | expect(lwm2mid.addSpecificRid).to.be.a('function'); 442 | }); 443 | 444 | it('should throw TypeError if input oid is not a number and not a string', function () { 445 | expect(function () { return lwm2mid.addSpecificRid(undefined, {}); }).to.throw(TypeError); 446 | expect(function () { return lwm2mid.addSpecificRid(null, {}); }).to.throw(TypeError); 447 | expect(function () { return lwm2mid.addSpecificRid(NaN, {}); }).to.throw(TypeError); 448 | expect(function () { return lwm2mid.addSpecificRid([], {}); }).to.throw(TypeError); 449 | expect(function () { return lwm2mid.addSpecificRid({}, {}); }).to.throw(TypeError); 450 | expect(function () { return lwm2mid.addSpecificRid(true, {}); }).to.throw(TypeError); 451 | expect(function () { return lwm2mid.addSpecificRid(new Date(), {}); }).to.throw(TypeError); 452 | expect(function () { return lwm2mid.addSpecificRid(function () {}, {}); }).to.throw(TypeError); 453 | 454 | expect(function () { return lwm2mid.addSpecificRid(3, {}); }).not.to.throw(Error); 455 | expect(function () { return lwm2mid.addSpecificRid('3', {}); }).not.to.throw(Error); 456 | }); 457 | 458 | it('should throw TypeError if input items is not an object', function () { 459 | expect(function () { return lwm2mid.addSpecificRid(3, 3); }).to.throw(TypeError); 460 | expect(function () { return lwm2mid.addSpecificRid('3', '3'); }).to.throw(TypeError); 461 | 462 | expect(function () { return lwm2mid.addSpecificRid('3', '3'); }).to.throw(TypeError); 463 | expect(function () { return lwm2mid.addSpecificRid('3', []); }).to.throw(TypeError); 464 | expect(function () { return lwm2mid.addSpecificRid('3', undefined); }).to.throw(TypeError); 465 | expect(function () { return lwm2mid.addSpecificRid('3', null); }).to.throw(TypeError); 466 | expect(function () { return lwm2mid.addSpecificRid('3', NaN); }).to.throw(TypeError); 467 | expect(function () { return lwm2mid.addSpecificRid('3', true); }).to.throw(TypeError); 468 | expect(function () { return lwm2mid.addSpecificRid('3', function () {}); }).to.throw(TypeError); 469 | 470 | expect(function () { return lwm2mid.addSpecificRid(3, '3'); }).to.throw(TypeError); 471 | expect(function () { return lwm2mid.addSpecificRid(3, []); }).to.throw(TypeError); 472 | expect(function () { return lwm2mid.addSpecificRid(3, undefined); }).to.throw(TypeError); 473 | expect(function () { return lwm2mid.addSpecificRid(3, null); }).to.throw(TypeError); 474 | expect(function () { return lwm2mid.addSpecificRid(3, NaN); }).to.throw(TypeError); 475 | expect(function () { return lwm2mid.addSpecificRid(3, true); }).to.throw(TypeError); 476 | expect(function () { return lwm2mid.addSpecificRid(3, function () {}); }).to.throw(TypeError); 477 | }); 478 | }); 479 | 480 | describe('#.addSpecificResrcChar', function() { 481 | it('should be a function', function () { 482 | expect(lwm2mid.addSpecificResrcChar).to.be.a('function'); 483 | }); 484 | 485 | it('should throw TypeError if input oid is not a number and not a string', function () { 486 | expect(function () { return lwm2mid.addSpecificResrcChar(undefined, {}); }).to.throw(TypeError); 487 | expect(function () { return lwm2mid.addSpecificResrcChar(null, {}); }).to.throw(TypeError); 488 | expect(function () { return lwm2mid.addSpecificResrcChar(NaN, {}); }).to.throw(TypeError); 489 | expect(function () { return lwm2mid.addSpecificResrcChar([], {}); }).to.throw(TypeError); 490 | expect(function () { return lwm2mid.addSpecificResrcChar({}, {}); }).to.throw(TypeError); 491 | expect(function () { return lwm2mid.addSpecificResrcChar(true, {}); }).to.throw(TypeError); 492 | expect(function () { return lwm2mid.addSpecificResrcChar(new Date(), {}); }).to.throw(TypeError); 493 | expect(function () { return lwm2mid.addSpecificResrcChar(function () {}, {}); }).to.throw(TypeError); 494 | 495 | expect(function () { return lwm2mid.addSpecificResrcChar(3, {}); }).not.to.throw(Error); 496 | expect(function () { return lwm2mid.addSpecificResrcChar('3', {}); }).not.to.throw(Error); 497 | }); 498 | 499 | it('should throw TypeError if input chars is not an object', function () { 500 | expect(function () { return lwm2mid.addSpecificResrcChar(3, 3); }).to.throw(TypeError); 501 | expect(function () { return lwm2mid.addSpecificResrcChar('3', '3'); }).to.throw(TypeError); 502 | 503 | expect(function () { return lwm2mid.addSpecificResrcChar('3', '3'); }).to.throw(TypeError); 504 | expect(function () { return lwm2mid.addSpecificResrcChar('3', []); }).to.throw(TypeError); 505 | expect(function () { return lwm2mid.addSpecificResrcChar('3', undefined); }).to.throw(TypeError); 506 | expect(function () { return lwm2mid.addSpecificResrcChar('3', null); }).to.throw(TypeError); 507 | expect(function () { return lwm2mid.addSpecificResrcChar('3', NaN); }).to.throw(TypeError); 508 | expect(function () { return lwm2mid.addSpecificResrcChar('3', true); }).to.throw(TypeError); 509 | expect(function () { return lwm2mid.addSpecificResrcChar('3', function () {}); }).to.throw(TypeError); 510 | 511 | expect(function () { return lwm2mid.addSpecificResrcChar(3, '3'); }).to.throw(TypeError); 512 | expect(function () { return lwm2mid.addSpecificResrcChar(3, []); }).to.throw(TypeError); 513 | expect(function () { return lwm2mid.addSpecificResrcChar(3, undefined); }).to.throw(TypeError); 514 | expect(function () { return lwm2mid.addSpecificResrcChar(3, null); }).to.throw(TypeError); 515 | expect(function () { return lwm2mid.addSpecificResrcChar(3, NaN); }).to.throw(TypeError); 516 | expect(function () { return lwm2mid.addSpecificResrcChar(3, true); }).to.throw(TypeError); 517 | expect(function () { return lwm2mid.addSpecificResrcChar(3, function () {}); }).to.throw(TypeError); 518 | }); 519 | }); 520 | }); 521 | -------------------------------------------------------------------------------- /test/getter.test.js: -------------------------------------------------------------------------------- 1 | var Enum = require('enum'), 2 | expect = require('chai').expect, 3 | lwm2mid = require('../index.js'); // lwm2m-id module 4 | 5 | var rspCodeKeys = [], 6 | rspCodeVals = [], 7 | cmdIdKeys = [], 8 | cmdIdVals = [], 9 | oidKeys = [], 10 | oidVals = [], 11 | uRidKeys = [], 12 | uRidVals = [], 13 | sOidKeys = [], 14 | sOidVals = [], 15 | sRidKeys = {}, 16 | sRidVals = {}, 17 | sOidCharKeys = [], 18 | sOidCharVals = [], 19 | k; 20 | 21 | for (k in lwm2mid._defs.rspCode) { 22 | rspCodeKeys.push(k); 23 | rspCodeVals.push(lwm2mid._defs.rspCode[k]); 24 | } 25 | 26 | for (k in lwm2mid._defs.cmdId) { 27 | cmdIdKeys.push(k); 28 | cmdIdVals.push(lwm2mid._defs.cmdId[k]); 29 | } 30 | 31 | for (k in lwm2mid._defs.oid) { 32 | oidKeys.push(k); 33 | oidVals.push(lwm2mid._defs.oid[k]); 34 | } 35 | 36 | for (k in lwm2mid._defs.uniqueRid) { 37 | uRidKeys.push(k); 38 | uRidVals.push(lwm2mid._defs.uniqueRid[k]); 39 | } 40 | 41 | for (k in lwm2mid._defs.specificRid) { 42 | sOidKeys.push(k); 43 | sOidVals.push(lwm2mid._defs.oid[k]); 44 | sRidKeys[k] = []; 45 | sRidVals[k] = []; 46 | for (var i in lwm2mid._defs.specificRid[k]) { 47 | sRidKeys[k].push(i); 48 | sRidVals[k].push(lwm2mid._defs.specificRid[k][i]); 49 | } 50 | } 51 | 52 | for (k in lwm2mid._defs.specificResrcChar) { 53 | sOidCharKeys.push(k); 54 | sOidCharVals.push(lwm2mid.Oid.get(k).value); 55 | } 56 | 57 | describe('Getters Check', function () { 58 | describe('#RspCode.get', function () { 59 | it('should get right keys', function () { 60 | rspCodeKeys.forEach(function (key) { 61 | var item = lwm2mid.RspCode.get(key), 62 | itemData = lwm2mid._defs.rspCode, 63 | val = item.value; 64 | 65 | expect(item).not.to.be.undefined; 66 | expect(val).to.be.eql(itemData[key]); 67 | 68 | item = lwm2mid.RspCode.get(val); 69 | 70 | expect(item).not.to.be.undefined; 71 | expect(item.key).to.be.eql(key); 72 | 73 | }); 74 | }); 75 | 76 | it('should get right values', function () { 77 | rspCodeVals.forEach(function (val) { 78 | var item = lwm2mid.RspCode.get(val), 79 | itemData = lwm2mid._defs.rspCode, 80 | key = item.key; 81 | 82 | expect(item).not.to.be.undefined; 83 | expect(val).to.be.eql(itemData[key]); 84 | item = lwm2mid.RspCode.get(key); 85 | expect(item).not.to.be.undefined; 86 | expect(item.value).to.be.eql(val); 87 | }); 88 | }); 89 | }); 90 | 91 | describe('#Cmd.get', function () { 92 | it('should get right keys', function () { 93 | cmdIdKeys.forEach(function (key) { 94 | var item = lwm2mid.Cmd.get(key), 95 | itemData = lwm2mid._defs.cmdId, 96 | val = item.value; 97 | 98 | expect(item).not.to.be.undefined; 99 | expect(val).to.be.eql(itemData[key]); 100 | 101 | item = lwm2mid.Cmd.get(val); 102 | expect(item).not.to.be.undefined; 103 | expect(item.key).to.be.eql(key); 104 | }); 105 | }); 106 | 107 | it('should get right values', function () { 108 | cmdIdVals.forEach(function (val) { 109 | var item = lwm2mid.Cmd.get(val), 110 | itemData = lwm2mid._defs.cmdId, 111 | key = item.key; 112 | 113 | expect(item).not.to.be.undefined; 114 | expect(val).to.be.eql(itemData[key]); 115 | 116 | item = lwm2mid.Cmd.get(key); 117 | expect(item).not.to.be.undefined; 118 | expect(item.value).to.be.eql(val); 119 | }); 120 | }); 121 | }); 122 | 123 | describe('#Oid.get', function () { 124 | it('should get right keys', function () { 125 | oidKeys.forEach(function (key) { 126 | var item = lwm2mid.Oid.get(key), 127 | itemData = lwm2mid._defs.oid, 128 | val = item.value; 129 | 130 | expect(item).not.to.be.undefined; 131 | expect(val).to.be.eql(itemData[key]); 132 | 133 | item = lwm2mid.Oid.get(val); 134 | expect(item).not.to.be.undefined; 135 | expect(item.key).to.be.eql(key); 136 | }); 137 | }); 138 | 139 | it('should get right values', function () { 140 | oidVals.forEach(function (val) { 141 | var item = lwm2mid.Oid.get(val), 142 | itemData = lwm2mid._defs.oid, 143 | key = item.key; 144 | 145 | expect(item).not.to.be.undefined; 146 | expect(val).to.be.eql(itemData[key]); 147 | 148 | item = lwm2mid.Oid.get(key); 149 | expect(item).not.to.be.undefined; 150 | expect(item.value).to.be.eql(val); 151 | }); 152 | }); 153 | }); 154 | 155 | describe('#UniqueRid.get', function () { 156 | it('should get right keys', function () { 157 | uRidKeys.forEach(function (key) { 158 | var item = lwm2mid.UniqueRid.get(key), 159 | itemData = lwm2mid._defs.uniqueRid, 160 | val = item.value; 161 | 162 | expect(item).not.to.be.undefined; 163 | expect(val).to.be.eql(itemData[key]); 164 | 165 | item = lwm2mid.UniqueRid.get(val); 166 | expect(item).not.to.be.undefined; 167 | expect(item.key).to.be.eql(key); 168 | }); 169 | }); 170 | 171 | it('should get right values', function () { 172 | uRidVals.forEach(function (val) { 173 | var item = lwm2mid.UniqueRid.get(val), 174 | itemData = lwm2mid._defs.uniqueRid, 175 | key = item.key; 176 | 177 | expect(item).not.to.be.undefined; 178 | expect(val).to.be.eql(itemData[key]); 179 | 180 | item = lwm2mid.UniqueRid.get(key); 181 | expect(item).not.to.be.undefined; 182 | expect(item.value).to.be.eql(val); 183 | }); 184 | }); 185 | }); 186 | 187 | describe('#SpecificRid[x].get', function () { 188 | it('should get right keys and values', function () { 189 | for (var sk in sRidKeys) { 190 | sRidKeys[sk].forEach(function (key) { 191 | var item = lwm2mid.SpecificRid[sk].get(key), 192 | itemData = lwm2mid._defs.specificRid[sk], 193 | val = item.value; 194 | 195 | expect(item).not.to.be.undefined; 196 | expect(val).to.be.eql(itemData[key]); 197 | 198 | item = lwm2mid.SpecificRid[sk].get(val); 199 | expect(item).not.to.be.undefined; 200 | expect(item.key).to.be.eql(key); 201 | }); 202 | 203 | sRidVals[sk].forEach(function (val) { 204 | var item = lwm2mid.SpecificRid[sk].get(val), 205 | itemData = lwm2mid._defs.specificRid[sk], 206 | key = item.key; 207 | 208 | expect(item).not.to.be.undefined; 209 | expect(val).to.be.eql(itemData[key]); 210 | 211 | item = lwm2mid.SpecificRid[sk].get(key); 212 | expect(item).not.to.be.undefined; 213 | expect(item.value).to.be.eql(val); 214 | }); 215 | } 216 | }); 217 | }); 218 | 219 | describe('#getOid', function () { 220 | it('should get right item by oid string', function () { 221 | oidKeys.forEach(function (okey) { 222 | var hitA = lwm2mid.getOid(okey), 223 | hitB = lwm2mid.Oid.get(okey); 224 | 225 | expect(hitA).not.to.be.undefined; 226 | expect(hitA.key).to.be.eql(hitB.key); 227 | expect(hitA.value).to.be.eql(hitB.value); 228 | }); 229 | }); 230 | 231 | it('should get right item by oid number', function () { 232 | oidVals.forEach(function (oval) { 233 | var hitA = lwm2mid.getOid(oval), 234 | hitB = lwm2mid.Oid.get(oval); 235 | 236 | expect(hitA).not.to.be.undefined; 237 | expect(hitA.key).to.be.eql(hitB.key); 238 | expect(hitA.value).to.be.eql(hitB.value); 239 | }); 240 | }); 241 | 242 | it('should get undefined if oid not found', function () { 243 | expect(lwm2mid.getOid('xxx')).to.be.undefined; 244 | expect(lwm2mid.getOid(12345)).to.be.undefined; 245 | }); 246 | }); 247 | 248 | describe('#getRid - from UniqueRid', function () { 249 | it('should get right item by rid string', function () { 250 | uRidKeys.forEach(function (rkey) { 251 | var hitA = lwm2mid.getRid(rkey), 252 | hitB = lwm2mid.UniqueRid.get(rkey); 253 | 254 | expect(hitA).not.to.be.undefined; 255 | expect(hitA.key).to.be.eql(hitB.key); 256 | expect(hitA.value).to.be.eql(hitB.value); 257 | }); 258 | }); 259 | 260 | it('should get right item by rid number', function () { 261 | uRidVals.forEach(function (rval) { 262 | var hitA = lwm2mid.getRid(rval), 263 | hitB = lwm2mid.UniqueRid.get(rval); 264 | 265 | expect(hitA).not.to.be.undefined; 266 | expect(hitA.key).to.be.eql(hitB.key); 267 | expect(hitA.value).to.be.eql(hitB.value); 268 | }); 269 | }); 270 | 271 | it('should get undefined if rid not found', function () { 272 | expect(lwm2mid.getRid('xxx')).to.be.undefined; 273 | expect(lwm2mid.getRid(12345)).to.be.undefined; 274 | }); 275 | }); 276 | 277 | 278 | describe('#getRid - from SpecificRid', function () { 279 | it('should get right item by oid string and rid string', function () { 280 | sOidKeys.forEach(function (okey) { 281 | sRidKeys[okey].forEach(function (rkey) { 282 | var hitA = lwm2mid.getRid(okey, rkey), 283 | hitB = lwm2mid.SpecificRid[okey].get(rkey); 284 | 285 | expect(hitA).not.to.be.undefined; 286 | expect(hitA.key).to.be.eql(hitB.key); 287 | expect(hitA.value).to.be.eql(hitB.value); 288 | }); 289 | }); 290 | }); 291 | 292 | it('should get right item by oid string and rid number', function () { 293 | sOidKeys.forEach(function (okey) { 294 | sRidVals[okey].forEach(function (rval) { 295 | var hitA = lwm2mid.getRid(okey, rval), 296 | hitB = lwm2mid.SpecificRid[okey].get(rval); 297 | 298 | expect(hitA).not.to.be.undefined; 299 | expect(hitA.key).to.be.eql(hitB.key); 300 | expect(hitA.value).to.be.eql(hitB.value); 301 | }); 302 | }); 303 | }); 304 | 305 | 306 | it('should get right item by oid number and rid string', function () { 307 | sOidVals.forEach(function (oval) { 308 | var okey = lwm2mid.getOid(oval).key; 309 | 310 | sRidKeys[okey].forEach(function (rkey) { 311 | var hitA = lwm2mid.getRid(oval, rkey), 312 | hitB = lwm2mid.SpecificRid[okey].get(rkey); 313 | 314 | expect(hitA).not.to.be.undefined; 315 | expect(hitA.key).to.be.eql(hitB.key); 316 | expect(hitA.value).to.be.eql(hitB.value); 317 | }); 318 | }); 319 | }); 320 | 321 | it('should get right item by oid number and rid number', function () { 322 | sOidVals.forEach(function (oval) { 323 | var okey = lwm2mid.getOid(oval).key; 324 | 325 | sRidVals[okey].forEach(function (rval) { 326 | var hitA = lwm2mid.getRid(oval, rval), 327 | hitB = lwm2mid.SpecificRid[okey].get(rval); 328 | 329 | expect(hitA).not.to.be.undefined; 330 | expect(hitA.key).to.be.eql(hitB.key); 331 | expect(hitA.value).to.be.eql(hitB.value); 332 | }); 333 | }); 334 | }); 335 | 336 | it('should get undefined if target not found', function () { 337 | expect(lwm2mid.getRid('device', 'dddd')).to.be.undefined; 338 | expect(lwm2mid.getRid('device', 12345)).to.be.undefined; 339 | expect(lwm2mid.getRid(3, 'dddd')).to.be.undefined; 340 | expect(lwm2mid.getRid(3, 12345)).to.be.undefined; 341 | }); 342 | 343 | it('should get an item if target is found', function () { 344 | expect(lwm2mid.getRid('device', 'reboot')).not.to.be.undefined; 345 | expect(lwm2mid.getRid('device', 4)).not.to.be.undefined; 346 | expect(lwm2mid.getRid(3, 'reboot')).not.to.be.undefined; 347 | expect(lwm2mid.getRid(3, 4)).not.to.be.undefined; 348 | }); 349 | }); 350 | 351 | describe('getOdef', function () { 352 | it('should get right spec', function () { 353 | oidKeys.forEach(function (key) { 354 | var item = lwm2mid.getOid(key), 355 | itemData = lwm2mid._defs.oid, 356 | val = item.value, 357 | spec; 358 | 359 | expect(item).not.to.be.undefined; 360 | expect(val).to.be.eql(itemData[key]); 361 | 362 | spec = lwm2mid.getOdef(key); 363 | 364 | if (val >= 3200 && val <= 3400) 365 | expect(spec).to.be.deep.eql({ multi: true, mand: false }); 366 | else if (key === 'lwm2mSecurity') 367 | expect(spec).to.be.deep.eql({ multi: true, mand: true }); 368 | else if (key === 'lwm2mServer') 369 | expect(spec).to.be.deep.eql({ multi: true, mand: true }); 370 | else if (key === 'accessCtrl') 371 | expect(spec).to.be.deep.eql({ multi: true, mand: false }); 372 | else if (key === 'device') 373 | expect(spec).to.be.deep.eql({ multi: false, mand: true }); 374 | else if (key === 'connMonitor') 375 | expect(spec).to.be.deep.eql({ multi: false, mand: false }); 376 | else if (key === 'firmware') 377 | expect(spec).to.be.deep.eql({ multi: false, mand: false }); 378 | else if (key === 'location') 379 | expect(spec).to.be.deep.eql({ multi: false, mand: false }); 380 | else if (key === 'connStatistics') 381 | expect(spec).to.be.deep.eql({ multi: false, mand: false }); 382 | else 383 | expect(spec).to.be.undefined; 384 | 385 | item = lwm2mid.Oid.get(val); 386 | expect(item).not.to.be.undefined; 387 | expect(item.key).to.be.eql(key); 388 | 389 | spec = lwm2mid.getOdef(val); 390 | if (val >= 3200 && val <= 3400) 391 | expect(spec).to.be.deep.eql({ multi: true, mand: false }); 392 | else if (key === 'lwm2mSecurity') 393 | expect(spec).to.be.deep.eql({ multi: true, mand: true }); 394 | else if (key === 'lwm2mServer') 395 | expect(spec).to.be.deep.eql({ multi: true, mand: true }); 396 | else if (key === 'accessCtrl') 397 | expect(spec).to.be.deep.eql({ multi: true, mand: false }); 398 | else if (key === 'device') 399 | expect(spec).to.be.deep.eql({ multi: false, mand: true }); 400 | else if (key === 'connMonitor') 401 | expect(spec).to.be.deep.eql({ multi: false, mand: false }); 402 | else if (key === 'firmware') 403 | expect(spec).to.be.deep.eql({ multi: false, mand: false }); 404 | else if (key === 'location') 405 | expect(spec).to.be.deep.eql({ multi: false, mand: false }); 406 | else if (key === 'connStatistics') 407 | expect(spec).to.be.deep.eql({ multi: false, mand: false }); 408 | else 409 | expect(spec).to.be.undefined; 410 | }); 411 | }); 412 | 413 | }); 414 | 415 | describe('#getSpecificResrcChar', function () { 416 | it('should get right char by oid string and rid string', function () { 417 | sOidCharKeys.forEach(function (okey) { 418 | sRidKeys[okey].forEach(function (skey) { 419 | expect(lwm2mid.getSpecificResrcChar(okey, skey)).to.be.eql(lwm2mid.SpecificResrcChar[okey][skey]); 420 | }); 421 | }); 422 | }); 423 | 424 | it('should get right char by oid number and rid string', function () { 425 | sOidCharVals.forEach(function (oval) { 426 | var okey = lwm2mid.getOid(oval).key; 427 | 428 | sRidKeys[okey].forEach(function (skey) { 429 | var sid = lwm2mid.getRid(oval, skey).value; 430 | expect(lwm2mid.getSpecificResrcChar(oval, sid)).to.be.eql(lwm2mid.SpecificResrcChar[okey][skey]); 431 | }); 432 | }); 433 | }); 434 | }); 435 | }); 436 | -------------------------------------------------------------------------------- /test/setter.test.js: -------------------------------------------------------------------------------- 1 | var Enum = require('enum'), 2 | expect = require('chai').expect, 3 | lwm2mid = require('../index.js'); // lwm2m-id module 4 | 5 | var rspCodeKeys = [], 6 | rspCodeVals = [], 7 | cmdIdKeys = [], 8 | cmdIdVals = [], 9 | oidKeys = [], 10 | oidVals = [], 11 | uRidKeys = [], 12 | uRidVals = [], 13 | sOidKeys = [], 14 | sOidVals = [], 15 | sRidKeys = {}, 16 | sRidVals = {}, 17 | sOidCharKeys = [], 18 | sOidCharVals = [], 19 | k; 20 | 21 | for (k in lwm2mid._defs.rspCode) { 22 | rspCodeKeys.push(k); 23 | rspCodeVals.push(lwm2mid._defs.rspCode[k]); 24 | } 25 | 26 | for (k in lwm2mid._defs.cmdId) { 27 | cmdIdKeys.push(k); 28 | cmdIdVals.push(lwm2mid._defs.cmdId[k]); 29 | } 30 | 31 | for (k in lwm2mid._defs.oid) { 32 | oidKeys.push(k); 33 | oidVals.push(lwm2mid._defs.oid[k]); 34 | } 35 | 36 | for (k in lwm2mid._defs.uniqueRid) { 37 | uRidKeys.push(k); 38 | uRidVals.push(lwm2mid._defs.uniqueRid[k]); 39 | } 40 | 41 | for (k in lwm2mid._defs.specificRid) { 42 | sOidKeys.push(k); 43 | sOidVals.push(lwm2mid._defs.oid[k]); 44 | sRidKeys[k] = []; 45 | sRidVals[k] = []; 46 | for (var i in lwm2mid._defs.specificRid[k]) { 47 | sRidKeys[k].push(i); 48 | sRidVals[k].push(lwm2mid._defs.specificRid[k][i]); 49 | } 50 | } 51 | 52 | for (k in lwm2mid._defs.specificResrcChar) { 53 | sOidCharKeys.push(k); 54 | sOidCharVals.push(lwm2mid.Oid.get(k).value); 55 | } 56 | 57 | describe('Setters Check', function () { 58 | describe('#addOid', function () { 59 | it('should get properly after add a new oid', function () { 60 | lwm2mid.addOid({ 'test1': 1001, 'test2': 1002 }); 61 | 62 | expect(lwm2mid.getOid('test1').key).to.be.eql('test1'); 63 | expect(lwm2mid.getOid('test2').key).to.be.eql('test2'); 64 | expect(lwm2mid.getOid('test1').value).to.be.eql(1001); 65 | expect(lwm2mid.getOid('test2').value).to.be.eql(1002); 66 | 67 | expect(lwm2mid.getOid('1001').key).to.be.eql('test1'); 68 | expect(lwm2mid.getOid('1002').key).to.be.eql('test2'); 69 | expect(lwm2mid.getOid('1001').value).to.be.eql(1001); 70 | expect(lwm2mid.getOid('1002').value).to.be.eql(1002); 71 | 72 | expect(lwm2mid.getOid(1001).key).to.be.eql('test1'); 73 | expect(lwm2mid.getOid(1002).key).to.be.eql('test2'); 74 | expect(lwm2mid.getOid(1001).value).to.be.eql(1001); 75 | expect(lwm2mid.getOid(1002).value).to.be.eql(1002); 76 | }); 77 | 78 | 79 | it('should throw if oid string conficts when adding', function () { 80 | expect(function () { return lwm2mid.addOid({ "cmdhLimits": 1234 }); }).to.throw(Error); 81 | }); 82 | 83 | it('should throw if oid number conficts when adding', function () { 84 | expect(function () { return lwm2mid.addOid({ "xxxxx": 2053 }); }).to.throw(Error); 85 | }); 86 | }); 87 | 88 | describe('#addUniqueRid', function () { 89 | it('should get properly after add a new rid', function () { 90 | lwm2mid.addUniqueRid({ 'rtest1': 1001, 'rtest2': 1002 }); 91 | 92 | 93 | expect(lwm2mid.getRid('rtest1').key).to.be.eql('rtest1'); 94 | expect(lwm2mid.getRid('rtest2').key).to.be.eql('rtest2'); 95 | expect(lwm2mid.getRid('rtest1').value).to.be.eql(1001); 96 | expect(lwm2mid.getRid('rtest2').value).to.be.eql(1002); 97 | 98 | expect(lwm2mid.getRid('1001').key).to.be.eql('rtest1'); 99 | expect(lwm2mid.getRid('1002').key).to.be.eql('rtest2'); 100 | expect(lwm2mid.getRid('1001').value).to.be.eql(1001); 101 | expect(lwm2mid.getRid('1002').value).to.be.eql(1002); 102 | 103 | expect(lwm2mid.getRid(1001).key).to.be.eql('rtest1'); 104 | expect(lwm2mid.getRid(1002).key).to.be.eql('rtest2'); 105 | expect(lwm2mid.getRid(1001).value).to.be.eql(1001); 106 | expect(lwm2mid.getRid(1002).value).to.be.eql(1002); 107 | }); 108 | 109 | it('should throw if rid string conficts when adding', function () { 110 | expect(function () { return lwm2mid.addUniqueRid({ "edgeSelection": 1234 }); }).to.throw(Error); 111 | }); 112 | 113 | it('should throw if rid number conficts when adding', function () { 114 | expect(function () { return lwm2mid.addUniqueRid({ "xxxxx": 5504 }); }).to.throw(Error); 115 | }); 116 | }); 117 | 118 | describe('#addSpecificRid', function () { 119 | it('should get properly after add a new rid', function () { 120 | lwm2mid.addSpecificRid('lwm2mServer', { 'srTest1': 1001, 'srTest2': 1002 }); 121 | 122 | expect(lwm2mid.getRid('lwm2mServer', 'srTest1').key).to.be.eql('srTest1'); 123 | expect(lwm2mid.getRid('lwm2mServer', 'srTest2').key).to.be.eql('srTest2'); 124 | expect(lwm2mid.getRid('lwm2mServer', 'srTest1').value).to.be.eql(1001); 125 | expect(lwm2mid.getRid('lwm2mServer', 'srTest2').value).to.be.eql(1002); 126 | 127 | expect(lwm2mid.getRid('lwm2mServer', '1001').key).to.be.eql('srTest1'); 128 | expect(lwm2mid.getRid('lwm2mServer', '1002').key).to.be.eql('srTest2'); 129 | expect(lwm2mid.getRid('lwm2mServer', '1001').value).to.be.eql(1001); 130 | expect(lwm2mid.getRid('lwm2mServer', '1002').value).to.be.eql(1002); 131 | 132 | expect(lwm2mid.getRid('lwm2mServer', 1001).key).to.be.eql('srTest1'); 133 | expect(lwm2mid.getRid('lwm2mServer', 1002).key).to.be.eql('srTest2'); 134 | expect(lwm2mid.getRid('lwm2mServer', 1001).value).to.be.eql(1001); 135 | expect(lwm2mid.getRid('lwm2mServer', 1002).value).to.be.eql(1002); 136 | 137 | }); 138 | 139 | it('should throw if no such oid', function () { 140 | expect(function() { return lwm2mid.addSpecificRid('xyz', { 'xyzTest1': 1001, 'xyzTest2': 1002 }); }).to.throw(Error); 141 | }); 142 | 143 | it('should not throw if there is the oid found', function () { 144 | lwm2mid.addOid({ 'xyz': 9999 }); 145 | expect(function() { return lwm2mid.addSpecificRid('xyz', { 'xyzTest1': 1001, 'xyzTest2': 1002 }); }).not.to.throw(Error); 146 | }); 147 | 148 | it('should get properly after add a new oid', function () { 149 | expect(lwm2mid.getRid('xyz', 'xyzTest1').key).to.be.eql('xyzTest1'); 150 | expect(lwm2mid.getRid('xyz', 'xyzTest2').key).to.be.eql('xyzTest2'); 151 | expect(lwm2mid.getRid('xyz', 'xyzTest1').value).to.be.eql(1001); 152 | expect(lwm2mid.getRid('xyz', 'xyzTest2').value).to.be.eql(1002); 153 | 154 | expect(lwm2mid.getRid('xyz', '1001').key).to.be.eql('xyzTest1'); 155 | expect(lwm2mid.getRid('xyz', '1002').key).to.be.eql('xyzTest2'); 156 | expect(lwm2mid.getRid('xyz', '1001').value).to.be.eql(1001); 157 | expect(lwm2mid.getRid('xyz', '1002').value).to.be.eql(1002); 158 | 159 | expect(lwm2mid.getRid('xyz', 1001).key).to.be.eql('xyzTest1'); 160 | expect(lwm2mid.getRid('xyz', 1002).key).to.be.eql('xyzTest2'); 161 | expect(lwm2mid.getRid('xyz', 1001).value).to.be.eql(1001); 162 | expect(lwm2mid.getRid('xyz', 1002).value).to.be.eql(1002); 163 | 164 | expect(lwm2mid.getRid(9999, 'xyzTest1').key).to.be.eql('xyzTest1'); 165 | expect(lwm2mid.getRid(9999, 'xyzTest2').key).to.be.eql('xyzTest2'); 166 | expect(lwm2mid.getRid(9999, 'xyzTest1').value).to.be.eql(1001); 167 | expect(lwm2mid.getRid(9999, 'xyzTest2').value).to.be.eql(1002); 168 | 169 | expect(lwm2mid.getRid(9999, '1001').key).to.be.eql('xyzTest1'); 170 | expect(lwm2mid.getRid(9999, '1002').key).to.be.eql('xyzTest2'); 171 | expect(lwm2mid.getRid(9999, '1001').value).to.be.eql(1001); 172 | expect(lwm2mid.getRid(9999, '1002').value).to.be.eql(1002); 173 | 174 | expect(lwm2mid.getRid(9999, 1001).key).to.be.eql('xyzTest1'); 175 | expect(lwm2mid.getRid(9999, 1002).key).to.be.eql('xyzTest2'); 176 | expect(lwm2mid.getRid(9999, 1001).value).to.be.eql(1001); 177 | expect(lwm2mid.getRid(9999, 1002).value).to.be.eql(1002); 178 | }); 179 | }); 180 | 181 | describe('#addSpecificResrcChar', function () { 182 | it('should throw if no such oid when add', function () { 183 | expect(function () { 184 | lwm2mid.addSpecificResrcChar('abc', { 185 | "xValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 186 | "yValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 187 | "zValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 188 | "units": { "access": "R", "multi": false, "mand": false, "type": "string", "range": null, "init": "uint" }, 189 | "compassDir": { "access": "R", "multi": false, "mand": false, "type": "float", "range": 360, "init": 0 } 190 | }); 191 | }).to.throw(Error); 192 | }); 193 | 194 | it('should throw if rids do not exist under a specifc oid when add', function () { 195 | lwm2mid.addOid({ abc: 9998 }); 196 | expect(function () { 197 | return lwm2mid.addSpecificResrcChar('abc', { 198 | "xValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 199 | "yValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 200 | }); 201 | }).to.throw(Error); 202 | }); 203 | 204 | it('should throw if a rid does not exist under a specifc oid when add', function () { 205 | lwm2mid.addSpecificRid(9998, { xValue: 3000, yValue: 3001 }); 206 | expect(function () { 207 | return lwm2mid.addSpecificResrcChar('abc', { 208 | "xValue": { "access": "R", "multi": false, "mand": true, "type": "float", "range": null, "init": 0 }, 209 | "yValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 210 | "zValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 211 | }); 212 | }).to.throw(Error); 213 | }); 214 | 215 | it('should throw if one of rids exists under a specifc oid when add', function () { 216 | expect(function () { 217 | return lwm2mid.addSpecificRid(9998, { 218 | xValue: 3000, 219 | yValue: 3001, 220 | zValue: 3002, 221 | }); 222 | }).to.throw(Error); 223 | }); 224 | 225 | it('should not throw if a rid does not exist under a specifc oid when add', function () { 226 | expect(function () { 227 | return lwm2mid.addSpecificRid(9998, { 228 | zValue: 3002 229 | }); 230 | }).not.to.throw(Error); 231 | }); 232 | 233 | it('should not throw if a rid exists under a specifc oid when add', function () { 234 | expect(function () { 235 | return lwm2mid.addSpecificResrcChar('abc', { 236 | "zValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 } 237 | }); 238 | }).not.to.throw(Error); 239 | }); 240 | 241 | it('should throw if a rid exists under a specifc oid when add again', function () { 242 | expect(function () { 243 | return lwm2mid.addSpecificResrcChar('abc', { 244 | "zValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 } 245 | }); 246 | }).to.throw(Error); 247 | }); 248 | 249 | it('should not throw if a rid does under a specifc oid when add', function () { 250 | expect(function () { 251 | return lwm2mid.addSpecificRid('setPoint', { 252 | zValue: 3002, 253 | }); 254 | }).not.to.throw(Error) 255 | }); 256 | 257 | it('should not throw if a rid does under a specifc oid when add', function () { 258 | expect(function () { 259 | return lwm2mid.addSpecificResrcChar('setPoint', { 260 | "zValue": { "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 }, 261 | }); 262 | }).not.to.throw(Error); 263 | }); 264 | 265 | it('should get properly after addSpecificResrcChar succefully ', function () { 266 | expect(lwm2mid.getSpecificResrcChar('setPoint', 3002)).to.be.eql({ 267 | "access": "R", "multi": false, "mand": false, "type": "float", "range": null, "init": 0 268 | }); 269 | }); 270 | }); 271 | }); 272 | --------------------------------------------------------------------------------