Create lifecycle/resource events subscription

The create lifecycle/resource events subscription request allows the client application to subscribe to the lifecycle/resource events of all the endpoints and gateways pertaining to a particular group. This request allows the client applications to specify the conditions for the subscription.

Create lifecycle/resource events subscription describes the API structure for creating lifecycle/resource event subscription.

Table 1. Create lifecycle/resource events subscription
Title Create lifecycle/resource events subscription
URL http://<impact_url>/m2m/subscriptions?type=[resources/GWresources/lifecycleEvents/GWlifecycleEvents]
Method POST
Content-Type application/json
URL Params

The following are the URL parameters:

  • Criteria: [composite]: Either the device serial numbers or combination of make/model/firmware version.

  • ManufacturerData: [composite]: Specifies the manufacturer information. It consists of make (M), model (O), firmware version (O)

  • Make: [string]: Specifies a device make (manufacturer) for observation. Only devices of the specified make are observed.
  • Model: [string]: Specifies a device model for observation. Only devices of the specified model are observed.

    Note: Provide a value for this parameter, only if you have specified the Make parameter. If you use this parameter without specifying the Make parameter, IMPACT IoT returns an error.
  • firmwareVersion: [string]: Specifies a device firmware version for observation. Only devices of the specified firmware version are observed.

    Note: Provide a value for this parameter, only if you have specified the Make and Model parameter. If you use this parameter without specifying the Makeand Model parameter, IMPACT IoT returns an error.
  • serialNumbers: [Array]: Specifies the list of endpoint IDs (serial numbers) the client application wants to observe.

    Note: Provide a value for this parameter, only if ManufacturerData parameter is not specified.
  • deletionPolicy: [integer]: In the create subscription request, the deletionPolicy determines the retry mechanism of the notification received from device.

    • 0 - Specifies the notification response sent to the callback server and if the callback server is offline or throws an error response, the message is dropped from messaging queue.
    • 1 – Specifies the notification retried indefinitely until a success response is received from the callback server.
  • events: [array]: Specifies the list of lifecycle events to be observed and notified. Valid values are:
    • registration
    • deregistration
    • update
    • expiration
  • groupName: [string]: Name of the IMPACT IoT group to which the selected devices belong.

    Note:

    If no criteria is specified, the API selects all the devices present inside the group specified in input.

  • subscriptionType: [string]: Specifies the type of subscription.
    • lifecycleEvents – For lifecycle events subscription of devices.
    • resources – For resources subscription of devices.
    • GWlifeCycleEvents – For lifecycle events subscription of gateways.
    • GWresources – For resources subscription of gateways.
  • needNotification: [Boolean]: Allows to request or to prevent, wake up trigger which is sent to the device in order to speed up the processing of subscription.

    The default value is false. When set to false, the wake up trigger is not sent to the device.

Example payload for Group-Level Subscription:
{
    "resources": [
        {
            "conditions": {
                "gt": 40,
                "lt": 20,
                "pmin": 120,
                "pmax": 180,
                "steps": 5
            },
            "resourcePath": "4/0/4"
        }
    ],
    "groupName": "tenantram",
    "criteria": {
        "manufacturerData": {
            "make": "Nokia",
            "model": "Lightweight M2M Client",
            "firmwareVersion": "2.2"
        }
    },
    "subscriptionType": "resources",
    "deletionPolicy": 0,
    "needNotification": true
}
Example payload for Device-Level Subscription:
{
    "resources": [
        {
            "conditions": {
                "gt": 40,
                "lt": 20,
                "pmin": 120,
                "pmax": 180,
                "steps": 5
            },
            "resourcePath": "6/0/0"
        }
    ],
    "groupName": "",
    "criteria": {
        "serialNumbers": [
            "urn:imei:201001201102020"
        ]
    },
    "subscriptionType": "resources",
    "deletionPolicy": 0,
    "needNotification": false
}
Data Params

The following are the data parameters:

  • subscriptionID:[string]: Specifies the subscription correlator Id, to be used for any further operations subscription.

  • Msg:[String]: info/warning/error message

    Example:
    {
      "subscriptionId": "string,
      "msg": "string"
    }
  • Conditions: [composite]: Specifies the set conditions that must be met for the release of the notifications to the client application. Valid conditions are:

    • gt:[float]: Notify the client application, if the value of the observed resource is greater than the threshold specified in this parameter.

    • lt: [float]: Notify the client application, if the value of the observed resource is less than the threshold specified in this parameter.

    • pmin: [integer]: Specifies the minimum time gap (in seconds) between two successive notifications.

    • pmax: [integer]: Specifies the maximum period of time an LWM2M client can wait before sending the next notification.

    • steps: [float]: Specifies the minimum change value (delta value) between successive notifications. Notify the client application, if the variation in the value of the observed resource since last observation is equal to or more than the threshold specified in this parameter.
      Note: While creating a subscription in IMPACT IoT, the parameters gt, lt and steps in Conditions take floating values.
Success Code
Response Code: 202
Error Code
401 : Unauthorized 
403 : Forbidden 
404 : Not Found
Sample Call Lifecycle subscription example for particular manufacturer data (make & model)

Curl:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json'  --header 'Authorization: Basic ZG9jdXNlcjpBc2RmMSM=' -d '{
  "criteria": {
    "manufacturerData": {
      "make": "NXP",
      "model": "LPC1768"
    }
  },
  "events": ["registration"],
  "deletionPolicy": 0,
  "groupName": "DM.MFORM",
  "subscriptionType": "lifecycleEvents"
}' 'http://<impact_url>/m2m/subscriptions?type=lifecycleEvents'
Response Body:
{
  "subscriptionId": "4d1d5aab-c33c-4b7d-a73f-f9891939b3b0",
  "msg": "Success", "code":1000
}
Lifecycle subscription for particular list of serial numbers

Curl:

curl -X POST --header 'Content-Type: application/json' --header 'Accept:
            application/json'  --header 'Authorization: Basic
          ZG9jdXNlcjpBc2RmMSM=' -d '{  "criteria": {    "serialNumbers":
        [     
          "NXP:DEVKIT3","NXP:DEVKIT4","NXP:DEVKIT5"    ]  },  "deletionPolicy":
        0,  "events": [   
      "registration"  ],  "groupName":
        "DM.MFORM",   "subscriptionType":
          "lifecycleEvents"}'
          'http://<impact_url>/m2m/subscriptions?type=lifecycleEvents'
Response Body:
{
  "subscriptionId": "77e67a2b-4601-4aa2-b739-48de1858bda0",
  "msg": "Success","code":1000
}
HTTP Request payload at Group-Level
curl -X POST /m2m/subscriptions?type=resources HTTP/1.1
Host: cbam-ipv6-test2-edge-1
Accept: application/json
Content-Type: application/json
Authorization: Basic dXNlcnJhbTp1c2VycmFt
{
    "resources": [
        {
            "conditions": {
                "gt": 40,
                "lt": 20,
                "pmin": 120,
                "pmax": 180,
                "steps": 5
            },
            "resourcePath": "4/0/4"
        }
    ],
    "groupName": "tenantram",
    "criteria": {
        "manufacturerData": {
            "make": "Nokia",
            "model": "Lightweight M2M Client",
            "firmwareVersion": "2.2"
        }
    },
    "subscriptionType": "resources",
    "deletionPolicy": 0,
    "needNotification": true
}

HTTP Request payload at Device-Level

curl -X POST /m2m/subscriptions?type=resources HTTP/1.1
Host: lenin1906new-edge-01
Accept: application/json
Content-Type: application/json
Authorization: Basic c3VwZXJhZG1pbjpzdXBlcmFkbWlu
{
    "resources": [
        {
            "conditions": {
                "gt": 40,
                "lt": 20,
                "pmin": 120,
                "pmax": 180,
                "steps": 5
            },
            "resourcePath": "6/0/0"
        }
    ],
    "groupName": "tenantram",
    "criteria": {
        "serialNumbers": [
            "urn:imei:201001201102020"
        ]
    },
    "subscriptionType": "resources",
    "deletionPolicy": 0,
    "needNotification": false
}
Notes

While setting subscription, IMPACT IoT checks the JSON format of the subscription payload only. At the time of setting of pre-subscriptions, IMPACT IoTdoes not have any information about the nature or resource model of the endpoint. Moreover, the endpoints defined in pre-subscriptions may or may not register with the system in future.