TI Sensor Tags v2¶
The code to manage the second generation TI sensor tags is still in flux and incomplete. These instructions are a stop-gap.
WARNING: These instructions are in progress and have not been tested.
These instructions are only for the BBB. Since we don't have source for the TI-provided code it is unlikely that it can run on a SwarmBox.
Every gateway also requires a special mote to act as the root of the network mesh. This must have special code flashed and be connected to the gateway via USB.
The following packages must be installed on the gateway host before these instructions can be completed:
From standard packages (i.e.,
apt install ...):
From other places:
- gdp-client (not available in standard repositories)
Getting the TI Code¶
The TI code is not open source and hence is not in the repo. Ken is the keeper of the code.
Installing the Code¶
Before installing the TI code, make sure you have the GDP client package installed on your host. See the GDP project site for more information. Note that you will not need the server package.
Currently the only platform supported is the BBB, and (for better or for worse) the code is installed in (and run from) the
debian home directory. Right now this appears fairly haphazard, with different gateway hosts configured differently. I'm going to assume the following directory structure:
~debian └─ i3 — you should create this if you want to keep ~debian clean ├─ i3mote — this is from our git repository │ └─ libcoap — see below └─ ti — this is the code from TI, which you get from Ken. └─ webapp — the web application and network coordinator from TI
i3mote directory is a copy of the
i3mote directory in the
There are also an example program from
libcoap that must be installed in
libcoap/examples/client.c, which should be installed in
sudo apt install autoconf automake libtool cd i3/i3mote git clone --depth 1 https://github.com/obgm/libcoap.git cd libcoap ./autogen.sh ./configure --disable-examples make make install
NOTE: THIS DOES NOT WORK. We need examples because they have
coap-client, which is what Nitesh uses to get access to the data. But if you make the examples (i.e., omit the
--disable-examples flag on the
configure line) then we also have to install
asciidoc, which pulls in a huge number of packages including
tk — and there simply isn't enough room on the 4GB disk built into a BBB.
TODO: show details
Starting up the Gateway¶
This is in two steps: starting up the TI gateway code and starting the CoAP to GDP server.
Starting the TI code¶
cd ~debian/i3_workshop/bin sudo ./gwapp.exe -s /dev/ttyACM0 &
gwapp.exe program runs in foreground and produces output (check this), so you may want to redirect the output to a file. Be aware that the BBB disk is very small, so keeping this output is likely to fill up your disk very quickly.
cd webapp sudo node app.js
This application also produces output, so the same comments apply as for
gwapp.exe. Check this.
At this point you should be able to point a browser at
/ to see a display of the motes that have joined the network. Node 1 is the network root. Assuming you have other motes installed and running you'll see other motes as well. If you only have one node in the network, you should probably fix that before continuing.
Provision sensors (motes)¶
Each mote must have a GDP log created for it; they are not auto-created. The logs are named with a prefix that you specify (see below) and the "EUI" (unique identifier) for each mote. These will be displayed in the web browser window you saw above. The secret keys for the logs should ended up in
~debian/i3mote. This step should only be done once, although you may have to do it again if you add more motes to your network. The variable
$logprefix generally indicate the location of the motes, for example,
edu.berkeley.eecs.swarmlab.device. The EUIs you enter below in the 〈list of mote EUIs〉 should be listed in lower case and without hyphens; for example, use
cd ~debian/i3mote $logprefix=<prefix for logs> for eui in <list of mote EUIs>; do gcl-create -e none $logprefix.$eui done
Start the CoAP to GDP gateway¶
At this point you can start the actual gateway (this assumes that
$logprefix is set to the same prefix (including
.device at the end) as shown above:
# set to your local log prefix: logprefix=edu.berkeley.eecs.swarmlab.device cd ~debian/i3mote ./restart_wrapper ./CoAP-gateway.py ~debian/i3mote/arm-coap-client $logprefix
restart-wrapper will restart
CoAP-gateway.py every 20 minutes. This is a temporary hack so that the system recovers from issues such as mote failures.
CoAP-gateway.py will find the EUIs of all the attached motes and start logging them.
If logs do not already exist for some of the devices you'll get an erro rmessage that looks something like this:
>>> Node (00124b000a630206), IPV6 (2001:0db8:1234:ffff:0000:00ff:fe00:0007), tmpfile (/var/tmp/debian.tmp/i3mesh-00124b000a630206), log(edu.berkeley.eecs.swarmlab.device.00124b000a630206) Traceback (most recent call last): File "./CoAP-gateway.py", line 220, in <module> main(sys.argv, sys.argv) File "./CoAP-gateway.py", line 204, in main node = Node(n['eui64'], n['address'], prefix) File "./CoAP-gateway.py", line 64, in __init__ self.g = gdp.GDP_GCL(gdp.GDP_NAME(self.logname), gdp.GDP_MODE_AO) File "/usr/lib/python2.7/dist-packages/gdp/GDP_GCL.py", line 116, in __new__ check_EP_STAT(estat) File "/usr/lib/python2.7/dist-packages/gdp/MISC.py", line 173, in check_EP_STAT raise EP_STAT_SEV_ERROR(ep_stat) gdp.MISC.EP_STAT_SEV_ERROR: 'ERROR: 600 no route available [Berkeley:Swarm-GDP:600]'
To fix this you will need to create the log by hand. First use control-C (
^C) to exit from the script. Then, from the
# logname is the name of the log to be created logname=edu.berkeley.eecs.swarmlab.device.00124b000a630206 # -e none means no encryption on the secret key gcl-create -e none $logname
You may also need a
-s flag to specify the name of the log server on which to host the log. If you do not it will randomly pick one of the public log servers at Berkeley. The secret key will be written to a
.pem file in the
KEYS subdirectory. You can then try again. You may have to do this several times if there are multiple logs to be created. Once it stops giving errors, you'll probably want to kill it and restart it one more time, redirecting the output to a log file (it is quite chatty) and putting it in background:
./restart_wrapper ./CoAP-gateway.py ~debian/i3mote/arm-coap-client $logprefix | logger -t coap-gdp-gateway -p user.info &
logger command will write the output to the system logger tagging each line with
coap-gdp-gateway and using the
user facility and priority
info. You may prefer to log the output in different ways or to different facilities.)
Note: if you add motes you must restart
CoAP-gateway.py (or wait 20 minutes for
restart-wrapper to do it for you).
The current version of the TI software that we have is still a bit sensitive. Things must be done in precise order and any failure usually requires a restart.