Skip to content

Commit

Permalink
Fix unqique parameter and add more hw types
Browse files Browse the repository at this point in the history
  • Loading branch information
xx committed Sep 25, 2024
1 parent 324ed85 commit d5522f6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
10 changes: 8 additions & 2 deletions firmware/esp32/gdoor/src/gdoor_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@

// Map the HW Type field between bus value and human readable string
std::map<int, const char*>GDOOR_DATA_HWTYPE = {
{ 0xA1, "INDOOR"},
{ 0xA0, "OUTDOOR"},
{ 0xA3, "CONTROLLER"}
{ 0xA1, "INDOOR"},
{ 0xA2, "INDOOR_RECEIVER"},
{ 0xA3, "CONTROLLER"},
{ 0xA4, "ACTUATOR"},
{ 0xA5, "GATEWAY_TK"},
{ 0xA6, "CHIME"},
{ 0xA7, "BUTTON_IF"},
{ 0xA8, "GATEWAY_IP"},
};

// Map the Action field between bus value and human readable string
Expand Down
19 changes: 12 additions & 7 deletions software/bus-debugger/mqttlisten.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
parser.add_argument('-s','--server', help='MQTT Server', default="127.0.0.1")
parser.add_argument('-p','--port', help='MQTT Port', default=1883)
parser.add_argument('-t','--topic', help='MQTT Topic', default="/gdoor/bus_rx")
parser.add_argument('-u','--unique', help='Show only unique', default=True, type=bool)
parser.add_argument('-u','--unique', help='Show only unique', default="true", type=str, choices=["false","true"])
args = parser.parse_args()

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

datas = []
def check_uinque(data):
def check_unique(data):
if data in datas:
return False

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

def on_message(client, userdata, message, properties=None):
data = json.loads(message.payload)
elem = gdoor.GDOOR(data["busdata"])

if args.unique == True and check_uinque(data["busdata"]):
prependRow([data["event_id"], data["action"], data["source"], data["destination"], data["parameters"], data["busdata"][0:2], data["busdata"][2:4], data["type"], data["busdata"]])
try:
data = json.loads(message.payload)

if args.unique == "true":
if check_unique(data["busdata"]):
prependRow([data["event_id"], data["action"], data["source"], data["destination"], data["parameters"], data["busdata"][0:2], data["busdata"][2:4], data["type"], data["busdata"]])
else:
prependRow([data["event_id"], data["action"], data["source"], data["destination"], data["parameters"], data["busdata"][0:2], data["busdata"][2:4], data["type"], data["busdata"]])
except json.JSONDecodeError:
pass

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

0 comments on commit d5522f6

Please sign in to comment.