This example acts as a gateway between COSM and XBee modules.

It sends to COSM any received data (it expects doubles as data) in order to update the value of a feed/datastream.

It is actually provided with two different strategies: either using COSM WebSockets API or using the HTTP API. The WebSockets is a nice way to do this, but proves to be quite unstable on COSM side, hence the provided HTTP version.

Build

First make sure you have built the project. Next, if you have a look at the examples/cosm/target/appassembler directory, you will find a complete distribution of the example.

Configure

A few settings are required in order to get the gateway to run properly. If you launch xbee-cosm with no arguments, the usage will be displayed.

Here is below a list of the parameters:

CLI arg Description
-b Bauds (optional, by default 9600)
-api COSM API Key
-f COSM Feed ID
-d COSM datastream ID (0 usually if you only 1 datastream in your feed)
-ws Switch to WebSockets API (optional, by default use HTTP API unfortunately the WS API is quite unreliable on COSM side)
serial port Serial port to use: one Windows something like COM3, on Unix machines something like /dev/tty.usbmodem123

Run

Depending on your OS you either need to run sh bin/xbee-cosm or bin\xbee-cosm.bat. Do not forget to read the next section as there are some required CLI parameters for this example to work.

If the WebSockets API does not work, use instead of HTTP API.

Suggestions

Thinks twice about how often you need to push data from a sensor to this COSM gateway.

For example sending temperature every 5 seconds does not make sense most of the time.

Back to top

Version: 0.1. Last Published: 2013-01-23.