Stop write queue when BLE is not connected to avoid loosing commands

- Set max retry count to 10 since BLE loop will set channel to disconnected after 5 retries (or known unrecoverable errors)
This commit is contained in:
Victor Hagelbäck 2021-02-22 09:50:06 +01:00
parent e8ab13aed3
commit 4d5a4ddbe3
5 changed files with 99 additions and 81 deletions

View file

@ -41,10 +41,10 @@ class DeviceRegistry {
);
if (added.roomId) {
this.deviceIdsByRoom[added.roomId] = [
...(this.deviceIdsByRoom[added.roomId] || []),
added.id,
];
const room = this.deviceIdsByRoom[added.roomId] || [];
if (!room.includes(added.roomId)) {
this.deviceIdsByRoom[added.roomId] = [...room, added.roomId];
}
logger.verbose(
`Added to room #${added.roomId}: ${JSON.stringify(this.deviceIdsByRoom[added.roomId])}`,
);