Sampl-sensor-andrew

Version 11 (Anthony Rowe, 08/11/2009 10:18 pm)

1 1 Anthony Rowe
2 11 Anthony Rowe
3 11 Anthony Rowe
h2. SAMPL Sensor Andrew
4 11 Anthony Rowe
5 9 Anthony Rowe
Before you begin, make sure that you have a Sensor Andrew JID and password that the gateway client can login as and use to run the subnet.  Make sure that the subnet part of the MAC addresses you are using are unique.  The gateway JID will automatically create event nodes if they don't already exist and publish data to them.  If these nodes already exist, make sure that the gateway JID has publish permissions for them. In order for Sensor Andrew to log data, you must obtain a unique registry ID from the Sensor Andrew database registry.  
6 9 Anthony Rowe
7 1 Anthony Rowe
To compile SAMPL with Sensor Andrew support, you must include the SOX (Sensor Over XMPP) library.  This can be found here:
8 1 Anthony Rowe
svn checkout svn://sensor.andrew.cmu.edu:/srv/svn/repos/sensor-andrew
9 1 Anthony Rowe
10 11 Anthony Rowe
*Step 1: Install Loudmouth*
11 11 Anthony Rowe
* Install: glib2, expat, gnutls 
12 11 Anthony Rowe
<pre>
13 1 Anthony Rowe
   cd sensor-andrew/sox/libs/loudmouth
14 1 Anthony Rowe
    ./configure
15 1 Anthony Rowe
    make
16 1 Anthony Rowe
    sudo make install
17 11 Anthony Rowe
</pre>
18 1 Anthony Rowe
19 1 Anthony Rowe
20 11 Anthony Rowe
*Step 2: Install C Sox Library*
21 11 Anthony Rowe
* Double check the path of GLIB, GNUTLS, LOUDMOUTH etc in vars.mk
22 11 Anthony Rowe
** This may work fine with the default values
23 11 Anthony Rowe
<pre>
24 1 Anthony Rowe
    cd sensor-andrew/sox/libs/lib_c
25 1 Anthony Rowe
    make
26 1 Anthony Rowe
    sudo make install
27 11 Anthony Rowe
</pre>
28 1 Anthony Rowe
29 1 Anthony Rowe
30 11 Anthony Rowe
*Step 3: Build [[FireFly]] sox-gateway*
31 11 Anthony Rowe
* In this step build "gateway_client" which will be used to communicate to the SLIPstream server and then in turn to the [[FireFly]] gateway node
32 11 Anthony Rowe
* edit makefile to correctly set XMPP_LIBRARY_PATH to sox/libs/lib_c
33 11 Anthony Rowe
<pre>
34 1 Anthony Rowe
    cd nano-RK/projects/SAMPL/slip-clients/sox-gateway
35 1 Anthony Rowe
    make
36 11 Anthony Rowe
</pre>
37 4 Anthony Rowe
38 1 Anthony Rowe
39 11 Anthony Rowe
*Step 4: Flash [[FireFly]] nodes*
40 11 Anthony Rowe
* First Program the nodes
41 11 Anthony Rowe
<pre>
42 1 Anthony Rowe
    cd nano-RK/projects/SAMPL/clients/FF-basic-sensors
43 2 Anthony Rowe
    make clean
44 2 Anthony Rowe
    make program
45 11 Anthony Rowe
</pre>
46 11 Anthony Rowe
* You will see a red blinking led and the following messages from the serial port:
47 11 Anthony Rowe
<pre>
48 1 Anthony Rowe
* ERROR reading MAC address from EEPROM run eeprom-config utility
49 1 Anthony Rowe
* ERROR reading MAC address from EEPROM run eeprom-config utility
50 1 Anthony Rowe
* ERROR reading MAC address from EEPROM run eeprom-config utility
51 11 Anthony Rowe
</pre>
52 11 Anthony Rowe
* Next, set the EEPROM values
53 11 Anthony Rowe
** MAC Address
54 11 Anthony Rowe
** Subnet MAC
55 11 Anthony Rowe
** Encryption Key (optional)
56 11 Anthony Rowe
** Wireless Update image file (optional)
57 11 Anthony Rowe
* Note the following with respect to the MAC address:
58 11 Anthony Rowe
** The first six hex digits in the MAC address denote the subnet 
59 11 Anthony Rowe
** All nodes must be part of the same subnet to communicate
60 11 Anthony Rowe
** The gateway node must be set to 0 inside a subnet
61 11 Anthony Rowe
** No other node besides the gateway can be 0
62 11 Anthony Rowe
* Use the config-eeprom tool to set the EEPROM
63 11 Anthony Rowe
<pre>
64 1 Anthony Rowe
cd nano-RK/tools/EEPROM_mac_set
65 1 Anthony Rowe
make (if not already built)
66 4 Anthony Rowe
./config-eeprom /dev/ttyUSB1 00000001 26 00112233445566778899AABBCCDDEEFF
67 11 Anthony Rowe
</pre>
68 1 Anthony Rowe
69 11 Anthony Rowe
*Step 5: Flash [[FireFly]] gateway*
70 11 Anthony Rowe
* Flash the gateway node that will be connected to the gateway computer
71 11 Anthony Rowe
<pre>
72 3 Anthony Rowe
cd nano-RK/projects/SAMPL/gateway
73 3 Anthony Rowe
make clean
74 5 Anthony Rowe
make program
75 11 Anthony Rowe
</pre>
76 11 Anthony Rowe
* Set the EEPROM like any other [[FireFly]] client except with the last two hex digits being '00'
77 11 Anthony Rowe
<pre>
78 2 Anthony Rowe
cd nano-RK/tools/EEPROM_mac_set
79 6 Anthony Rowe
./config-eeprom /dev/ttyUSB1 00000000 26 00112233445566778899AABBCCDDEEFF
80 11 Anthony Rowe
</pre>
81 6 Anthony Rowe
82 11 Anthony Rowe
*Step 6: Run the SLIPstream Server*
83 11 Anthony Rowe
* The SLIPstream server forwards messages from the gateway_client to and from the gateway firefly node
84 11 Anthony Rowe
* Connect the gateway node and run the server as follows
85 11 Anthony Rowe
<pre>
86 6 Anthony Rowe
cd /nano-RK/tools/SLIPstream/SLIPstream-server
87 6 Anthony Rowe
make
88 6 Anthony Rowe
./SLIPstream /dev/ttyUSB0 5000 
89 11 Anthony Rowe
</pre>
90 11 Anthony Rowe
* Reset the gateway node and you should see something similar to the following on the SLIPstream server
91 11 Anthony Rowe
<pre>
92 6 Anthony Rowe
Netmask = 0x0 0 0
93 6 Anthony Rowe
MAC = 0x0
94 6 Anthony Rowe
Channel = 26
95 6 Anthony Rowe
slip_init()
96 6 Anthony Rowe
bmac_started()
97 6 Anthony Rowe
Waiting for SLIP data...
98 11 Anthony Rowe
</pre>
99 6 Anthony Rowe
100 11 Anthony Rowe
*Step 7: Run the sox-gateway*
101 11 Anthony Rowe
* The sox-gateway will handle requests to the sensor network and arbitrate communication with sensor andrew
102 11 Anthony Rowe
* Edit the following files in "configs" directory before starting
103 11 Anthony Rowe
** pkt-script.xml
104 11 Anthony Rowe
*** This is an XML file describing the default operation of the network.  Sensor polling times and scripts can be configured here.
105 11 Anthony Rowe
** ff_basic_sensor_cal.txt
106 11 Anthony Rowe
*** This file contains sensor calibration information for each [[FireFly]] environmental node in the subnet
107 11 Anthony Rowe
** jiga_watt_cal.txt
108 11 Anthony Rowe
*** This file contains [[JigaWatt]] calibration information for each [[JigaWatt]] FireFly sensor board
109 11 Anthony Rowe
** xmpp-config.txt
110 11 Anthony Rowe
*** This file contains the XMPP configuration used to set the gateway's Sensor Andrew JID and password.  This is not required unless XMPP support is enabled.
111 11 Anthony Rowe
** registry.txt
112 11 Anthony Rowe
*** This file contains the Sensor Andrew registry ID values that should be sent with each XMPP message for database logging. This is not required unless XMPP support is enabled. This is only required for XMPP support.
113 11 Anthony Rowe
** subscribe-nodes.txt
114 11 Anthony Rowe
*** This file should contain the event-nodes of any devices that require external actuation.  The gateway will subscribe to these nodes so that it receives any incoming actuation commands or configuration messages.
115 11 Anthony Rowe
* To test the new subnet, run the gateway_client without connecting to Sensor Andrew follows
116 11 Anthony Rowe
<pre>
117 7 Anthony Rowe
cd nano-RK/projects/SAMPL/slip-clients/sox-gateway
118 7 Anthony Rowe
./gateway_client localhost 5000 -verbose -no_xmpp
119 11 Anthony Rowe
</pre>
120 11 Anthony Rowe
* After running the gateway, you should see data coming back from each node.
121 11 Anthony Rowe
* Now try running the node so that it publishes this data to Sensor Andrew.  This requires that you configure the XMPP specific files
122 11 Anthony Rowe
<pre>
123 6 Anthony Rowe
./gateway_client localhost 5000 -slipstream_mirror 5001 localhost
124 11 Anthony Rowe
</pre>
125 1 Anthony Rowe
126 1 Anthony Rowe
127 1 Anthony Rowe