Skip to content

Commit 113526d

Browse files
committed
implement change_flags on contact
1 parent a551478 commit 113526d

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Commands are given after arguments, they can be chained and some have shortcuts.
6666
Messenging
6767
msg <name> <msg> : send message to node by name m {
6868
wait_ack : wait an ack wa }
69-
chan &lt;nb> &lt;msg> : send message to channel number <nb> ch
69+
chan &lt;nb> &lt;msg> : send message to channel number &lt;nb> ch
7070
public &lt;msg> : send message to public channel (0) dch
7171
recv : reads next msg r
7272
wait_msg : wait for a message and read it wm
@@ -85,9 +85,12 @@ Commands are given after arguments, they can be chained and some have shortcuts.
8585
contacts / list : gets contact list lc
8686
share_contact &lt;ct> : share a contact with others sc
8787
export_contact &lt;ct> : get a contact's URI ec
88+
import_contact &lt;URI> : import a contactt from its URI ic
8889
remove_contact &lt;ct> : removes a contact from this node
8990
reset_path &lt;ct> : resets path to a contact to flood rp
9091
change_path &lt;ct> &lt;pth> : change the path to a contact cp
92+
change_flags &lt;ct> &lt;f> : change contact flags (tel_l|tel_a|star)cf
93+
req_telemetry &lt;ct> : prints telemetry data as json rt
9194
Repeaters
9295
login &lt;name> &lt;pwd> : log into a node (rep) with given pwd l
9396
logout &lt;name> : log out of a repeater

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "meshcore-cli"
7-
version = "1.0.0.rc2"
7+
version = "0.8.2"
88
authors = [
99
{ name="Florent de Lamotte", email="[email protected]" },
1010
]
@@ -17,7 +17,7 @@ classifiers = [
1717
]
1818
license = "MIT"
1919
license-files = ["LICEN[CS]E*"]
20-
dependencies = [ "meshcore >= 1.9.8.dev6", "prompt_toolkit >= 3.0.50", "requests >= 2.28.0" ]
20+
dependencies = [ "meshcore >= 1.9.8", "prompt_toolkit >= 3.0.50", "requests >= 2.28.0" ]
2121

2222
[project.urls]
2323
Homepage = "https://github.com/fdlamotte/meshcore-cli"

src/meshcore_cli/meshcore_cli.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from meshcore import MeshCore, EventType, logger
2323

2424
# Version
25-
VERSION = "v1.0.0rc2"
25+
VERSION = "v0.8.2"
2626

2727
# default ble address is stored in a config file
2828
MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
@@ -238,6 +238,7 @@ def make_completion_dict(contacts, to=None):
238238
"path": contact_list,
239239
"reset_path" : contact_list,
240240
"change_path" : contact_list,
241+
"change_flags" : contact_list,
241242
"remove_contact" : contact_list,
242243
"import_contact" : {"meshcore://":None},
243244
"login" : contact_list,
@@ -296,6 +297,7 @@ def make_completion_dict(contacts, to=None):
296297
"upload_contact" : None,
297298
"reset_path" : None,
298299
"change_path" : None,
300+
"change_flags" : None,
299301
"req_telemetry" : None,
300302
})
301303

@@ -550,6 +552,7 @@ def _(event):
550552
# same but for commands with a parameter
551553
elif contact["type"] > 0 and (line.startswith("cmd ") or\
552554
line.startswith("cp ") or line.startswith("change_path ") or\
555+
line.startswith("cf ") or line.startswith("change_flags ") or\
553556
line.startswith("login ")) :
554557
cmds = line.split(" ", 1)
555558
args = [cmds[0], contact['adv_name'], cmds[1]]
@@ -1209,6 +1212,24 @@ async def next_cmd(mc, cmds, json_output=False):
12091212
print(json.dumps(res.payload, indent=4))
12101213
await mc.commands.get_contacts()
12111214

1215+
case "change_flags" | "cf":
1216+
argnum = 2
1217+
await mc.ensure_contacts()
1218+
contact = mc.get_contact_by_name(cmds[1])
1219+
if contact is None:
1220+
if json_output :
1221+
print(json.dumps({"error" : "contact unknown", "name" : cmds[1]}))
1222+
else:
1223+
print(f"Unknown contact {cmds[1]}")
1224+
else:
1225+
res = await mc.commands.change_contact_flags(contact, int(cmds[2]))
1226+
logger.debug(res)
1227+
if res.type == EventType.ERROR:
1228+
print(f"Error setting path: {res}")
1229+
elif json_output :
1230+
print(json.dumps(res.payload, indent=4))
1231+
await mc.commands.get_contacts()
1232+
12121233
case "reset_path" | "rp" :
12131234
argnum = 1
12141235
await mc.ensure_contacts()
@@ -1546,6 +1567,7 @@ def command_help():
15461567
remove_contact <ct> : removes a contact from this node
15471568
reset_path <ct> : resets path to a contact to flood rp
15481569
change_path <ct> <pth> : change the path to a contact cp
1570+
change_flags <ct> <f> : change contact flags (tel_l|tel_a|star)cf
15491571
req_telemetry <ct> : prints telemetry data as json rt
15501572
Repeaters
15511573
login <name> <pwd> : log into a node (rep) with given pwd l

0 commit comments

Comments
 (0)