Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merges in fixes that have been merged to master. #144

Open
wants to merge 5 commits into
base: upcoming/v1.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.0.1] - 2024-01-15

- Fixes MQTT connection errors post AnkerMake Firmware Upgrades

## [1.0.0] - 2023-05-24

- Version 1.0.0!
Expand Down
6 changes: 3 additions & 3 deletions libflagship/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class _MqttMsg:
packet_num : u16le # maybe for fragmented messages?set to 1 for unfragmented messages.
time : u32le # `gettimeofday()` in whole seconds
device_guid: bytes # device guid, as hex string
padding : bytes = field(repr=False, kw_only=True, default='\x00' * 11) # padding bytes, allways zero
padding : bytes # padding bytes, unknown usage
data : bytes # payload data

@classmethod
Expand All @@ -105,7 +105,7 @@ def parse(cls, p):
packet_num, p = u16le.parse(p)
time, p = u32le.parse(p)
device_guid, p = String.parse(p, 37)
padding, p = Zeroes.parse(p, 11)
padding, p = Bytes.parse(p, 11)
data, p = Tail.parse(p)
return cls(signature=signature, size=size, m3=m3, m4=m4, m5=m5, m6=m6, m7=m7, packet_type=packet_type, packet_num=packet_num, time=time, device_guid=device_guid, padding=padding, data=data), p

Expand All @@ -121,7 +121,7 @@ def pack(self):
p += u16le.pack(self.packet_num)
p += u32le.pack(self.time)
p += String.pack(self.device_guid, 37)
p += Zeroes.pack(self.padding, 11)
p += Bytes.pack(self.padding, 11)
p += Tail.pack(self.data)
return p

Expand Down
3 changes: 2 additions & 1 deletion libflagship/mqttapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def _on_message(self, client, userdata, msg):
try:
pkt, tail = MqttMsg.parse(msg.payload, key=self._key)
except Exception as E:
log.error(f"Failed to decode mqtt message: {E}")
hexStr =' '.join([f'0x{byte:02x}' for byte in msg.payload])
log.error(f"Failed to decode mqtt message\n Exception: {E}\n Message : {hexStr}")
return

data = json.loads(pkt.data)
Expand Down
4 changes: 2 additions & 2 deletions specification/mqtt.stf
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ struct _MqttMsg
# device guid, as hex string
device_guid: string<37>

# padding bytes, allways zero
padding: zeroes<11>
# padding bytes, unknown usage
padding: bytes<11>

# payload data
data: tail
Expand Down