Skip to content

Commit 6f86602

Browse files
committed
Initial sensor support
1 parent 628fff3 commit 6f86602

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/meshcore_cli/meshcore_cli.py

Lines changed: 10 additions & 2 deletions
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.3"
25+
VERSION = "v1.0.5"
2626

2727
# default ble address is stored in a config file
2828
MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
@@ -59,6 +59,8 @@
5959
ANSI_LIGHT_YELLOW = "\033[0;93m"
6060
ANSI_LIGHT_GRAY="\033[0;38;5;247m"
6161
ANSI_BGRAY="\033[1;38;5;247m"
62+
ANSI_ORANGE="\033[0;38;5;208m"
63+
ANSI_BORANGE="\033[1;38;5;208m"
6264

6365
def escape_ansi(line):
6466
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):
117119

118120
if ct is None: # Unknown
119121
disp = f"{ANSI_RED}"
122+
elif ct["type"] == 4 : # sensor
123+
disp = f"{ANSI_ORANGE}"
120124
elif ct["type"] == 3 : # room
121125
disp = f"{ANSI_CYAN}"
122126
elif ct["type"] == 2 : # repeater
@@ -439,6 +443,8 @@ def _(event):
439443
prompt = prompt + f"{ANSI_BRED}"
440444
if classic :
441445
prompt = prompt + "!"
446+
elif contact["type"] == 4 : # sensor
447+
prompt = prompt + f"{ANSI_BORANGE}"
442448
elif contact["type"] == 3 : # room server
443449
prompt = prompt + f"{ANSI_BCYAN}"
444450
elif contact["type"] == 2 :
@@ -597,7 +603,9 @@ def _(event):
597603
elif contact["type"] == 1 : # chat, send to recipient and wait ack
598604
last_ack = await msg_ack(mc, contact, line)
599605

600-
elif contact["type"] == 2 or contact["type"] == 3 : # repeater, send cmd
606+
elif contact["type"] == 2 or\
607+
contact["type"] == 3 or\
608+
contact["type"] == 4 : # repeater, room, sensor send cmd
601609
await process_cmds(mc, ["cmd", contact["adv_name"], line])
602610

603611
except (EOFError, KeyboardInterrupt):

0 commit comments

Comments
 (0)