update_hw_params
To update hardware configuration, use the unit/update_hw_params method:
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:
|
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
{
"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:
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
{
"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
{
"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:
{}
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 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. |