Skip to main content
Version: 2.2.0

Support Commands for Direct Methods

ThingsPro Agent offered below 6 direct methods. You can invoke them when device is on-line.

NoMethod NameDescription
1thingspro-api-v1An universal direct method, allow to invoke almost all Restful API of ThingsPro Edge.
2system-rebootA direct method to restart Moxa's device.
3thingspro-applications-controlTo control application run time on device.
4thingspro-software-upgradeTo perform software upgrade over the air.

ThingsPro Agent Universal Method​

An universal direct method, to invoke almost all Restful API on ThingsPro Edge device. You can get ThingsPro Edge Restful API document at here.

  • Method Name:

    thingspro-api-v1
  • Request Payload: (Example to set SSH configuration)

    {
    "path":"/system/sshserver",
    "method":"PUT",
    "headers":[],
    "requestBody": {"enable": true, "port": 22}
    }
    NoNameDescription
    1pathThingsPro Edge Restful API endpoint.
    2methodThe method which associated with API endpoint.
    3headersIt shall always be application/json.
    4requestBodyThe post data which required by API endpoint.
  • Response:

    {
    "status":200,
    "payload":{"data":{"enable":true,"port":22}}
    }
  • Example screen shot

Note : Please change below time out parameters to prevent any exception.- Connection Timeout with 30 seconds - Method Timeout with 60 seconds.

Restart Device​

This command will trigger device to reboot immediately.

  • Method Name:

    system-reboot
  • Request Payload:

    {}
  • Response:

    {
    "status": 200,
    "payload": {
    "data": "rebooting"
    }
    }

Control Application runtime​

This direct method offers you a quick way to start/stop/restart applications which running on ThingsPro Edge.

  • Method Name:

    thingspro-applications-control
  • Request Payload:

    {
    "appName": "modbusmaster-tcp",
    "command": "stop"
    }
    NoNameDescription
    1appNameThe name of applications running and managed by ThingsPro Edge. You can get application list by ThingsPro Restful API.
    2commandSupport commands:
    - start
    - stop
    - restart
  • Response:

    {
    "status": 200,
    "payload": {
    "data": ""
    }
    }

Software Upgrade​

This direct method allow you to download upgrade software over the air.

  • Method Name:

    thingspro-software-upgrade
  • Example to trigger download and installation at one upgrade job

    • Request Payload:
    {
    "downloadURL": "http://xxx/edge/87/doc_0.1.0-87_armhf.yaml",
    "runInstallation": true
    }
    NoNameDescription
    1downloadURLThe URL point to upgrade software location.
    2runInstallationvalue true : The installation task will auto start after download task completed.
    • Response:
    {
    "status": 200,
    "payload": {
    "data": {
    "id": 1
    }
    }
    }
  • Example to trigger a download software only upgrade job

    • Request Payload:
    {
    "downloadURL": "http://xxx/edge/87/doc_0.1.0-87_armhf.yaml",
    "runInstallation": false
    }
    NoNameDescription
    1downloadURLThe URL point to upgrade software location.
    2runInstallationvalue false : The installation task doesn't start by default. You can invoke next direct method to launch it.
    • Response:
    {
    "status": 200,
    "payload": {
    "data": {
    "id": 2
    }
    }
    }
  • Example to trigger an installation for a upgrade job id

    • Request Payload:
    {
    "id": 2,
    "runInstallation": true
    }
    NoNameDescription
    1runInstallationValue shall always be true at this case.
    2idThe Id returned from previous direct method.
    • Response
    {
    "status": 200,
    "payload": {
    "data": {
    "id": 3
    }
    }
    }
Note:
  1. ThingsPro agent will send back upgrade progress and status via reported properties.
    • Report download progress

    • Download success

  1. ThingsPro Edge allow only one active software upgrade job once.

Last updated on 2022-05-31 by Aeluin Chen (陳映攸)