Skip to content
Merged
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
5 changes: 4 additions & 1 deletion src/infuse_iot/rpc_wrappers/wifi_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ def handle_response(self, return_code, response):
print("WiFi State:")
print(f"\t State: {wifi.state.name}")
if wifi.state >= z_wifi.WiFiState.AUTHENTICATING:
print(f"\t SSID: {wifi.ssid.decode('utf-8')}")
try:
print(f"\t SSID: {wifi.ssid.decode('utf-8')}")
except UnicodeDecodeError:
print(f"\t SSID: Decode Error (Hex: {wifi.ssid.hex()})")
print(f"\t BSSID: {bssid}")
print(f"\t Frequency Band: {wifi.band}")
print(f"\t Channel: {wifi.channel}")
Expand Down
35 changes: 30 additions & 5 deletions src/infuse_iot/rpc_wrappers/zbus_channel_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ class AmbeintEnvChannel(ctypes.LittleEndianStructure):
id = 0x43210001
data = defs.readings.ambient_temp_pres_hum

class ImuChannel(ctypes.LittleEndianStructure):
id = 0x43210002
data = None

class AccMagChannel(ctypes.LittleEndianStructure):
id = 0x43210003
data = None

class LocationChannel(ctypes.LittleEndianStructure):
id = 0x43210004
data = defs.readings.gcs_wgs84_llha
Expand Down Expand Up @@ -57,6 +65,20 @@ def add_parser(cls, parser):
const=cls.AmbeintEnvChannel,
help="Ambient environmental channel",
)
group.add_argument(
"--imu",
dest="channel",
action="store_const",
const=cls.ImuChannel,
help="IMU channel",
)
group.add_argument(
"--acc-mag",
dest="channel",
action="store_const",
const=cls.AccMagChannel,
help="Accelerometer magnitude channel",
)
group.add_argument(
"--location",
dest="channel",
Expand Down Expand Up @@ -102,10 +124,13 @@ def handle_response(self, return_code, response):
print(f"\t Publish count: {response.pub_count}")
print(f"\tPublish period: {response.pub_period_ms} ms")
try:
data = self._channel.data.from_buffer_copy(data_bytes)
table = []
for field in data.iter_fields():
table.append([field.name, field.val_fmt(), field.postfix])
print(tabulate.tabulate(table, tablefmt="simple"))
if self._channel.data is None:
print(f"\t Data: {data_bytes.hex()}")
else:
data = self._channel.data.from_buffer_copy(data_bytes)
table = []
for field in data.iter_fields():
table.append([field.name, field.val_fmt(), field.postfix])
print(tabulate.tabulate(table, tablefmt="simple"))
except Exception as _:
print(f"\t Data: {data_bytes.hex()}")
2 changes: 1 addition & 1 deletion src/infuse_iot/tools/ota_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def run(self):

# Check against pending upgrades
if source.infuse_id in self._pending:
if time.time() < self._pending[source.infuse_id]:
if (v_str != self._new_ver) and (time.time() < self._pending[source.infuse_id]):
# Device could still be applying the upgrade
continue
self._pending.pop(source.infuse_id)
Expand Down