Initial sensor support

This commit is contained in:
Florent 2025-07-09 16:48:24 +02:00
parent 628fff3307
commit 6f866020e3

View file

@ -22,7 +22,7 @@ from meshcore import TCPConnection, BLEConnection, SerialConnection
from meshcore import MeshCore, EventType, logger
# Version
VERSION = "v1.0.3"
VERSION = "v1.0.5"
# default ble address is stored in a config file
MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
@ -59,6 +59,8 @@ ANSI_LIGHT_GREEN = "\033[0;92m"
ANSI_LIGHT_YELLOW = "\033[0;93m"
ANSI_LIGHT_GRAY="\033[0;38;5;247m"
ANSI_BGRAY="\033[1;38;5;247m"
ANSI_ORANGE="\033[0;38;5;208m"
ANSI_BORANGE="\033[1;38;5;208m"
def escape_ansi(line):
ansi_escape = re.compile(r'(?:\x1B[@-_]|[\x80-\x9F])[0-?]*[ -/]*[@-~]')
@ -117,6 +119,8 @@ async def process_event_message(mc, ev, json_output, end="\n", above=False):
if ct is None: # Unknown
disp = f"{ANSI_RED}"
elif ct["type"] == 4 : # sensor
disp = f"{ANSI_ORANGE}"
elif ct["type"] == 3 : # room
disp = f"{ANSI_CYAN}"
elif ct["type"] == 2 : # repeater
@ -439,6 +443,8 @@ Line starting with \"$\" or \".\" will issue a meshcli command.
prompt = prompt + f"{ANSI_BRED}"
if classic :
prompt = prompt + "!"
elif contact["type"] == 4 : # sensor
prompt = prompt + f"{ANSI_BORANGE}"
elif contact["type"] == 3 : # room server
prompt = prompt + f"{ANSI_BCYAN}"
elif contact["type"] == 2 :
@ -597,7 +603,9 @@ Line starting with \"$\" or \".\" will issue a meshcli command.
elif contact["type"] == 1 : # chat, send to recipient and wait ack
last_ack = await msg_ack(mc, contact, line)
elif contact["type"] == 2 or contact["type"] == 3 : # repeater, send cmd
elif contact["type"] == 2 or\
contact["type"] == 3 or\
contact["type"] == 4 : # repeater, room, sensor send cmd
await process_cmds(mc, ["cmd", contact["adv_name"], line])
except (EOFError, KeyboardInterrupt):