forked from deepcoder/bluetooth-temperature-sensors
-
Notifications
You must be signed in to change notification settings - Fork 0
/
detailed-build-instructions.txt
157 lines (119 loc) · 3.19 KB
/
detailed-build-instructions.txt
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
build rapsberry pi ble to mqtt
202012161409
sudo dd bs=1m if=2020-08-20-raspios-buster-armhf-full.img of=/dev/rdisk6 conv=sync
touch /Volumes/boot/ssh
vi /Volumes/boot/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
network={
ssid="xxx"
psk="yyy"
key_mgmt=WPA-PSK
}
diskutil eject /dev/disk6
boot the pi
find on network
sudo raspi-config
# wait for network
# consistent network names
edit /etc/dhcpcd.conf
interface eth0
static ip_address=192.168.x.y/24
static routers=192.168.x.x
static domain_name_servers=1.1.1.1
interface enxb827ebczzzzz
static ip_address=192.168.x.y/24
static routers=192.168.x.x
static domain_name_servers=1.1.1.1
removed /etc/wpa_supplicant.conf
sudo apt-get update
sudo apt-get full-upgrade
reboot
sudo apt-get install tmux
fix login warning:
/etc/profile.d/sshpwd.sh
/etc/xdg/lxsession/LXDE-pi/sshpwd.sh
mkdir ~/.ssh
cat .ssh/id_rsa.pub | ssh [email protected] 'cat >> .ssh/authorized_keys'
create .vimrc for pi and root
sudo mkdir /media/pi
sudo mkdir /media/pi/nas
vi /home/pi/.NASCREDS
user=xxx
password=yyy
in /etc/fstab
//192.168.x.y/nas /media/pi/nas cifs credentials=/home/pi/.NASCREDS,uid=pi,gid=pi,vers=1.0,comment=x-systemd.automount 0 0
# test it
sudo mount -a
mkdir ~/ble-sensors
cd ~/ble-sensors
git clone https://github.com/deepcoder/bluetooth-temperature-sensors.git
sudo apt-get install libbluetooth-dev
git clone https://github.com/eclipse/paho.mqtt.c.git
cd paho.mqtt.c
make
sudo make install
cd ..
cd bluetooth-temperature-sensors
gcc -o ble_sensor_mqtt_pub ble_sensor_mqtt_pub.c -lbluetooth -l paho-mqtt3c
cp ble_sensor_mqtt_pub ..
cd ..
create ble_sensor_mqtt_pub.csv
create hack_ble.sh
=====
#!/bin/bash
trap "echo Exited!; exit;" SIGINT SIGTERM
if [ $EUID -ne 0 ]; then
echo "This script should be run as root." > /dev/stderr
exit 1
fi
while :
do
echo 'Running ble_sensor_mqtt_pub'
date '+%Y%m%d%H%M%S'
echo "Press [CTRL+C] to stop.."
cd /home/pi/ble-sensors
/home/pi/ble-sensors/ble_sensor_mqtt_pub 0 1 200 500
done
=====
chmod +x hack_ble.sh
sudo vi /etc/rc.local
=====
#!/bin/bash
########!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
# wait for networks to start
STATE="error";
while [ $STATE == "error" ]; do
#do a ping and check that its not a default message or change to grep for something else
STATE=$(ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null && echo ok || echo error)
#sleep for 2 seconds and try again
sleep 2
done
su pi -c 'tmux new-session -d -s ble'
su pi -c 'tmux send-keys sudo Space /home/pi/ble-sensors/hack_ble.sh C-m'
exit 0
=====
hciconfig
hci0: Type: Primary Bus: UART
BD Address: cc:bb:aa:zz:yy:xx ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING
RX bytes:1476 acl:0 sco:0 events:90 errors:0
TX bytes:3274 acl:0 sco:0 commands:90 errors:0
tmux attach -t ble