File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 3
3
mac_address=" $1 "
4
4
file=" $2 "
5
5
6
- if [[ " $mac_address " =~ ^([a-fA-F0-9]{2}:){5}[a-zA-Z0-9]{2}$ && -r $file && -f $file ]] ; then
6
+ function load() {
7
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 "
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
10
10
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
11
19
exit
12
20
fi
13
21
14
22
cat << - EOH
23
+ $error
24
+
15
25
Usage: $0 <MAC address> <file>
16
26
17
27
This tool will upload the file to the BlueBasic device that has that MAC address
You can’t perform that action at this time.
0 commit comments