Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Reverted from v. 13

GadgetKeeper and Thing exchange messages using an use external MQTT broker :to exchange messages. 

(GadgetKeeper sends
request, device responds)

 

Device () (publishes) Device Device (publishes)

How it works:

(Device sends request,
GadgetKeeper responds)

  1. GadgetKeeper subscribes to a request topic on MQTT message broker
  2. Device (Thing) subscribes to the response topic on MQTT message broker
  3. Device sends (publishes) a command to the request topic
  4. GadgetKeeper receives command from the request topic
  5. GadgetKeeper sends (publishes) a response to the response topic
  6. Device receives the response
  7. GadgetKeeper disconnects from MQTT message broker
Communication Protocols: MQTT
RPC Protocol: JSON-RPC 2.0
How it works:
  1. Thing
  1. subscribes to a request topic on MQTT message broker
  2. GadgetKeeper subscribes to the response topic on MQTT message broker
  3. GadgetKeeper sends
  1. a command to the request topic
  1. Thing receives command from the request topic
  1. Thing sends
  1. a response to the response topic
  2. GadgetKeeper receives the response
  3. GadgetKeeper disconnects from MQTT message broker
Constraints:
  1. MQTT message broker must be reachable from both Thing and GadgetKeeper
  2. Thing must keep alive connection to MQTT message broker

 

Connection Settings

...

Field Required Description Dialog
Name x Connection connection name Image Modified
Protocol x Select select "json-rpc over mqtt"
Host x MQTT broker host
Port x MQTT broker port
Secure   When checked, the connection uses use MQTTS
Request topic x Topic topic to send a command
Response topic x Topic topic to receive a response
Connection, ms x

Number number of milliseconds GadgetKeeper can spend spent on connection to MQTT broker

Response, ms x

Number number of milliseconds GadgetKeeper will wait for Thing

to receive message and send response

Date format x

Date date format representation:

  • iso-8601 - date is represented as string (example: "2013-05-27UTC06:07:16Z")
  • unix-timestamp - not supported, date is represented as number (example: 1369634836)
Description   Connection connection description

 

 

Example

...

Scenario Using MQTT

Info

See Message Format for detailed instructions on how to format a request/response message using the JSON-RPC 2.0 protocol

Device (thing) responds to a request from GadgetKeeper:

...

Given

  1. Thing has remote method "echo"
  2. Thing will want to be set up able to execute handle this method in response to a command from GadgetKeeper


Workflow

  1. Thing establishes MQTT connection to the specified MQTT Broker server
  2. Thing subscribes to the specified request topic
  3. GadgetKeeper subscribes to the specified response topic
  4. GadgetKeeper sends (publishes) a JSON-RPC request message to the request topic: 

    Code Block
    language javascript
    {
       "jsonrpc":"2.0",
       "method":"echo",
       "params":"hello world!",
       "id":990909000
    }
  5. Thing receives the JSON request message and sends (publishes) send a response back to the response topic:

    Code Block
    {
       "jsonrpc":"2.0",
       "result":"hello world!",
       "id":990909000
    }
  6. GadgetKeeper receives the response and disconnects from MQTT broker

 

...

Workflow

...



...

 

Code Block
language javascript
{
        "jsonrpc":"2.0",
        "id":"7755",
        "method":"things.methods.execute",
        "params": {
                "thingId":"990fc000c90211e2b5566c626dd90e00",
                "methodId":"99614181155811e4abd06c626dd90e00",
                "async":true,
                "args":"hello world!"
        }
}

...

GadgetKeeper receives the JSON request message and sends (publishes) a response back to the response topic:

Code Block
{
        "jsonrpc":"2.0",
        "id":"7755",
        "result":"hello world!"
}

...

Thing receives the response and disconnects from MQTT broker

 

Info