Testing the Setup

You can test the set-up as follows:

Viewing Auto Events

You can view the readings set up in the Readings pane of the Edge Xpert Manager, as described in Displaying Readings. To do this, complete the following steps:

  1. Select READINGS from the main menu

  2. Select the MQ_DEVICE from the list box

    The device resources are displayed.

  3. Select number from the list of device resources

    The readings for the room number are given in the table.

Reading from the Async Value

The MQTT device simulator publishes data from the room sensor every 10, 30 and 50 seconds. The Device Service subscribed to the data topic waits for the device to send a value to the broker, parses the value and sends the output to core-data.

You can read a device event from the async value in any of the following ways:

  • Using the Edge Xpert Manager READING pane, see Displaying Readings for more information

  • Open a browser and navigate to http://<host-ip>:48080/api/v1/event, replacing <host-ip> with the host IP address or localhost as appropriate

  • Open a terminal and enter the following cURL command, replacing <host-ip> with the host IP address or localhost as appropriate:

    curl http://<host-ip>:48080/api/v1/event | json_pp
    

    The output is similar to the following:

    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                   Dload  Upload   Total   Spent    Left  Speed
      100 14987    0 14987    0     0   770k      0 --:--:-- --:--:-- --:--:--  770k
      [
         ...
         {
            "readings" : [
               {
                  "name" : "switch",
                  "id" : "7d25f3d5-1edf-4584-b58b-b40b97ea2acd",
                  "created" : 1574671041006,
                  "value" : "ON",
                  "origin" : 1574671041004784819,
                  "dataType" : "",
                  "device" : "MQ_DEVICE"
               },
               {
                  "dataType" : "",
                  "device" : "MQ_DEVICE",
                  "created" : 1574671041006,
                  "value" : "64",
                  "origin" : 1574671041004815453,
                  "id" : "9bd638e3-aaa6-4d56-8eaa-7eada62a6092",
                  "name" : "humidity"
               },
               {
                  "origin" : 1574671041004801681,
                  "value" : "-1.990000e+01",
                  "created" : 1574671041006,
                  "device" : "MQ_DEVICE",
                  "dataType" : "",
                  "name" : "temperature",
                  "id" : "fc0bd736-4520-412e-9e4f-10f9aa23af09"
               }
            ],
            "id" : "f3ba57f6-5354-4424-b147-b5a2d07547fb",
            "device" : "MQ_DEVICE",
            "created" : 1574671041006,
            "origin" : 1574671041004851415
         },
         {
            "device" : "MQ_DEVICE",
            "created" : 1574671038009,
            "origin" : 1574671038008909319,
            "readings" : [
               {
                  "device" : "MQ_DEVICE",
                  "origin" : 1574671038008879585,
                  "value" : "3.170000e+01",
                  "created" : 1574671038009,
                  "id" : "6e6b3751-81b2-49ee-a47f-f6c3e1957f67",
                  "name" : "temperature"
               },
               {
                  "name" : "humidity",
                  "id" : "97234a6f-aa6b-471a-92e8-5308e37249f4",
                  "created" : 1574671038009,
                  "value" : "69",
                  "origin" : 1574671038008888805,
                  "device" : "MQ_DEVICE"
               },
               {
                  "name" : "switch",
                  "id" : "e8ae6144-aab5-4817-93db-8cc4534cd476",
                  "origin" : 1574671038008870334,
                  "value" : "ON",
                  "created" : 1574671038009,
                  "device" : "MQ_DEVICE",
               }
            ],
            "id" : "f9139246-a58e-4243-bf8e-1a2505a6d07d"
         }
      ]
    

Sending Commands and Receiving Responses

To test the set-up, complete the following steps:

  1. Open a browser

  2. Enter one of the following URLs to list all available commands, replacing <host-ip> with the host IP address or localhost as appropriate:

    http://<host-ip>:48082/api/v1/device
    http://<host-ip>:48082/api/v1/device/name/MQ_DEVICE
    
  3. Open a terminal

  4. Send a PUT command using the following cURL command, replacing <host-ip> with the host IP address or localhost as appropriate:

    curl curl http://host-ip:48082/api/v1/device/bb5197b8-0759-4f80-a4f8-b40d71009af1/command/b0704a96-81f6-4b10-81c9-066391955c5a -H "Content-Type:application/json" -X PUT -d '{"number":"1123"}'
    

    Alternatively, you can use the following command, replacing <host-ip> with the host IP address or localhost as appropriate:

    curl http://host-ip:48082/api/v1/device/name/MQ_DEVICE/command/roomNumber -H "Content-Type:application/json" -X PUT -d '{"number":"1123"}'
    
  5. Send a GET command using the following cURL command:

    curl http://<host-ip>:48082/api/v1/device/bb5197b8-0759-4f80-a4f8-b40d71009af1/command/b0704a96-81f6-4b10-81c9-066391955c5a
    

    Alternatively, you can use the following command, replacing <host-ip> with the host IP address or localhost as appropriate:

    curl http://<host-ip>:48082/api/v1/device/name/MQ_DEVICE/command/roomNumber | json_pp
    

    The output is similar to the following:

    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                   Dload  Upload   Total   Spent    Left  Speed
      100   168  100   168    0     0   2126      0 --:--:-- --:--:-- --:--:--  2126
      {
         "EncodedEvent" : null,
         "device" : "MQ_DEVICE",
         "readings" : [
            {
               "value" : "1123",
               "name" : "number",
               "origin" : 1574669486444938122,
               "device" : "MQ_DEVICE"
            }
         ],
         "origin" : 1574669486444968871
      }