casambi-bt-revamped 0.3.7.dev13__py3-none-any.whl → 0.3.8.dev1__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
@@ -418,6 +418,13 @@ class CasambiClient:
418
418
  # Store raw encrypted packet for reference
419
419
  raw_encrypted_packet = data[:]
420
420
 
421
+ # Extract the device-provided 4-byte little-endian counter from the
422
+ # encrypted header. This is the true per-session packet sequence.
423
+ try:
424
+ device_sequence = int.from_bytes(data[:4], byteorder="little", signed=False)
425
+ except Exception:
426
+ device_sequence = None
427
+
421
428
  try:
422
429
  decrypted_data = self._encryptor.decryptAndVerify(
423
430
  data, data[:4] + self._nonce[4:]
@@ -433,8 +440,11 @@ class CasambiClient:
433
440
  if packetType == IncommingPacketType.UnitState:
434
441
  self._parseUnitStates(decrypted_data[1:])
435
442
  elif packetType == IncommingPacketType.SwitchEvent:
443
+ # Pass the device sequence as the packet sequence for consumers,
444
+ # and still include the raw encrypted packet for diagnostics.
445
+ seq_for_consumer = device_sequence if device_sequence is not None else self._inPacketCount
436
446
  self._parseSwitchEvent(
437
- decrypted_data[1:], self._inPacketCount, raw_encrypted_packet
447
+ decrypted_data[1:], seq_for_consumer, raw_encrypted_packet
438
448
  )
439
449
  elif packetType == IncommingPacketType.NetworkConfig:
440
450
  # We don't care about the config the network thinks it has.
@@ -733,7 +743,11 @@ class CasambiClient:
733
743
  "event": event_string,
734
744
  "flags": flags,
735
745
  "extra_data": extra_data,
746
+ # packet_sequence is the device-provided sequence number when available
747
+ # (true 32-bit counter from the BLE header), otherwise the local arrival index.
736
748
  "packet_sequence": packet_seq,
749
+ # Include the local arrival index for debugging and correlation.
750
+ "arrival_sequence": self._inPacketCount,
737
751
  "raw_packet": b2a(raw_packet) if raw_packet else None,
738
752
  "decrypted_data": b2a(full_data),
739
753
  "message_position": start_pos,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: casambi-bt-revamped
3
- Version: 0.3.7.dev13
3
+ Version: 0.3.8.dev1
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=AfyuzEU2ylJOGLmZ87Qft-aNXI_JK8Ng9Tfk4fWYOwo,34345
4
- CasambiBt/_client.py,sha256=2rcwBQ6fuFsM9Zlp8tO_relirwMi5lJq7NDmsQ72HFo,30249
4
+ CasambiBt/_client.py,sha256=k2VQbmWpH6kOmGxF4zFvN0exFmWyKafgGEK3zORFTmc,31136
5
5
  CasambiBt/_constants.py,sha256=_AxkG7Btxl4VeS6mO7GJW5Kc9dFs3s9sDmtJ83ZEKNw,359
6
6
  CasambiBt/_discover.py,sha256=H7HpiFYIy9ELvmPXXd_ck-5O5invJf15dDIRk-vO5IE,1696
7
7
  CasambiBt/_encryption.py,sha256=CLcoOOrggQqhJbnr_emBnEnkizpWDvb_0yFnitq4_FM,3831
@@ -11,8 +11,8 @@ CasambiBt/_operation.py,sha256=Q5UccsrtNp_B_wWqwH_3eLFW_yF6A55FMmfUKDk2WrI,1059
11
11
  CasambiBt/_unit.py,sha256=M-Q8-Xd3qjJSUEvsFtic8E4xDc_gtWYakbTGyoIA-P8,16377
12
12
  CasambiBt/errors.py,sha256=0JgDjaKlAKDes0poWzA8nrTUYQ8qdNfBb8dfaqqzCRA,1664
13
13
  CasambiBt/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- casambi_bt_revamped-0.3.7.dev13.dist-info/licenses/LICENSE,sha256=TAIIitFxpxEDi6Iju7foW4TDQmWvC-IhLVLhl67jKmQ,11341
15
- casambi_bt_revamped-0.3.7.dev13.dist-info/METADATA,sha256=-xP_7qA_GzrD9o_QkzHoKIZmPCF963yjYqh92VmVkCA,3049
16
- casambi_bt_revamped-0.3.7.dev13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
- casambi_bt_revamped-0.3.7.dev13.dist-info/top_level.txt,sha256=uNbqLjtecFosoFzpGAC89-5icikWODKI8rOjbi8v_sA,10
18
- casambi_bt_revamped-0.3.7.dev13.dist-info/RECORD,,
14
+ casambi_bt_revamped-0.3.8.dev1.dist-info/licenses/LICENSE,sha256=TAIIitFxpxEDi6Iju7foW4TDQmWvC-IhLVLhl67jKmQ,11341
15
+ casambi_bt_revamped-0.3.8.dev1.dist-info/METADATA,sha256=JVgVrFaryIi0V5MUG7VHTZrrDYTrW3MuosTTc2Zy3QA,3048
16
+ casambi_bt_revamped-0.3.8.dev1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
+ casambi_bt_revamped-0.3.8.dev1.dist-info/top_level.txt,sha256=uNbqLjtecFosoFzpGAC89-5icikWODKI8rOjbi8v_sA,10
18
+ casambi_bt_revamped-0.3.8.dev1.dist-info/RECORD,,