From 7666874d49a6e7332f9b4fbad7145be172f8fbc5 Mon Sep 17 00:00:00 2001 From: atrovato Date: Fri, 1 Nov 2019 10:38:10 +0100 Subject: [PATCH] Bluetooth: remove sub brands --- .../{bluetooth/devices => }/awox/index.js | 0 .../devices => }/awox/lib/awox.utils.js | 0 .../devices => }/awox/models/awox.remote.mesh.js | 2 +- .../devices => }/awox/models/awox.smlc.js | 2 +- .../devices => }/awox/models/awox.smlc.mesh.js | 2 +- .../devices => }/awox/models/awox.smlw.js | 4 ++-- .../devices => }/awox/models/awox.smlw.mesh.js | 2 +- server/services/awox/package.json | 16 ++++++++++++++++ server/services/bluetooth/lib/index.js | 4 ---- .../{bluetooth/devices => }/nut/index.js | 0 .../devices => }/nut/models/nut.tracker.js | 4 ++-- server/services/nut/package.json | 16 ++++++++++++++++ .../devices => }/awox/bluetooth.awox.test.js | 12 ++++++------ .../lib/bluetooth.availableBrands.test.js | 4 +--- .../bluetooth.getMatchingDevices.test.js | 7 ------- .../devices => }/nut/bluetooth.nut.test.js | 4 ++-- .../nut/models/bluetooth.nut.tracker.test.js | 2 +- 17 files changed, 50 insertions(+), 31 deletions(-) rename server/services/{bluetooth/devices => }/awox/index.js (100%) rename server/services/{bluetooth/devices => }/awox/lib/awox.utils.js (100%) rename server/services/{bluetooth/devices => }/awox/models/awox.remote.mesh.js (92%) rename server/services/{bluetooth/devices => }/awox/models/awox.smlc.js (96%) rename server/services/{bluetooth/devices => }/awox/models/awox.smlc.mesh.js (97%) rename server/services/{bluetooth/devices => }/awox/models/awox.smlw.js (92%) rename server/services/{bluetooth/devices => }/awox/models/awox.smlw.mesh.js (96%) create mode 100644 server/services/awox/package.json rename server/services/{bluetooth/devices => }/nut/index.js (100%) rename server/services/{bluetooth/devices => }/nut/models/nut.tracker.js (80%) create mode 100644 server/services/nut/package.json rename server/test/services/{bluetooth/devices => }/awox/bluetooth.awox.test.js (73%) rename server/test/services/{bluetooth/devices => }/nut/bluetooth.nut.test.js (77%) rename server/test/services/{bluetooth/devices => }/nut/models/bluetooth.nut.tracker.test.js (92%) diff --git a/server/services/bluetooth/devices/awox/index.js b/server/services/awox/index.js similarity index 100% rename from server/services/bluetooth/devices/awox/index.js rename to server/services/awox/index.js diff --git a/server/services/bluetooth/devices/awox/lib/awox.utils.js b/server/services/awox/lib/awox.utils.js similarity index 100% rename from server/services/bluetooth/devices/awox/lib/awox.utils.js rename to server/services/awox/lib/awox.utils.js diff --git a/server/services/bluetooth/devices/awox/models/awox.remote.mesh.js b/server/services/awox/models/awox.remote.mesh.js similarity index 92% rename from server/services/bluetooth/devices/awox/models/awox.remote.mesh.js rename to server/services/awox/models/awox.remote.mesh.js index 730134b7e3..5bb0b0bab7 100644 --- a/server/services/bluetooth/devices/awox/models/awox.remote.mesh.js +++ b/server/services/awox/models/awox.remote.mesh.js @@ -1,5 +1,5 @@ const { isRemote, isMesh } = require('../lib/awox.utils'); -const { DEVICE_FEATURE_CATEGORIES, DEVICE_FEATURE_TYPES } = require('../../../../../utils/constants'); +const { DEVICE_FEATURE_CATEGORIES, DEVICE_FEATURE_TYPES } = require('../../../utils/constants'); module.exports = { name: 'rcum', diff --git a/server/services/bluetooth/devices/awox/models/awox.smlc.js b/server/services/awox/models/awox.smlc.js similarity index 96% rename from server/services/bluetooth/devices/awox/models/awox.smlc.js rename to server/services/awox/models/awox.smlc.js index 3e86fd2419..342b860443 100644 --- a/server/services/bluetooth/devices/awox/models/awox.smlc.js +++ b/server/services/awox/models/awox.smlc.js @@ -1,5 +1,5 @@ const { isRemote, isMesh, isColor } = require('../lib/awox.utils'); -const { DEVICE_FEATURE_CATEGORIES, DEVICE_FEATURE_TYPES } = require('../../../../../utils/constants'); +const { DEVICE_FEATURE_CATEGORIES, DEVICE_FEATURE_TYPES } = require('../../../utils/constants'); module.exports = { name: 'smlc', diff --git a/server/services/bluetooth/devices/awox/models/awox.smlc.mesh.js b/server/services/awox/models/awox.smlc.mesh.js similarity index 97% rename from server/services/bluetooth/devices/awox/models/awox.smlc.mesh.js rename to server/services/awox/models/awox.smlc.mesh.js index ade9273d82..54324a41a5 100644 --- a/server/services/bluetooth/devices/awox/models/awox.smlc.mesh.js +++ b/server/services/awox/models/awox.smlc.mesh.js @@ -1,5 +1,5 @@ const { isRemote, isMesh, isColor } = require('../lib/awox.utils'); -const { DEVICE_FEATURE_CATEGORIES, DEVICE_FEATURE_TYPES } = require('../../../../../utils/constants'); +const { DEVICE_FEATURE_CATEGORIES, DEVICE_FEATURE_TYPES } = require('../../../utils/constants'); module.exports = { name: 'smlcm', diff --git a/server/services/bluetooth/devices/awox/models/awox.smlw.js b/server/services/awox/models/awox.smlw.js similarity index 92% rename from server/services/bluetooth/devices/awox/models/awox.smlw.js rename to server/services/awox/models/awox.smlw.js index 01a59421c2..d5b07691b4 100644 --- a/server/services/bluetooth/devices/awox/models/awox.smlw.js +++ b/server/services/awox/models/awox.smlw.js @@ -1,6 +1,6 @@ const { isRemote, isMesh, isWhite } = require('../lib/awox.utils'); -const { connectAndSend } = require('../../../lib/utils/connectAndSend'); -const { DEVICE_FEATURE_CATEGORIES, DEVICE_FEATURE_TYPES } = require('../../../../../utils/constants'); +const { connectAndSend } = require('../../bluetooth/lib/utils/connectAndSend'); +const { DEVICE_FEATURE_CATEGORIES, DEVICE_FEATURE_TYPES } = require('../../../utils/constants'); module.exports = { name: 'smlw', diff --git a/server/services/bluetooth/devices/awox/models/awox.smlw.mesh.js b/server/services/awox/models/awox.smlw.mesh.js similarity index 96% rename from server/services/bluetooth/devices/awox/models/awox.smlw.mesh.js rename to server/services/awox/models/awox.smlw.mesh.js index a639678cef..3c34335046 100644 --- a/server/services/bluetooth/devices/awox/models/awox.smlw.mesh.js +++ b/server/services/awox/models/awox.smlw.mesh.js @@ -1,5 +1,5 @@ const { isRemote, isMesh, isWhite } = require('../lib/awox.utils'); -const { DEVICE_FEATURE_CATEGORIES, DEVICE_FEATURE_TYPES } = require('../../../../../utils/constants'); +const { DEVICE_FEATURE_CATEGORIES, DEVICE_FEATURE_TYPES } = require('../../../utils/constants'); module.exports = { name: 'smlwm', diff --git a/server/services/awox/package.json b/server/services/awox/package.json new file mode 100644 index 0000000000..3b5d4841a9 --- /dev/null +++ b/server/services/awox/package.json @@ -0,0 +1,16 @@ +{ + "name": "gladys-awox", + "version": "1.0.0", + "main": "index.js", + "os": [ + "darwin", + "linux", + "freebsd", + "win32" + ], + "cpu": [ + "x64", + "arm", + "arm64" + ] +} diff --git a/server/services/bluetooth/lib/index.js b/server/services/bluetooth/lib/index.js index 1f22b6c43c..959b753ead 100644 --- a/server/services/bluetooth/lib/index.js +++ b/server/services/bluetooth/lib/index.js @@ -1,6 +1,4 @@ // DEVICE IMPL -const nutDevice = require('../devices/nut'); -const awoxDevice = require('../devices/awox'); const GenericDevice = require('../devices'); // EVENTS @@ -40,8 +38,6 @@ const BluetoothManager = function BluetoothManager(noble, gladys, serviceId) { // All types of device managed by implementations this.availableBrands = new Map(); - this.availableBrands.set('nut', new GenericDevice(nutDevice)); - this.availableBrands.set('awox', new GenericDevice(awoxDevice)); }; // EVENTS diff --git a/server/services/bluetooth/devices/nut/index.js b/server/services/nut/index.js similarity index 100% rename from server/services/bluetooth/devices/nut/index.js rename to server/services/nut/index.js diff --git a/server/services/bluetooth/devices/nut/models/nut.tracker.js b/server/services/nut/models/nut.tracker.js similarity index 80% rename from server/services/bluetooth/devices/nut/models/nut.tracker.js rename to server/services/nut/models/nut.tracker.js index 0f8c5d3ca6..4f2e5ee9cf 100644 --- a/server/services/bluetooth/devices/nut/models/nut.tracker.js +++ b/server/services/nut/models/nut.tracker.js @@ -1,5 +1,5 @@ -const { battery } = require('../../generic/generic.pollFeatures'); -const { DEVICE_FEATURE_CATEGORIES, DEVICE_FEATURE_TYPES } = require('../../../../../utils/constants'); +const { battery } = require('../../bluetooth/devices/generic/generic.pollFeatures'); +const { DEVICE_FEATURE_CATEGORIES, DEVICE_FEATURE_TYPES } = require('../../../utils/constants'); module.exports = { name: 'tracker', diff --git a/server/services/nut/package.json b/server/services/nut/package.json new file mode 100644 index 0000000000..82eabc0832 --- /dev/null +++ b/server/services/nut/package.json @@ -0,0 +1,16 @@ +{ + "name": "gladys-nut", + "version": "1.0.0", + "main": "index.js", + "os": [ + "darwin", + "linux", + "freebsd", + "win32" + ], + "cpu": [ + "x64", + "arm", + "arm64" + ] +} diff --git a/server/test/services/bluetooth/devices/awox/bluetooth.awox.test.js b/server/test/services/awox/bluetooth.awox.test.js similarity index 73% rename from server/test/services/bluetooth/devices/awox/bluetooth.awox.test.js rename to server/test/services/awox/bluetooth.awox.test.js index 5095453eb4..53e41e9258 100644 --- a/server/test/services/bluetooth/devices/awox/bluetooth.awox.test.js +++ b/server/test/services/awox/bluetooth.awox.test.js @@ -1,13 +1,13 @@ const { expect } = require('chai'); const sinon = require('sinon'); -const awox = require('../../../../../services/bluetooth/devices/awox'); +const awox = require('../../../services/awox'); -const remote = require('../../../../../services/bluetooth/devices/awox/models/awox.remote.mesh'); -const smlc = require('../../../../../services/bluetooth/devices/awox/models/awox.smlc'); -const smlcm = require('../../../../../services/bluetooth/devices/awox/models/awox.smlc.mesh'); -const smlw = require('../../../../../services/bluetooth/devices/awox/models/awox.smlw'); -const smlwm = require('../../../../../services/bluetooth/devices/awox/models/awox.smlw.mesh'); +const remote = require('../../../services/awox/models/awox.remote.mesh'); +const smlc = require('../../../services/awox/models/awox.smlc'); +const smlcm = require('../../../services/awox/models/awox.smlc.mesh'); +const smlw = require('../../../services/awox/models/awox.smlw'); +const smlwm = require('../../../services/awox/models/awox.smlw.mesh'); describe('Bluetooth AwoX -> getMatchingModels', () => { beforeEach(() => { diff --git a/server/test/services/bluetooth/lib/bluetooth.availableBrands.test.js b/server/test/services/bluetooth/lib/bluetooth.availableBrands.test.js index 0090b3042d..a7953e0abf 100644 --- a/server/test/services/bluetooth/lib/bluetooth.availableBrands.test.js +++ b/server/test/services/bluetooth/lib/bluetooth.availableBrands.test.js @@ -218,9 +218,7 @@ describe('Bluetooth : verify all available brands', () => { if (feature.min >= feature.max) { assert.fail( - `Feature min (${feature.min}) should be lower than max (${ - feature.max - }) for ${key} ${featureName} feature at position ${fIndex} (${modelName} model at position ${index})`, + `Feature min (${feature.min}) should be lower than max (${feature.max}) for ${key} ${featureName} feature at position ${fIndex} (${modelName} model at position ${index})`, ); } }); diff --git a/server/test/services/bluetooth/lib/commands/bluetooth.getMatchingDevices.test.js b/server/test/services/bluetooth/lib/commands/bluetooth.getMatchingDevices.test.js index 2ba4e0c1ad..18c255ec88 100644 --- a/server/test/services/bluetooth/lib/commands/bluetooth.getMatchingDevices.test.js +++ b/server/test/services/bluetooth/lib/commands/bluetooth.getMatchingDevices.test.js @@ -8,7 +8,6 @@ const event = new EventEmitter(); const BluetoothManager = require('../../../../../services/bluetooth/lib'); const GenericDevice = require('../../../../../services/bluetooth/devices'); -const nutDevice = require('../../../../../services/bluetooth/devices/nut/models/nut.tracker'); const { EVENTS } = require('../../../../../utils/constants'); @@ -38,12 +37,6 @@ describe('BluetoothManager getMatchingDevices command', () => { expect(result).deep.eq([]); }); - it('get single matching device', () => { - const charMap = { '2a00': 'nut' }; - const result = bluetoothManager.getMatchingDevices(charMap); - expect(result).deep.eq([{ brand: 'nut', model: 'tracker', device: nutDevice.device }]); - }); - it('get matching device but missing method', () => { bluetoothManager.availableBrands.set('new', new GenericDevice({})); const charMap = { '?': '?' }; diff --git a/server/test/services/bluetooth/devices/nut/bluetooth.nut.test.js b/server/test/services/nut/bluetooth.nut.test.js similarity index 77% rename from server/test/services/bluetooth/devices/nut/bluetooth.nut.test.js rename to server/test/services/nut/bluetooth.nut.test.js index 9a094237d7..fed008cf0d 100644 --- a/server/test/services/bluetooth/devices/nut/bluetooth.nut.test.js +++ b/server/test/services/nut/bluetooth.nut.test.js @@ -1,8 +1,8 @@ const { expect } = require('chai'); const sinon = require('sinon'); -const nut = require('../../../../../services/bluetooth/devices/nut'); -const nutDevice = require('../../../../../services/bluetooth/devices/nut/models/nut.tracker'); +const nut = require('../../../services/nut'); +const nutDevice = require('../../../services/nut/models/nut.tracker'); describe('Bluetooth Nut -> getMatchingModels', () => { beforeEach(() => { diff --git a/server/test/services/bluetooth/devices/nut/models/bluetooth.nut.tracker.test.js b/server/test/services/nut/models/bluetooth.nut.tracker.test.js similarity index 92% rename from server/test/services/bluetooth/devices/nut/models/bluetooth.nut.tracker.test.js rename to server/test/services/nut/models/bluetooth.nut.tracker.test.js index 8433271184..06ee782f0c 100644 --- a/server/test/services/bluetooth/devices/nut/models/bluetooth.nut.tracker.test.js +++ b/server/test/services/nut/models/bluetooth.nut.tracker.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); -const model = require('../../../../../../services/bluetooth/devices/nut/models/nut.tracker'); +const model = require('../../../../services/nut/models/nut.tracker'); describe('Bluetooth model Tracker', () => { beforeEach(() => {