Отлов пользовательских устройств с известными BT MAC-адресами. С точностью до комнаты.
authorRoman Bazalevsky <rvb@rvb.name>
Tue, 27 Sep 2016 11:52:53 +0000 (14:52 +0300)
committerRoman Bazalevsky <rvb@rvb.name>
Tue, 27 Sep 2016 11:52:53 +0000 (14:52 +0300)
mqtt-bt/bt-macs [new file with mode: 0644]
mqtt-bt/bt-proximity [new file with mode: 0755]
mqtt-bt/bt-proximity.conf [new file with mode: 0644]

diff --git a/mqtt-bt/bt-macs b/mqtt-bt/bt-macs
new file mode 100644 (file)
index 0000000..0c2bfca
--- /dev/null
@@ -0,0 +1,4 @@
+00:01:02:03:04:05 user1
+01:02:03:04:05:06 user2
+
+
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
diff --git a/mqtt-bt/bt-proximity.conf b/mqtt-bt/bt-proximity.conf
new file mode 100644 (file)
index 0000000..ea85fe1
--- /dev/null
@@ -0,0 +1,6 @@
+mqtt_host="server"
+mqtt_port=1883
+mqtt_user="bt"
+mqtt_passwd="password"
+mqtt_topic="bt"
+