casambi-bt-revamped 0.3.6.dev3__py3-none-any.whl → 0.3.6.dev4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- CasambiBt/_client.py +44 -9
- {casambi_bt_revamped-0.3.6.dev3.dist-info → casambi_bt_revamped-0.3.6.dev4.dist-info}/METADATA +1 -1
- {casambi_bt_revamped-0.3.6.dev3.dist-info → casambi_bt_revamped-0.3.6.dev4.dist-info}/RECORD +6 -6
- {casambi_bt_revamped-0.3.6.dev3.dist-info → casambi_bt_revamped-0.3.6.dev4.dist-info}/WHEEL +0 -0
- {casambi_bt_revamped-0.3.6.dev3.dist-info → casambi_bt_revamped-0.3.6.dev4.dist-info}/licenses/LICENSE +0 -0
- {casambi_bt_revamped-0.3.6.dev3.dist-info → casambi_bt_revamped-0.3.6.dev4.dist-info}/top_level.txt +0 -0
CasambiBt/_client.py
CHANGED
|
@@ -437,9 +437,11 @@ class CasambiClient:
|
|
|
437
437
|
return
|
|
438
438
|
|
|
439
439
|
# Protocol analysis: Current implementation vs Android
|
|
440
|
-
#
|
|
441
|
-
#
|
|
442
|
-
#
|
|
440
|
+
# These are fundamentally different protocols:
|
|
441
|
+
# - Current: Type 0x07 + message-based protocol (0x10/0x08 messages)
|
|
442
|
+
# - Android: Complex header with command types 29-36 for buttons
|
|
443
|
+
# No conversion possible - they're incompatible formats
|
|
444
|
+
android_switch_event = None
|
|
443
445
|
|
|
444
446
|
packetType = decrypted_data[0]
|
|
445
447
|
self._logger.debug(f"Incoming data of type {packetType}: {b2a(decrypted_data)}")
|
|
@@ -505,12 +507,15 @@ class CasambiClient:
|
|
|
505
507
|
"""Parse switch event packet which contains multiple message types"""
|
|
506
508
|
self._logger.info(f"Parsing incoming switch event packet... Data: {b2a(data)}")
|
|
507
509
|
|
|
508
|
-
#
|
|
509
|
-
if
|
|
510
|
-
self._logger.
|
|
510
|
+
# Special handling for message type 0x29 - not a switch event
|
|
511
|
+
if len(data) >= 1 and data[0] == 0x29:
|
|
512
|
+
self._logger.debug(f"Ignoring message type 0x29 (not a switch event): {b2a(data)}")
|
|
513
|
+
return
|
|
511
514
|
|
|
512
515
|
pos = 0
|
|
513
516
|
oldPos = 0
|
|
517
|
+
switch_events_found = 0
|
|
518
|
+
|
|
514
519
|
try:
|
|
515
520
|
while pos <= len(data) - 3:
|
|
516
521
|
oldPos = pos
|
|
@@ -522,6 +527,15 @@ class CasambiClient:
|
|
|
522
527
|
parameter = data[pos + 2] & 15
|
|
523
528
|
pos += 3
|
|
524
529
|
|
|
530
|
+
# Sanity check: message type should be reasonable
|
|
531
|
+
if message_type > 0x80:
|
|
532
|
+
self._logger.debug(
|
|
533
|
+
f"Skipping invalid message type 0x{message_type:02x} at position {oldPos}"
|
|
534
|
+
)
|
|
535
|
+
# Try to resync by looking for next valid message
|
|
536
|
+
pos = oldPos + 1
|
|
537
|
+
continue
|
|
538
|
+
|
|
525
539
|
# Check if we have enough data for the payload
|
|
526
540
|
if pos + length > len(data):
|
|
527
541
|
self._logger.debug(
|
|
@@ -536,11 +550,21 @@ class CasambiClient:
|
|
|
536
550
|
|
|
537
551
|
# Process based on message type
|
|
538
552
|
if message_type == 0x08 or message_type == 0x10: # Switch/button events
|
|
553
|
+
switch_events_found += 1
|
|
539
554
|
self._processSwitchMessage(message_type, flags, parameter, payload, data, oldPos, packet_seq, raw_packet, android_switch_event)
|
|
540
|
-
|
|
541
|
-
#
|
|
555
|
+
elif message_type == 0x29:
|
|
556
|
+
# This shouldn't happen due to check above, but just in case
|
|
557
|
+
self._logger.debug(f"Ignoring embedded type 0x29 message")
|
|
558
|
+
elif message_type in [0x00, 0x06, 0x09, 0x1f, 0x2a]:
|
|
559
|
+
# Known non-switch message types - log at debug level
|
|
542
560
|
self._logger.debug(
|
|
543
|
-
f"
|
|
561
|
+
f"Non-switch message type 0x{message_type:02x}: flags=0x{flags:02x}, "
|
|
562
|
+
f"param={parameter}, payload={b2a(payload)}"
|
|
563
|
+
)
|
|
564
|
+
else:
|
|
565
|
+
# Unknown message types - log at info level
|
|
566
|
+
self._logger.info(
|
|
567
|
+
f"Unknown message type 0x{message_type:02x}: flags=0x{flags:02x}, "
|
|
544
568
|
f"param={parameter}, payload={b2a(payload)}"
|
|
545
569
|
)
|
|
546
570
|
|
|
@@ -551,6 +575,9 @@ class CasambiClient:
|
|
|
551
575
|
f"Ran out of data while parsing switch event packet! "
|
|
552
576
|
f"Remaining data {b2a(data[oldPos:])} in {b2a(data)}."
|
|
553
577
|
)
|
|
578
|
+
|
|
579
|
+
if switch_events_found == 0:
|
|
580
|
+
self._logger.debug(f"No switch events found in packet: {b2a(data)}")
|
|
554
581
|
|
|
555
582
|
def _processSwitchMessage(self, message_type: int, flags: int, button: int, payload: bytes, full_data: bytes, start_pos: int, packet_seq: int = None, raw_packet: bytes = None, android_switch_event: dict = None) -> None:
|
|
556
583
|
"""Process a switch/button message (types 0x08 or 0x10)"""
|
|
@@ -567,6 +594,14 @@ class CasambiClient:
|
|
|
567
594
|
extra_data = b''
|
|
568
595
|
if len(payload) > 2:
|
|
569
596
|
extra_data = payload[2:]
|
|
597
|
+
|
|
598
|
+
# Validate extra data for type 0x10
|
|
599
|
+
if message_type == 0x10 and len(extra_data) >= 3:
|
|
600
|
+
# Expected pattern: [unit_id_echo][0x12 or similar][0x00]
|
|
601
|
+
if extra_data[0] != unit_id:
|
|
602
|
+
self._logger.warning(
|
|
603
|
+
f"Extra data validation failed: unit_id_echo {extra_data[0]} != unit_id {unit_id}"
|
|
604
|
+
)
|
|
570
605
|
|
|
571
606
|
event_string = "unknown"
|
|
572
607
|
|
{casambi_bt_revamped-0.3.6.dev3.dist-info → casambi_bt_revamped-0.3.6.dev4.dist-info}/RECORD
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
CasambiBt/__init__.py,sha256=TW445xSu5PV3TyMjJfwaA1JoWvQQ8LXhZgGdDTfWf3s,302
|
|
2
2
|
CasambiBt/_cache.py,sha256=KZ2xbiHAHXUPa8Gw_75Nw9NL4QSY_sTWHbyYXYUDaB0,3865
|
|
3
3
|
CasambiBt/_casambi.py,sha256=gLLkhEcObgapqTx5Mk7WRClyG29UyfZYZCCIhhOg4H4,23101
|
|
4
|
-
CasambiBt/_client.py,sha256=
|
|
4
|
+
CasambiBt/_client.py,sha256=sYK0PpgzhqRc164Q6E2miPK0pNtQmPLoXiZ69-Wxgxk,27667
|
|
5
5
|
CasambiBt/_client_android_parser.py,sha256=1lVkVYMO0Nhh9_nkNwgb68hlCS_uD8WxYQDir5hOdHs,7744
|
|
6
6
|
CasambiBt/_constants.py,sha256=_AxkG7Btxl4VeS6mO7GJW5Kc9dFs3s9sDmtJ83ZEKNw,359
|
|
7
7
|
CasambiBt/_discover.py,sha256=H7HpiFYIy9ELvmPXXd_ck-5O5invJf15dDIRk-vO5IE,1696
|
|
@@ -12,8 +12,8 @@ CasambiBt/_operation.py,sha256=-BuC1Bvtg-G-zSN_b_0JMvXdHZaR6LbTw0S425jg96c,842
|
|
|
12
12
|
CasambiBt/_unit.py,sha256=YiQWoHmMDWHHo4XAjtW8rHsBqIqpmp9MVdv1Mbu2xw4,17043
|
|
13
13
|
CasambiBt/errors.py,sha256=0JgDjaKlAKDes0poWzA8nrTUYQ8qdNfBb8dfaqqzCRA,1664
|
|
14
14
|
CasambiBt/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
casambi_bt_revamped-0.3.6.
|
|
16
|
-
casambi_bt_revamped-0.3.6.
|
|
17
|
-
casambi_bt_revamped-0.3.6.
|
|
18
|
-
casambi_bt_revamped-0.3.6.
|
|
19
|
-
casambi_bt_revamped-0.3.6.
|
|
15
|
+
casambi_bt_revamped-0.3.6.dev4.dist-info/licenses/LICENSE,sha256=TAIIitFxpxEDi6Iju7foW4TDQmWvC-IhLVLhl67jKmQ,11341
|
|
16
|
+
casambi_bt_revamped-0.3.6.dev4.dist-info/METADATA,sha256=IvmEQbo-l6PRaDjjfmO5CyG2jFsXRYsCL2JCZLOBHrU,3049
|
|
17
|
+
casambi_bt_revamped-0.3.6.dev4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
18
|
+
casambi_bt_revamped-0.3.6.dev4.dist-info/top_level.txt,sha256=uNbqLjtecFosoFzpGAC89-5icikWODKI8rOjbi8v_sA,10
|
|
19
|
+
casambi_bt_revamped-0.3.6.dev4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{casambi_bt_revamped-0.3.6.dev3.dist-info → casambi_bt_revamped-0.3.6.dev4.dist-info}/top_level.txt
RENAMED
|
File without changes
|