-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathZStackOtaServer.go
More file actions
40 lines (32 loc) · 879 Bytes
/
ZStackOtaServer.go
File metadata and controls
40 lines (32 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package zigbee
import (
"github.com/gogo/protobuf/proto"
"github.com/ninjasphere/go-zigbee/otasrvr"
)
type ZStackOta struct {
*ZStackServer
}
type zStackOtaCommand interface {
proto.Message
GetCmdId() otasrvr.OtaMgrCmdIdT
}
// SendCommand sends a protobuf Message to the Z-Stack OTA server, and waits for the response
func (s *ZStackOta) SendCommand(request zStackOtaCommand, response zStackOtaCommand) error {
return s.sendCommand(
&zStackCommand{
message: request,
commandID: uint8(request.GetCmdId()),
},
&zStackCommand{
message: response,
commandID: uint8(response.GetCmdId()),
},
)
}
func ConnectToOtaServer(hostname string, port int) (*ZStackOta, error) {
server, err := connectToServer("OTA", uint8(otasrvr.ZStackOTASysIDs_RPC_SYS_PB_OTA_MGR), hostname, port)
if err != nil {
return nil, err
}
return &ZStackOta{server}, nil
}