-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgroups.go
More file actions
65 lines (57 loc) · 3.17 KB
/
groups.go
File metadata and controls
65 lines (57 loc) · 3.17 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
package goopenzwave
// #include "gzw_manager.h"
// #include <stdlib.h>
import "C"
import "unsafe"
// GetNumGroups returns the number of association groups reported by this node.
//
// In Z-Wave, groups are numbered starting from one. For example, if a call to
// GetNumGroups returns 4, the _groupIdx value to use in calls to
// GetAssociations, AddAssociation and RemoveAssociation will be a number
// between 1 and 4.
func GetNumGroups(homeID uint32, nodeID uint8) uint8 {
return uint8(C.manager_getNumGroups(cmanager, C.uint32_t(homeID), C.uint8_t(nodeID)))
}
// GetAssociations returns the associations for a group.
//
// Makes a copy of the list of associated nodes in the group, and returns it in
// an array of uint8's. The caller is responsible for freeing the array memory
// with a call to delete [].
//TODO func GetAssociations(homeID uint32, nodeID uint8, groupIDx uint8, uint8 **o_associations) ...
// GetAssociations returns the associations for a group.
//
// Makes a copy of the list of associated nodes in the group, and returns it in
// an array of InstanceAssociation's. The caller is responsible for freeing the
// array memory with a call to delete [].
//TODO func GetAssociations(homeID uint32, nodeID uint8, groupIDx uint8, InstanceAssociation **o_associations) ...
// GetMaxAssociations returns the maximum number of associations for a group.
func GetMaxAssociations(homeID uint32, nodeID uint8, groupIDx uint8) uint8 {
return uint8(C.manager_getMaxAssociations(cmanager, C.uint32_t(homeID), C.uint8_t(nodeID), C.uint8_t(groupIDx)))
}
// GetGroupLabel returns a label for the particular group of a node. This label
// is populated by the device specific configuration files.
func GetGroupLabel(homeID uint32, nodeID uint8, groupIDx uint8) string {
cstr := C.manager_getGroupLabel(cmanager, C.uint32_t(homeID), C.uint8_t(nodeID), C.uint8_t(groupIDx))
defer C.free(unsafe.Pointer(cstr))
return C.GoString(cstr)
}
// AddAssociation adds a node to an association group.
//
// Due to the possibility of a device being asleep, the command is assumed to
// succeed, and the association data held in this class is updated directly.
// This will be reverted by a future Association message from the device if the
// Z-Wave message actually failed to get through. Notification callbacks will be
// sent in both cases.
func AddAssociation(homeID uint32, nodeID uint8, groupIDx uint8, targetNodeID uint8, instance uint8) {
C.manager_addAssociation(cmanager, C.uint32_t(homeID), C.uint8_t(nodeID), C.uint8_t(groupIDx), C.uint8_t(targetNodeID), C.uint8_t(instance))
}
// RemoveAssociation removes a node from an association group.
//
// Due to the possibility of a device being asleep, the command is assumed to
// succeed, and the association data held in this class is updated directly.
// This will be reverted by a future Association message from the device if the
// Z-Wave message actually failed to get through. Notification callbacks will be
// sent in both cases.
func RemoveAssociation(homeID uint32, nodeID uint8, groupIDx uint8, targetNodeID uint8, instance uint8) {
C.manager_removeAssociation(cmanager, C.uint32_t(homeID), C.uint8_t(nodeID), C.uint8_t(groupIDx), C.uint8_t(targetNodeID), C.uint8_t(instance))
}