Skip to content

Commit

Permalink
Support API level 2. (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Stegeman authored Mar 2, 2018
1 parent db0826c commit a74682b
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zigbee-adapter",
"version": "0.3.1",
"version": "0.3.2",
"description": "Zigbee adapter plugin for Mozilla IoT Gateway",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -43,7 +43,7 @@
"moziot": {
"api": {
"min": 1,
"max": 1
"max": 2
},
"enabled": true,
"plugin": true,
Expand Down
16 changes: 14 additions & 2 deletions zb-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,30 @@

'use strict';

var Adapter = require('../adapter');
var ZigbeeNode = require('./zb-node');
var SerialPort = require('serialport');
var xbeeApi = require('xbee-api');
var at = require('./zb-at');
var util = require('util');
var utils = require('../utils');
var zdo = require('./zb-zdo');
var zcl = require('zcl-packet');
var zclId = require('zcl-id');
var zigBeeClassifier = require('./zb-classifier');

let Adapter, utils;
try {
Adapter = require('../adapter');
utils = require('../utils');
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}

const gwa = require('gateway-addon');
Adapter = gwa.Adapter;
utils = gwa.Utils;
}

var C = xbeeApi.constants;
var AT_CMD = at.AT_CMD;

Expand Down
16 changes: 14 additions & 2 deletions zb-classifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,23 @@

'use strict';

const Constants = require('../addon-constants');
const zclId = require('zcl-id');
const utils = require('../utils');
const ZigbeeProperty = require('./zb-property');

let Constants, utils;
try {
Constants = require('../addon-constants');
utils = require('../utils');
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}

const gwa = require('gateway-addon');
Constants = gwa.Constants;
utils = gwa.Utils;
}

const ZHA_PROFILE_ID = zclId.profile('HA').value;

const CLUSTER_ID_GENONOFF = zclId.cluster('genOnOff').value;
Expand Down
16 changes: 14 additions & 2 deletions zb-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,25 @@

'use strict';

var Device = require('../device');
var utils = require('../utils');
var xbeeApi = require('xbee-api');
var zclId = require('zcl-id');
var zcl = require('zcl-packet');
var zdo = require('./zb-zdo');

let Device, utils;
try {
Device = require('../device');
utils = require('../utils');
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}

const gwa = require('gateway-addon');
Device = gwa.Device;
utils = gwa.Utils;
}

var C = xbeeApi.constants;

const ZHA_PROFILE_ID = zclId.profile('HA').value;
Expand Down
19 changes: 16 additions & 3 deletions zb-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,24 @@
'use strict';

const Color = require('color');
const Deferred = require('../deferred');
const Property = require('../property');
const utils = require('../utils');
const zclId = require('zcl-id');

let Deferred, Property, utils;
try {
Deferred = require('../deferred');
Property = require('../property');
utils = require('../utils');
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}

const gwa = require('gateway-addon');
Deferred = gwa.Deferred;
Property = gwa.Property;
utils = gwa.Utils;
}

/**
* @function levelToPercent
*
Expand Down
12 changes: 11 additions & 1 deletion zb-zdo.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,20 @@
const assert = require('assert');
const BufferBuilder = require('buffer-builder');
const BufferReader = require('buffer-reader');
const utils = require('../utils');
const xbeeApi = require('xbee-api');
const zclId = require('zcl-id');

let utils;
try {
utils = require('../utils');
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}

utils = require('gateway-addon').Utils;
}

const C = xbeeApi.constants;

exports = module.exports;
Expand Down

0 comments on commit a74682b

Please sign in to comment.