update_hw_params

To update hardware configuration, use the unit/update_hw_params method:

Copied!
svc=unit/update_hw_params&params={
    "hwId": <text>,
    "action": <text>,
    ...
}

Parameters

The request must contain the following parameters:

Parameter Description
hwId Device type ID.
action Action:
  • set — set the configuration
  • check_config — check if the device has parameters for configuring
  • download_file — download the configuration file
  • get — get the configuration

If action=set, specify the following additional parameters:

Parameter Description
itemId Unit ID.
params_data Parameter data.
params Array of parameter configurations.
name Parameter name.
type Parameter type (see below).
value Parameter value.
reset Flag: 1 — reset to the default value, 0 — do not reset.
set_psw Flag (if the parameter type is password): 1 — change the password, 0 — do not change the password.
reset_all Reset the device type configuration.
full_data If 0 is passed, the parameter value stores the path of the uploading file, if 1 is passed, it stores the HEX string.

Example

Copied!
{
  "itemId": <long>,
  "params_data": {
    "params": [
      {
        "name": <text>,
        "type": <text>,
        "value": <text|int|double>,
        "reset": <uint>,
        "set_psw": <uint>
      }
    ],
    "reset_all": <uint>,
    "full_data": <uint>
  }
}

Parameter types

  • text
  • file
  • long
  • double
  • int
  • bool
  • password

If the parameter is of the file type, use a POST request with multiple contents (multipart/form-data) to upload the file. For example:

Copied!
POST /wialon/ajax.html?svc=unit/update_hw_params&sid=<long> HTTP/1.1
Host: <host>
Connection: keep-alive
Content-Length: <uint>
Cache-Control: max-age=0
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryUZNF25nwwhMzU9Me
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.3
 
------WebKitFormBoundaryUZNF25nwwhMzU9Me
Content-Disposition: form-data; name="params"
 
{"itemId":<long>,"hwId":<text>,"params_data":{"reset_all":0,"params":[
{"name":"custom_polls_file","type":"file","value":"cfg_param_custom_polls_file","data":"","reset":0}],
"full_data":0},"action":"set"}
 
------WebKitFormBoundaryUZNF25nwwhMzU9Me
Content-Disposition: form-data; name="cfg_param_custom_polls_file"; filename="file.txt"
Content-Type: text/plain
 
<binary data>
------WebKitFormBoundaryUZNF25nwwhMzU9Me--

If action=set, specify the following additional parameters:

Parameter Description
itemId Unit ID.
field Configuration file ID.

Example

Copied!
{
    "itemId":<long>,
    "fileId":<text>
}

If action=get, specify the following additional parameters:

Parameter Description
itemId Unit ID.
fullData Flag: 0 — request the configuration without files, 1 — request the configuration with files.

Example

Copied!
{
    "itemId":<long>,
    "fullData":<uint>
}

Response

If the request is completed successfully, the response depends on the value of the action parameter.

For action = set:

Copied!
{}

For action = check_config:

Copied!
{
    "error":<uint>    /* If the value is 0, the device has additional parameters. Any other value indicates no parameters. */
}

For action = download_file:

Copied!
{}

For action = get:

Copied!
[
    {               /* Parameter configuration.*/
        "default":<text|int|double>,  /* Default value. */
        "description":<text>,     /* Description. */
        "label":<text>,           /* Name. */
        "maxval":<int|double>,        /* Maximum value. */
        "minval":<int|double>,        /* Minimum value. */
        "name":<text>,            /* System name. */
        "readonly":<bool>,        /* Read only: 1 - yes, 0 - no. */
        "type":<text>,            /* Type. */
        "value":<text|int|double> /* Value. */
    }
]

If the request fails, an error code is returned.

Error codes

Error code Description
6 Failed to update the hardware parameters.
1005 The hw_config property value of hwId is empty. Only for the check_config action.

If you find a mistake in the text, please select it and press Ctrl+Enter.

Report a mistake

Your message was sent. Thank you!

An error occurred while submitting the form

Download PDF file
Download Word document

See also