onenet

package
v0.0.0-...-a878d8a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sign

func Sign(version, res, method, apiKey string, et int64) (signature string)

Sign *

  • @Description: 签名
  • @param version
  • @param res
  • @param method
  • @param apiKey
  • @param et
  • @return signature

Types

type AccessKey

type AccessKey string

AccessKey is an option used for RequestClientOptions

type ApiKey

type ApiKey string

ApiKey is an option used for RequestClientOptions

type Body

type Body string

Body is an option used for RequestClientOptions

type Client

type Client struct {
	MasterAPIkey string // Master-APIkey
	AccessKey    string // access_key
	ProductId    string // 产品ID
	TimeOut      time.Duration
}

Client 请求客户端

func NewOneNetRequestClient

func NewOneNetRequestClient(apiKey, accessKey, productId string) (client *Client)

NewOneNetRequestClient *

  • @Description: 创建一个OneNET请求器
  • @param apiKey
  • @param accessKey
  • @param productId
  • @return client

func (*Client) CreateAPIKey

func (c *Client) CreateAPIKey()

CreateAPIKey *

  • @Description: 新增apikey
  • @receiver c

func (*Client) CreateDataPoint

func (c *Client) CreateDataPoint(deviceId, dataStreamName string, value interface{}) (res onenetmod.CreateDataPointsRes, err error)

CreateDataPoint *

  • @Description: 新增单个数据点
  • @receiver c
  • @param deviceId
  • @param dataStreamName
  • @param value
  • @return res
  • @return err

func (*Client) CreateDataStream

func (c *Client) CreateDataStream(deviceId string, req onenetmod.CreateDataStreamReq) (res onenetmod.CreateDataStreamRes, err error)

CreateDataStream *

  • @Description: 新增数据流
  • @receiver c
  • @param deviceId 设备ID
  • @param req 请求参数
  • @return res 响应参数
  • @return err 异常

func (*Client) CreateDevice

func (c *Client) CreateDevice(req onenetmod.CreateOrUpdateDeviceReq) (res onenetmod.CreateDeviceRes, err error)

CreateDevice *

  • @Description: 新增设备
  • @receiver c
  • @param req 请求参数
  • @return res 响应参数
  • @return err 错误

func (*Client) CreateTrigger

func (c *Client) CreateTrigger()

CreateTrigger *

  • @Description: 新增触发器
  • @receiver c

func (*Client) DeleteAPIKey

func (c *Client) DeleteAPIKey()

DeleteAPIKey *

  • @Description: 删除apikey
  • @receiver c

func (*Client) DeleteDataStream

func (c *Client) DeleteDataStream(deviceId, dataStreamId string) (res onenetmod.DeleteDataStreamRes, err error)

DeleteDataStream *

  • @Description: 删除数据流
  • @receiver c
  • @param deviceId 设备ID
  • @param dataStreamId 数据流ID
  • @return res 响应参数
  • @return err 错误

func (*Client) DeleteDevice

func (c *Client) DeleteDevice(deviceId string) (res onenetmod.UpdateDeviceRes, err error)

DeleteDevice *

  • @Description: 删除设备
  • @receiver c

func (*Client) DeleteTrigger

func (c *Client) DeleteTrigger()

DeleteTrigger *

  • @Description: 删除触发器
  • @receiver c

func (*Client) GetAPIKey

func (c *Client) GetAPIKey()

GetAPIKey *

  • @Description: 查询apikey
  • @receiver c

func (*Client) GetCmdResponse

func (c *Client) GetCmdResponse(cmdUUID string) (res string, err error)

GetCmdResponse *

  • @Description: 查询命令响应(只有当命令状态为“设备正常响应”时,API才有效)
  • @receiver c
  • @param cmdUUID 命令ID
  • @return res 响应参数
  • @return err 错误

func (*Client) GetCmdStatus

func (c *Client) GetCmdStatus(cmdUUID string) (res onenetmod.GetCMDStatusRes, err error)

GetCmdStatus *

  • @Description: 查询命令状态
  • @receiver c
  • @param cmdUUID 命令ID
  • @return res 响应参数
  • @return err 错误

func (*Client) GetDataStream

func (c *Client) GetDataStream(deviceId, dataStreamId string) (res onenetmod.GetDataStreamRes, err error)

GetDataStream *

  • @Description:查询数据流详情
  • @receiver c
  • @param deviceId 设备ID
  • @param dataStreamId 数据流ID
  • @return res 响应参数
  • @return err 错误

func (*Client) GetDataStreams

func (c *Client) GetDataStreams(deviceId string) (res onenetmod.GetDataStreamsRes, err error)

GetDataStreams *

  • @Description: 批量查询数据流信息
  • @receiver c
  • @param deviceId 设备ID
  • @return res 响应参数
  • @return err 错误

func (*Client) GetDeviceDataPoint

func (c *Client) GetDeviceDataPoint()

GetDeviceDataPoint *

  • @Description: 查询设备历史数据
  • @receiver c

func (*Client) GetDeviceHistoryCmd

func (c *Client) GetDeviceHistoryCmd(deviceId string, start, end *time.Time, page, perPage int) (res onenetmod.GetHistoryCMDRes, err error)

GetDeviceHistoryCmd *

  • @Description: 查询设备历史命令
  • @receiver c
  • @param deviceId 设备ID
  • @param start 查询的开始时间(必填)
  • @param end 查询的结束时间
  • @param page 指定页码
  • @param perPage 指定每页输出设备个数,默认30,最多100
  • @return res 响应参数
  • @return err 错误

func (*Client) GetDeviceInfo

func (c *Client) GetDeviceInfo(deviceId string) (res onenetmod.DeviceInfoRes, err error)

GetDeviceInfo *

  • @Description: 查询设备详情
  • @receiver c
  • @param deviceId 设备ID
  • @return res 响应参数
  • @return err 错误

func (*Client) GetDeviceTopic

func (c *Client) GetDeviceTopic()

GetDeviceTopic *

  • @Description: 查询设备订阅的topic
  • @receiver c

func (*Client) GetDevicesDataPoint

func (c *Client) GetDevicesDataPoint(deviceIds []string) (res onenetmod.GetDataPointsRes, err error)

GetDevicesDataPoint *

  • @Description: 批量查询设备最新数据
  • @receiver c
  • @param deviceIds
  • @return res
  • @return err

func (*Client) GetDevicesInfo

func (c *Client) GetDevicesInfo(req onenetmod.GetDevicesReq) (res onenetmod.DevicesInfoRes, err error)

GetDevicesInfo *

  • @Description: 批量查询设备详情
  • @receiver c
  • @param req
  • @return res
  • @return err

func (*Client) GetDevicesStatus

func (c *Client) GetDevicesStatus(deviceIds []string) (res onenetmod.GetDevicesStatusRes, err error)

GetDevicesStatus *

  • @Description: 批量查询设备状态
  • @receiver c
  • @param deviceIds 指定设备ID,多个用逗号分隔,最多1000个
  • @return res 响应参数
  • @return err 错误

func (*Client) GetFile

func (c *Client) GetFile()

GetFile *

  • @Description: 获取文件
  • @receiver c

func (*Client) GetTopic

func (c *Client) GetTopic()

GetTopic *

  • @Description: 查询产品的topic
  • @receiver c

func (*Client) GetTopicDevice

func (c *Client) GetTopicDevice()

GetTopicDevice *

  • @Description: 查询订阅topic设备
  • @receiver c

func (*Client) GetTrigger

func (c *Client) GetTrigger()

GetTrigger *

  • @Description: 查询触发器
  • @receiver c

func (*Client) PublishMsg

func (c *Client) PublishMsg()

PublishMsg *

  • @Description: 发布消息
  • @receiver c

func (*Client) RegisterDevice

func (c *Client) RegisterDevice()

RegisterDevice *

  • @Description: 注册设备
  • @receiver c

func (*Client) RequestClient

func (c *Client) RequestClient(url string, Method string, opts ...RequestClientOptions) (body []byte, err error)

RequestClient *

  • @Description: http请求Client
  • @receiver c
  • @param url
  • @param Method
  • @param opts
  • @return body
  • @return err

func (*Client) SendCmd

func (c *Client) SendCmd(deviceId string, qos, timeout int, cmd string) (res onenetmod.SendCMDRes, err error)

SendCmd *

  • @Description: 发送命令
  • @receiver c
  • @param deviceId 接收该数据的设备ID
  • @param qos 是否需要设备应答,默认为0。 0:最多发送一次,不关心设备是否响应 1:至少发送一次,如果设备收到命令后没有应答,则会在下一次设备登录时若命令在有效期内(有效期定义参见timeout参数)则会重发该命令
  • @param timeout 命令有效时间,默认0。有效范围:0~2678400
  • @param cmd 用户自定义数据:json、string、二进制数据(小于64K)
  • @return res 响应数据
  • @return err 错误

func (*Client) SetTimeOut

func (c *Client) SetTimeOut(timeOut time.Duration)

SetTimeOut *

  • @Description: 设置超时时间
  • @receiver c
  • @param timeOut

func (*Client) UpdateAPIKey

func (c *Client) UpdateAPIKey()

UpdateAPIKey *

  • @Description: 更新apikey
  • @receiver c

func (*Client) UpdateDataStream

func (c *Client) UpdateDataStream(deviceId, dataStreamId string, req onenetmod.UpdateDataStreamReq) (res onenetmod.UpdateDataStreamRes, err error)

UpdateDataStream *

  • @Description: 更新数据流属性
  • @receiver c
  • @param deviceId 设备ID
  • @param dataStreamId 数据流ID
  • @param req 请求参数
  • @return res 响应参数
  • @return err 错误

func (*Client) UpdateDevice

func (c *Client) UpdateDevice(deviceId string, req onenetmod.CreateOrUpdateDeviceReq) (res onenetmod.UpdateDeviceRes, err error)

UpdateDevice *

  • @Description: 更新设备
  • @receiver c
  • @param deviceId 设备ID
  • @param req 请求参数
  • @return res 响应参数
  • @return err 错误

func (*Client) UpdateTrigger

func (c *Client) UpdateTrigger()

UpdateTrigger *

  • @Description: 更新触发器
  • @receiver c

func (*Client) UploadFile

func (c *Client) UploadFile()

UploadFile *

  • @Description: 上传文件
  • @receiver c

type ContentType

type ContentType string

ContentType is an option used for RequestClientOptions

type RequestClientOptions

type RequestClientOptions interface {
	// contains filtered or unexported methods
}

type RequestClientPr

type RequestClientPr struct {
	ContentType string // ContentType
	Body        string // RequestBody
	ApiKey      string // ApiKey
	AccessKey   string // AccessKey
	SafeSign    bool   // 是否使用安全方式签名
}

type SafeSign

type SafeSign bool // 使用安全方式签名

SafeSign is an option used for RequestClientOptions

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL