rosio: opensensors.io in RThe
rosiopackage is in very early development. It will be updated regularly and current functionality is very likely to evolve. Enjoy at your own risks!
We have a set of devices that publish information to a specific topic. The topic essentially contains all the raw data packets that are sent by the device(s) that publish with it. Not all that data is usable. A dataset is the cleaned/usable subset of a topic, and multiple datasets form a project.
Devices, topcis, datasets and projects are set up by users, that can belong to organisations. As a user, you will have an identifier and a unique API key.
Let's get started
library("rosio")
Data is accessed through datasets, which are instantiated as dataset
objects. The data is then retrieved using the messages
function. Similarly, devices are created with the device function
and data is retrieved with the messages function.
We are going to explore publicly available topics/datasets here. To access your own private devices, topics, ... you will need a valid username and API key (or, alternatively, JWT).
This is handled by the Rosio class, that stores the user's username,
password, API key and JWT token, or any subset thereof. For example,
to create the Rosio objet matching user rosio with API key
authentication method.
(usr <- Rosio("rosio", key = "e770424c-e62f-49ff-adf1-2f72c49a3c89"))
The username, password, key and jwt functions can be used to
access and replace the different fields.
If a password is provided, the getJWttoken function can be used to
add a JWT token to the user object. In case of doubt, users can ask
themselves
whoami(usr)
Let's have a look at dataset number 77.
(kw <- dataset(77))
As it is public, we won't need any authentical method and thus can ignore pasing any user information when querying for the data (messages) from that dataset. Below, we ask for the messages published during the last hour.
messages(kw, duration = 3600)
To get a user's devices
devices(usr)
(dev <- device(5424))
messages(dev, usr, start.date = "2016-11-14")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.