Добавил протоколирование
authorRoman Bazalevsky <rvb@rvb.name>
Fri, 30 Sep 2016 09:23:36 +0000 (12:23 +0300)
committerRoman Bazalevsky <rvb@rvb.name>
Fri, 30 Sep 2016 09:23:36 +0000 (12:23 +0300)
mqtt-bt/bt-proximity
mqtt-bt/bt-proximity~ [new file with mode: 0755]

index bfbbfdbee5360554f28487f5da8d06cf0362f642..c2c85d4f696f46afa355b05a242fb51519dced38 100755 (executable)
@@ -15,6 +15,7 @@ do
     if [ "$?" = "0" ]
     then
       mosquitto_pub -h $mqtt_host -p $mqtt_port -u $mqtt_user -P $mqtt_passwd -t $mqtt_topic/$user -m $host
     if [ "$?" = "0" ]
     then
       mosquitto_pub -h $mqtt_host -p $mqtt_port -u $mqtt_user -P $mqtt_passwd -t $mqtt_topic/$user -m $host
+      logger -t bt-proximity "$mac ($user) detected by $host"
     fi
   fi 
 
     fi
   fi 
 
diff --git a/mqtt-bt/bt-proximity~ b/mqtt-bt/bt-proximity~
new file mode 100755 (executable)
index 0000000..bfbbfdb
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+. /etc/bt-proximity.conf
+
+host=`hostname`
+
+hciconfig hci0 up
+
+cat $1 | while read mac user
+do
+
+  if [ "$mac" != "" ]
+  then
+    l2ping -c 2 -t 10 $mac
+    if [ "$?" = "0" ]
+    then
+      mosquitto_pub -h $mqtt_host -p $mqtt_port -u $mqtt_user -P $mqtt_passwd -t $mqtt_topic/$user -m $host
+    fi
+  fi 
+
+done