Documentation ¶
Index ¶
- func AepCmd(cfg *AepConf, sn string, parameter string, serviceIdentifier string, ...) error
- func DelRdValue(key string) (int64, error)
- func EmqxApiPublish(emqxCfg *config.EmqxConf, params *EmqxParamsConf)
- func GetClient(addr, username, password, database, precision string) client.Client
- func GetMqttClient(broker_, username_, password_ string, defaultHandler mqtt.MessageHandler) mqtt.Client
- func GetRdKeys(key string) ([]string, error)
- func GetRdValue(key string) (string, error)
- func GetRedisClient(addr, password string, db int) *redis.Client
- func MqttSend(topic string, payload interface{}, qos_ byte) error
- func MqttSubscribe(broker_, username_, password_ string, topic_ []string, qos_ byte, ...) (mqtt.Client, error)
- func OneNetDevice(deviceId int, apiKey string) bool
- func SelectFieldsInflux(fields, sn, sql string, database, prefix string) (res []client.Result, err1 error)
- func SelectInflux(sn, sql string, database, prefix string) (res []client.Result, err1 error)
- func SetRdValue(key string, value interface{}) error
- func SetRdValueTimeout(key string, value interface{}, expiration time.Duration) error
- func SubscribeKeyExpired(db string, fc RedisKeyExpiredFunc) error
- func TcpClientSend_(sn string, snConnMap map[string]*gtcp.Conn, data []byte)
- func TcpServer(tcpPort, debug int, replyFunc TcpReplyFunc, resolvingFunc TcpResolvingFunc, ...)
- func WirteInflux(sn string, productKey string, status int64, fields map[string]interface{}, ...) (string, error)
- type AepCmdBody
- type AepCmdBodyContent
- type AepCmdRespone
- type AepCmdResponeResult
- type AepConf
- type AepCreateBody
- type AepCreateOther
- type AepCreateResponeResult
- type AepListByDeviceIdsBody
- type AepListByDeviceIdsItem
- type AepListByDeviceIdsRespone
- type AepRespone
- type EmqxParamsConf
- type MqRecieveMsgFunc
- type OneNetDeviceReq
- type OneNetDeviceStatusRsp
- type OneNetDeviceStatusRspList
- type RabbitMQ
- func NewRabbitMQ(queuename string, exchange string, key string, mqurl string) *RabbitMQ
- func NewRabbitMQPubSub(exchangeName string, mqurl string) *RabbitMQ
- func NewRabbitMQRouting(exchagne string, routingKey string, mqurl string) *RabbitMQ
- func NewRabbitMQSimple(queueName string, mqurl string) *RabbitMQ
- func NewRabbitMQTopic(exchagne string, routingKey string, mqurl string) *RabbitMQ
- func (r *RabbitMQ) ConsumeSimple(fc MqRecieveMsgFunc)
- func (r *RabbitMQ) Destory()
- func (r *RabbitMQ) PublishPub(message string)
- func (r *RabbitMQ) PublishRouting(message string)
- func (r *RabbitMQ) PublishSimple(message string)
- func (r *RabbitMQ) PublishTopic(message string)
- func (r *RabbitMQ) RecieveRouting()
- func (r *RabbitMQ) RecieveSub(fc MqRecieveMsgFunc)
- func (r *RabbitMQ) RecieveTopic()
- type RedisKeyExpiredFunc
- type TcpOfflineFunc
- type TcpReplyFunc
- type TcpResolvingFunc
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 EmqxApiPublish ¶
func EmqxApiPublish(emqxCfg *config.EmqxConf, params *EmqxParamsConf)
EmqxApiPublish 使用emqx自带api服务,便于业务管理后台操作
func GetMqttClient ¶
func GetMqttClient(broker_, username_, password_ string, defaultHandler mqtt.MessageHandler) mqtt.Client
func GetRdValue ¶
func GetRedisClient ¶
func MqttSubscribe ¶
func OneNetDevice ¶
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 ¶
SelectInflux sql是赛选条件,例:`LIMIT 10`
func SetRdValue ¶
func SetRdValueTimeout ¶
func SubscribeKeyExpired ¶
func SubscribeKeyExpired(db string, fc RedisKeyExpiredFunc) error
SubscribeKeyExpired 订阅redis key过期事件 *
- 订阅redis key过期事件
- @param db redis库,*表示所有库
- @param fc 回调函数
func TcpClientSend_ ¶
TcpClientSend_ 发送例子
func TcpServer ¶
func TcpServer(tcpPort, debug int, replyFunc TcpReplyFunc, resolvingFunc TcpResolvingFunc, offlineFunc TcpOfflineFunc)
TcpServer 因转发需要用到RabbitMQ,所以需先初始化RabbitMQ
Types ¶
type AepCmdBody ¶
type AepCmdBodyContent ¶
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 AepCreateBody ¶
type AepCreateOther ¶
type AepCreateResponeResult ¶
type AepListByDeviceIdsBody ¶
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 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 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 ¶
NewRabbitMQ 创建RabbitMQ结构体实例
func NewRabbitMQPubSub ¶
NewRabbitMQPubSub 订阅模式创建rabbitmq实例
func NewRabbitMQRouting ¶
NewRabbitMQRouting 路由模式 创建RabbitMQ实例
func NewRabbitMQSimple ¶
NewRabbitMQSimple 简单模式step:1。创建简单模式下RabbitMQ实例
func NewRabbitMQTopic ¶
NewRabbitMQTopic 话题模式 创建RabbitMQ实例
func (*RabbitMQ) ConsumeSimple ¶
func (r *RabbitMQ) ConsumeSimple(fc MqRecieveMsgFunc)
ConsumeSimple 修改简单模式,其实支持外部函数调用
func (*RabbitMQ) PublishRouting ¶
PublishRouting 路由模式发送信息
func (*RabbitMQ) PublishSimple ¶
PublishSimple 简单模式Step:2、简单模式下生产代码
func (*RabbitMQ) PublishTopic ¶
PublishTopic 话题模式发送信息
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 ¶
TcpReplyFunc tcp回复函数