Project

General

Profile

Statistics
| Branch: | Revision:

gdp-if / i3mote / README.md @ master

History | View | Annotate | Download (10.7 KB)

GDP Software User Guide for TI i3mote sensors and BeagleBone Black Gateway

Prerequisites

  • BeagleBone Black hardware, connected to the Internet
  • Debian 8 operating system installed
  • DHCP server providing BeagleBone Black IP address assignment
  • Password-less sudo access by the "debian" user account

A New BeagleBone Black Setup Guide is appended to these instructions, with notes on setting up a BeagleBone Black from scratch.

Acquire and Compile Required Software

The BeagleBone will require GDP library, libcoap, the CoAP=>GDP gateway, and TI software.

Clone the main GDP repository:

$cd ~ && git clone https://repo.eecs.berkeley.edu/git-anon/projects/swarmlab/gdp.git

Install the necessary packages required for compilation:

$ cd ~/gdp/adm && sudo ./gdp-setup.sh

Compile and install the client side:

$ cd ~/gdp && make
$ cd ~/gdp && sudo make install-client install-python

Make sure that the default routers are setup appropriately:

$ sudo mkdir /etc/ep_adm_params
$ sudo bash -c "echo 'swarm.gdp.routers=gdp-01.eecs.berkeley.edu; gdp-02.eecs.berkeley.edu; gdp-03.eecs.berkeley.edu; gdp-04.eecs.berkeley.edu' >> /etc/ep_adm_params/gdp"

Clone the GDP-IF (or "GDP Interfaces") repository, which primarily consists of GDP applications and gateways. Certain setup scripts for some of the software will assume the location of this repository to be inside the gdp directory.

$ cd ~/gdp/ && git clone https://repo.eecs.berkeley.edu/git-anon/projects/swarmlab/gdp-if.git uhb

Acquire libcoap and compile it. Avoid building the documentation (--disable-documentation parameter), because it requires way too many dependencies for the limited disk space on a BeagleBone.

$ sudo apt install unzip
$ mkdir ~/libcoap
$ cd ~/libcoap && wget https://github.com/obgm/libcoap/archive/master.zip && unzip master.zip
$ cd ~/libcoap/libcoap-master && ./autogen.sh && ./configure --disable-documentation && make

Start collecting the necessary components a single directory:

$ cp -a ~/gdp/uhb/i3mote ~
$ cp -a ~/libcoap/libcoap-master/examples/coap-client ~/i3mote/arm-coap-client

Copy TI software to the Beaglebone. TI software must be installed at the following paths:

  • Gateway executable: /home/debian/gwapp.exe
  • Node.js web application directory (recursive copy advised): /home/debian/webapp

Verify that the ~/i3mote directory has the following files to confirm success in the above steps:

  • CoAP-gateway.py: This is the main wrapper script that (re)starts TI software and threads (one per physical sensor) for CoAP subscription and data publishing.
  • arm-coap-client: This is the CoAP client binary from libcoap used by the CoAP-gateway.py script.
  • gateway_control.sh: This is a shell script to start/stop the TI software (both gwapp.exe and app.js). The CoAP-gateway.py invokes this script for starting/restarting the TI code. The paths in this script should be updated if the TI software is not at the assumed location.
  • read_csv.py: This is a script to dump the logged data in a CSV format to a file.

Execution and Log Creation

If the Urban Heartbeat Kit software distribution was installed on this BeagleBone at some point, be sure to stop the gateway-server now:

$ sudo service gateway-server stop

If the root node and sensors are not yet physically cabled to the BeagleBone with power enabled, then shutdown the BeagleBone, connect a root node and one or more sensors with power enabled, and then power up the BeagleBone, as advised in the I3 Mesh User Guide.

Since a bug exists which can crash the network and require everything to be restarted, it is highly recommended that only gateway_control.sh be used for any process control; the following script invocation method saves the process-IDs appropriately and can terminate these processes. Therefore, presuming the TI software has not already been started by another method, select a site-unique __SITE_UNIQUE_LOG_PREFIX__ string for the following command specification, where the chosen prefix satisfies the bulleted notes listed below the command:

$ cd ~/i3mote && ./CoAP-gateway.py ./gateway_control.sh ./arm-coap-client __SITE_UNIQUE_LOG_PREFIX__
  • __SITE_UNIQUE_LOG_PREFIX__ is an installation specific string that will be used to derive log names. The log names to which individual sensor data is published are programmatically generated using the sensor EUI64 appended to this log name prefix. For example, with a prefix edu.berkeley.eecs.swarmlab.device and a sensor with EUI64 22-12-4b-00-0a-4a-b9-05, the software will automatically search GDP for a log named edu.berkeley.eecs.swarmlab.device.22124b000a4ab905.
  • Open a web browser session using the URL http://<BeagleBone_IP_address> to view the BeagleBone-hosted I3-Mesh web site. If only the root node is listed in the I3-Mesh list, power cycle the root node to trigger discovery of powered up sensors. Refresh the browser window occasionally to confirm sensor discovery.
  • The current setup does not automatically create logs. On the first execution, CoAP-gateway.py will throw a [Berkeley:Swarm-GDP:600] (shown below) error, but the script will also print the GDP log (<expected_log_name>) showing the log name it expects (also shown below), based on the prefix and the available EUI64's.
New nodes: [(3, u'00-12-4b-00-0c-29-99-01', u'2001:0db8:1234:ffff:0000:00ff:fe00:0003')]
>>> Node (00124b000c299901),
    IPV6 (2001:0db8:1234:ffff:0000:00ff:fe00:0003),
    tmpfile (/tmp/i3mesh-00124b000c299901),
    GDP log(edu.berkeley.eecs.swarmlab.device.00124b000c299901),
    Subscription statistics(/tmp/00124b000c299901-subscription_stats.log)
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "./CoAP-gateway.py", line 175, in __processing_thread
    __loghandle = gdp.GDP_GCL(gdp.GDP_NAME(self.logname), gdp.GDP_MODE_AO)
  File "/usr/local/lib/python2.7/dist-packages/gdp/GDP_GCL.py", line 116, in __new__
    check_EP_STAT(estat)
  File "/usr/local/lib/python2.7/dist-packages/gdp/MISC.py", line 173, in check_EP_STAT
    raise EP_STAT_SEV_ERROR(ep_stat)
EP_STAT_SEV_ERROR: 'ERROR: 600 no route available [Berkeley:Swarm-GDP:600]'
  • After collecting the necessary GDP log names, stop (control-c) the CoAP-gateway.py
  • To create GDP logs, run the following command for each GDP log name which was displayed in the previous step:
$ cd ~/i3mote/ && gcl-create -e none edu.berkeley.eecs.swarmlab.device.22124b000a4ab905

Note that it is important that gcl-create be executed from the correct directory. An auto-generated secret key is stored in the directory that can be later found by the CoAP-gateway.py during publishing. Such keys ought to be securely backed up.

  • Once the logs have been created manually, restart the CoAP-gateway.py process as shown above and leave it running.

Use of a tool like 'GNU screen' or 'byobu' is highly recommended for BeagleBone access using SSH.

GDP Log Files

There are a few log files that may be of interest:

  • /tmp/app.js.log and /tmp/gwapp.exe.log: Console log from the TI software
  • /tmp/app.js.pid and /tmp/gwapp.exe.pid: Process IDs of the TI software
  • /tmp/*-subscription_stats.log: A log of CoAP subscriptions to a given sensor, and the data received relative to the start of CoAP subscription.

New BeagleBone Black Setup Guide

New BeagleBone Black Hardware Setup

  • Flash the Debian 8 image to the SD card, and then to internal flash storage. > * See instructions on the beagleboard.org and related links. > * If the only available SD image does not flash eMMC as part of the SD boot process, an alternative eMMC flash method is to boot from SD, ssh into BeagleBone Black via ethernet (DHCP server required), and execute the proper flasher script interactively. For example:
user@otherhost$ ssh debian@<dhcp_IP_address_assignment>  (login banner displays password)
$ grep init-eMMC-flasher /boot/uEnv.txt
#cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh
$ cd /opt/scripts/tools/eMMC/
$ sudo ./init-eMMC-flasher-v3.sh
  • Change default "debian" user's password.
  • Verify that password-less root login is now disabled.
  • Verify that password-less sudo access from debian user is functional

After completing the above hardware setup, go do the steps described in the Acquire and Compile Required Software section of the GDP Software Users Guide, and then return to this section to perform the following steps:

Stop and disable a few default services to free up the web server standard port:

$ sudo systemctl disable bonescript.service bonescript-autorun.service bonescript.socket
$ sudo systemctl stop bonescript.service bonescript-autorun.service bonescript.socket
$ sudo systemctl disable cloud9.service cloud9.socket
$ sudo systemctl stop cloud9.service cloud9.socket
$ sudo systemctl disable node-red.service node-red.socket
$ sudo systemctl stop node-red.service node-red.socket
$ sudo systemctl disable lighttpd.service
$ sudo systemctl stop lighttpd.service

Then proceed to the Execution and Log Creation section of the GDP Software Users Guide, being sure to review the System Administration Tips section below, after installation is complete.

System Administration Tips

The BeagleBone Black eMMC will be somewhat tight on working space as configured:

$ df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/mmcblk1p1  3.5G  3.0G  259M  93% /

Consider adjusting /etc/logrotate.conf to rotate "daily" rather than "weekly" or reduce the weekly rotate count from the default 4 to something less, to avoid running out of space when a month's worth of system and daemon logs accumulate. If this was not done at first, space may be consumed by syslog and daemon logs, such that it may be necessary to rotate the syslog and daemon logs followed by deletion to regain space.

Consider pruning the following software directories to gain space, depending upon need:

$ sudo -i
[sudo] password for debian:
# pwd
/root
# df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/mmcblk1p1  3.5G  3.0G  259M  93% /
# rm -rf /root/.c9
# rm -rf /root/.node-red
# rm -rf /opt/cloud9
# rm -rf /opt/ti-llvm-3.6
# rm -rf /opt/source/adafruit-beaglebone-io-python
# rm -rf /opt/source/BB*
# rm -rf /opt/source/bb*
# rm -rf /opt/source/beagle-tester
# rm -rf /opt/source/dtb*
# rm -rf /opt/source/fb-test-app
# rm -rf /opt/source/prufh
# rm -rf /opt/source/Userspace-Arduino
# df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/mmcblk1p1  3.5G  2.6G  727M  79% /
# exit