MyController V2.0 Can't enable Serial Gateway
-
I'm trying to setup a serial gateway with a node and 1 temperature sensor.
The gateway has been configured without labels (see attached picture):
No error in trying to enable the gateway, the status becomes green but I can't see any log that says that the serial connection is established and the gateway started. I also tried to send a paylod from the Fields section but nothing happens.
I then started the go debugger delve and I saw that even if the gateway is without lables, internally it seems that the default label is still present:251: return false 252: } 253: 254: // IsMine verifies the supplied id and labels with valid list 255: func IsMine(svcFilter *sfML.ServiceFilter, targetType, targetID string, targetLabels cmap.CustomStringMap) bool { => 256: if !svcFilter.HasFilter() { 257: return true 258: } 259: 260: matches := make([]bool, 0) 261: (dlv) print svcFilter *github.com/mycontroller-org/server/v2/pkg/model/service_filter.ServiceFilter { Disabled: false, MatchAll: false, Types: []string len: 0, cap: 0, [], IDs: []string len: 0, cap: 0, [], Labels: github.com/mycontroller-org/server/v2/pkg/model/cmap.CustomStringMap [ "location": "server", ],} (dlv) continue
and that prevents the serial gateway to be started; if I delete from the debugger the Labels then the gateway starts and I am able to communicate with field:
(dlv) set sf.Labels=nil (dlv) next > github.com/mycontroller-org/server/v2/pkg/utils/filter_sort.IsMine() /go/src/pkg/utils/filter_sort/utils_filter.go:256 (PC: 0xac42ab) Values returned: ~r0: false 253: 254: // IsMine verifies the supplied id and labels with valid list 255: func IsMine(svcFilter *sfML.ServiceFilter, targetType, targetID string, targetLabels cmap.CustomStringMap) bool { => 256: if !svcFilter.HasFilter() { 257: return true 258: } 259: 260: matches := make([]bool, 0) 261: (dlv) next > github.com/mycontroller-org/server/v2/pkg/utils/filter_sort.IsMine() /go/src/pkg/utils/filter_sort/utils_filter.go:257 (PC: 0xac4378) 252: } 253: 254: // IsMine verifies the supplied id and labels with valid list 255: func IsMine(svcFilter *sfML.ServiceFilter, targetType, targetID string, targetLabels cmap.CustomStringMap) bool { 256: if !svcFilter.HasFilter() { => 257: return true 258: } 259: 260: matches := make([]bool, 0) 261: 262: if len(svcFilter.Types) > 0 { (dlv) continue
2021-12-21T09:48:14.605Z info gateway/service.go:34 starting a gateway {"id": "Serial_Gateway"} 2021-12-21T09:48:14.613Z info protocol_serial/client.go:61 opening a serial port {"gateway": "Serial_Gateway", "port": "/dev/ttyUSB0"} 2021-12-21T09:48:14.658Z info gateway/service.go:47 started a gateway {"id": "Serial_Gateway", "timeTaken": "53.016413ms"}
sorry but I was not able to format in a better way the code snippets
-
I then started the go debugger delve and I saw that even if the gateway is without lables, internally it seems that the default label is still present:
By default the configuration file contains the label filter for the gateway and handlers
https://github.com/mycontroller-org/server/blob/master/resources/sample-binary-server.yaml#L50~L62labels: location: server
You can delete those labels, or add the label in your gateway configuration(GUI)
The label idea is to run multiple gateways in different locations and filter those by labels.
As thelocation: server
, configured for server, it takes only the label withserver
.sorry but I was not able to format in a better way the code snippets
no worries, you have to use Markdown format or just use
</>
in the text editor -
Hi @jkandasa thanks for the explanation; I understood your idea; by the way that means that I can't remove the defualt label or I need to have at least one label for a gateway, right?
-
@giuseppez you can remove the default label in your
yaml
file.If you do not have any label and in future if you have multiple mycontroller-gateways, your serial gateway configuration will be loaded in all the mycontroller-gateways
Here is the doc: https://v2.mycontroller.org/docs/user-interface/resources/gateway/#power-of-the-labels -
Thank you for the link; I will read it more carefully