@@ -303,7 +303,7 @@ Bytes 7+: Binary payload bytes (variable length)
303303- Values other than ` 0xFF ` are reserved for official protocol extensions.
304304
305305** Limits** :
306- - Maximum payload length is ` 163 ` bytes ( ` MAX_GROUP_DATA_LENGTH ` ) .
306+ - Maximum payload length is ` 160 ` bytes.
307307- Larger payloads are rejected with ` PACKET_ERROR ` / ` ERR_CODE_ILLEGAL_ARG ` .
308308
309309** Response** : ` PACKET_OK ` (0x00) on success
@@ -326,7 +326,7 @@ Byte 0: 0x0A
326326
327327** Response** :
328328- ` PACKET_CHANNEL_MSG_RECV ` (0x08) or ` PACKET_CHANNEL_MSG_RECV_V3 ` (0x11) for channel messages
329- - ` PACKET_CHANNEL_DATA_RECV ` (0x1B) or ` PACKET_CHANNEL_DATA_RECV_V3 ` (0x1C) for channel data
329+ - ` PACKET_CHANNEL_DATA_RECV ` (0x1B) for channel data
330330- ` PACKET_CONTACT_MSG_RECV ` (0x07) or ` PACKET_CONTACT_MSG_RECV_V3 ` (0x10) for contact messages
331331- ` PACKET_NO_MORE_MSGS ` (0x0A) if no messages available
332332
@@ -397,8 +397,7 @@ Messages are received via the TX characteristic (notifications). The device send
397397 - ` PACKET_CHANNEL_MSG_RECV_V3 ` (0x11) - Version 3 with SNR
398398
3993992 . ** Channel Data** :
400- - ` PACKET_CHANNEL_DATA_RECV ` (0x1B) - Standard format
401- - ` PACKET_CHANNEL_DATA_RECV_V3 ` (0x1C) - Version 3 with SNR
400+ - ` PACKET_CHANNEL_DATA_RECV ` (0x1B) - Includes SNR and reserved bytes
402401
4034023 . ** Contact Messages** :
404403 - ` PACKET_CONTACT_MSG_RECV ` (0x07) - Standard format
@@ -502,45 +501,39 @@ Bytes 11+: Payload bytes
502501
503502### Channel Data Format
504503
505- ** Standard Format** (` PACKET_CHANNEL_DATA_RECV ` , 0x1B):
504+ ** Format** (` PACKET_CHANNEL_DATA_RECV ` , 0x1B):
506505```
507506Byte 0: 0x1B (packet type)
508- Byte 1: Channel Index (0-7)
509- Byte 2: Path Length
510- Byte 3: Data Type
511- Bytes 4-7: Timestamp (32-bit little-endian)
512- Bytes 8+: Payload bytes
513- ```
514-
515- ** V3 Format** (` PACKET_CHANNEL_DATA_RECV_V3 ` , 0x1C):
516- ```
517- Byte 0: 0x1C (packet type)
518507Byte 1: SNR (signed byte, multiplied by 4)
519508Bytes 2-3: Reserved
520509Byte 4: Channel Index (0-7)
521510Byte 5: Path Length
522511Byte 6: Data Type
523- Bytes 7-10: Timestamp (32-bit little-endian)
524- Bytes 11+: Payload bytes
512+ Byte 7: Data Length
513+ Bytes 8-11: Timestamp (32-bit little-endian)
514+ Bytes 12+: Payload bytes
525515```
526516
527517** Parsing Pseudocode** :
528518``` python
529519def parse_channel_frame (data ):
530520 packet_type = data[0 ]
531521 offset = 1
522+ snr = None
532523
533- # Check for V3 format
534- if packet_type in (0x 11 , 0x 1C ): # V3
524+ # Formats with explicit SNR/reserved bytes
525+ if packet_type in (0x 11 , 0x 1B ):
535526 snr_byte = data[offset]
536527 snr = ((snr_byte if snr_byte < 128 else snr_byte - 256 ) / 4.0 )
537528 offset += 3 # Skip SNR + reserved
538529
539530 channel_idx = data[offset]
540531 path_len = data[offset + 1 ]
541532 item_type = data[offset + 2 ]
542- timestamp = int .from_bytes(data[offset+ 3 :offset+ 7 ], ' little' )
543- payload = data[offset+ 7 :]
533+ data_len = data[offset + 3 ] if packet_type == 0x 1B else None
534+ timestamp = int .from_bytes(data[offset+ 4 :offset+ 8 ], ' little' ) if packet_type == 0x 1B else int .from_bytes(data[offset+ 3 :offset+ 7 ], ' little' )
535+ payload_offset = offset + 8 if packet_type == 0x 1B else offset + 7
536+ payload = data[payload_offset:payload_offset + data_len] if packet_type == 0x 1B else data[payload_offset:]
544537 is_text = packet_type in (0x 08 , 0x 11 )
545538 if is_text and item_type == 0 :
546539 message = payload.decode(' utf-8' )
@@ -553,7 +546,7 @@ def parse_channel_frame(data):
553546 ' timestamp' : timestamp,
554547 ' payload' : payload,
555548 ' message' : message,
556- ' snr' : snr if packet_type in ( 0x 11 , 0x 1C ) else None
549+ ' snr' : snr
557550 }
558551```
559552
@@ -590,8 +583,7 @@ Use `CMD_SEND_CHANNEL_TXT_MSG` for plain text, and `CMD_SEND_CHANNEL_DATA` for b
590583| 0x10 | PACKET_CONTACT_MSG_RECV_V3 | Contact message (V3 with SNR) |
591584| 0x11 | PACKET_CHANNEL_MSG_RECV_V3 | Channel message (V3 with SNR) |
592585| 0x12 | PACKET_CHANNEL_INFO | Channel information |
593- | 0x1B | PACKET_CHANNEL_DATA_RECV | Channel data (standard) |
594- | 0x1C | PACKET_CHANNEL_DATA_RECV_V3| Channel data (V3 with SNR) |
586+ | 0x1B | PACKET_CHANNEL_DATA_RECV | Channel data (includes SNR) |
595587| 0x80 | PACKET_ADVERTISEMENT | Advertisement packet |
596588| 0x82 | PACKET_ACK | Acknowledgment |
597589| 0x83 | PACKET_MESSAGES_WAITING | Messages waiting notification |
@@ -892,7 +884,7 @@ def on_notification_received(data):
892884 packet_type = data[0 ]
893885
894886 if packet_type in (PACKET_CHANNEL_MSG_RECV , PACKET_CHANNEL_MSG_RECV_V3 ,
895- PACKET_CHANNEL_DATA_RECV , PACKET_CHANNEL_DATA_RECV_V3 ):
887+ PACKET_CHANNEL_DATA_RECV ):
896888 message = parse_channel_frame(data)
897889 handle_channel_message(message)
898890 elif packet_type == PACKET_MESSAGES_WAITING :
0 commit comments