projects
/
air-quality
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d50681e
)
simplify script to use only gattool, awk and curl
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Fri, 27 Jan 2023 09:13:02 +0000
(10:13 +0100)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Fri, 27 Jan 2023 09:13:02 +0000
(10:13 +0100)
ble-mijia.sh
patch
|
blob
|
history
diff --git
a/ble-mijia.sh
b/ble-mijia.sh
index
016675b
..
9659e29
100755
(executable)
--- a/
ble-mijia.sh
+++ b/
ble-mijia.sh
@@
-1,16
+1,9
@@
-#!/bin/
ba
sh -e
-mac=A4:C1:38:
D8:3F:9C
+#!/bin/sh -e
+mac=A4:C1:38:
90:DC:63
test ! -z "$1" && mac=$1
test ! -z "$1" && mac=$1
-gatttool -b $mac --char-write-req --handle='0x0038' --value="0100" --listen | tee /dev/stderr | grep --line-buffered value: | while read bt ; do
+gatttool -b $mac --char-write-req --handle='0x0038' --value="0100" --listen | \
+ awk 'BEGIN { OFS=","; ORS="\n" } /value:/ { print "temperature=" strtonum("0x"$7$6) / 100, "humidity=" strtonum("0x"$8), "a=" strtonum("0x"$9), "b="strtonum("0x"$10) ; fflush() }' | \
+ xargs -i curl --silent -XPOST 'http://10.60.0.92:8086/write?consistency=any&db=rot13' --data-binary "mijia,dc=trnjanska,mac=$mac {}"
-#echo "XXX[$bt]"
-
-v=$( echo $bt | awk '{ print "temperature=" strtonum("0x"$7$6) / 100, "humidity=" strtonum("0x"$8), "a=" strtonum("0x"$9), "b="strtonum("0x"$10) }' | sed 's/ /,/g' )
-
-#echo $(date +%Y-%m-%d\ %H:%M:%S) $mac $v
-
-curl --silent -XPOST 'http://10.60.0.92:8086/write?consistency=any&db=rot13' --data-binary "mijia,dc=trnjanska,mac=$mac $v"
-
-done # gattool