Hardware configuration

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

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

Parameters

Required parameters:

Name Description
hwId hardware type ID
action action:
set - set configuration;
check_config - check if hardware has parameters for configuring;
download_file - download configuration file;
get - get configuration

Additional parameters, if action = set:

{
	"itemId":<long>,
	"params_data":{
		"params": [{
			"name":<text>,
			"type":<text>,
			"value":<text|int|double>,
			"reset":<uint>,
			"set_psw":<uint>
		}],
		"reset_all":<uint>,
		"full_data":<uint>
	}
}
Name Description
itemId unit ID
params_data parameters data
params array of parameters configurations
name parameter name
type parameter type (see below)
value parameter value
reset flag: 1 - reset on default value, 0 - do not reset
set_psw flag (if parameter type “password”): 1 - change password, 0 - do not change
reset_all reset hardware type configuration
full_data if 0 - then “value” store path of uploading file, if 1 - then “value” store HEX-string

Parameter types:

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

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

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--

Additional parameters, if action = download_file:

{
	"itemId":<long>,
	"fileId":<text>
}
Name Description
itemId unit ID
fileId configuration file ID

Additional parameters, if action = get:

{
	"itemId":<long>,
	"fullData":<uint>
}
Name Description
itemId unit ID
fullData flag: 0 - request configuration without files, 1 - request configuration with files

Response

If action = set:

{}	/* empty object if execution successful, if not - error code */

If action = check_config:

{
	"error":<uint>	/* 0 - hardware has additional parameters, any other value - no parameters */
}

If action = download_file:

{}	/* empty object if execution successful, if not - error code */

If action = get:

[
	{				/* parameter configuration*/
		"default":<text|int|double>,	/* default value */
		"description":<text>,		/* description */
		"label":<text>,			/* name */
		"maxval":<int|double>,		/* max value */
		"minval":<int|double>,		/* min value */
		"name":<text>,			/* system name */
		"readonly":<bool>,		/* read only: 1 - yes, 0 - no */
		"type":<text>,			/* type */
		"value":<text|int|double>	/* value */
	}
]
Follow us on Facebook Gurtam Wialon Twitter Gurtam Wialon info@gurtam.com   |   Copyright © 2002-2024 Gurtam