# SETTING UP A CONNECTION INSTANCE
# Creating a Connection instance
Follow the example below to create your connection:
POST /connections
{
"connectorId": "actility-aws-iot",
"name": "Test AWS Connection",
"active": true,
"alarms": [
{
"startTime": "2019-01-31T09:00:00+01:00",
"endTime": "2019-01-31T18:00:00+01:00",
"timezone": "Europe/Paris",
"recurrence": [
{
"frequency": "weekly",
"byDays": ["monday", "tuesday", "wednesday", "thursday", "friday"]
}
],
"uplinkRateMinPerHour": 10,
"message": "Low rate during business day..."
}
],
"configuration": {
"description": "AWS Europe Datacenter",
"createDevices": true,
"sendMetadata": false,
"sendRawDecodedFormat": true,
"uplinkTimeValidity": "5m",
"downlinkEnabled": false,
"downlinkAsId": "TWA_199983788.1972.AS",
"downlinkAsKey": "9311e33d7d44fc52215b0dc789aa1d22",
"downlinkPort": 5,
"uplinkTopicPattern": "tpx/things/{DevEUI}/uplink",
"downlinkTopicPattern": "tpx/things/{DevEUI}/downlink",
"deviceType": "actilitytestsensor",
"region": "eu-central-1",
"accountPrefix": "a2sheeefctigr-ats",
"secretAccessKey": "lymHcfefddzerrZHnV5Q5YN/GTMFNiTREAj/7dz3358",
"accessKeyId": "AKIAJUJWTO76B3XZGHYA",
"certificateId": "arn:aws:iot:eu-central-1:101513775872:cert/8be79f58542e4f8983t45fgjb0842465efa41fea4554fa974",
"certificate": "-----BEGIN CERTIFICATE-----xxx-----END CERTIFICATE-----",
"privateKey": "-----BEGIN RSA PRIVATE KEY-----xxx-----END RSA PRIVATE KEY-----"
}
}
None of the fields is mandatory.
# Common Parameters
The following table lists the properties that are applicable to all connections.
Property | Configuration value |
---|---|
(optional, default = true) |
|
(mandatory) | Defines the type of connector that you choose.E.g.:actility-aws-iot or actility-azure-iot |
(mandatory) | Name of the connection. Used for information only. |
(optional) | Defines alarms on low rate flow. For more information, see the section below. |
(mandatory) |
|
(optional) | Description text for the configuration (optional) |
(optional, default = true) |
|
(optional, default = false) | For backward compatibility with tpdx-dataflow you can set sendMetadata to true to remove ‘DevEUI_uplink’ root node from uplinks.Default value in tpx-flow is false. |
(optional, default = false) | If sendMetadata is set to false (default value) and sendRawDecodedFormat is set to true, the uplink sent to the cloud contains only ‘payload’ field content. In case ‘payload’ is not present, full uplink msg body is sent. Default values is false, so that full uplink msg body is sent. |
(optional) | If set with a value (for instance, 1m), uplinks older than the set validity, will not be sent to the cloud service, and an alarm event is saved in the events’ log. No default value. When connections have not started or have downtimes, uplinks are accumulating. Most of these uplinks expire before connections get up again. |
(optional, default = true) |
|
(optional) | In cases where downlinks need authentication, set the AS_ID value to downlinkAsId. |
(optional) | In cases where downlinks need authentication, set the AS_KEY value to downlinkAsKey. |
(optional) | In cases where downlinks messages don’t specify a downlink port, set the default port to downlinkPort. |
(optional, default = NORMAL) | Reconnect strategy to use when a connection is unable to get to OPENED state in time. Possible values are:
CALM
NORMAL - default
AGGRESSIVE |
# Configuring the Low Message Rate Alarm
ThingPark X IoT Flow has a built-in functionality to detect unusually low uplink message rates processed by the connector towards the IoT cloud platform. This rate is set by connection and not for a specific Device. You can set up one or several low message rate alarms by specifying the following parameters:
- A recurring time window for which the minimum message rate will be checked.
- The minimum uplink message rate expected during this time window for the connector instance.
For example, your Devices send on average 1 message per hour, and you have a pool of 20 Devices associated with this connector via ThingPark X IoT Flow. Therefore, you expect 20 messages per hour during open hours through the connector instance. You believe that the average rate of uplinks per hour should never get below 15 messages per hour during open hours, and you configure an alarm as in the example below:
- If during off hours the rate is lower than 15 messages per minute, no alarm is raised.
- If during open hours the rate gets lower than 15 messages per minute, a low-level uplink message rate alarm event is raised and added to the event log.
"alarms": [
{
"startTime": "2019-01-31T09:00:00+01:00",
"endTime": "2019-01-31T18:00:00+01:00",
"timezone": "Europe/Paris",
"recurrence": [
{
"frequency": "weekly",
"byDays": ["monday", "tuesday", "wednesday", "thursday", "friday"]
}
],
"uplinkRateMinPerHour": 15,
"message": "Low rate during business day..."
}
]
Note
ThingPark Wireless also has a message rate alarm functionality per Device, which is configured per Device profile. This functionality generates alarms in ThingPark Wireless Device Manager tool and APIs. The ThingPark X low message rate alarm functionality is completely independent and accessed via TPX IoT Flow API.
# Retrieving Connection Instance Details
Follow the example below to list your connections:
GET /connections
[
{
"configuration": {
"protocol": "SSL",
"region": "eu-central-1",
"accountPrefix": "a2e8k469sk385s-ats",
"accessKeyId": "*****",
"secretAccessKey": "*****",
"certificateId": "arn:aws:iot:eu-central-1:076081621542:cert/28e7cc38a99f78b3d0b2b1af5d4cd8ddc83264ad435ce4248f4146ccc34e3329",
"privateKey": "*****",
"deviceType": "actilityDeviceType",
"uplinkTopicPattern": "tpx/things/{DevEUI}/uplink",
"downlinkTopicPattern": "tpx/things/{DevEUI}/downlink",
"description": "Test AWS Connection configuration",
"createDevices": true,
"sendMetadata": false,
"sendRawDecodedFormat": false,
"certificate": "*****"
},
"id": "8",
"connectorId": "actility-aws-iot",
"name": "Test AWS Connection",
"active": true,
"startupTime": "2019-09-27T10:08:08.309+02:00",
"state": "OPENED"
},
]
Beside connection details, you get also startupTime
and connection state
.
# Connection states
The state of a connection is provided by the connection object. An action does not change immediately the state of a connection due to the asynchronous architecture. When you start a connection, the connection can remain on CLOSED state during a short period before changing to OPENING. It is a normal behavior. Depending on the cloud connector, a connection can take time to be in a stable state.
Connection states are depicted in the following table.
Connection state | Property |
---|---|
OPENING | The connection is currently opening. |
OPENED | The connection is up and running. |
CLOSED | The connection is currently closing. |
AUTHENTICATING | The connection is currently authenticating. |
AUTHENTICATION_FAILED | The authentication has failed. |
UNREACHABLE | The bridge that hosts the connection is unreachable; none of the connection information can be retried. |
DEACTIVATED | The connection is currently authenticating. |
AUTHENTICATING | The connection is deactivated. |
The corresponding workflow is illustrated In the following graphic: