# Example: equipment diagnostic command execution

# Send the operation request to OpenGate

Click bellow to see how to send the operation request to your device.

Using curl
curl 'https://api.opengate.es/north/v80/operation/jobs' \
  -H 'X-ApiKey: your-api-key' \
  -H 'Content-Type: application/json' \
  -H 'Accept: */*' \
  --data '{
  "job": {
    "request": {
      "operationParameters": {
        "timeout": 90000,
        "retries": 0,
        "retriesDelay": 0
      },
      "name": "EQUIPMENT_DIAGNOSTIC",
      "schedule": {
        "stop": {
          "delayed": 120000
        }
      },
      "parameters": {
        "type": "HARDWARE"
      },
      "target": {
        "append": {
          "entities": [
            "649843"
          ]
        }
      },
      "active": true
    }
  }
}'

# Receiving operation request into device

You must be connected to OpenGate MQTT connector as subscriber to topic odm/request/your-device-id, if so then you'll receive the an operation request like this:

{
  "operation": {
    "request": {
      "timestamp": 1614238879802,
      "name": "EQUIPMENT_DIAGNOSTIC",
      "parameters": {
        "type": "HARDWARE"
      },
      "id": "14502149-99f9-4348-93f1-23aea495811b"
    }
  }
}

# Answering the operation

Your device must publish a message to the topic odm/response/your-device-id to let know OpenGate it's going to anwer the operation:

{
  "operation": {
    "response": {
      "name": "EQUIPMENT_DIAGNOSTIC",
      "timestamp": 1614238881241,
      "resultDescription": "Success",
      "steps": [
        {
          "timestamp": 1614238881241,
          "description": "System is OK",
          "name": "EQUIPMENT_DIAGNOSTIC",
          "result": "SUCCESSFUL"
        }
      ],
      "deviceId": "649843",
      "resultCode": "SUCCESSFUL",
      "id": "14502149-99f9-4348-93f1-23aea495811b"
    }
  },
  "version": "1.0"
}