Skip to content

Commit ab7e1fe

Browse files
author
Helio
committed
Update load
1 parent eb2ed4c commit ab7e1fe

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

load

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,25 @@
33
mac_address="$1"
44
file="$2"
55

6-
if [[ "$mac_address" =~ ^([a-fA-F0-9]{2}:){5}[a-zA-Z0-9]{2}$ && -r $file && -f $file ]]; then
6+
function load() {
77
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"
8+
line=$(printf '%s\r' "$line" | xxd -p | tr -d '\n')
9+
echo gatttool -i hci0 -b "$mac_address" --char-write-req -a 0x0031 -n $line # @0xFACE: Remove echo when done
1010
done < $file
11+
}
12+
13+
if [[ ! "$mac_address" =~ ^([a-fA-F0-9]{2}:){5}[a-zA-Z0-9]{2}$ ]]; then
14+
error="Wrong MAC address! Example: AA:BB:CC:DD:EE:FF"
15+
elif [[ ! -r $file && -f $file ]]; then
16+
error="No such file!"
17+
else
18+
load
1119
exit
1220
fi
1321

1422
cat <<- EOH
23+
$error
24+
1525
Usage: $0 <MAC address> <file>
1626
1727
This tool will upload the file to the BlueBasic device that has that MAC address

0 commit comments

Comments
 (0)