File tree Expand file tree Collapse file tree 1 file changed +18
-19
lines changed Expand file tree Collapse file tree 1 file changed +18
-19
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
3
-
4
3
mac_address=" $1 "
5
4
file=" $2 "
6
5
7
6
7
+ function error() {
8
+ cat << - EOH
9
+ $1
10
+
11
+ Usage: $0 <MAC address> <file>
12
+
13
+ This tool will upload the file to the BlueBasic device that has that MAC address
14
+ Need gatttool installed
15
+ EOH
16
+ exit 1
17
+ }
18
+
19
+
8
20
function upload_progress() {
9
21
progress_character=' ='
10
22
progress_length=20
@@ -35,6 +47,8 @@ function load() {
35
47
chunks+=(" ${hexdump: chunk: 180} " )
36
48
done
37
49
50
+ upload_progress 0
51
+
38
52
for chunk in ${! chunks[@]} ; do
39
53
result=" $( gatttool -i hci0 \
40
54
-a 0x0031 \
@@ -49,29 +63,14 @@ function load() {
49
63
exit 1
50
64
fi
51
65
done
52
-
53
66
printf " \n"
54
- exit 0
55
67
}
56
68
57
69
58
- if [[ ! " $mac_address " =~ ^([a-fA-F0-9]{2}:){5}[a-zA-Z0-9]{2}$ ]]; then
59
- error= " Wrong MAC address! Example: AA:BB:CC:DD:EE:FF"
70
+ if ! [[ " $mac_address " =~ ^([a-fA-F0-9]{2}:){5}[a-zA-Z0-9]{2}$ ]]; then
71
+ error " Wrong MAC address! Example: AA:BB:CC:DD:EE:FF"
60
72
elif ! [[ -r $file && -f $file ]]; then
61
- error= " No such file!"
73
+ error " No such file!"
62
74
else
63
75
load
64
76
fi
65
-
66
-
67
- cat << - EOH
68
- $error
69
-
70
- Usage: $0 <MAC address> <file>
71
-
72
- This tool will upload the file to the BlueBasic device that has that MAC address
73
- Need gatttool installed
74
- EOH
75
-
76
-
77
- exit 1
You can’t perform that action at this time.
0 commit comments