initial commit

This commit is contained in:
2022-12-16 23:27:24 +01:00
commit 60487a79db
13 changed files with 550 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
package MqttService
import (
"errors"
"strings"
)
func PinNameFromTopic(topic string) (string,error) {
topicComponents := strings.Split(topic, "/")
if len(topicComponents) >= 2 {
gpioCh := topicComponents[len(topicComponents)-2]
return gpioCh, nil
} else {
return "", errors.New("invalid topic")
}
}