Architecture Design
In short, I used Home Assistant to bind Raspberry Pi and HomeKit service, link rolling door with relay by GPIO.
To prevent error opening, lock operating in LAN by HomeKit
- Very easy
⇢ Decoupling HomeKit
⇢ Add more location awareness authorization
GPS
GPS
LAN / Mac Address
Use VPN / Mac Address is changable
built in @ Raspberry Pi 3 / 4
issue OTP
Request open with OTP
Peripheral
Central
mostly low power devices
mostly smart phone
Exchangable
https://learn.adafruit.com/introduction-to-bluetooth-low-energy?view=all#gatt
One peripheral device can broadcast message to unlimited central devices
https://learn.adafruit.com/introduction-to-bluetooth-low-energy?view=all#gatt
Each peripheral device connected to one central at same time. Up to 7 peripheral devices in a piconet, but each peripheral device can be another piconet central.
https://learn.adafruit.com/introduction-to-bluetooth-low-energy?view=all#gatt
Profile
Service
Characteristic
https://www.bluetooth.com/zh-cn/specifications/gatt/
挖個坑
https://github.com/WebBluetoothCG/web-bluetooth/blob/gh-pages/implementation-status.md
navigator.bluetooth.requestLEScan({
keepRepeatedDevices: true
}).then(() => {
navigator.bluetooth.addEventListener('advertisementreceived', event => {
const appleData = event.manufacturerData.get(0x004C);
if (appleData.byteLength != 23) {
// Isn’t an iBeacon.
return;
}
const major = appleData.getUint16(18, false);
const minor = appleData.getUint16(20, false);
const txPowerAt1m = -appleData.getInt8(22);
const pathLossVs1m = txPowerAt1m - event.rssi;
recordNearbyBeacon(major, minor, pathLossVs1m);
});
})
BLE / JS / gyro / temp / light / button