File tree Expand file tree Collapse file tree 1 file changed +28
-5
lines changed Expand file tree Collapse file tree 1 file changed +28
-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
+ function load() {
7
+ while read line; do
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
+ 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
19
+ exit
20
+ fi
21
+
22
+ cat << - EOH
23
+ $error
24
+
25
+ Usage: $0 <MAC address> <file>
26
+
27
+ This tool will upload the file to the BlueBasic device that has that MAC address
28
+ Fixme: I can't properly document a script, please fix it before commiting to Master branch.
29
+ EOH
You can’t perform that action at this time.
0 commit comments