Documentation ¶
Index ¶
- Constants
- func NewTLSConfig(certFile string, certPrivateKey string) (*tls.Config, error)
- func PublishData(mc *MqttClient, topic string, data interface{}) (msgId string, err error)
- func SubscribeData(mc *MqttClient, topic string, handler func(res *Message, err error)) (err error)
- func ToTopic(str ...string) string
- type DeviceInfo
- type Identity
- type Message
- type MinerGuestData
- type MinerHeartbeatData
- type MinerSettingsData
- type MinerWorkloadData
- type MqttClient
- func (mc *MqttClient) ClientId() string
- func (mc *MqttClient) Close()
- func (mc *MqttClient) Publish(topic string, payload []byte) error
- func (mc *MqttClient) PublishData(topicType TopicType, data interface{}) (string, error)
- func (mc *MqttClient) PublishDataTo(clientId string, topicType TopicType, data interface{}) (string, error)
- func (mc *MqttClient) Subscribe(topic string, onMessage mqtt.MessageHandler) error
- func (mc *MqttClient) SubscribeData(topicType TopicType, handler func(res *Message, err error)) (err error)
- func (mc *MqttClient) SubscribeDataFrom(clientId string, topicType TopicType, handler func(res *Message, err error)) (err error)
- func (mc *MqttClient) Unsubscribe(topics ...string) error
- type MqttConfig
- type OtaFirmwareCheckData
- type OtaFirmwareUpgradeData
- type OtaFirmwareUpgradeReplyData
- type Qos
- type ReplyData
- type SystemCommandData
- type SystemCommandReplyData
- type SystemInfo
- type TopicType
- type WiFiStatus
- type WifiClientInfo
Constants ¶
View Source
const Biz = "/biz"
View Source
const Broadcast = "/broadcast"
View Source
const ClientId = "${clientid}"
View Source
const Ext = "/ext"
View Source
const MLW = "#" // multi level wildcard
View Source
const Ota = "/ota"
View Source
const ProductKey = "miner" // Temporarily fixed as “miner”
View Source
const SLW = "+" // single level wildcard
View Source
const SSys = "$SYS"
View Source
const Shadow = "/shadow"
View Source
const Sys = "/sys"
View Source
const Version = "1.0"
Variables ¶
This section is empty.
Functions ¶
func NewTLSConfig ¶
NewTLSConfig New TLS Config
func PublishData ¶
func PublishData(mc *MqttClient, topic string, data interface{}) (msgId string, err error)
func SubscribeData ¶
func SubscribeData(mc *MqttClient, topic string, handler func(res *Message, err error)) (err error)
Types ¶
type DeviceInfo ¶
type DeviceInfo struct { Kernel string `json:"kernel"` Hostname string `json:"hostname"` System string `json:"system"` Model string `json:"model"` BoardName string `json:"board_name"` Release struct { Distribution string `json:"distribution"` Version string `json:"version"` Revision string `json:"revision"` Target string `json:"target"` Description string `json:"description"` } `json:"release"` }
type Identity ¶
type Identity struct { Validator interface{} `json:"validator" v:"required" binding:"required"` Miner interface{} `json:"miner" v:"required" binding:"required"` }
type Message ¶
type Message struct { Id string `json:"id"` Ts int64 `json:"ts"` Data interface{} `json:"data"` Version string `json:"version"` // contains filtered or unexported fields }
func NewMessage ¶
func NewMessage(data interface{}) *Message
func NewMessageWithId ¶
func (Message) ProductKey ¶
func (Message) RawMessage ¶
type MinerGuestData ¶
type MinerGuestData struct { MinerSn string `json:"minerSn" description:""` ClientId string `json:"clientId" description:"Device ID"` Hostname string `json:"hostname" description:"guest phone brand"` Mac string `json:"mac" description:"guest device mac"` DisplayName string `json:"displayName" description:"guest display name"` PhoneNumber string `json:"phoneNumber" description:"Phone number"` BirthDate string `json:"birthDate" description:"Birthday"` Gender int `json:"gender" description:"Gender(0-Unknown,1-Male,2-Female)"` Email string `json:"email" description:"Email address"` EmailVerified bool `json:"emailVerified" description:"Whether the email has been verified"` CountryCode string `json:"countryCode" description:"Country Code"` LanguageCode string `json:"languageCode" description:"Language code"` }
MinerGuestData is the golang structure for table miner_guest_record.
type MinerHeartbeatData ¶
type MinerHeartbeatData struct { Sn string `json:"sn" binding:"required" v:"required"` Did string `json:"did" binding:"required" v:"required"` Mac string `json:"mac" binding:"required" v:"required"` PublicIP string `json:"publicIP"` WalletAddress string `json:"walletAddress" ` RadioStatus []WiFiStatus `json:"radioStatus" binding:"required"` SystemStatus SystemInfo `json:"systemStatus" binding:"required"` DeviceStatus DeviceInfo `json:"deviceStatus" binding:"required"` }
type MinerSettingsData ¶
type MinerWorkloadData ¶
type MqttClient ¶
MqttClient MQTT Client
func NewMqttClient ¶
func NewMqttClient(cfg MqttConfig) (*MqttClient, error)
func (*MqttClient) ClientId ¶
func (mc *MqttClient) ClientId() string
func (*MqttClient) Close ¶
func (mc *MqttClient) Close()
func (*MqttClient) Publish ¶
func (mc *MqttClient) Publish(topic string, payload []byte) error
Publish Mqtt message.
func (*MqttClient) PublishData ¶
func (mc *MqttClient) PublishData(topicType TopicType, data interface{}) (string, error)
func (*MqttClient) PublishDataTo ¶
func (mc *MqttClient) PublishDataTo(clientId string, topicType TopicType, data interface{}) (string, error)
func (*MqttClient) Subscribe ¶
func (mc *MqttClient) Subscribe(topic string, onMessage mqtt.MessageHandler) error
Subscribe subscribe a Mqtt topic.
func (*MqttClient) SubscribeData ¶
func (mc *MqttClient) SubscribeData(topicType TopicType, handler func(res *Message, err error)) (err error)
func (*MqttClient) SubscribeDataFrom ¶
func (*MqttClient) Unsubscribe ¶
func (mc *MqttClient) Unsubscribe(topics ...string) error
Unsubscribe unsubscribe a Mqtt topic.
type MqttConfig ¶
type MqttConfig struct { Broker string `json:"broker"` ClientId string `json:"clientId"` //SN Username string `json:"username"` //did (optional) Password string `json:"password"` CertFile string `json:"certFile"` CertPrivateKey string `json:"certPrivateKey"` WillEnabled bool `json:"willEnabled"` WillPayload string `json:"willPayload"` WillQos byte `json:"willQos"` Qos byte `json:"qos"` Retained bool `json:"retained"` ConnectionLostHandler mqtt.ConnectionLostHandler OnConnectHandler mqtt.OnConnectHandler }
MqttConfig MQTT Config
type OtaFirmwareCheckData ¶
type OtaFirmwareCheckData struct { Distribution string `json:"distribution" binding:"required" v:"required"` Version string `json:"version" binding:"required" v:"required"` Target string `json:"target" binding:"required" v:"required"` Description string `json:"description" binding:"required" v:"required"` Model string `json:"model" binding:"required" v:"required"` BoardName string `json:"boardName" binding:"required" v:"required"` Sn string `json:"sn" binding:"required" v:"required"` }
type OtaFirmwareUpgradeData ¶
type OtaFirmwareUpgradeData struct { Id int `json:"id" binding:"required" v:"required"` Distribution string `json:"distribution" binding:"required" v:"required"` Version string `json:"version" binding:"required" v:"required"` Target string `json:"target" binding:"required" v:"required"` Description string `json:"description" binding:"required" v:"required"` ImageUrl string `json:"imageUrl" binding:"required" v:"required"` IsForced bool `json:"isForced" binding:"required" v:"required"` Sha256 string `json:"sha256" binding:"required" v:"required"` Model string `json:"model" binding:"required" v:"required"` BoardName string `json:"boardName" binding:"required" v:"required"` }
type SystemCommandData ¶
type SystemCommandReplyData ¶
type SystemInfo ¶
type SystemInfo struct { Localtime int `json:"localtime"` Uptime int `json:"uptime"` Load []int `json:"load"` Memory struct { Total int `json:"total"` Free int `json:"free"` Shared int `json:"shared"` Buffered int `json:"buffered"` Available int `json:"available"` Cached int `json:"cached"` } `json:"memory"` Swap struct { Total int `json:"total"` Free int `json:"free"` } `json:"swap"` }
type TopicType ¶
type TopicType string
const ( SysWillStatus TopicType = Sys + "/%s/%s/will/status" // client Pub SysHeartbeatUpdate TopicType = Sys + "/%s/%s/heartbeat/update" // client Pub SysHeartbeatUpdateReply TopicType = SysHeartbeatUpdate + _REPLY // client Sub SysSettingsGet TopicType = Sys + "/%s/%s/settings/get" // client Pub SysSettingsUpdate TopicType = Sys + "/%s/%s/settings/update" // client Sub SysCommand TopicType = Sys + "/%s/%s/command/issue" // client Sub SysCommandReply TopicType = SysCommand + _REPLY // client Pub BizWorkloadValidate TopicType = Biz + "/%s/%s/workload/validate" // client Pub BizWorkloadValidateReply TopicType = BizWorkloadValidate + _REPLY // client Sub OtaFirmwareCheck TopicType = Ota + "/%s/%s/firmware/check" // client Pub OtaFirmwareUpgrade TopicType = Ota + "/%s/%s/firmware/upgrade" // client Sub OtaFirmwareUpgradeReply TopicType = OtaFirmwareUpgrade + _REPLY // client Pub )
type WiFiStatus ¶
type WiFiStatus struct { Disabled bool `json:"disabled"` Type string `json:"type"` // openroaming | free Phy string `json:"phy"` Ssid string `json:"ssid"` Bssid string `json:"bssid"` Country string `json:"country"` Mode string `json:"mode"` Channel int `json:"channel"` CenterChan1 int `json:"center_chan1"` Frequency int `json:"frequency"` FrequencyOffset int `json:"frequency_offset"` Txpower int `json:"txpower"` TxpowerOffset int `json:"txpower_offset"` Quality int `json:"quality"` QualityMax int `json:"quality_max"` Signal int `json:"signal"` Noise int `json:"noise"` Bitrate int `json:"bitrate"` Encryption struct { Enabled bool `json:"enabled"` Wpa []int `json:"wpa,omitempty"` Authentication []string `json:"authentication,omitempty"` Ciphers []string `json:"ciphers,omitempty"` } `json:"encryption"` Htmodes []string `json:"htmodes"` Hwmodes []string `json:"hwmodes"` Hwmode string `json:"hwmode"` Htmode string `json:"htmode"` Station []WifiClientInfo `json:"station"` }
Click to show internal directories.
Click to hide internal directories.