Sign inSign up

actility/iot-flow-drivers

By actility

•Updated about 2 years ago

Thingpark X standalone IoT Flow Drivers API

Image
Developer tools
0

5M+

actility/iot-flow-drivers repository overview

Thingpark X standalone IoT Flow Drivers API

⁠Pull

Start by pulling the docker image:

docker pull actility/iot-flow-drivers

⁠Run

This docker image downloads the drivers from public repository and store them in local memory.

The port 8095 must be exposed from the docker in order to access the API.

Example:

docker run -d -p 8095:8095 actility/iot-flow-drivers

⁠Usage

Once the container is running, you can access the REST API.

To start, you can open the Swagger UI from the following URL:

http://localhost:8095/v1/swagger-ui

The Swagger UI completely describes the REST API of the iot-flow-driver service, as well as providing usage examples.

You can list the available drivers using the REST API as described in the Swagger UI:

curl -X GET http://localhost:8095/v1/drivers

Example response:

[
  {
    "id": "{driverId}",
    "producerId": "example",
    "moduleId": "myDriver",
    "version": "1"
  }
]

You can finally use one of the available drivers to encode a downlink:

curl -X POST \
  http://localhost:8095/v1/encode \
  -H 'Content-Type: application/json' \
  -d '{
  "direction": "downlink",
  "meta": {
    "driverId": "${driverId}",
    "lorawan": {
      "fPort": 15
    }
  },
  "message": {
    "temperature": 23.5,
    "humidity": 65.0
  }
}'

response:

{
  "direction": "downlink",
  "meta": {
    "driverId": "${driverId}"
  },
  "message": {
    "temperature": 23.5,
    "humidity": 65.0
  },
  "raw": {
    "binary": "{payload_in_hexadecimal}"
  }
}

Where {payload_in_hexadecimal} is the raw payload produced by the driver.

And to decode an uplink:

curl -X POST \
  http://localhost:8095/v1/decode \
  -H 'Content-Type: application/json' \
  -d '{
  "direction": "uplink",
  "meta": {
    "driverId": "${driverId}",
  },
  "raw": {
    "binary": "{payload_in_hexadecimal}"
  }
}'

response:

{
  "direction": "uplink",
  "meta": {
    "driverId": "${driverId}",
  },
  "thing": {
    "points": {
      "temperature": {
        "records": [{
          "eventTime": "2019-01-01T10:00:00+01:00",
          "value": 23.5
        }],
        "unitId": "Cel",
        "type": "double"
      },
      "humidity": {
        "records": [{
          "eventTime": "2019-01-01T10:00:00+01:00"
          "value": 65.0
        }],
      "unitId": "%RH",
      "type": "double"
      }
    }
  },
  "raw": {
      "binary": "{payload_in_hexadecimal}"
  },
  "message": {
    "temperature": 23.5,
    "humidity": 65.0
  }
}

Where the message is the decoded payload.

The batch decoding is also possible:

curl -X POST \
  http://localhost:8095/v1/decode \
  -H 'Content-Type: application/json' \
  -d '[
    {
      "id": "correlationId1"
      "input": {
        "direction": "uplink",
        "meta": {
          "driverId": "${driverId1}",
        },
        "raw": {
          "binary": "${payload_in_hexadecimal1}"
        }
      }
    },
    {
        "id": "correlationId2"
        "input": {
          "direction": "uplink",
          "meta": {
            "driverId": "${driverId2}",
          },
          "raw": {
            "binary": "${payload_in_hexadecimal2}"
          }
        }
      }
    }
  ]'

where driverId1 and driverId2 can be different as well as having different directions in the same batch.

response:

[
  {
    "id": "correlationId1",
    "output": {
      "direction": "uplink",
      "sourceTime": "2019-01-01T10:00:00.000+01:00",
      "meta": {
        "driverId": "${driverId1}"
      },
      "raw": {
        "binary": "${payload_in_hexadecimal1}"
      },
      "message": {
        "dateTime": "2019-05-27T09:18:52.681Z",
        "temperature": 75.0,
        "relativeHumidity": 50.0
      },
      "thing": {
        "points": {
          "relativeHumidity": {
            "records": [
              {
                "eventTime": "2019-05-27T09:18:52.681Z",
                "value": 50.0
              }
            ],
           "unitId": "%RH",
           "type": "double"
          },
          "temperature": {
            "records": [
              {
                "eventTime": "2019-05-27T09:18:52.681Z",
                "value": 75.0
              }
            ],
           "unitId": "Cel",
           "type": "double"
          }
        }
      }
    }
  },
  {
    "id": "correlationId2",
    "output": {
      "direction": "uplink",
      "sourceTime": "2019-01-01T10:00:00.000+01:00",
      "meta": {
        "driverId": "${driverId2}"
      },
      "raw": {
        "binary": "${payload_in_hexadecimal2}"
      },
      "message": {
        "dateTime": "2019-05-27T09:18:52.681Z",
        "temperature": 75.0,
        "relativeHumidity": 50.0
      },
      "thing": {
        "points": {
          "relativeHumidity": {
            "records": [
              {
                "eventTime": "2019-05-27T09:18:52.681Z",
                "value": 50
              }
            ],
           "unitId": "%RH",
           "type": "double"
          },
          "temperature": {
            "records": [
              {
                "eventTime": "2019-05-27T09:18:52.681Z",
                "value": 75
              }
            ],
           "unitId": "Cel",
           "type": "double"
          }
        }
      }
    }
  }
]

Tag summary

Content type

Image

Digest

sha256:8ca539e33…

Size

488.2 MB

Last updated

about 2 years ago

docker pull actility/iot-flow-drivers