Skip to content

Commit 80fd97c

Browse files
Merge pull request #282 from zeridon/improve-manufacturer-checking
Improve manufacturer checking
2 parents 3a3c93c + bfe33a9 commit 80fd97c

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

monitor.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# ----------------------------------------------------------------------------------------
2626

2727
#VERSION NUMBER
28-
export version=0.2.198
28+
export version=0.2.200
2929

3030
#COLOR OUTPUT FOR RICH OUTPUT
3131
ORANGE=$'\e[1;33m'
@@ -1100,7 +1100,9 @@ while true; do
11001100
publish_presence_message \
11011101
"id=$addr" \
11021102
"confidence=$device_state" \
1103+
"name=${known_public_device_name[$addr]}" \
11031104
"type=KNOWN_MAC"
1105+
11041106
done
11051107

11061108
elif [[ $mqtt_topic_branch =~ .*ADD\ STATIC\ DEVICE.* ]] || [[ $mqtt_topic_branch =~ .*DELETE\ STATIC\ DEVICE.* ]]; then

support/btle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ btle_text_listener () {
348348

349349
#DEFINE VARAIBLES
350350
while IFS= read -r line; do
351-
352-
351+
#maintain the pipe for faster machines.
352+
printf "%s\n" "" > packet_pipe
353353
if [[ $line =~ ^\> ]] || [[ $line =~ ^\< ]] || [[ $line =~ RSSI ]]; then
354354
[[ $line =~ RSSI ]] && packet="$packet~$line"
355355
if [[ $packet =~ ^\> ]]; then

support/data

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,23 @@ determine_manufacturer () {
3333
#EXCEPTION FOR SUSPECT PRODUCTS
3434
[[ $address =~ ^FF:FF ]] && manufacturer="SIG Unassigned or Noncompliant OEM"
3535

36+
# If no cache try if we have ieee-data
37+
if [ -z "$manufacturer" ] ; then
38+
_temp=$(echo ${address:0:8} | sed 's/://gi')
39+
_found=false
40+
local remote_result=''
41+
if [ ! ${_found} ] && [ -f /var/lib/ieee-data/oui.csv ] ; then
42+
remote_result=$(egrep ",${_temp}," /var/lib/ieee-data/oui.csv | cut -d\, -f3)
43+
_found=true
44+
fi
45+
if [ ! ${_found} ] && [ -f /usr/share/ieee-data/oui.csv ] ; then
46+
remote_result=$(egrep ",${_temp}," /var/lib/ieee-data/oui.csv | cut -d\, -f3)
47+
_found=true
48+
fi
49+
[ -n "$remote_result" ] && echo "${address:0:8} $remote_result" >> .manufacturer_cache
50+
manufacturer="$remote_result"
51+
fi
52+
3653
#IF CACHE DOES NOT EXIST, USE MACVENDORS.COM
3754
if [ -z "$manufacturer" ]; then
3855
local remote_result=$(curl -sL https://api.macvendors.com/${address:0:8} | grep -vi "error" | head -1 | sed 's/[^A-Za-z ]//gi')
@@ -48,4 +65,4 @@ determine_manufacturer () {
4865
[ -z "$manufacturer" ] && manufacturer="Unknown" && echo "${address:0:8} Unknown" >> .manufacturer_cache
4966
echo "$manufacturer"
5067
fi
51-
}
68+
}

support/mqtt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,9 @@ mqtt_error_handler () {
163163

164164
if [ -n "$received" ]; then
165165
#ERRORS
166-
[[ ${received^^} =~ .*"NO ROUTE TO HOST".* ]] && return_value=1 && print_message="networking errors, no route to host - check username, password, and host address"
167-
[[ ${received^^} =~ .*"CONNECTION REFUSED".* ]] && return_value=1 && print_message="mqtt broker refused connection - check username, password, and host address"
166+
[[ ${received^^} =~ .*CONNECTION.* ]] && [[ ${received^^} =~ .*REFUSED.* ]] && return_value=1 && print_message="mqtt broker refused connection - check username, password, and host address"
168167
[[ ${received^^} =~ .*NETWORK.* ]] && [[ ${received^^} =~ .*UNREACHABLE.* ]] && return_value=0 && print_message="network is down. enqueuing command to try again after a delay"
169-
[[ ${received^^} =~ .*"LOOKUP ERROR".* ]] && return_value=0 && print_message="issue connecting to mqtt server (lookup error). enqueuing command to try again after a delay"
168+
[[ ${received^^} =~ .*LOOKUP.* ]] && [[ ${received^^} =~ .*ERROR.* ]] && return_value=0 && print_message="issue connecting to mqtt server (lookup error). enqueuing command to try again after a delay"
170169

171170

172171
if [ -n "$last_error_message" ] && [ "$last_error_message" == "$print_message" ]; then

0 commit comments

Comments
 (0)