Skip to content

Commit d5522f6

Browse files
author
xx
committed
Fix unqique parameter and add more hw types
1 parent 324ed85 commit d5522f6

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

firmware/esp32/gdoor/src/gdoor_data.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@
2121

2222
// Map the HW Type field between bus value and human readable string
2323
std::map<int, const char*>GDOOR_DATA_HWTYPE = {
24-
{ 0xA1, "INDOOR"},
2524
{ 0xA0, "OUTDOOR"},
26-
{ 0xA3, "CONTROLLER"}
25+
{ 0xA1, "INDOOR"},
26+
{ 0xA2, "INDOOR_RECEIVER"},
27+
{ 0xA3, "CONTROLLER"},
28+
{ 0xA4, "ACTUATOR"},
29+
{ 0xA5, "GATEWAY_TK"},
30+
{ 0xA6, "CHIME"},
31+
{ 0xA7, "BUTTON_IF"},
32+
{ 0xA8, "GATEWAY_IP"},
2733
};
2834

2935
// Map the Action field between bus value and human readable string

software/bus-debugger/mqttlisten.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
parser.add_argument('-s','--server', help='MQTT Server', default="127.0.0.1")
1010
parser.add_argument('-p','--port', help='MQTT Port', default=1883)
1111
parser.add_argument('-t','--topic', help='MQTT Topic', default="/gdoor/bus_rx")
12-
parser.add_argument('-u','--unique', help='Show only unique', default=True, type=bool)
12+
parser.add_argument('-u','--unique', help='Show only unique', default="true", type=str, choices=["false","true"])
1313
args = parser.parse_args()
1414

1515
table = Table(show_header=True, header_style="bold magenta")
@@ -30,7 +30,7 @@ def prependRow(row):
3030
table.rows.append(Row(style=None, end_section=False))
3131

3232
datas = []
33-
def check_uinque(data):
33+
def check_unique(data):
3434
if data in datas:
3535
return False
3636

@@ -43,11 +43,16 @@ def on_connect(client, userdata, flags, reason_code, properties=None):
4343
client.subscribe(topic=args.topic)
4444

4545
def on_message(client, userdata, message, properties=None):
46-
data = json.loads(message.payload)
47-
elem = gdoor.GDOOR(data["busdata"])
48-
49-
if args.unique == True and check_uinque(data["busdata"]):
50-
prependRow([data["event_id"], data["action"], data["source"], data["destination"], data["parameters"], data["busdata"][0:2], data["busdata"][2:4], data["type"], data["busdata"]])
46+
try:
47+
data = json.loads(message.payload)
48+
49+
if args.unique == "true":
50+
if check_unique(data["busdata"]):
51+
prependRow([data["event_id"], data["action"], data["source"], data["destination"], data["parameters"], data["busdata"][0:2], data["busdata"][2:4], data["type"], data["busdata"]])
52+
else:
53+
prependRow([data["event_id"], data["action"], data["source"], data["destination"], data["parameters"], data["busdata"][0:2], data["busdata"][2:4], data["type"], data["busdata"]])
54+
except json.JSONDecodeError:
55+
pass
5156

5257
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2, client_id="mqttlisten.py", clean_session=True)
5358
client.on_connect = on_connect

0 commit comments

Comments
 (0)