主要的 API 参考文档如下:
- getConfig()
- Config()
- Config#getDeviceInfos()
- Config#getDriverInfo()
- BaseEdgeException
- EdgeDriverLinkException
- EdgeDriverLinkTimeoutException
- EdgeDriverLinkDeviceConfigException
- EdgeDriverLinkDeviceOfflineException
- EdgeDriverLinkOfflineException
- EdgeDriverLinkDeviceProductSecretException
- SubDevice()
- SubDevice#set_product_sn()
- SubDevice#set_device_sn()
- SubDevice#set_product_secret()
- SubDevice#set_msg_callback()
- SubDevice#set_rrpc_callback()
- SubDevice#login()
- SubDevice#logout()
- SubDevice#publish()
- SubDevice#registerDevice()
- register_device()
- set_on_topo_change_callback()
- set_on_status_change_callback()
- get_topo()
- add_topo()
- delete_topo()
返回驱动内置 logger。
返回驱动相关配置。
基于当前驱动配置字符串构造新的 Config 对象。
返回所有设备相关信息,返回 DeviceInfoList
DeviceInfo 包括如下信息:
- productSN
str
: 官网申请的 productKey。 - deviceSN
str
: 设备名 - config
dict
:设备自定义配置
返回驱动相关信息,返回 DriverInfoList
设备接入客户端类, 用户主要通过它上下线设备和主动上报消息
- product_sn
str
: 云端分配的 ProductSN - device_sn
str
: 云端分配的 DeviceSN - on_msg_callback
func(topic:str, msg:b'')
: 云端下发消息回调,消息类型 []byte, 例如:def callbacl(topic:str, msg:b''): print(str(msg,'utf-8')
设置子设备的 productSN
- product_sn
str
: 云端分配的 ProductSN
设备子设备的 DeviceSN
- device_sn
str
: 云端分配的 DeviceSN
设置子设备的 Product Secret
- product_secret
str
: 云端分配的 Product Secret
设置子设备的 Product Secret
- product_secret
str
: 云端分配的 Product Secret
设置子设备的接收消息的回调函数
- set_msg_callback
func
: 子设备收消息回调,例如:def callbacl(topic:str, msg:b''): print(str(msg,'utf-8')
设置子设备的接收 RRPC 的回调函数
- set_RRPC_callback
func
: 子设备收消息回调,例如:def callback(topic:str, msg:b''): return b 'hello'
上报上线事件到 Link IoT Edge
- sync
bool
: 是否异步登陆 - timeout
int
: 等待响应超时时间,单位 s(秒)
上报下线事件到 Link IoT Edge
- sync
bool
: 是否异步登陆 - timeout
int
: 等待响应超时时间,单位 s(秒)
上报消息到 Link IoT Edge。异步
- topic
str
: 上报消息到 Link IoT Edge 的 mqtt topic。 - payload
[]byte
: 上报消息到 Link IoT Edge 的消息内容
动态注册一个设备到 Link IoT Edge。同步
- timeout
int
: 等待响应超时时间,单位 s(秒)
上报动态注册到 Link IoT Edge。同步执行,等待响应
- product_sn
str
: 云端分配的 ProductSN - device_sn
str
: 自定义的 DeviceSN - product_secret
str
: ProductSecret - timeout
int
: 等待响应超时时间,单位 s(秒)
云端 topo 信息变化的下发消息的回调函数
- callback
func
: 云端下发消息回调,消息类型 {}, 例如:def callback(msg): print(msg)
云端设备启用和禁用信息变化的下发消息的回调函数
- callback
func
: 云端下发消息回调,消息类型 {}, 例如:def callback(msg): print(msg)
上报 get topo 信息到 Link IoT Edge。同步执行,等待响应
- timeout
int
: 等待响应超时时间,单位 s(秒)
上报 add topo 信息到 Link IoT Edge
- product_sn
str
: 云端分配的 ProductSN - device_sn
str
: 云端分配的 DeviceSN - timeout
int
: 等待响应超时时间,单位 s(秒)
上报 delete topo 信息到 Link IoT Edge
- product_sn
str
: 云端分配的 ProductSN - device_sn
str
: 云端分配的 DeviceSN - timeout
int
: 等待响应超时时间,单位 s(秒)
获取网关的在线状态,返回 True / False
通过 nats Publish 消息
- subject
str
: nats Subject - payload
bytes
: nats 消息
通过 nats 订阅 主题
- subject
str
: nats Subject - queue
str
: nats 队列 - callback
func(msg)
: nats 消息回调, msg 为 nats 消息