ICMP JavaScript API

Connector functions ICMP JS API guide

This API allows users to send operations of PING to IP Address.

Icmp Object

The icmp object is the main object of the ICMP. It allows to send a operations PING to IP Addres, send commands and receive responses (in synchronous mode).

Icmp Object Properties

Property Type Default Description
ip string (*) IP address to send PING.
retries number 5 Number of PING delivery retries.
timeout number 2500 Timeout in milliseconds of retry.
async boolean true Decide if the request is asynchronous (true) or synchronous (false).

(*) By default, select the IP of the device or the provisioned subscription.

Icmp Object Methods

send () ⇒ Object or NULL

Send PING using the properties of the icmp object:

  • ip: IP address to send PING.
  • retries: Number of PING delivery retries.
  • timeout: Timeout in milliseconds of retry.
  • async: Decide if the request is asynchronous or synchronous.
  • RETURN: If the async property is false, then returns an object with the following properties:

    • result: String. The value will be “OK” when the result is successfull or “NOK” when the result of the request had error, for example, timeout.
    • deviceId: String. Entity receiving the ping.
    • datastreams: An array with the information of the request result.

Example:

  • SUCESSFULL:
{
  "result": "OK",
  "datastreams": [
    {
        "id":"device.communicationModules[].subscription.address",
        "datapoints":[
            {
                "value":{
                    "value": "10.10.10.174"
                }
            }
        ]
    },
    {
        "id":"device.communicationModules[].subscription.presence.ip",
        "datapoints":[
            {
                "value": "OK"
            }
        ]
    },
    {
        "id":"device.communicationModules[].subscription.presence.ipRtt",
        "datapoints":[
            {
                "value": 6
            }
        ]
    }
  ]
}
  • ERROR:
{
  "result": "NOK",
  "deviceId": "deviceId",
  "datastreams": [
    {
      "datastreamId": "collected.device.communicationModules.subscription.address",
      "value": "172.19.18.95"
    },
    {
      "datastreamId": "collected.device.communicationModules.subscription.presence.ip",
      "value": "NOK"
    }
  ]
}