Skip to content

Commit eb2ed4c

Browse files
author
Helio
committed
The smart way
;-)
1 parent a3fccaa commit eb2ed4c

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

load

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
#!/bin/bash
2-
MAC=20:C3:8F:F2:C1:7F
3-
while read in; do
4-
HEX=$(echo "`echo $in | hexdump -vC | awk 'BEGIN {IFS="\t"} {$1=""; print }' | awk '{sub(/\|.*/,"")}1' | tr -d '\n' | tr -d ' '`" | rev | cut -c 3- | rev)
5-
gatttool -i hci0 -b $MAC --char-write-req -a 0x0031 -n $HEX"0d"
6-
done < $1
2+
3+
mac_address="$1"
4+
file="$2"
5+
6+
if [[ "$mac_address" =~ ^([a-fA-F0-9]{2}:){5}[a-zA-Z0-9]{2}$ && -r $file && -f $file ]]; then
7+
while read line; do
8+
line=$(printf '%s\r' "$line" | xxd -p)
9+
echo gatttool -i hci0 -b "$mac_address" --char-write-req -a 0x0031 -n "$line"
10+
done < $file
11+
exit
12+
fi
13+
14+
cat <<- EOH
15+
Usage: $0 <MAC address> <file>
16+
17+
This tool will upload the file to the BlueBasic device that has that MAC address
18+
Fixme: I can't properly document a script, please fix it before commiting to Master branch.
19+
EOH

0 commit comments

Comments
 (0)