Giter Site home page Giter Site logo

iotstack-driver-sdk-python's Introduction

API 参考文档

主要的 API 参考文档如下:

from uiotedgedriverlinksdk


from uiotedgedriverlinksdk.client


from uiotedgedriverlinksdk.exception

  • BaseEdgeException
  • EdgeDriverLinkException
  • EdgeDriverLinkTimeoutException
  • EdgeDriverLinkDeviceConfigException
  • EdgeDriverLinkDeviceOfflineException
  • EdgeDriverLinkOfflineException
  • EdgeDriverLinkDeviceProductSecretException

from uiotedgedriverlinksdk.client


from uiotedgedriverlinksdk.edge


from uiotedgedriverlinksdk.nats



getLogger()

返回驱动内置 logger。


getConfig()

返回驱动相关配置。


Config()

基于当前驱动配置字符串构造新的 Config 对象。


Config. getDeviceInfos()

返回所有设备相关信息,返回 DeviceInfoList DeviceInfo 包括如下信息:

  • productSN str : 官网申请的 productKey。
  • deviceSN str : 设备名
  • configdict :设备自定义配置

Config. getDriverInfo()

返回驱动相关信息,返回 DriverInfoList


SubDevice(product_sn,device_sn, on_msg_callback)

设备接入客户端类, 用户主要通过它上下线设备和主动上报消息

  • product_snstr: 云端分配的 ProductSN
  • device_snstr: 云端分配的 DeviceSN
  • on_msg_callbackfunc(topic:str, msg:b''): 云端下发消息回调,消息类型 []byte, 例如: def callbacl(topic:str, msg:b''): print(str(msg,'utf-8')

SubDevice.set_product_sn(product_sn)

设置子设备的 productSN

  • product_snstr: 云端分配的 ProductSN

SubDevice.set_device_sn(device_sn)

设备子设备的 DeviceSN

  • device_snstr: 云端分配的 DeviceSN

SubDevice.set_product_secret(product_secret)

设置子设备的 Product Secret

  • product_secretstr: 云端分配的 Product Secret

SubDevice.set_product_secret(product_secret)

设置子设备的 Product Secret

  • product_secretstr: 云端分配的 Product Secret

SubDevice.set_msg_callback(msg_callback)

设置子设备的接收消息的回调函数

  • set_msg_callbackfunc: 子设备收消息回调,例如: def callbacl(topic:str, msg:b''): print(str(msg,'utf-8')

SubDevice.set_rrpc_callback(msg_callback)->bytes

设置子设备的接收 RRPC 的回调函数

  • set_RRPC_callbackfunc: 子设备收消息回调,例如: def callback(topic:str, msg:b''): return b 'hello'

SubDevice.login(sync=False, timeout=5)

上报上线事件到 Link IoT Edge

  • syncbool: 是否异步登陆
  • timeoutint: 等待响应超时时间,单位 s(秒)

SubDevice.logout(sync=False, timeout=5)

上报下线事件到 Link IoT Edge

  • syncbool: 是否异步登陆
  • timeoutint: 等待响应超时时间,单位 s(秒)

SubDevice.publish(topic, payload)

上报消息到 Link IoT Edge。异步

  • topicstr: 上报消息到 Link IoT Edge 的 mqtt topic。
  • payload[]byte: 上报消息到 Link IoT Edge 的消息内容

SubDevice.registerDevice(timeout)

动态注册一个设备到 Link IoT Edge。同步

  • timeoutint: 等待响应超时时间,单位 s(秒)


register_device(product_sn, device_sn, product_secret, timeout=5)

上报动态注册到 Link IoT Edge。同步执行,等待响应

  • product_snstr: 云端分配的 ProductSN
  • device_snstr: 自定义的 DeviceSN
  • product_secretstr: ProductSecret
  • timeoutint: 等待响应超时时间,单位 s(秒)

set_on_topo_change_callback(callback)

云端 topo 信息变化的下发消息的回调函数

  • callbackfunc: 云端下发消息回调,消息类型 {}, 例如: def callback(msg): print(msg)

set_on_status_change_callback(callback)

云端设备启用和禁用信息变化的下发消息的回调函数

  • callbackfunc: 云端下发消息回调,消息类型 {}, 例如: def callback(msg): print(msg)

get_topo(timeout=5)

上报 get topo 信息到 Link IoT Edge。同步执行,等待响应

  • timeoutint: 等待响应超时时间,单位 s(秒)

add_topo(product_sn, device_sn, timeout=5)

上报 add topo 信息到 Link IoT Edge

  • product_snstr: 云端分配的 ProductSN
  • device_snstr: 云端分配的 DeviceSN
  • timeoutint: 等待响应超时时间,单位 s(秒)

delete_topo(product_sn, device_sn, timeout=5)

上报 delete topo 信息到 Link IoT Edge

  • product_snstr: 云端分配的 ProductSN
  • device_snstr: 云端分配的 DeviceSN
  • timeoutint: 等待响应超时时间,单位 s(秒)

get_edge_online_status()

获取网关的在线状态,返回 True / False


natsPublish(subject, payload)

通过 nats Publish 消息

  • subjectstr: nats Subject
  • payloadbytes: nats 消息

natsSubscribe(subject, queue, callback)

通过 nats 订阅 主题

  • subjectstr: nats Subject
  • queuestr: nats 队列
  • callbackfunc(msg): nats 消息回调, msg 为 nats 消息

iotstack-driver-sdk-python's People

Contributors

ethandu1 avatar lynn-zhang89 avatar uiot-core avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.