-
Notifications
You must be signed in to change notification settings - Fork 0
POC Setup
- An SD card, at least 8GB. (4GB was the previous minimum, but will not suffice for latest BTRFS file system beta versions of Kinisi endpoints).
- An installation of Raspbian (Debian Jessie)
- Either via the NOOBS setup (recommend 8GB or larger) OR
- Raw image (
ddor Win32DiskImager)
- A GPS dongle attached as /dev/ttyUSB0 (top USB port)
- A WiFi dongle (tested with Realtek chipset)
https://gist.github.com/sajacy/9086656
# Do everything as root
sudo suapt-get install gpsd
dpkg-reconfigure gpsd
# A wizard will prompt you:
# 1. Select Yes to start gpsd automatically.
# 2. Select No to automatically recognize GPS devices !!! IMPORTANT !!!
# 3. Enter "/dev/ttyUSB0" as the device to use
# 4. Leave blank the options to GPSD
# 5. Leave the default (/var/run/gpsd.sock)
# Restart
shutdown -r now
# Verify that gpsd is working:
nc localhost 2947
# You should see a status message, now type:
# ?WATCH={"enable":true,"json":true}You should see something like the following. The "class":"TPV" lines indicate that you are successfully receiving GPS data:
$ nc localhost 2947
{"class":"VERSION","release":"3.6","rev":"3.6","proto_major":3,"proto_minor":7}
?WATCH={"enable":true,"json":true}
{"class":"DEVICES","devices":[{"class":"DEVICE","path":"/dev/ttyUSB0","activated":"2014-03-07T06:10:56.955Z","native":0,"bps":9600,"parity":"N","stopbits":1,"cycle":1.00}]}
{"class":"WATCH","enable":true,"json":true,"nmea":false,"raw":0,"scaled":false,"timing":false}
{"class":"DEVICE","path":"/dev/ttyUSB0","activated":"2014-03-07T06:10:58.109Z","driver":"SiRF binary","native":1,"bps":4800,"parity":"N","stopbits":1,"cycle":1.00}
{"class":"TPV","tag":"MID2","device":"/dev/ttyUSB0","mode":3,"time":"2014-03-07T06:10:57.000Z","ept":0.005,"lat":40.651987984,"lon":-73.978259567,"alt":16.879,"track":100.5959,"speed":0.122,"climb":0.026}# Get back into sudo!
sudo su
# Download and extract
cd /usr/local
wget http://nodejs.org/dist/v0.10.24/node-v0.10.24-linux-arm-pi.tar.gz
tar xzf node-v0.10.24-linux-arm-pi.tar.gz
# Link binaries to directory in PATH
ln -s node-v0.10.24-linux-arm-pi nodejs
ln -s /usr/local/nodejs/bin/node /usr/local/bin/node
ln -s /usr/local/nodejs/bin/npm /usr/local/bin/npm
# Install forever:
npm install -g forever# Change to a reasonable directory
cd /usr/local/
# Choose one:
# 1. the Tarball method (only requires username/pw)
# 2. the Repo Clone method (requires Git Setup, below)
# 1. Tarball Method
$ curl -sL --user "{github_username}:{github_password}" https://github.com/kinisi/kinisi-agent-nodejs/archive/master.tar.gz > master.tar.gz
$ tar xzf master.tar.gz
$ mv kinisi-agent-nodejs-master kinisi-agent-nodejs
# 2. Repo Clone method
git clone [email protected]:kinisi/kinisi-agent-nodejs.git
# Now continue...
cd kinisi-agent-nodejs
# Install NPM dependencies.
# This will take a bit of time…
npm install
# Setup data directories (for configs, logs, and data points)
chmod -R 777 config
mkdir -p /var/log/kinisiagent/archive
mkdir -p /usr/local/kinisi-agent-nodejs/run/commit
# Install service
cp /usr/local/kinisi-agent-nodejs/scripts/kinisiagent /etc/init.d/kinisiagent
chmod 755 /etc/init.d/kinisiagent
update-rc.d kinisiagent defaults
# You may get a warning about ‘mathkernel’... that’s unrelated to us.
# Change the Auth Token
nano /usr/local/kinisi-agent-nodejs/config/auth.jsexport NODE_ENV=mock
pushd /usr/local/kinisi-agent-nodejs
node kinisi-agent.jsNotes: As long as it starts and doesn’t crash - the install worked. This should show the config, simulate GPSD data, simulate sync’ing, simulate network disconnects, and simulate reconfiguration. Very verbose. Ctrl^C to stop at any time.
service kinisiagent start
service kinisiagent status
tail -100f /var/log/kinisiagent/forever.log &Notes: This lets you verify that the service is installed. It should be sampling and uploading data at this point. This will run automatically as root upon startup.
sudo shutdown -r now
# After restart and login as pi
# This should show two processes,
# - the actual kinisi-agent.js process,
# - and the watchdog forever.js process
ps aux | grep node
# Check on the log
tail -20f /var/log/kinisiagent/forever.log &Notes: The ps check should return something similar to the below. First is the “forever” watchdog. Second is the Kinisi Agent process. The logs should show the startup config and “Connected to GPSD”.
pi@gpraspi ~ $ ps aux | grep node
root 2204 0.0 4.0 71048 19244 ? Ssl Feb23 0:08 /usr/local/node-v0.10.24-linux-arm-pi/bin/node /usr/local/lib/node_modules/forever/bin/monitor kinisi-agent.js
root 2224 0.6 8.5 86728 40892 ? Sl Feb23 2:12 /usr/local/node-v0.10.24-linux-arm-pi/bin/node /usr/local/kinisi-agent-nodejs/kinisi-agent.js
pi 2968 0.0 0.1 3544 808 pts/1 S+ 04:21 0:00 grep --color=auto node
You can turn on debug (verbose) logging in real-time by doing this:
# Turn on debug logging
echo '{ "debug": true }' > /usr/local/kinisi-agent-nodejs/config/runtime.json
# This should start spewing stuff now
tail -f /var/log/kinisiagent/forever.log &
# Turn off debug logging
echo '{ "debug": false }' > /usr/local/kinisi-agent-nodejs/config/runtime.jsonIf using a Mausberry power switch, you should install the setup script:
wget http://files.mausberrycircuits.com/setup.sh
sudo bash setup.sh
sudo rebootThis is only needed if installing via Git method.
Git should be installed by default on Raspbian. Just setup the SSH keys and config settings.
- https://help.github.com/articles/generating-ssh-keys
- https://help.github.com/articles/set-up-git#platform-linux
git config --global user.name “[firstname] [lastname]”
git config --global user.email “[email]”
git config --global credential.helper cache
ssh-keygen -t rsa -C “[deviceID]”
cat ~/.ssh/id_rsa.pub
# Copy the printout to the “Add New Key” UI at https://github.com/settings/ssh
# Now you should be able to clone the repo on the Pi# Setup the /dev/gps0 device
sudo cp kinisi-agent-nodejs/scripts/71-kinisi.rules /etc/udev/rules.d/.
dpkg-reconfigure gpsd
# A wizard will prompt you:
# 1. Select Yes to start gpsd automatically.
# 2. Select No to automatically recognize GPS devices !!! IMPORTANT !!!
# 3. Enter "/dev/gps0" as the device to use
# Setup the PPP internet connection dialer
sudo apt-get install wvdial
sudo cp kinisi-agent-nodejs/scripts/wvdial.conf
# Install a modern version of usb-modeswitch and usb-modeswitch-data
# It should be at least 2.2.0 and 20140529 which should be included by default now in raspbian
# http://archive.raspbian.org/raspbian/pool/main/u/usb-modeswitch/usb-modeswitch_2.2.0%2brepack0-1%2bb1_armhf.deb
# http://archive.raspbian.org/raspbian/pool/main/u/usb-modeswitch-data/usb-modeswitch-data_20140529-1_all.deb
sudo apt-get update
sudo apt-get install usb-modeswitch-data usb-modeswitch
# Install our Huawei modeswitch config
sudo cp kinisi-agent-nodejs/scripts/12d1\:14d1 /etc/usb_modeswitch.d/.
# Install service
cp /usr/local/kinisi-agent-nodejs/scripts/kinisiinternet /etc/init.d/kinisiinternet
chmod 755 /etc/init.d/kinisiinternet
update-rc.d kinisiinternet defaults
# Update the kinisiinternet script to choose the correct wvdial profile
# currently, bluevia is selected, but T-Mobile is also available
# Eventually, we'll want to use the kinisi-agent-nodejs/scripts/get_iccid.sh script to automatically determine the required APN for the given card (shouldn't there be a database out there ... maybe we can use Apple or Google's APN configuration settings that they are using.
sudo nano /etc/init.d/kinisiinternet