forked from decodeais/FortiusANT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPiBulleye_Install.sh
199 lines (163 loc) · 6.67 KB
/
PiBulleye_Install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
e#!/bin/bash
echo ----------------------------------------------------------
echo Update your system
echo ----------------------------------------------------------
sudo apt update -y
sudo apt full-upgrade -y
cd ~
echo ----------------------------------------------------------
echo Install Python
echo ----------------------------------------------------------
sudo apt upgrade python3
sudo apt install python3-pip
pip3 install --upgrade pip
echo ----------------------------------------------------------
echo Install Git
echo ----------------------------------------------------------
sudo apt install git
echo ----------------------------------------------------------
echo Clone FortiusANT from Github into ~/FortiusANT directoy
echo ----------------------------------------------------------
rm $HOME/FortiusANT -r -f
git clone https://github.com/Decodeais/FortiusANT.git $HOME/FortiusANT
#git clone https://github.com/WouterJD/FortiusANT.git $HOME/FortiusANT
echo ----------------------------------------------------------
echo Install: build-essential bluetooth bluez libbluetooth-dev libudev-dev
echo ibatlas-base-dev npm
echo ----------------------------------------------------------
sudo apt install -y build-essential bluetooth bluez libbluetooth-dev libudev-dev
sudo apt-get install -y libatlas-base-dev # for numpy, https://github.com/numpy/numpy/issues/11110
sudo apt-get install npm -y
sudo npm update -g #???
echo ----------------------------------------------------------
echo Install: node Version 14.15.3 mit nodemanager n
echo ----------------------------------------------------------
cd ~/FortiusANT/node/
sudo npm install -g n
sudo npm update -g
sudo n 14.15.3
#sudo n latest
# im Verzeichnis node
npm install -no-audit
#npm install @abandonware/bluetooth-hci-socket@abandonware/bleno
cd ~
echo ----------------------------------------------------------
echo Next step is to grant the node binary cap_net_raw privileges,
echo so it can start/stop BLE advertising without root access.
echo ----------------------------------------------------------
sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)
echo ----------------------------------------------------------
echo Install: wxPython4 für ubuntu-20.04
echo ---------------------------------no-audit---------------------------
URL=https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-20.04
pip install -U -f $URL wxPython
echo ----------------------------------------------------------
echo Install: Python Modules from Requierments.txt
echo ----------------------------------------------------------
pip3 install lib_programname
pip3 install lib_detect_testenv
pip3 install -r ~/FortiusANT/pythoncode/requirements.txt
sudo apt install python3-usb
python -m pip install --upgrade lib_detect_testenv
echo ----------------------------------------------------------
echo Install: Find out Modell of Headunit and ANT+ -Stick
echo ----------------------------------------------------------
# ----------------------------------------------------------
# Tacx USB-interface info
# Remove everything untill : (including)
# Remove spaces (Note: 's/ *//' does not work
# ----------------------------------------------------------
HEADUNIT=`lsusb | grep 3561 | sed -e 's/^.*://' -e 's/ //g'`
if [ T$HEADUNIT = T ]; then
echo No Tacx USB-interface connected
else
echo Tacx with T$HEADUNIT connected
fi
# ----------------------------------------------------------
# ANT USB-interface info
# ----------------------------------------------------------
ANT=NoAntFound
ANTTYPE=
if `lsusb | grep -c ':1004'` == 1 ; then
ANT=1004
ANTTYPE=Older
fi
if `lsusb | grep -c ':1008'` == 1 ; then
ANT=1008
ANTTYPE=Suunto
fi
if `lsusb | grep -c ':1009'` == 1 ; then
ANT=1009
ANTTYPE=Garmin
fi
if ANT == NoAntFound ; then
echo No ANTdongle found
else
VENDOR=`lsusb | grep $ANT | sed -e 's/^.*ID //' -e 's/:.*$//'`
echo ANT dongle $VENDOR:$ANT $ANTTYPE found
lsusb | grep ":$ANT"
fi
# ----------------------------------------------------------
# First create files, then cp to target
# ----------------------------------------------------------
# Assign the Linux USB serial driver to the ANT stick by
# noting the driver with the id's:
# ----------------------------------------------------------
USBCONF=FortiusAntUsb2.conf
if [ ANT != NoAntFound ]; then
cat << EOF > $USBCONF
# Options for ANTdongle $ANTTYPE $VENDOR:$ANT
Options usbserial vendor=0x$VENDOR product=0x$ANT
EOF
sudo cp $USBCONF /etc/modprobe.d/
rm $USBCONF
fi
# ----------------------------------------------------------
# Furthermore we assign the device file to our user so that
# he can read and write to it. In my example the user is pi.
# Please also adjust the following example with your usb ids
# (vendor and product).
# It is also possible to assign Groups.
# See udev rules documentation or search the web for more examples.
# More general udev rules can be found here:
# https://github.com/WouterJD/FortiusANT/issues/262#issuecomment-790384254
# https://stackoverflow.com/questions/3738173/why-does-pyusb-libusb-require-root-sudo-permissions-on-linux
# ----------------------------------------------------------
USBRULES=FortiusAntUsbAccess.rules
cat << EOF > $USBRULES
# Allow users in group usbtacx to access Tacx USB headunit
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0664", GROUP="usbtacx"
EOF
if [ ANT != NoAntFound ]; then
cat << EOF >> $USBRULES
# Allow users in group usbtacx to access ANTdongle
SUBSYSTEM==”tty”, ACTION==”add”, ATTRS{idProduct}==”$ANT”, ATTRS{idVendor}==”$VENDOR”, MODE=”0666”, GROUP=”usbtacx”
EOF
fi
sudo cp $USBRULES /etc/udev/rules.d/
rm $USBRULES
# ----------------------------------------------------------
# Verify
# ----------------------------------------------------------
#nano /etc/modprobe.d/$USBCONF
#nano /etc/udev/rules.d/$USBRULES
# ----------------------------------------------------------
# Create group and add user
# ----------------------------------------------------------
echo Create group usbtacx
sudo addgroup usbtacx
echo add user pi to this group
sudo adduser pi usbtacx
echo -----------------------------------------------------
echo Disable Standard Bluetooth and enable new HCI socket
echo -----------------------------------------------------
#sudo systemctl disable bluetooth
#sudo cp ~/FortiusAnt_Install/enable-bluetooth.service /etc/systemd/system
#sudo systemctl enable enable-bluetooth
#echo -----------------------------------------------------
#
Raspberry='\033[0;35m'
printf "${Raspberry} pi user is granted access to usb after reboot, press Enter to continue: "
read reply
# Reboot to activate rule
sudo reboot now