package main
import (
"gobot.io/x/gobot"
"gobot.io/x/gobot/platforms/mqtt"
"fmt"
"time"
)
func main() {
mqttAdaptor := mqtt.NewAdaptor("tcp://0.0.0.0:1883", "pinger")
work := func() {
mqttAdaptor.On("hello", func(msg mqtt.Message) {
fmt.Println(msg)
})
mqttAdaptor.On("hola", func(msg mqtt.Message) {
fmt.Println(msg)
})
data := []byte("o")
gobot.Every(1*time.Second, func() {
mqttAdaptor.Publish("hello", data)
})
gobot.Every(5*time.Second, func() {
mqttAdaptor.Publish("hola", data)
})
}
robot := gobot.NewRobot("mqttBot",
[]gobot.Connection{mqttAdaptor},
work,
)
robot.Start()
}
使用 mqttAdaptor.Publish可以发送消息 mqttAdaptor.On 可以订阅消息,如果有用户验证可以使用如下方式:
mqttAdaptor = mqtt.NewAdaptorWithAuth(
"EMQ.host",
"EMQ.clientID",
"EMQ.userName",
"EMQ.passWordActive",
)
断开也可以配置重连规则自动重连(默认未开启,作为服务端强烈建议开启)
mqttAdaptor.SetAutoReconnect(true)
以及消息清理机制(默认断开连接清理消息)
mqttAdaptor.SetCleanSession(false)
也可以指定使用TLS证书连接
mqttAdaptor.SetUseSSL(true)
# 下面可以指定证书(如果EMQ使用了标准的CA证书下面就不用配置了)
mqttAdaptor.SetClientKey(`/client/client-key.pem`)
mqttAdaptor.SetClientCert(`/client/client-cert.pem`)
分享到:
相关推荐
Xcode的安装路径在描述中给出,位于"/应用程序/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/De"。这个路径揭示了Xcode的内部结构,其中“/应用程序/”是MacOS系统的应用程序目录,“Xcode.app”是...
每个版本的iOS都会有一个对应的子目录,例如,针对iOS 13.6的子目录可能是 `./DeviceSupport/13.6 (17G70)`,其中包含了用于真机调试的固件信息和模拟器所需的数据。 四、设备支持文件的作用 设备支持文件包含了与...
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/ 模拟器 dylib放到这个路径 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS....
"gobot.io/x/gobot/platforms/firmata" ) func main () { firmataAdaptor := firmata . NewAdaptor ( "/dev/ttyACM0" ) led := gpio . NewLedDriver ( firmataAdaptor , "13" ) work := func () { gobot . ...
# Eclipse Paho MQTT C/C++ client for Embedded platforms This repository contains the source code for the [Eclipse Paho](http://eclipse.org/paho) MQTT C/C++ client library for Embedded platorms.
xcode ios12.4真机调试包 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
IOS12.3 beta版真机调试包,真机运行的支持包的位置位于:Xcode.app//Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport,直接解压拷贝进去即可使用
An Open Source Content Decryption Module to Improve DRM Integration with HTML5 Platforms https://ieeexplore.ieee.org/document/7442371
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libstdc++.6.0.9.dylib ...
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/ //模拟器 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/...
路径/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/对应版本/: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/10.3.1\ \(14E...
路径参考/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/对应版本/: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/10.3.1\ \...
路径参考/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/对应版本/: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/10.3.1\ \...
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/ For Simulator Put dylib copy to the path: /Applications/Xcode.app/Contents/Developer/...
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/...
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/ /Applications/Xcode.app...
devzkndeMacBook-Pro:Platforms devzkn$ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport devzkndeMacBook-Pro:Platforms devzkn$ open /Applications/Xcode8.3.3.app/...
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/ 模拟器 将tdb副本放到下面路径中: /Applications/Xcode.app/Contents/Developer/Platforms/...
IOS真机调试包 解压后放在目录:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport