Welcome to m2m.io Customer Service and Support!

Stay updated with announcements, get answers from the community and share your feature suggestions with us.
You can also submit a request or send us an email at support@2lemetry.zendesk.com.

 
 

m2mio

2lemetry Support June 21, 2012 Q & A and Misc.

 

m2m.io information and examples

The following examples show how to use the m2m.io MQtt broker and the api's to retrieve that data.

Connecting to the broker

The first step is to acquire a username and password from http://help.m2m.io

Next using a compatible 3.1 MQtt client, configure the username and md5sum(password) for the client. You may use anything for the clientid. Every clientid will require a license for connecting to q.m2m.io. Licenses are automatically provisioned until your license limit is reached. The clientid may be prefixed with '<stuff>/'to automatically configure the client for this grouping. This is useful when retrieving information about your 'thing'. See Topic Namespace for further info on this.

Topic Namespace

In order for m2m.io to properly store your data this namespace pattern must be followed.

<domain>/<stuff>/<thing>

By default the topic namespace for an m2m.io client must start with their 'domain'. Domains are obtained during registration of a new user account. The next level of the namespace, 'stuff' is a logical grouping of related things. The third level of the namespace, 'thing' relates to the client's unique identifier.

If you don't follow our recommended namespace pattern messages will still be passed by the broker as long as you have rights to publish/subscribe on the given topic. Messages will not be stored if the topic space is different.

Payload

In order for m2m.io to store the payload data the client must send the data in standard json object form. Here is an multi nested object example:

{
  "report": {
    "gps": {
        "latitude": "39.702610038220882",
        "longitude": "-104.97231300920248"
        },
        "temp": {
        "celsius": "252",
        "fahrenheit": "76"
        }
    }
}

Using the m2m.io API

Use the m2m.io API to retrieve the client information and data that you have published over time.

API Url - http://api.m2m.io/1

These examples will use the curl command line tool to show how to get the date that was just published:

Get account info

curl --user user@m2m.io:xxxxxx http://api.m2m.io/1/account

{
    domain = "io.m2m";
    email = "user@m2m.io";
    key = "user@m2m.io";
    ok = 1;
    password = xxxxxx;
}

Get domain info

curl --user user@m2m.io:xxxxxx http://api.m2m.io/1/domain/io.m2m

{
    active = 1;
    domain = "io.m2m";
    key = "io.m2m";
    licenselimit = 1000000;
    name = m2mIO;
    ok = 1;
    stuff =     [
        "io.mqtt",
        tests,
        test,
        things,
        examples,
        scala
    ];
}

Get stuff info

curl --user user@m2m.io:xxxxxx http://api.m2m.io/1/stuff/io.m2m

[
  {
    active = 1;
    domain = "io.m2m";
    key = "io.m2m:things:Ee6DR";
    licenseid = "uJ5ULi6YL8Flf0w:ba481581-2eb3-40af-af3e-75b86624694a";
    ok = 1;
    stuff = things;
    thing = Ee6DR;
  },
   {
    active = 1;
    domain = "io.m2m";
    key = "io.m2m:examples:publisher";
    ok = 1;
    stuff = examples;
    thing = publisher;
  }
]

To filter by 'stuff'

curl --user user@m2m.io:xxxxxx http://api.m2m.io/1/stuff/io.m2m/examples

[
  {
    active = 1;
    domain = "io.m2m";
    key = "io.m2m:examples:publisher";
    ok = 1;
    stuff = examples;
    thing = publisher;
  }
]

Present

Shows last known data sent from client

curl --user user@m2m.io:xxxxxx http://api.m2m.io/1/present/io.m2m/examples/publisher

{
    domain = "io.m2m";
    key = "io.m2m:examples:publisher";
    "m2m_nestedkeys" =     [
        report
    ];
    "m2m_raw" = "{\n\t  \"report\": {\n    \t\"gps\": {\n      \t\t\"latitude\": \"39.702610038220882\",\n      \t\t\"longitude\": \"-104.97231300920248\"\n    \t\t},\n    \t\t\"temp\": {\n      \t\t\"celsius\": \"252\",\n      \t\t\"fahrenheit\": \"76\"\n    \t\t}\n  \t\t}\n\t}";
ok = 1;
stuff = examples;
thing = publisher;
ttl = 0;

}

MultiPresent

Shows all last known data from a client parsed

curl --user user@m2m.io:xxxxxx http://api.m2m.io/1/multipresent/io.m2m/examples/publisher

{
  "report:gps" =     {
    customFieldMap =         {
        latitude = "39.702610038220882";
        longitude = "-104.97231300920248";
    };
    domain = "io.m2m";
    key = "io.m2m:examples:publisher:report:gps";
    ok = 1;
    stuff = examples;
    thing = "publisher:report:gps";
    ttl = 0;
  };
  "report:temp" =     {
    customFieldMap =         {
        celsius = 252;
        fahrenheit = 76;
    };
    domain = "io.m2m";
    key = "io.m2m:examples:publisher:report:temp";
    ok = 1;
    stuff = examples;
    thing = "publisher:report:temp";
    ttl = 0;
  };
}

Past

Shows history of all data from a client in a time series

curl --user user@m2m.io:xxxxxx http://api.m2m.io/1/past/io.m2m/examples/publisher?whatevers=report:gps:latitude,report:gps:longitude,report:temp:celcius,report:temp:fahrenheit

{
  1340314565706000 =     {
    "report:gps:latitude" = "39.702610038220882";
    "report:gps:longitude" = "-104.97231300920248";
    "report:temp:celsius" = 252;
    "report:temp:fahrenheit" = 76;
  };
  1340320480805000 =     {
    "report:gps:latitude" = "39.702610038220882";
    "report:gps:longitude" = "-104.97231300920248";
    "report:temp:celsius" = 252;
    "report:temp:fahrenheit" = 76;
  };
  1340320484088000 =     {
    "report:gps:latitude" = "39.702610038220882";
    "report:gps:longitude" = "-104.97231300920248";
    "report:temp:celsius" = 252;
    "report:temp:fahrenheit" = 76;
  };
  1340320484855000 =     {
    "report:gps:latitude" = "39.702610038220882";
    "report:gps:longitude" = "-104.97231300920248";
    "report:temp:celsius" = 252;
    "report:temp:fahrenheit" = 76;
  };
  1340320485523000 =     {
    "report:gps:latitude" = "39.702610038220882";
    "report:gps:longitude" = "-104.97231300920248";
    "report:temp:celsius" = 252;
    "report:temp:fahrenheit" = 76;
  };
  1340320486135000 =     {
    "report:gps:latitude" = "39.702610038220882";
    "report:gps:longitude" = "-104.97231300920248";
    "report:temp:celsius" = 252;
    "report:temp:fahrenheit" = 76;
  };
  1340320486746000 =     {
    "report:gps:latitude" = "39.702610038220882";
    "report:gps:longitude" = "-104.97231300920248";
    "report:temp:celsius" = 252;
    "report:temp:fahrenheit" = 76;
  };
}

2lemetry Support June 14, 2012 Q & A and Misc.

q.m2m.io

The q.m2m.io Broker allows the ability to connect your device and application clients using MQTT; a simple publish/subscribe protocol.  For more information about MQTT please visit http://mqtt.org

The m2m.io broker allows incoming connections to q.m2m.io on port 1883.  (If you're licensed for SSL, use port 8883).  Any client connected is sandboxed within their "domain" level topic.  Only clients with authorization are allowed to connect to the broker. 

Here are the following steps in order to connect to our MQTT Broker.

Download a compatible 3.1 mqtt client.  We recommend the Eclipse Paho clients for Java or C.  The source can be downloaded from https://github.com/eclipse/paho.mqtt.java or https://github.com/eclipse/paho.mqtt.c

 Authentication

All clients connecting to q.m2m.io require a username and password.  Please request one at http://help.m2m.io

The client's password must be sent as the md5sum of the password string.

Licenses

Licenses are given on a 'domain' level.  Each domain has a limited number of licenses that are auto provisioned to clientID's that connect.  When a new client connects to our broker the clientID is checked for a license and allocated if needed.  Random clientID's are not recommended since it will allocate a new license for each randomly created clientID.

Subscribing and Publishing

Subscribing is based on a TOPIC string.  By default your client will have access to public/# and <domain>/#  Any clients my publish and subscribe on public/# and only authorized clients can publish on your <domain>/#

Data is stored in m2m.io if the following 3 level topic is defined.  <domain>/<stuff>/<thing>  where <domain> is your domain, <stuff> is a grouping of things and <thing> is a unique identifier for a device.  Payload data must be in JSON object format to be parsed and saved to the datastore.  Any single or nested JSON object is allowed.  All other topic patterns or payload structure would not be stored but are allowed for pub/sub.  

Payload

This is an example of a valid payload that would be stored in the m2m.io datastore:

{
  "report": {
    "gps": {
      "latitude": "39.702610038220882",
      "longitude": "-104.97231300920248"
    },
    "temp": {
      "celsius": "252",
      "fahrenheit": "76"
    }
  }
}