Skip to content

Commit a2c50a0

Browse files
committed
implementing get/set default_scope
1 parent 37b8273 commit a2c50a0

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

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.5.6"
7+
version = "1.5.7"
88
authors = [
99
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
1010
]
@@ -17,7 +17,7 @@ classifiers = [
1717
]
1818
license = "MIT"
1919
license-files = ["LICEN[CS]E*"]
20-
dependencies = [ "meshcore >= 2.3.6",
20+
dependencies = [ "meshcore >= 2.3.7",
2121
"bleak >= 0.22",
2222
"prompt_toolkit >= 3.0.50",
2323
"requests >= 2.28.0" ]

src/meshcore_cli/meshcore_cli.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from meshcore import MeshCore, EventType, logger
3636

3737
# Version
38-
VERSION = "v1.5.5"
38+
VERSION = "v1.5.7"
3939

4040
# default ble address is stored in a config file
4141
MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
@@ -586,6 +586,7 @@ def make_completion_dict(contacts, pending={}, to=None, channels=None):
586586
"max_flood_attempts" : None,
587587
"flood_after" : None,
588588
"path_hash_mode": None,
589+
"default_scope": None,
589590
},
590591
"get" : {"name":None,
591592
"bat":None,
@@ -627,6 +628,7 @@ def make_completion_dict(contacts, pending={}, to=None, channels=None):
627628
"stats_packets":None,
628629
"allowed_repeat_freq":None,
629630
"path_hash_mode":None,
631+
"default_scope":None,
630632
},
631633
"?get":None,
632634
"?set":None,
@@ -2243,7 +2245,12 @@ async def next_cmd(mc, cmds, json_output=False):
22432245
print(f"Error : {res}")
22442246
else:
22452247
print(f"Policy for adv_loc: {policy}")
2246-
2248+
case "default_scope":
2249+
res = await mc.commands.set_default_flood_scope(cmds[2])
2250+
if res.type == EventType.ERROR:
2251+
print(f"Error : {res}")
2252+
else:
2253+
print("Default scope set")
22472254
case _: # custom var
22482255
if cmds[1].startswith("_") :
22492256
vname = cmds[1][1:]
@@ -2534,6 +2541,9 @@ async def next_cmd(mc, cmds, json_output=False):
25342541
case "allowed_repeat_freq" :
25352542
res = await mc.commands.get_allowed_repeat_freq()
25362543
print(json.dumps(res.payload))
2544+
case "default_scope" :
2545+
res = await mc.commands.get_default_flood_scope()
2546+
print(json.dumps(res.payload))
25372547
case _ :
25382548
res = await mc.commands.get_custom_vars()
25392549
logger.debug(res)
@@ -3875,6 +3885,8 @@ def get_help_for (cmdname, context="line") :
38753885
When entering chat mode, scope will be reset to *, meaning classic flood.
38763886
You can switch scope using the scope command, or postfixing the to command with %<scope>.
38773887
Scope can also be applied to a command using % before the scope name. For instance login%#Morbihan will limit diffusion of the login command (which is usually sent flood to get the path to a repeater) to the #Morbihan region.
3888+
3889+
default_scope for the device can be set/get by using set default_scope and get default_scope, if set, the scope will revert to this default.
38783890
""")
38793891

38803892
elif cmdname == "contact_info":

0 commit comments

Comments
 (0)