diff --git a/openwrt/files/usbserial-dw.config b/openwrt/files/usbserial-dw.config index e6f3e57..b29222b 100644 --- a/openwrt/files/usbserial-dw.config +++ b/openwrt/files/usbserial-dw.config @@ -5,3 +5,7 @@ config capture option file camera.jpg option url https://meranie.bh.ttx.sk/upload/image option time 300 +config post + option host 172.16.1.254 + option topic home/sensor/strecha/bme280 + option mqtt_prg mosquitto_pub \ No newline at end of file diff --git a/openwrt/files/usbserial-dw.sh b/openwrt/files/usbserial-dw.sh index 5a3dc3b..b90666f 100644 --- a/openwrt/files/usbserial-dw.sh +++ b/openwrt/files/usbserial-dw.sh @@ -25,5 +25,27 @@ parse_capture() { rm $_file } +parse_post() { + local section="$1" + local _host + local _topic + local _mqtt_prg + + config_get _host "$section" "host" + config_get _topic "$section" "topic" + config_get _mqtt_prg "$section" "mqtt_prg" + + _tmp=`$PROG --temperature` + _hum=`$PROG --humidity` + _pre=`$PROG --pressure` + + $_mqtt_prg -h $_host -t $_topic/temperature -m N:$_tmp + $_mqtt_prg -h $_host -t $_topic/humidity -m N:$_hum + $_mqtt_prg -h $_host -t $_topic/pressure -m N:$_pre + +} + config_load usbserial config_foreach parse_capture capture +config_foreach parse_post post +