This commit is contained in:
2026-02-27 16:26:25 +01:00
parent a8f49f629e
commit b23ad9a1fd
3 changed files with 17 additions and 10 deletions

View File

@@ -21,11 +21,14 @@ type Packet struct {
SNR float64 `json:"snr"`
// RSSI is the received signal strength indicator (in dBm).
RSSI int8 `json:"rssi"`
RSSI int `json:"rssi"`
// Raw bytes (optional).
Raw []byte `json:"raw,omitempty"`
// Version for this packet.
Version int `json:"version"`
// RouteType is the type of route for this packet.
RouteType RouteType `json:"route_type"`
@@ -111,7 +114,7 @@ func (packet *Packet) MarshalBytes() []byte {
data [1 + 4 + 1 + maxPathSize + maxPayloadSize]byte
offset int
)
data[offset] = byte(packet.RouteType&0x03) | byte((packet.PayloadType&0x0f)<<2)
data[offset] = byte(packet.RouteType&0x03) | byte((packet.PayloadType&0x0f)<<2) | byte((packet.Version&0x03)<<6)
offset += 1
if packet.RouteType.HasTransportCodes() {
@@ -138,6 +141,7 @@ func (packet *Packet) UnmarshalBytes(data []byte) error {
packet.RouteType = RouteType(data[0] & 0x03)
packet.PayloadType = PayloadType((data[0] >> 2) & 0x0f)
packet.Version = int((data[0] >> 6) & 0x03)
offset := 1
if packet.RouteType.HasTransportCodes() {
@@ -187,7 +191,7 @@ func (packet *Packet) Hash() []byte {
func (packet *Packet) MarshalJSON() ([]byte, error) {
return json.Marshal(struct {
SNR float64 `json:"snr"`
RSSI int8 `json:"rssi"`
RSSI int `json:"rssi"`
RouteType RouteType `json:"route_type"`
PayloadType PayloadType `json:"payload_type"`
TransportCodes []uint16 `json:"transport_codes,omitempty"`