-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathadapter_endpoints.go
52 lines (41 loc) · 1.31 KB
/
adapter_endpoints.go
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
41
42
43
44
45
46
47
48
49
50
51
52
package zstack
import (
"context"
"fmt"
"github.com/shimmeringbee/zigbee"
)
func (z *ZStack) RegisterAdapterEndpoint(ctx context.Context, endpoint zigbee.Endpoint, appProfileId zigbee.ProfileID, appDeviceId uint16, appDeviceVersion uint8, inClusters []zigbee.ClusterID, outClusters []zigbee.ClusterID) error {
if err := z.sem.Acquire(ctx, 1); err != nil {
return fmt.Errorf("failed to acquire semaphore: %w", err)
}
defer z.sem.Release(1)
request := AFRegister{
Endpoint: endpoint,
AppProfileId: appProfileId,
AppDeviceId: appDeviceId,
AppDeviceVersion: appDeviceVersion,
LatencyReq: 0x00, // No latency, no other valid option for Zigbee
AppInClusters: inClusters,
AppOutClusters: outClusters,
}
resp := AFRegisterReply{}
if err := z.requestResponder.RequestResponse(ctx, request, &resp); err != nil {
return err
}
if resp.Status != ZSuccess {
return ErrorZFailure
}
return nil
}
type AFRegister struct {
Endpoint zigbee.Endpoint
AppProfileId zigbee.ProfileID
AppDeviceId uint16
AppDeviceVersion uint8
LatencyReq uint8
AppInClusters []zigbee.ClusterID `bcsliceprefix:"8"`
AppOutClusters []zigbee.ClusterID `bcsliceprefix:"8"`
}
const AFRegisterID uint8 = 0x00
type AFRegisterReply GenericZStackStatus
const AFRegisterReplyID uint8 = 0x00