Skip to content

Latest commit

 

History

History
89 lines (65 loc) · 3.2 KB

README.md

File metadata and controls

89 lines (65 loc) · 3.2 KB

riot-saul-coap

This application offers saul data via coap.

Available resources

There are multiple ways supported to receive data from / about sensors.

Resource by sensor type

  • /temp to retrieve the temperature (GET)
  • /hum to retrieve the humidity (GET)

These resources offer a quick path, to fetch sensor data by type. They return the values of the first sensor of the requested type; multiple sensors of the same type are ignored. More sensor types need to be manually added to the code base. These paths can be used without knowledge about the RIOT-intern type representation.

Returns phydat_t as CBOR; see below for more info.

/sensor

The /sensor resource is reachable with an GET request. As payload it needs the ID of a saul sensor type (as they are defined in drivers/include/saul.h). GET command has parameter of a 3-digit decimal number to specify sensor type. The query parameter is class. It will return the values of the first sensor of the requested sensor type. All sensor types will work out of the box. However, the systems calling this resource, need information about the RIOT-intern saul type IDs. This could be used by other RIOT powered boards.

Returns phydat_t as CBOR; see below for more info.

/saul/cnt and /saul/dev (incomplete)

The idea of these resources is, to offer similar functionality as the saul shell command via a CoAP interface.

  • /saul/cnt (GET) returns the number of devices, that are connected to the board. This can be used to know, what IDs can be used to request information about connected sensors.
  • /saul/dev (POST) needs an ID as argument. Returns some information about the sensor for that ID (name and type).

Phydat in Concise Binary Object Representation (CBOR)

In all resources by sensor type, we return the phydat_t struct in the CBOR data format. In the following code block, you can see a CBOR example of what could be returned for a temperature sensor:

A3                 # map(3)
   66              # text(6)
      76616C756573 # "values"
   81              # array(1)
      19 0959      # unsigned(2393)
   64              # text(4)
      756E6974     # "unit"
   02              # unsigned(2)
   65              # text(5)
      7363616C65   # "scale"
   21              # negative(1)

If you want to use this resource, you can parse it to JSON. The example above translates to the following JSON object:

{"values": [2393], "unit": 2, "scale": -2}

Please see the list of CBOR implementations if you want to use this resource. The documentation of the phydat_t struct explains, how these values have to be interpreted.

Build and Execute

Enter shell with board command (Phytec)

SERIAL=... BOARD=pba-d-01-kw2x BUILD_IN_DOCKER=1 make all flash term

To distinguish multiple boards using SERIAL number

make list-ttys