commit 768d2ab93cc72ed23ba5505157eb23eb731e188f Author: Bujue.Win10 Date: Fri Jan 21 19:09:34 2022 +0800 首次提交 diff --git a/logDataClean.awk b/logDataClean.awk new file mode 100644 index 0000000..92ea0ce --- /dev/null +++ b/logDataClean.awk @@ -0,0 +1,46 @@ +#!/bin/awk -f + +############################# +# clean data and filter some to rediect to new file +# Author: Liao +# modify time: 2021/12/15 17:05 (+8:00) +############################# + +BEGIN{ + + # system("echo '\n\n\n----------' >> "awk_run_log_path" && date '+%x %X' >> "awk_run_log_path) + + dp_recv_from_device = @/ dp rept_type:[[:digit:]]+, data:{/ + dp_is_condition = @/dp [[:digit:]]+ match/ + dp_not_condition = @/no [[:digit:]]+ match/ + pattern = @/([[:digit:]]+-[[:digit:]]+ ([[:digit:]]+:){3}[[:digit:]]+)/ + + connection_check_ok = @ + # Get form OS + +} +!a++{ + +} +$0~dp_recv_from_device{ + matchRet(/([0-9]{1,2}-[0-9]{1,2} ([0-9]{1,2}:){3}[0-9]{1,3})/); + substr($0,RSTART,RLENGTH) + match($0,"^\\[([[:digit:]]+-[[:digit:]]+ ([[:digit:]]+:){3}[[:digit:]]+).*? dp .*?, data:(.*)$",d) + print d[1],d[3] + echo '[12-09 19:03:03:863 TUYA Debug][smart_frame.c:2110] dp rept_type:0, data:{"1":true}' +} +$0~dp_is_condition{ + +} +$0~connection_check_ok{ + +} + +END{ + +} + +function matchRet(reg ,RSTART,RLENGTH){ + match($0,reg); + return substr($0,RSTART,RLENGTH) +} \ No newline at end of file diff --git a/start_monitor.sh b/start_monitor.sh new file mode 100644 index 0000000..10aab70 --- /dev/null +++ b/start_monitor.sh @@ -0,0 +1,16 @@ + + +# 创建场景 +tail -f /tmp/tuya.log | grep '\] Rev MQTT:' | grep '"ruleId":' >> /data/SceneLinkage & + +# 触发场景 +tail -f /tmp/tuya.log | grep 'condition set is ok,then execute action set. scene:' >> + +# 子设备上报 +# 是否有相关场景( dp \d+ match | no dp match) +# 条件判断(conditions check finish. result:true) + # 条件判断结果(condition set is ok,then execute action set. scene:6DAMVviZamUqanPP, 0x8b26d8) +# 动作执行(in work-queue. execute scene:6DAMVviZamUqanPP begin)([scene_linkage_rule_exe.c) +# 子设备上报 + + diff --git a/必要日志.log b/必要日志.log new file mode 100644 index 0000000..e9e89bd --- /dev/null +++ b/必要日志.log @@ -0,0 +1,24 @@ + +[12-09 19:03:03:863 TUYA Debug][smart_frame.c:2110] dp rept_type:0, data:{"1":true} +[12-09 19:03:03:884 TUYA Debug][mqc_app.c:862] Send MQTT Msg.P:4 N:54368 Q:1 Data:{"dps":{"1":true},"cid":"000d6ffffe972ab8"} + +[12-09 19:03:03:885 TUYA Debug][scene_linkage_dp_detect.c:377] rev id:000d6ffffe972ab8 cmd:{"1":true} type:0 +[12-09 19:03:03:885 TUYA Debug][scene_linkage_dp_detect.c:415] dp 1 match + +[12-09 19:03:03:887 TUYA Debug][condition.c:1376] time_cond is disabled. skip + +[12-09 19:03:03:887 TUYA Debug][condition.c:1496] conditions check finish. result:true +[12-09 19:03:03:887 TUYA Notice][scene_linkage_rule_exe.c:2152] condition set is ok,then execute action set. scene:6DAMVviZamUqanPP, 0x89eb80 + +[12-09 19:03:03:888 TUYA Debug][scene_linkage_rule_exe.c:3430] in work-queue. execute scene:6DAMVviZamUqanPP begin + +[12-09 19:03:03:888 TUYA Debug][scene_linkage_rule_exe.c:2392] action<0> is dp cmd:{"cid":"000d6ffffe972ab8","dps":{"2":true}} +[12-09 19:03:03:932 TUYA Debug][scene_linkage_rule_exe.c:2392] action<1> is dp cmd:{"cid":"086bd7fffe1ecf52","dps":{"1":false}} + +[12-09 19:03:04:17 TUYA Debug][smart_frame.c:2110] dp rept_type:0, data:{"2":true} +[12-09 19:03:04:47 TUYA Debug][mqc_app.c:862] Send MQTT Msg.P:4 N:54369 Q:1 Data:{"dps":{"2":true},"cid":"000d6ffffe972ab8"} + +[12-09 19:03:04:113 TUYA Debug][smart_frame.c:2110] dp rept_type:0, data:{"1":false} +[12-09 19:03:04:157 TUYA Debug][mqc_app.c:862] Send MQTT Msg.P:4 N:54370 Q:1 Data:{"dps":{"1":false},"cid":"086bd7fffe1ecf52"} + +