initial commit
This commit is contained in:
17
internal/MqttService/Helpers.go
Normal file
17
internal/MqttService/Helpers.go
Normal 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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user