Skip to content

Commit 8fdba59

Browse files
committed
wip
1 parent debbb8c commit 8fdba59

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

meshtastic/__main__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,13 @@ def setSimpleConfig(modem_preset):
10191019
print("--show-fields can only be used with --nodes")
10201020
return
10211021

1022+
if args.fs_ls:
1023+
if args.dest != BROADCAST_ADDR:
1024+
print("Listing filesystem of a remote node is not supported.")
1025+
return
1026+
closeNow = True
1027+
interface.showFileSystem()
1028+
10221029
if args.qr or args.qr_all:
10231030
closeNow = True
10241031
url = interface.getNode(args.dest, True, **getNode_kwargs).getURL(includeAll=args.qr_all)
@@ -1827,6 +1834,12 @@ def addLocalActionArgs(parser: argparse.ArgumentParser) -> argparse.ArgumentPars
18271834
default=None
18281835
)
18291836

1837+
group.add_argument(
1838+
"--fs-ls",
1839+
help="List filesystem entries reported by the local node",
1840+
action="store_true",
1841+
)
1842+
18301843
return parser
18311844

18321845
def addRemoteActionArgs(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:

meshtastic/mesh_interface.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def __init__(
133133
self.queueStatus: Optional[mesh_pb2.QueueStatus] = None
134134
self.queue: collections.OrderedDict = collections.OrderedDict()
135135
self._localChannels = None
136+
self.filesystem_entries = collections.OrderedDict()
136137

137138
# We could have just not passed in debugOut to MeshInterface, and instead told consumers to subscribe to
138139
# the meshtastic.log.line publish instead. Alas though changing that now would be a breaking API change
@@ -376,6 +377,22 @@ def getNestedValue(node_dict: Dict[str, Any], key_path: str) -> Any:
376377
print(table)
377378
return table
378379

380+
def showFileSystem(self) -> str:
381+
"""Display filesystem entries reported by the radio."""
382+
if not self.filesystem_entries:
383+
message = "No filesystem entries received."
384+
print(message)
385+
return message
386+
387+
rows = []
388+
for path, size in self.filesystem_entries.items():
389+
size_str = str(size) if size or size == 0 else "-"
390+
rows.append((path, size_str))
391+
392+
table = tabulate(rows, headers=("Path", "Size (bytes)"), tablefmt="plain")
393+
print(table)
394+
return table
395+
379396
def getNode(
380397
self, nodeId: str, requestChannels: bool = True, requestChannelAttempts: int = 3, timeout: int = 300
381398
) -> meshtastic.node.Node:
@@ -1349,6 +1366,10 @@ def _handleFromRadio(self, fromRadioBytes):
13491366
self._handleLogRecord(fromRadio.log_record)
13501367
elif fromRadio.HasField("queueStatus"):
13511368
self._handleQueueStatusFromRadio(fromRadio.queueStatus)
1369+
elif fromRadio.HasField("fileInfo"):
1370+
file_info = fromRadio.fileInfo
1371+
logger.debug(f"Received file info: {file_info}")
1372+
self.filesystem_entries[file_info.file_name] = file_info.size_bytes
13521373
elif fromRadio.HasField("clientNotification"):
13531374
publishingThread.queueWork(
13541375
lambda: pub.sendMessage(

0 commit comments

Comments
 (0)