casambi-bt-revamped 0.3.6.dev10__py3-none-any.whl → 0.3.6.dev12__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 CHANGED
@@ -551,10 +551,22 @@ class CasambiClient:
551
551
  # Process based on message type
552
552
  if message_type == 0x08 or message_type == 0x10: # Switch/button events
553
553
  switch_events_found += 1
554
- # For type 0x10 messages, include the full data from start position to current position
555
- # This ensures we capture any additional bytes after the declared payload
556
- full_message_data = data[oldPos:pos] if message_type == 0x10 else data
557
- self._processSwitchMessage(message_type, flags, parameter, payload, full_message_data, oldPos, packet_seq, raw_packet, android_switch_event)
554
+ # Extract button ID based on message type
555
+ if message_type == 0x08:
556
+ # Type 0x08: button is in upper nibble of flags byte
557
+ button = (flags >> 4) & 15
558
+ else: # message_type == 0x10
559
+ # Type 0x10: button is the parameter field
560
+ button = parameter
561
+
562
+ # For type 0x10 messages, we need to pass additional data beyond the declared payload
563
+ if message_type == 0x10:
564
+ # Extend to include at least 10 bytes from message start for state byte
565
+ extended_end = min(oldPos + 11, len(data))
566
+ full_message_data = data[oldPos:extended_end]
567
+ else:
568
+ full_message_data = data
569
+ self._processSwitchMessage(message_type, flags, button, payload, full_message_data, oldPos, packet_seq, raw_packet, android_switch_event)
558
570
  elif message_type == 0x29:
559
571
  # This shouldn't happen due to check above, but just in case
560
572
  self._logger.debug(f"Ignoring embedded type 0x29 message")
@@ -615,6 +627,7 @@ class CasambiClient:
615
627
  elif message_type == 0x10:
616
628
  # Type 0x10: The state byte is at position 9 (0-indexed) from message start
617
629
  # This applies to all units, not just unit 31
630
+ # full_data for type 0x10 is the message data starting from position 0
618
631
  state_pos = 9
619
632
  if len(full_data) > state_pos:
620
633
  state_byte = full_data[state_pos]
@@ -627,7 +640,7 @@ class CasambiClient:
627
640
  elif state_byte == 0x0c:
628
641
  event_string = "button_release_after_hold"
629
642
  else:
630
- self._logger.debug(f"Type 0x10: State byte 0x{state_byte:02x} at pos {state_pos}")
643
+ self._logger.debug(f"Type 0x10: Unknown state byte 0x{state_byte:02x} at message pos {state_pos}")
631
644
  # Fallback: check if extra_data starts with 0x12 (indicates release)
632
645
  if len(extra_data) >= 1 and extra_data[0] == 0x12:
633
646
  event_string = "button_release"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: casambi-bt-revamped
3
- Version: 0.3.6.dev10
3
+ Version: 0.3.6.dev12
4
4
  Summary: Enhanced Casambi Bluetooth client library with switch event support
5
5
  Home-page: https://github.com/rankjie/casambi-bt
6
6
  Author: rankjie
@@ -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=BR-Lhv79ntkMTQuxC445BP9B_qaAQNdWE0vJ-fWbR0o,28892
4
+ CasambiBt/_client.py,sha256=grR_bx4a_5iweG4ky9GrkER1OqGwkxCYFuNFcBtfU04,29570
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.dev10.dist-info/licenses/LICENSE,sha256=TAIIitFxpxEDi6Iju7foW4TDQmWvC-IhLVLhl67jKmQ,11341
16
- casambi_bt_revamped-0.3.6.dev10.dist-info/METADATA,sha256=WcVq71w4pxbClRQx4jJ2k_z6CaMpMJxTf6nR1d9WUR8,3050
17
- casambi_bt_revamped-0.3.6.dev10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
- casambi_bt_revamped-0.3.6.dev10.dist-info/top_level.txt,sha256=uNbqLjtecFosoFzpGAC89-5icikWODKI8rOjbi8v_sA,10
19
- casambi_bt_revamped-0.3.6.dev10.dist-info/RECORD,,
15
+ casambi_bt_revamped-0.3.6.dev12.dist-info/licenses/LICENSE,sha256=TAIIitFxpxEDi6Iju7foW4TDQmWvC-IhLVLhl67jKmQ,11341
16
+ casambi_bt_revamped-0.3.6.dev12.dist-info/METADATA,sha256=3E1wBrrkhMFh0YptPZLkSWhgLoSubRvRfD4GzN9Pbm0,3050
17
+ casambi_bt_revamped-0.3.6.dev12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
+ casambi_bt_revamped-0.3.6.dev12.dist-info/top_level.txt,sha256=uNbqLjtecFosoFzpGAC89-5icikWODKI8rOjbi8v_sA,10
19
+ casambi_bt_revamped-0.3.6.dev12.dist-info/RECORD,,