mirror of
https://github.com/meshcore-dev/meshcore-cli.git
synced 2026-04-20 22:13:48 +00:00
autoupdate on by default, -P option for pairing
This commit is contained in:
parent
48821e92d0
commit
bf2f95a63a
2 changed files with 11 additions and 5 deletions
|
|
@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "meshcore-cli"
|
name = "meshcore-cli"
|
||||||
version = "1.1.23"
|
version = "1.1.24"
|
||||||
authors = [
|
authors = [
|
||||||
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
|
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
|
||||||
]
|
]
|
||||||
|
|
@ -17,7 +17,7 @@ classifiers = [
|
||||||
]
|
]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
license-files = ["LICEN[CS]E*"]
|
license-files = ["LICEN[CS]E*"]
|
||||||
dependencies = [ "meshcore >= 2.1.7", "prompt_toolkit >= 3.0.50", "requests >= 2.28.0" ]
|
dependencies = [ "meshcore >= 2.1.9", "prompt_toolkit >= 3.0.50", "requests >= 2.28.0" ]
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
Homepage = "https://github.com/fdlamotte/meshcore-cli"
|
Homepage = "https://github.com/fdlamotte/meshcore-cli"
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ from prompt_toolkit.shortcuts import radiolist_dialog
|
||||||
from meshcore import MeshCore, EventType, logger
|
from meshcore import MeshCore, EventType, logger
|
||||||
|
|
||||||
# Version
|
# Version
|
||||||
VERSION = "v1.1.23"
|
VERSION = "v1.1.24"
|
||||||
|
|
||||||
# default ble address is stored in a config file
|
# default ble address is stored in a config file
|
||||||
MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
|
MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
|
||||||
|
|
@ -2160,6 +2160,7 @@ def usage () :
|
||||||
-T <timeout> : timeout for the ble scan (-S and -l) default 2s
|
-T <timeout> : timeout for the ble scan (-S and -l) default 2s
|
||||||
-a <address> : specifies device address (can be a name)
|
-a <address> : specifies device address (can be a name)
|
||||||
-d <name> : filter meshcore devices with name or address
|
-d <name> : filter meshcore devices with name or address
|
||||||
|
-P : forces pairing via the OS
|
||||||
-t <hostname> : connects via tcp/ip
|
-t <hostname> : connects via tcp/ip
|
||||||
-p <port> : specifies tcp port (default 5000)
|
-p <port> : specifies tcp port (default 5000)
|
||||||
-s <port> : use serial port <port>
|
-s <port> : use serial port <port>
|
||||||
|
|
@ -2179,19 +2180,22 @@ async def main(argv):
|
||||||
serial_port = None
|
serial_port = None
|
||||||
baudrate = 115200
|
baudrate = 115200
|
||||||
timeout = 2
|
timeout = 2
|
||||||
|
pin = None
|
||||||
# If there is an address in config file, use it by default
|
# If there is an address in config file, use it by default
|
||||||
# unless an arg is explicitely given
|
# unless an arg is explicitely given
|
||||||
if os.path.exists(MCCLI_ADDRESS) :
|
if os.path.exists(MCCLI_ADDRESS) :
|
||||||
with open(MCCLI_ADDRESS, encoding="utf-8") as f :
|
with open(MCCLI_ADDRESS, encoding="utf-8") as f :
|
||||||
address = f.readline().strip()
|
address = f.readline().strip()
|
||||||
|
|
||||||
opts, args = getopt.getopt(argv, "a:d:s:ht:p:b:jDhvSlT:")
|
opts, args = getopt.getopt(argv, "a:d:s:ht:p:b:jDhvSlT:P")
|
||||||
for opt, arg in opts :
|
for opt, arg in opts :
|
||||||
match opt:
|
match opt:
|
||||||
case "-d" : # name specified on cmdline
|
case "-d" : # name specified on cmdline
|
||||||
address = arg
|
address = arg
|
||||||
case "-a" : # address specified on cmdline
|
case "-a" : # address specified on cmdline
|
||||||
address = arg
|
address = arg
|
||||||
|
case "-P" : # pairing
|
||||||
|
pin = True
|
||||||
case "-s" : # serial port
|
case "-s" : # serial port
|
||||||
serial_port = arg
|
serial_port = arg
|
||||||
case "-b" :
|
case "-b" :
|
||||||
|
|
@ -2297,7 +2301,7 @@ async def main(argv):
|
||||||
logger.info(f"Couldn't find device {address}")
|
logger.info(f"Couldn't find device {address}")
|
||||||
return
|
return
|
||||||
|
|
||||||
mc = await MeshCore.create_ble(address=address, device=device, client=client, debug=debug, only_error=json_output)
|
mc = await MeshCore.create_ble(address=address, device=device, client=client, debug=debug, only_error=json_output, pin=pin)
|
||||||
|
|
||||||
# Store device address in configuration
|
# Store device address in configuration
|
||||||
if os.path.isdir(MCCLI_CONFIG_DIR) :
|
if os.path.isdir(MCCLI_CONFIG_DIR) :
|
||||||
|
|
@ -2312,6 +2316,8 @@ async def main(argv):
|
||||||
mc.subscribe(EventType.PATH_UPDATE, handle_path_update)
|
mc.subscribe(EventType.PATH_UPDATE, handle_path_update)
|
||||||
mc.subscribe(EventType.NEW_CONTACT, handle_new_contact)
|
mc.subscribe(EventType.NEW_CONTACT, handle_new_contact)
|
||||||
|
|
||||||
|
mc.auto_update_contacts = True
|
||||||
|
|
||||||
res = await mc.commands.send_device_query()
|
res = await mc.commands.send_device_query()
|
||||||
if res.type == EventType.ERROR :
|
if res.type == EventType.ERROR :
|
||||||
logger.error(f"Error while querying device: {res}")
|
logger.error(f"Error while querying device: {res}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue