react-native-btsig-telink
Version:
Component implementation for Bluetooth SIG Mesh SDK of Telink
93 lines (89 loc) • 3.07 kB
JavaScript
/**
* composition raw data used when binding
* {@link BindingDevice#isDefaultBound()}
* Created by kee on 2019/2/27.
*/
class PrivateDevice {
static allList = {
PANEL: {
vid: 0x0211,
pid: 0x07,
name: 'panel',
cpsData: [
0x11, 0x02,
0x07, 0x00,
0x32, 0x37,
0x69, 0x00, 0x07, 0x00, 0x00, 0x00, 0x11, 0x02, 0x00, 0x00,
0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0xfe, 0x01, 0xfe, 0x02, 0xfe, 0x00, 0xff,
0x01, 0xff, 0x00, 0x12, 0x01, 0x12, 0x00, 0x10, 0x03, 0x12, 0x04, 0x12, 0x06, 0x12, 0x07, 0x12,
0x11, 0x02, 0x00, 0x00, 0x11, 0x02, 0x01, 0x00, 0x00, 0x00, 0x05, 0x01, 0x00, 0x10, 0x03, 0x12,
0x04, 0x12, 0x06, 0x12, 0x07, 0x12, 0x11, 0x02, 0x00, 0x00, 0x00, 0x00, 0x05, 0x01, 0x00, 0x10,
0x03, 0x12, 0x04, 0x12, 0x06, 0x12, 0x07, 0x12, 0x11, 0x02, 0x00, 0x00,
],
},
CT: {
vid: 0x0211,
pid: 0x01,
name: 'ct',
cpsData: [
0x11, 0x02,
0x01, 0x00,
0x32, 0x37,
0x69, 0x00, 0x07, 0x00, 0x00, 0x00, 0x19, 0x01, 0x00, 0x00,
0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0xfe, 0x01, 0xfe, 0x02, 0xfe, 0x00, 0xff,
0x01, 0xff, 0x00, 0x12, 0x01, 0x12, 0x00, 0x10, 0x02, 0x10, 0x04, 0x10, 0x06, 0x10, 0x07, 0x10,
0x03, 0x12, 0x04, 0x12, 0x06, 0x12, 0x07, 0x12, 0x00, 0x13, 0x01, 0x13, 0x03, 0x13, 0x04, 0x13,
0x11, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x10, 0x06, 0x13,
],
},
HSL: {
vid: 0x0211,
pid: 0x02,
name: 'hsl',
cpsData: [
0x11, 0x02, // cid
0x02, 0x00, // pid
0x33, 0x31, // vid(version)
0x69, 0x00, 0x07, 0x00, 0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00,
0x00, 0xFE, 0x01, 0xFE, 0x00, 0xFF, 0x01, 0xFF, 0x00, 0x10, 0x02, 0x10, 0x04, 0x10, 0x06, 0x10,
0x07, 0x10, 0x00, 0x13, 0x01, 0x13, 0x07, 0x13, 0x08, 0x13, 0x11, 0x02, 0x00, 0x00, 0x00, 0x00,
0x02, 0x00, 0x02, 0x10, 0x0A, 0x13, 0x00, 0x00, 0x02, 0x00, 0x02, 0x10, 0x0B, 0x13,
],
},
LPN: {
vid: 0x0211,
pid: 0x0201,
name: 'lpn',
cpsData: [
0x11, 0x02,
0x01, 0x02,
0x33, 0x33,
0x69, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x05, 0x01, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, 0x10, 0x02, 0x10, 0x11, 0x02, 0x00, 0x00,
],
},
};
static filter(deviceUUID) {
if (deviceUUID.length < 3) {
return null;
}
let vid = (deviceUUID[0] & 0xff) + ((deviceUUID[1] & 0xff) << 8);
let pid = (deviceUUID[2] & 0xff) + ((deviceUUID[3] & 0xff) << 8);
let devices = Object.values(this.allList);
for (let device of devices) {
if (device.vid === vid && device.pid === pid) {
return device;
}
}
return null;
}
static filterWithPid(pid) {
let devices = Object.values(this.allList);
for (let device of devices) {
if (device.pid === pid) {
return device;
}
}
return null;
}
}
module.exports = PrivateDevice;