API列表
更新时间:2018-10-23 21:27:49
aliyunIot.device(options)
和云端建立连接,返回一个 Device 连接实例,入参:
aliyunIot.device#publish(topic, message, [options], [callback])
等同于 mqtt.Client#publish() 方法。
aliyunIot.device#unsubscribe(topic, [callback])
等同于 mqtt.Client#unsubscribe() 方法。
aliyunIot.device#postProps(params, [callback])
上报物模型属性:
params属性参数,Object类型callbackerr错误,比如超时或者res.code !== 200res服务端 reply 消息内容
aliyunIot.device#postEvent(eventIdentifier, params, [callback])
上报物模型事件:
eventIdentifier事件 idString类型params事件参数,Object类型callbackerr错误,比如超时res服务端 reply 消息内容
aliyunIot.device#serve(seviceIdentifier, [callback])
监听物模型服务:
seviceIdentifier服务 idString类型callbackparams服务参数
值得注意的是,serve 方法返回的是一个 deServe 函数,可以通过调用 deServe 函数取消服务监听:
var deServe = device.serve('turnOn', function(params) {
// 收到 turnOn 服务消息后取消对该服务的监听
deServe();
});
aliyunIot.gateway(options)
和云端建立连接,返回一个网关 Gateway 类连接实例,继承自 Device 类。options 设备激活凭证
productKeydeviceNamedeviceSecret
aliyunIot.gateway#addTopo(deviceSign, [callback])
添加子设备到拓扑
deviceSign子设备身份加签信息,通过调用 aliyunIot.signUtil() 方法进行加签callbackerr错误,比如超时或者res.code !== 200res服务端 reply 消息内容
aliyunIot.gateway#getTopo()
获取子设备到拓扑关系
callbackerr错误,比如超时或者res.code !== 200res服务端 reply 消息内容
aliyunIot.gateway#removeTopo(thingId, [callback])
从拓扑关系里移除子设备
thingId子设备身份productKeydeviceName
callbackerr错误,比如超时或者res.code !== 200res服务端 reply 消息内容
aliyunIot.gateway#login(thingId, [callback])
子设备上线
deviceSign子设备身份加签信息,通过调用 aliyunIot.signUtil() 方法进行加签callbackerr错误,比如超时或者res.code !== 200res服务端 reply 消息内容
aliyunIot.gateway#logout(thingId, [callback])
子设备下线
thingId子设备身份productKeydeviceName
callbackerr错误,比如超时或者res.code !== 200res服务端 reply 消息内容
aliyunIot.gateway#postSubDeviceProps(thingId, params, [callback])
thingId子设备身份productKeydeviceName
params属性参数,类型Objectcallbackerr错误,比如超时或者res.code !== 200res服务端 reply 消息内容
aliyunIot.gateway#postSubDeviceEvent(thingId, eventIdentifier, params, [callback])
thingId子设备身份productKeydeviceName
eventIdentifier事件 id,String类型params事件参数,Object类型callbackerr错误,比如超时或者res.code !== 200res服务端 reply 消息内容
aliyunIot.gateway#serveSubDeviceService(thingId, serviceIdentifier, [callback])
thingId子设备身份productKeydeviceName
serviceIdentifier服务 id,String类型callbackparams服务参数
aliyunIot.signUtil(deviceId)
设备身份连接加签工具函数
deviceId设备激活凭证productKeydeviceNamedeviceSecret