meshcore-cli 1.3.21__tar.gz → 1.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meshcore-cli
3
- Version: 1.3.21
3
+ Version: 1.4.0
4
4
  Summary: Command line interface to meshcore companion radios
5
5
  Project-URL: Homepage, https://github.com/fdlamotte/meshcore-cli
6
6
  Project-URL: Issues, https://github.com/fdlamotte/meshcore-cli/issues
@@ -29,7 +29,7 @@ You can send commands as parameters to the meshcore-cli command (from your shell
29
29
 
30
30
  There is also an interactive mode (this is the default when no command is passed). In interactive mode you can enter a contact (another client a repeater, a sensor or a room) and interact with it. For clients, interaction consists in sending/receiving messages. For repeaters, rooms or sensors it will directly give you the remote cli (you can still send messages to rooms using double quote prefix or msg command).
31
31
 
32
- Note that meshcore-cli only interacts with companion radios (through BLE, Serial or TCP), you can't connect to a repeater using its serial interface.
32
+ By default meshcore-cli interacts with companion radios (through BLE, Serial or TCP). A serial repeater mode has been introduced, which is triggered using `-r`, which mainly adds line editing, history and completion to the serial interface, adds time syncing through `clock sync` and let you download/upload regions specs from a file.
33
33
 
34
34
  Also, most meshcore companions only have one interface compiled in at a time. So you can't connect via Serial to a node, which has been compiled as a BLE companion.
35
35
 
@@ -10,7 +10,7 @@ You can send commands as parameters to the meshcore-cli command (from your shell
10
10
 
11
11
  There is also an interactive mode (this is the default when no command is passed). In interactive mode you can enter a contact (another client a repeater, a sensor or a room) and interact with it. For clients, interaction consists in sending/receiving messages. For repeaters, rooms or sensors it will directly give you the remote cli (you can still send messages to rooms using double quote prefix or msg command).
12
12
 
13
- Note that meshcore-cli only interacts with companion radios (through BLE, Serial or TCP), you can't connect to a repeater using its serial interface.
13
+ By default meshcore-cli interacts with companion radios (through BLE, Serial or TCP). A serial repeater mode has been introduced, which is triggered using `-r`, which mainly adds line editing, history and completion to the serial interface, adds time syncing through `clock sync` and let you download/upload regions specs from a file.
14
14
 
15
15
  Also, most meshcore companions only have one interface compiled in at a time. So you can't connect via Serial to a node, which has been compiled as a BLE companion.
16
16
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "meshcore-cli"
7
- version = "1.3.21"
7
+ version = "1.4.0"
8
8
  authors = [
9
9
  { name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
10
10
  ]
@@ -32,7 +32,7 @@ import re
32
32
  from meshcore import MeshCore, EventType, logger
33
33
 
34
34
  # Version
35
- VERSION = "v1.3.21"
35
+ VERSION = "v1.4.0"
36
36
 
37
37
  # default ble address is stored in a config file
38
38
  MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
@@ -3924,10 +3924,9 @@ REPEATER_HELP = f"""
3924
3924
 
3925
3925
  {ANSI_BGREEN}Region management:{ANSI_END}
3926
3926
  region - display currently configured regions
3927
- region load - (don't use) reads region config line by line
3928
3927
  region save - save current region config to flash
3929
3928
  region download - download regions config from node to file
3930
- region upload - upload regions config to node from file
3929
+ region (up)load - upload regions config to node from file
3931
3930
  region home - get/set home region
3932
3931
  region get - get info (and parent) for a region
3933
3932
  region put - adds or update a region
@@ -3999,7 +3998,7 @@ async def process_repeater_script(ser, file):
3999
3998
  logger.error(f"Error processing {line}")
4000
3999
  break
4001
4000
 
4002
- async def process_repeater_line(ser, cmd, echo=False) :
4001
+ async def process_repeater_line(ser, cmd, echo=False, repeater_name=None) :
4003
4002
  if cmd.lower() == "help":
4004
4003
  print(REPEATER_HELP)
4005
4004
  return True
@@ -4011,9 +4010,10 @@ async def process_repeater_line(ser, cmd, echo=False) :
4011
4010
  f' ({cur_time}){ANSI_END}')
4012
4011
  cmd = f"time {cur_time}"
4013
4012
 
4014
- if cmd.lower().startswith("region upload"):
4013
+ if cmd.lower().startswith("region upload") or\
4014
+ cmd.lower().startswith("region load"): # removing normal load behavior
4015
4015
  try:
4016
- if cmd.lower() == "region upload": # prompt for a filename
4016
+ if len(cmd.split(" ")) < 3: # prompt for a filename
4017
4017
  file_path = await prompt_for_file()
4018
4018
  else :
4019
4019
  file_path = cmd.lower().split(" ", 3)[2]
@@ -4048,6 +4048,13 @@ async def process_repeater_line(ser, cmd, echo=False) :
4048
4048
  file_path = file_path.replace("~", str(Path.home()))
4049
4049
 
4050
4050
  with open(file_path, "w") as file:
4051
+ # write header (name and timestamp)
4052
+ if repeater_name is None:
4053
+ repeater_name = await get_repeater_name(ser)
4054
+
4055
+ file.write(f"; Regions spec downloaded from {repeater_name}\n")
4056
+ file.write(f"; On {datetime.datetime.fromtimestamp(time.time()).strftime('%a %d %b %Y %H:%M %z')}\n")
4057
+
4051
4058
  ser.write("region\r".encode()) # send regions command
4052
4059
 
4053
4060
  # seek start of regions description
@@ -4060,6 +4067,8 @@ async def process_repeater_line(ser, cmd, echo=False) :
4060
4067
  while line.rstrip() != "":
4061
4068
  file.write(line)
4062
4069
  line = ser.readline().decode(errors='ignore')
4070
+
4071
+ logger.info(f"{ANSI_CYAN}Wrote regions spec to {file_path}{ANSI_END}")
4063
4072
  except FileNotFoundError:
4064
4073
  logger.error("File not found")
4065
4074
  return False
@@ -4108,6 +4117,8 @@ async def process_repeater_line(ser, cmd, echo=False) :
4108
4117
  print(f"{ANSI_RED}{line}{ANSI_END}")
4109
4118
  elif line.strip().startswith("->"):
4110
4119
  print(f"{ANSI_CYAN}{line}{ANSI_END}")
4120
+ elif line.strip().startswith("DEBUG"):
4121
+ pass
4111
4122
  else:
4112
4123
  print(line)
4113
4124
  if "-> Unknown command" in line or \
@@ -4139,7 +4150,7 @@ async def setup_repeater_serial(port, baudrate):
4139
4150
 
4140
4151
  return ser
4141
4152
 
4142
- async def repeater_loop(ser):
4153
+ async def get_repeater_name(ser):
4143
4154
  # Try to get device name
4144
4155
  ser.write(b"get name\r")
4145
4156
  line = ""
@@ -4151,6 +4162,9 @@ async def repeater_loop(ser):
4151
4162
  if (line.startswith(" -> > ")):
4152
4163
  device_name = line[7:]
4153
4164
 
4165
+ return device_name
4166
+
4167
+ async def get_repeater_version(ser):
4154
4168
  # Getting version
4155
4169
  ser.write(b"ver\r")
4156
4170
  line = ser.readline().decode(errors="ignore").rstrip()
@@ -4162,6 +4176,13 @@ async def repeater_loop(ser):
4162
4176
  if (line.startswith(" -> ")):
4163
4177
  device_version = line[6:]
4164
4178
 
4179
+ return device_version
4180
+
4181
+ async def repeater_loop(ser):
4182
+
4183
+ device_name = await get_repeater_name(ser)
4184
+ device_version = await get_repeater_version(ser)
4185
+
4165
4186
  print(f"{ANSI_BGREEN}Connected!{ANSI_END} Device: {ANSI_BMAGENTA}{device_name}{ANSI_END} version {ANSI_BMAGENTA}{device_version}{ANSI_END}")
4166
4187
  print(f"Type {ANSI_BCYAN}help{ANSI_END} for commands, {ANSI_BCYAN}quit{ANSI_END} to exit, {ANSI_BCYAN}Tab{ANSI_END} for completion")
4167
4188
  print("-" * 50)
@@ -4214,7 +4235,7 @@ async def repeater_loop(ser):
4214
4235
  if cmd.lower() in ("quit", "exit", "q"):
4215
4236
  break
4216
4237
 
4217
- await process_repeater_line(ser, cmd)
4238
+ await process_repeater_line(ser, cmd, repeater_name=device_name)
4218
4239
 
4219
4240
 
4220
4241
  async def main(argv):
File without changes
File without changes
File without changes
File without changes