nubli
Version:
Nuki Bluetooth Library
26 lines (25 loc) • 983 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const smartLock_1 = require("./smartLock");
class SmartLockPeripheralFilter {
handle(peripheral) {
let data = peripheral.advertisement.manufacturerData;
if (data !== undefined && data !== null && data.length == 25) {
let type = data.readUInt8(2);
let dataLength = data.readUInt8(3);
// 0x02 == iBeacon
if (type == 2 && dataLength == 21) {
let serviceUuid = data.slice(4, 20).toString('hex');
if (serviceUuid == smartLock_1.SmartLock.NUKI_SERVICE_UUID) {
return true;
}
}
}
else {
let name = peripheral.advertisement.localName;
return name !== undefined && peripheral.advertisement.localName.slice(0, 5) == "Nuki_";
}
return false;
}
}
exports.SmartLockPeripheralFilter = SmartLockPeripheralFilter;