脚本文档

基本语法参照 https://github.com/alibaba/QLExpress

内置对象

device

device是下发设备对象

内置命令

send

格式: device send message; 其中, device是内置对象, send是关键字, message是Rpc调用对象.

内置函数

以下函数介绍中, 如果参数描述形如String parameterKey = ""语法, 说明该参数可以省略, 并且等号后面的是默认值. 函数调用示例:

  1. res = getNames("InternetGatewayDevice.", true);
  2. println(res[0]);
  3. res1 = getAttr(res[0].name);
  4. println(res1[0]);
  5. res2 = getValues([res[0].name]);
  6. println(res2[0]);

addObject

参数列表 返回值
AddObject
string objectName, string parameterKey = “” AddObjectResponse

其中的参数含义与tr069中的相同.

  • AddObject
字段名 字段类型
objectName string
parameterKey string
  • AddObjectResponse
字段名 字段类型
instanceNumber int
status int

响应字段与tr069协议中规定的相同.

deleteObject

参数列表 返回值
DeleteObject
string objectName, string parameterKey = “” DeleteObjectResponse

其中的参数含义与tr069中的相同.

  • DeleteObject
字段名 字段类型
objectName string
parameterKey string
  • DeleteObjectResponse
字段名 字段类型
status int

响应字段与tr069协议中规定的相同.

Download

参数列表 返回值
long id, int type, int delaySeconds = 0, string commandKey = “ DownloadResponse

其中, id资源管理 -> 文件管理中的文件的id; type是文件的类型, 可选值为1, 2, 3分别代表1 Firmware Upgrade Image,2 Web Content ,3 Vendor Configuration File; delaySecondscommandKey与tr069协议中规定的含义相同.

  • DownloadResponse
字段名 字段类型
startTime string
completeTime string

factoryReset

参数列表 返回值
boolean

如果下发命令成功返回true, 否则返回false

getAttr

参数列表 返回值
string parameterName ParameterAttributeStruct

相当于使用GetParameterAttributes获取一个节点.

  • ParameterAttributeStruct
字段名 字段类型
name string
notification int
accessList list

getAttrs

参数列表 返回值
string[] parameterNames ParameterAttributeStruct[]

相当于GetParameterAttributes.

getNames

参数列表 返回值
string parameterPath, boolean nextLevel = false ParameterInfoStruct[]

相当于GetParameterNames.

参数含义同tr069协议规定.

  • ParameterInfoStruct
字段名 字段类型
name string
writable boolean

getValues

参数列表 返回值
string[] parameterNames ParameterValueStruct[]

相当于GetParameterValues.

  • ParameterValueStruct
字段名 字段类型
name string
value string

getRpc

参数列表 返回值
string[]

相当于GetRPCMethods.

reboot

参数列表 返回值
boolean

相当于Reboot.返回值代表是否下发成功.

setAttr

参数列表 返回值
string name, boolean notificationChange, int notification, boolean accessListChange,list accessList ParameterInfoStruct[]

相当于SetParameterAttributes设置一个节点.

setValue

参数列表 返回值
string name,string value int

相当于SetParameterValues设置一个节点. 同tr069协议中规定.

upload

参数列表 返回值
int fileType, int instance = null, int delaySeconds = 0, string commandKey = “” UploadResponse

其中, fileType可选值为1, 2, 3, 4分别代表1 Vendor Configuration File, 2 Vendor Log File , 3 Vendor Configuration File {instance}, 4 Vendor Log File {instance}; 1,2是较老的tr069协议规定的值, 当fileType为1, 2的时候, instance要为空, 否则instance必须不为空.具体参见tr069协议upload一节. 其它参数含义与tr069协议中upload的相同.

  • UploadResponse
字段名 字段类型
startTime string
completeTime string
status int

脚本接口

  • uri: /api/device/executeScript
  • 格式: application/multi
  • 参数:
字段名 类型 说明
ids long[] 下发的设备的id
scriptFile byte[] 脚本文件
  • 响应: ScriptResponse[] 每次调用内置命令或函数都将增加一个ScriptResponse, 如果内置命令或函数调用成功, data字段将是对应命令或函数调用的返回值. ScriptResponse如下:
字段名 类型 说明
code int 响应码, 0为成功
msg string 响应消息
data object 响应对象