update_hw_params
To get, check, or update the hardware configuration, or to download a configuration file, use the unit/update_hw_params method.
Endpoint
svc=unit/update_hw_params¶ms={
"hwId": <text>,
"action": <text>,
...
}
Parameters
The request must contain the following parameters:
| Parameter | Description |
|---|---|
hwId |
Device type ID. |
action |
Action:
|
The other parameters depend on the value of action (see below).
Parameters for action=set
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 to reset to the default value, 0 not to reset. |
set_psw |
Flag (if the parameter type is password): 1 to change the password, 0 not to change the password. |
reset_all |
Reset the device type configuration. |
full_data |
If 0 is passed, the value parameter stores the path of the uploading file. If 1 is passed, it stores the HEX string. |
Example:
{
"itemId": <long>,
"params_data": {
"params": [
{
"name": <text>,
"type": <text>,
"value": <text|int|double>,
"reset": <uint>,
"set_psw": <uint>
}
],
"reset_all": <uint>,
"full_data": <uint>
}
}
The following parameter types are available:
textfilelongdoubleintboolpassword
If the parameter is of the file type, use a POST request with multiple contents (multipart/form-data) to upload the file. For example:
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--
Parameters for action=download_file
If action=download_file, specify the following additional parameters:
| Parameter | Description |
|---|---|
itemId |
Unit ID. |
fileId |
Configuration file ID. |
Example:
{
"itemId":<long>,
"fileId":<text>
}
Parameters for action=get
If action=get, specify the following additional parameters:
| Parameter | Description |
|---|---|
itemId |
Unit ID. |
fullData |
Flag: 0 to request the configuration without files, 1 to request the configuration with files. |
Example:
{
"itemId":<long>,
"fullData":<uint>
}
Response
If the request is completed successfully, the response depends on the value of the action parameter.
For action=set:
{}
For action=check_config:
{
"error":<uint> /* If the value is 0, the device has additional parameters. Any other value indicates no parameters. */
}
For action=download_file, the response contains the configuration file.
For action=get:
[
{ /* 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 device type has no configuration, the response for action=get is {}.
If the request fails, an error code is returned.
Error codes
| Error code | Description |
|---|---|
| 3 | The device type has no configuration. Only for the check_config action. |
| 4 | Invalid input parameters. |
| 6 | Failed to update the hardware parameters. |
| 1005 | The device type configuration contains no parameters. Only for the check_config action. |