crownstone / crownstone-lib-python-uart

Library to communicate with the Crownstone network via the Crownstone USB dongle
Apache License 2.0
0 stars 4 forks source link

Cannot switch multiple Crownstones at once #9

Open RicArch97 opened 3 years ago

RicArch97 commented 3 years ago

This was a test of switching multiple Crownstones at once. The following Crownstones were tested:

Crownstones are switched using their respective switch functions:

Following debug logs were found suggesting that the correct data was indeed sent to each Crownstone:

2021-05-09 16:18:12 DEBUG (SyncWorker_0) [crownstone_uart.core.uart.UartBridge] write_to_uart: [126, 15, 0, 1, 0, 0, 10, 0, 5, 21, 0, 3, 0, 1, 1, <SwitchValSpecial.SMART_ON: 255>, 239, 11]
2021-05-09 16:18:12 DEBUG (SyncWorker_2) [crownstone_uart.core.uart.UartBridge] write_to_uart: [126, 15, 0, 1, 0, 0, 10, 0, 5, 21, 0, 3, 0, 1, 11, <SwitchValSpecial.SMART_ON: 255>, 36, 228]
2021-05-09 16:18:12 DEBUG (SyncWorker_5) [crownstone_uart.core.uart.UartBridge] write_to_uart: [126, 15, 0, 1, 0, 0, 10, 0, 5, 21, 0, 3, 0, 1, 17, <SwitchValSpecial.SMART_ON: 255>, 156, 8]
2021-05-09 16:18:12 DEBUG (SyncWorker_4) [crownstone_uart.core.uart.UartBridge] write_to_uart: [126, 15, 0, 1, 0, 0, 10, 0, 5, 21, 0, 3, 0, 1, 18, <SwitchValSpecial.SMART_ON: 255>, 207, 93]
2021-05-09 16:18:18 DEBUG (SyncWorker_3) [crownstone_uart.core.uart.UartBridge] write_to_uart: [126, 15, 0, 1, 0, 0, 10, 0, 5, 21, 0, 3, 0, 1, 1, 0, 31, 21]
2021-05-09 16:18:18 DEBUG (SyncWorker_1) [crownstone_uart.core.uart.UartBridge] write_to_uart: [126, 15, 0, 1, 0, 0, 10, 0, 5, 21, 0, 3, 0, 1, 11, 0, 212, 250]
2021-05-09 16:18:18 DEBUG (SyncWorker_0) [crownstone_uart.core.uart.UartBridge] write_to_uart: [126, 15, 0, 1, 0, 0, 10, 0, 5, 21, 0, 3, 0, 1, 17, 0, 108, 22]
2021-05-09 16:18:18 DEBUG (SyncWorker_2) [crownstone_uart.core.uart.UartBridge] write_to_uart: [126, 15, 0, 1, 0, 0, 10, 0, 5, 21, 0, 3, 0, 1, 18, 0, 63, 67]

However only 2 of those Crownstones was actually switched each time. The Crownstone that can dim, and 1 of the relay Crownstones.

The multi switch does work correctly with the cloud implementation however.

vliedel commented 3 years ago

Hi ricardo, I suspect this is because the python library doesn't wait for a reply yet (@AlexDM0 correct me if i'm wrong), but just sends all commands at once. All commands before the reply are simply ignored. So for now, you'll have to add a little delay in between commands. If there's a "multiswitch" implementation, you could use that instead of all single switch commands.