weemesh

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

README

weemesh/weemesh-go-sdk

微麦石物联网平台SDK

功能

  1. 获取指定产品的物模型
  2. 获取指定设备的状态

使用方法

package main

import (
	"fmt"
	"gitee.com/winstar-smart/weemesh-go-sdk"
	"log"
)

const (
	accessKey    = "xxxx"
	accessSecret = "xxxx"
	address      = "xxxx"
	productKey   = "xxxx"
	orgId        = "xxxx"
	sn = "xxxx"
)

func main() {
	c := weemesh.NewClient(accessKey, accessSecret, address)

	// 获取指定产品的物模型
	result, err := c.GetThingModel(productKey, orgId)

	if err != nil {
		log.Fatal(err)
	}
	
	log.Println(result)
	
	// 获取指定设备的状态
	result, err = c.GetDeviceState(sn)

	if err != nil {
		log.Fatal(err)
	}

	log.Println(result)
	
}

Documentation

Index

Constants

View Source
const (
	Version230503 = "2023-05-03"
	MethodSha1    = "sha1"
	APIVersion    = "v1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(accessKey, accessSecret, address string) *Client

func (*Client) GetAppProductKeys

func (c *Client) GetAppProductKeys(appName string) (*CommonResult[[]string], error)

func (*Client) GetDevice

func (c *Client) GetDevice(sn string) (*CommonResult[map[string]interface{}], error)

func (*Client) GetDeviceLatestProperty

func (c *Client) GetDeviceLatestProperty(sn string) (*CommonResult[map[string]interface{}], error)

func (*Client) GetDeviceState

func (c *Client) GetDeviceState(sn string) (*CommonResult[bool], error)

func (*Client) GetFirmwareVersionsByProductKey

func (c *Client) GetFirmwareVersionsByProductKey(productKey string, tags []string) (*CommonResult[[]map[string]interface{}], error)

func (*Client) GetOTALatestJob added in v0.0.9

func (c *Client) GetOTALatestJob(sn string) (*CommonResult[map[string]interface{}], error)

func (*Client) GetProductsOfMe added in v0.1.2

func (c *Client) GetProductsOfMe() (*CommonResult[[]map[string]interface{}], error)

func (*Client) GetThingModel

func (c *Client) GetThingModel(productKey, organizationID string) (*CommonResult[any], error)

func (*Client) NewFirmware added in v0.1.1

func (c *Client) NewFirmware(params *model.NewFirmwareParams) (*CommonResult[any], error)

type CommonResult

type CommonResult[T any] struct {
	/** 错误编码
	 * 1xx:信息 - 收到请求,继续处理;
	 * 2xx:成功——动作被成功接收、理解和接受;
	 * 3xx:重定向 - 必须采取进一步的行动才能完成请求;
	 * 4xx:客户端错误 - 请求包含错误的语法或无法实现;
	 * 5xx:服务器错误——服务器未能完成明显有效的请求;
	 * */
	Code int `json:"code"`

	Message string `json:"message"`

	Data T `json:"data"`

	RequestID uuid.UUID `json:"request_id"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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