Locate trains with wifi data
- Download the resinOS from the Resin Dashboard (application:
traintraintrain) - Using a disk-imaging editor like WinImage, add
config.txtto/resin-boot(partition 0). Also addcellularto/resin-boot/system-connections. These configuration files are found inresinos_config/. Remember to save the image.
You may skip these steps by downloading the preconfigured image here.
- Use an image flasher like Etcher to flash the image.
- Insert the microSD card into the Rpi and connect an ethernet cable which provides an internet connection.
- During the first bootup, resinOS will connect to resin.io servers and register the device to the
traintraintrainapplication. - Resin.io will deploy the docker image to the device.
- Test and ensure that the app is successfully running on the device.
- Switch the device off and disconnect the ethernet cable. Connect the GSM dongle.
Internet connection via ethernet cable is preferred as the initial deployment will fetch the entire docker image which can be large. Subsequent deployments fetches only the new docker image layers.
Repeat steps for all the Rpis needed to be setup.
This is an automated step done by Travis whenever a PR is merged into the master branch.
Symptoms of a problematic resin supervisor:
- You cannot reach your resin device via the resin APIs/dashboard (e.g. reboot or restart)
- Resin.io does not push a new release to your device
- No logs shown on the resin device dashboard
The issue is described in detail here: https://forums.resin.io/t/no-logs-found-error/2917/4?u=chrissng
From the resin device's host OS,
cd /resin-data/resin-supervisor
mv database.sqlite database.sqlite.bak # or to something else if it exists
balena restart resin_supervisorThis assumes Raspbian (host OS) is installed.
- Using
raspi-config, set Locale to en-US UTF-8, use the US keyboard, and use Singapore time zone - Disable wlan soft block and power save (see HOW-TOs below)
git clone git@github.com:datagovsg/mrt-location.gitCredentials are stored in scrape/mrtScanner/config.ini.
Configure the credentials according to the following the template:
[default]
train_id = < unique_train_device_id >
[firebase]
[aws]
region_name = < aws_region_name >
aws_secret_access_key = < aws_secret_access_key >
aws_access_key_id = < aws_access_key_id >
curl -sSL https://get.docker.com | sh
sudo docker build -t traintraintrain .
sudo docker run --net=host --privileged --restart=always --name=ttt -d --env-file=env.list traintraintrainFollow the docker setup steps in the previous section
To make development easy without having to rebuild the image every time scripts are modified.
sudo docker run ... --volume scrape:/mrt:ro ...We recommend virtualenv. For instructions: http://www.pythonforbeginners.com/basics/how-to-use-python-virtualenv
git clone git@github.com:datagovsg/mrt-location.git
cd mrt-location
virtualenv -p python2 env
source env/bin/activate
pip install -r requirements.txt
python scrapeMac.py
- Add
country=SGas the first line in/etc/wpa_supplicant/wpa_supplicant.conf - Add
iwconfig wlan0 power offin/etc/rc.local
https://github.com/seemoo-lab/nexmon
https://nicovddussen.wordpress.com/2014/11/12/setting-up-your-raspberry-pi-to-work-with-a-3g-dongle/ https://www.thefanclub.co.za/how-to/how-setup-usb-3g-modem-raspberry-pi-using-usbmodeswitch-and-wvdial
Create an empty file named ssh in the /boot directory on the Pi. This only needs to be done once.
sudo touch /boot/sshThe script in /etc/rc.local script has been modified to include the following
- Add monitoring mode to the wireless adapter
- Run
python scrapePi.py
- The
&on the second last lime is required to prevent the pi from hanging
#
# 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
sudo su
iw phy phy0 interface add mon0 type monitor
ifconfig mon0 up
cd /home/pi/mrt-location/scrape/
python scrapePi.py &
exit 0