File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change 1
1
#! /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
You can’t perform that action at this time.
0 commit comments