mirror of
https://github.com/brianshea2/meshmap.net.git
synced 2025-02-02 08:42:28 -08:00
allow custom root topics
This commit is contained in:
parent
ec6cb716a6
commit
1b62110914
|
@ -227,6 +227,16 @@ func main() {
|
|||
}
|
||||
// connect to MQTT
|
||||
client := &meshtastic.MQTTClient{
|
||||
Topics: []string{
|
||||
"msh/+/2/map/",
|
||||
"msh/+/2/e/+/+",
|
||||
"msh/+/+/2/map/",
|
||||
"msh/+/+/2/e/+/+",
|
||||
"msh/+/+/+/2/map/",
|
||||
"msh/+/+/+/2/e/+/+",
|
||||
"msh/+/+/+/+/2/map/",
|
||||
"msh/+/+/+/+/2/e/+/+",
|
||||
},
|
||||
TopicRegex: regexp.MustCompile(`/2/e/[^/]+/![0-9a-f]+$|/2/map/$`),
|
||||
Accept: func(from uint32) bool {
|
||||
_, found := blocked[from]
|
||||
|
|
|
@ -31,6 +31,7 @@ func NewBlockCipher(key []byte) cipher.Block {
|
|||
}
|
||||
|
||||
type MQTTClient struct {
|
||||
Topics []string
|
||||
TopicRegex *regexp.Regexp
|
||||
Accept func(from uint32) bool
|
||||
BlockCipher cipher.Block
|
||||
|
@ -56,11 +57,8 @@ func (c *MQTTClient) Connect() error {
|
|||
}
|
||||
log.Print("[info] connected")
|
||||
topics := make(map[string]byte)
|
||||
for i, region := range generated.Config_LoRaConfig_RegionCode_name {
|
||||
if i == 0 {
|
||||
continue
|
||||
}
|
||||
topics["msh/"+region+"/#"] = 0
|
||||
for _, topic := range c.Topics {
|
||||
topics[topic] = 0
|
||||
}
|
||||
token = c.SubscribeMultiple(topics, nil)
|
||||
<-token.Done()
|
||||
|
|
Loading…
Reference in a new issue