service

package
v0.0.0-...-3249af5 Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: MIT Imports: 24 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AepCmd

func AepCmd(cfg *AepConf, sn string, parameter string, serviceIdentifier string, operator string) error

AepCmd 指令下发

func DelRdValue

func DelRdValue(key string) (int64, error)

func EmqxApiPublish

func EmqxApiPublish(emqxCfg *config.EmqxConf, params *EmqxParamsConf)

EmqxApiPublish 使用emqx自带api服务,便于业务管理后台操作

func GetClient

func GetClient(addr, username, password, database, precision string) client.Client

func GetMqttClient

func GetMqttClient(broker_, username_, password_ string, defaultHandler mqtt.MessageHandler) mqtt.Client

func GetRdKeys

func GetRdKeys(pattern string) ([]string, error)

func GetRdValue

func GetRdValue(key string) (string, error)

func GetRedisClient

func GetRedisClient(addr, password string, db int) *redis.Client

func MqttSend

func MqttSend(topic string, payload interface{}, qos_ byte) error

func MqttSubscribe

func MqttSubscribe(broker_, username_, password_ string, topic_ []string, qos_ byte, defaultHandler mqtt.MessageHandler) (mqtt.Client, error)

func OneNetDevice

func OneNetDevice(deviceId int, apiKey string) bool

func SelectFieldsInflux

func SelectFieldsInflux(fields, sn, sql string, database, prefix string) (res []client.Result, err1 error)

SelectFieldsInflux fields,例:`a,b` sql是赛选条件,例:`LIMIT 10`

func SelectInflux

func SelectInflux(sn, sql string, database, prefix string) (res []client.Result, err1 error)

SelectInflux sql是赛选条件,例:`LIMIT 10`

func SetRdValue

func SetRdValue(key string, value interface{}) error

func SetRdValueTimeout

func SetRdValueTimeout(key string, value interface{}, expiration time.Duration) error

func SubscribeKeyExpired

func SubscribeKeyExpired(db string, fc RedisKeyExpiredFunc) error

SubscribeKeyExpired 订阅redis key过期事件 *

  • 订阅redis key过期事件
  • @param db redis库,*表示所有库
  • @param fc 回调函数

func TcpClientSend_

func TcpClientSend_(sn string, snConnMap map[string]*gtcp.Conn, data []byte)

TcpClientSend_ 发送例子

func TcpServer

func TcpServer(tcpPort, debug int, replyFunc TcpReplyFunc, resolvingFunc TcpResolvingFunc, offlineFunc TcpOfflineFunc)

TcpServer 因转发需要用到RabbitMQ,所以需先初始化RabbitMQ

func WirteInflux

func WirteInflux(sn string, productKey string, status int64, fields map[string]interface{}, database, prefix, precision string) (string, error)

Types

type AepCmdBody

type AepCmdBody struct {
	Content       AepCmdBodyContent `json:"content"`
	DeviceId      string            `json:"deviceId"`
	Operator      string            `json:"operator"`
	ProductId     int64             `json:"productId"`
	Ttl           int               `json:"ttl"`
	DeviceGroupId int               `json:"deviceGroupId"`
	Level         int               `json:"level"`
}

type AepCmdBodyContent

type AepCmdBodyContent struct {
	ServiceIdentifier string `json:"serviceIdentifier"`
	Params            string `json:"params"` // json 字符串
}

type AepCmdRespone

type AepCmdRespone struct {
	Code   int                 `json:"code"`
	Msg    string              `json:"msg"`
	Result AepCmdResponeResult `json:"result"`
}

type AepCmdResponeResult

type AepCmdResponeResult struct {
	CommandId     string `json:"commandId"`
	Command       string `json:"command"`
	CommandStatus string `json:"commandStatus"`
	ProductId     int64  `json:"productId"`
	DeviceId      string `json:"deviceId"`
	Imei          string `json:"imei"`
	CreateBy      string `json:"createBy"`
	CreateTime    int64  `json:"createTime"`
	Ttl           int    `json:"ttl"`
}

type AepConf

type AepConf struct {
	AppKey    string
	AppSecret string
	ProductId int64
	MasterKey string
}

type AepCreateBody

type AepCreateBody struct {
	DeviceName string         `json:"deviceName"`
	DeviceSn   string         `json:"deviceSn,omitempty"` // sn 和 imei 至少填一个
	Imei       string         `json:"imei,omitempty"`     // sn 和 imei 至少填一个
	Operator   string         `json:"operator"`
	Other      AepCreateOther `json:"other"`
	ProductId  int64          `json:"productId"`
}

type AepCreateOther

type AepCreateOther struct {
	AutoObserver int64  `json:"autoObserver"`
	Imsi         string `json:"imsi,omitempty"`
	PskValue     string `json:"pskValue,omitempty"`
}

type AepCreateResponeResult

type AepCreateResponeResult struct {
	DeviceSn   string `json:"deviceSn"`
	DeviceId   string `json:"deviceId"`
	DeviceName string `json:"deviceName"`
	TenantId   string `json:"tenantId"`
	ProductId  int64  `json:"productId"`
	Imei       string `json:"imei"`
	Token      string `json:"token"`
}

type AepListByDeviceIdsBody

type AepListByDeviceIdsBody struct {
	ProductId    int64    `json:"productId"`
	DeviceIdList []string `json:"deviceIdList"`
}

type AepListByDeviceIdsItem

type AepListByDeviceIdsItem struct {
	ActiveTime      int64  `json:"activeTime"`      //,omitempty"`
	CreateBy        string `json:"createBy"`        //,omitempty"`
	CreateTime      int64  `json:"createTime"`      //,omitempty"`
	DeviceId        string `json:"deviceId"`        //,omitempty"`
	DeviceName      string `json:"deviceName"`      //,omitempty"`
	DeviceSn        string `json:"deviceSn"`        //,omitempty"`
	DeviceStatus    int64  `json:"deviceStatus"`    //,omitempty"`
	FirmwareVersion string `json:"firmwareVersion"` //,omitempty"`
	Imei            string `json:"imei"`            //,omitempty"`
	Imsi            string `json:"imsi"`            //,omitempty"`
	LogoutTime      string `json:"logoutTime"`      //,omitempty"`
	NetStatus       int64  `json:"netStatus"`       //,omitempty"`
	OfflineAt       int64  `json:"offlineAt"`       //,omitempty"`
	OnlineAt        int64  `json:"onlineAt"`        //,omitempty"`
	ProductId       int64  `json:"productId"`       //,omitempty"`
	TenantId        string `json:"tenantId"`        //,omitempty"`
	UpdateBy        string `json:"updateBy"`        //,omitempty"`
	UpdateTime      int64  `json:"updateTime"`      //,omitempty"`
}

type AepListByDeviceIdsRespone

type AepListByDeviceIdsRespone struct {
	Code   int                      `json:"code"`
	Msg    string                   `json:"msg"`
	Result []AepListByDeviceIdsItem `json:"result"`
}

func AepListByDeviceIds

func AepListByDeviceIds(cfg *AepConf, deviceIdList []string) (*AepListByDeviceIdsRespone, error)

type AepRespone

type AepRespone struct {
	Code   int         `json:"code"`
	Msg    string      `json:"msg"`
	Result interface{} `json:"result"`
}

func AepCreate

func AepCreate(cfg *AepConf, sn, imei, deviceName, operator string) (*AepRespone, error)

AepCreate 增加设备:没有批量方法

func AepDeviceList

func AepDeviceList(cfg *AepConf, pageNow, pageSize int64, searchValue string) (*AepRespone, error)

AepDeviceList 批量获取设备信息

type EmqxParamsConf

type EmqxParamsConf struct {
	model.Eq2MqLog
	App     string // 暂时未使用,默认 runThings
	User    int64  // 用户id
	Project int64  // 项目id
}

type MqRecieveMsgFunc

type MqRecieveMsgFunc func(string)

MqRecieveMsgFunc 向外部提供方法

type OneNetDeviceReq

type OneNetDeviceReq struct {
	Ack      bool   `json:"ack"`
	ActTime  string `json:"act_time"`
	Area     string `json:"area"`
	AuthInfo struct {
		Field1 string `json:"869334059269368"`
	} `json:"auth_info"`
	CreateTime  string `json:"create_time"`
	Datastreams []struct {
		CreateTime string `json:"create_time"`
		Id         string `json:"id"`
		Uuid       string `json:"uuid"`
	} `json:"datastreams"`
	Desc     string   `json:"desc"`
	Fversion string   `json:"fversion"`
	Id       string   `json:"id"`
	Imsi     string   `json:"imsi"`
	ImsiMt   string   `json:"imsi_mt"`
	ImsiOld  []string `json:"imsi_old"`
	LastCt   string   `json:"last_ct"`
	Location struct {
		Lat int `json:"lat"`
		Lon int `json:"lon"`
	} `json:"location"`
	Obsv            bool          `json:"obsv"`
	ObsvSt          bool          `json:"obsv_st"`
	Online          bool          `json:"online"`
	Private         bool          `json:"private"`
	Protocol        string        `json:"protocol"`
	RgId            string        `json:"rg_id"`
	SoftwareVersion string        `json:"software_version"`
	Tags            []interface{} `json:"tags"`
	Title           string        `json:"title"`
}

type OneNetDeviceStatusRsp

type OneNetDeviceStatusRsp struct {
	Id     string `json:"id"`
	Online bool   `json:"online"`
	Title  string `json:"title"`
}

type OneNetDeviceStatusRspList

type OneNetDeviceStatusRspList struct {
	Devices    []*OneNetDeviceStatusRsp `json:"devices"`
	TotalCount int64                    `json:"total_Count"`
}

type RabbitMQ

type RabbitMQ struct {

	//队列名称
	QueueName string
	//交换机
	Exchange string
	//key Simple模式 几乎用不到
	Key string
	//连接信息
	Mqurl string
	// contains filtered or unexported fields
}

func NewRabbitMQ

func NewRabbitMQ(queuename string, exchange string, key string, mqurl string) *RabbitMQ

NewRabbitMQ 创建RabbitMQ结构体实例

func NewRabbitMQPubSub

func NewRabbitMQPubSub(exchangeName string, mqurl string) *RabbitMQ

NewRabbitMQPubSub 订阅模式创建rabbitmq实例

func NewRabbitMQRouting

func NewRabbitMQRouting(exchagne string, routingKey string, mqurl string) *RabbitMQ

NewRabbitMQRouting 路由模式 创建RabbitMQ实例

func NewRabbitMQSimple

func NewRabbitMQSimple(queueName string, mqurl string) *RabbitMQ

NewRabbitMQSimple 简单模式step:1。创建简单模式下RabbitMQ实例

func NewRabbitMQTopic

func NewRabbitMQTopic(exchagne string, routingKey string, mqurl string) *RabbitMQ

NewRabbitMQTopic 话题模式 创建RabbitMQ实例

func (*RabbitMQ) ConsumeSimple

func (r *RabbitMQ) ConsumeSimple(fc MqRecieveMsgFunc)

ConsumeSimple 修改简单模式,其实支持外部函数调用

func (*RabbitMQ) Destory

func (r *RabbitMQ) Destory()

Destory 断开channel和connection

func (*RabbitMQ) PublishPub

func (r *RabbitMQ) PublishPub(message string)

PublishPub 订阅模式生成

func (*RabbitMQ) PublishRouting

func (r *RabbitMQ) PublishRouting(message string)

PublishRouting 路由模式发送信息

func (*RabbitMQ) PublishSimple

func (r *RabbitMQ) PublishSimple(message string)

PublishSimple 简单模式Step:2、简单模式下生产代码

func (*RabbitMQ) PublishTopic

func (r *RabbitMQ) PublishTopic(message string)

PublishTopic 话题模式发送信息

func (*RabbitMQ) RecieveRouting

func (r *RabbitMQ) RecieveRouting()

RecieveRouting 路由模式接收信息

func (*RabbitMQ) RecieveSub

func (r *RabbitMQ) RecieveSub(fc MqRecieveMsgFunc)

RecieveSub 订阅模式消费端代码

func (*RabbitMQ) RecieveTopic

func (r *RabbitMQ) RecieveTopic()

RecieveTopic 话题模式接收信息 要注意key 其中* 用于匹配一个单词,#用于匹配多个单词(可以是零个) 匹配 表示匹配imooc.* 表示匹配imooc.hello,但是imooc.hello.one需要用imooc.#才能匹配到

type RedisKeyExpiredFunc

type RedisKeyExpiredFunc func(string)

type TcpOfflineFunc

type TcpOfflineFunc func(port string)

type TcpReplyFunc

type TcpReplyFunc func(conn *gtcp.Conn, clientPort string, data []byte)

TcpReplyFunc tcp回复函数

type TcpResolvingFunc

type TcpResolvingFunc func(ip, clientPort string, data []byte)

Jump to

Keyboard shortcuts

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