Skip to content
Daniel Lázaro edited this page Feb 7, 2019 · 3 revisions

= TinyOS Wrapper (tinyos-mig) =

The TinyOS wrapper can receive data from both version 1.x and 2.x TinyOS based networks. This wrapper can interract with any TinyOS compatible Base Station and any type of TinyOS Packet Source. For instance The TinyOS wrapper can interact with the serial forwarder (provided by TinyOS distribution) which inturn presents a sensor network. In order to use the TinyOS wrapper with a sensor network you need to first generate the java representation of the message structures used in the network (in TinyOS they are defined in the .h files). NesC language provides a tool called mig (message interface generator for nesC) for this purpose. The tool has a standard man page documentation in addition to being described in the lession 4 of the TinyOS 2 tutorial (further informations can be found at http://www.tinyos.net/tinyos-1.x/doc/nesc/mig.html, http://www.tinyos.net/tinyos-2.x/doc/html/tutorial/lesson4.html and http://www.tinyos.net/tinyos-1.x/doc/tutorial/lesson6.html).

Both TinyOS 1.x and 2.x are using very same package structures and class names which generates conflict when you have both TinyOS1.x and 2.x jar files in your classpath (which is the case for GSN). To solve this issue, gsn provides a slightly modified version of the TinyOS 1.x java tools by renaming the net.tinyos.xxx package to net.tinyos1x.xxx. Thus the messages classes generated with MIG must be configured depending on the version of TinyOS your are using. The following table shows the class that your MIG generated messages must extend (directly or not directly).

TinyOS version Must extends
1.x net.tinyos1x.message.Message
2.x net.tinyos.message.Message

Parameters:

  • source is a mandatory parameter which specifies the TinyOS data source (eg. sf@serial.forwarder.url:9001).
  • message-classname is a mandatory parameter which specifies the full package path to the message class generated by MIG (e.g., ch.ethz.permafrozer.DozerDataMsg).
  • message-length is an integer, defaulted to 29. This parameter is useful for overriding the default size of the received messages.
  • getter-prefix is defaulted to ''get_'' and indicates that the methods of the message class that contain this prefix will be added in the output structure. Keep the default value for the messages generated with MIG.

This wrapper infers the output structure from the methods names contained into the MIG generated message class and the super classes. To filter these methods, this wrapper applies a prefix pattern matching on the methods names (hence the ''getter-prefix'' parameter).

The mapping between the TinyOS types and the types to use in your virtual sensor are shown below:

nesC Java GSN Remarks
nx_int8_t byte TINYINT 8-bit signed
nx_uint8_t short SMALLINT 8-bit unsigned
nx_int16_t short SMALLINT 16-bit signed
nx_uint16_t int INTEGER 16-bit unsigned
nx_int32_t int INTEGER 32-bit signed
nx_uint32_t long BIGINT 32-bit unsigned
NOT SUPPORTED float DOUBLE 32-bit floating point number
NOT SUPPORTED double DOUBLE 64-bit floating point number
<source alias="Sensorscope" sampling-rate="1000" storage-size="1">
  <address wrapper="tinyos-mig">
    <predicate key="source">sf@lcavsrv6.epfl.ch:20100</predicate>
    <predicate key="message-classname">gsn.wrappers.tinyos2x.sensorscope</predicate>
    <predicate key="path">/Users/ristohietala/NetBeansProjects/gsn/trunk/src/gsn/wrappers/tinyos2x/</predicate>
  </address>
<query>
select NTWSENDERID,NTWDISTTOBS,TSPHOPCOUNT,TSPPACKETSN,REPORTERID,TIMESTAMP,RAINMETER,WINDSPEED,WATERMARK,SOLARRADIATION,AIRTEMPERATURE,
AIRHUMIDITY,SKINTEMPERATURE,SOILMOISTURE,WINDDIRECTION,FOO from wrapper
</query>
Clone this wiki locally