-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdatagram.go
113 lines (102 loc) · 3.49 KB
/
datagram.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package resources
const SPECIFICATION_VERSION = "1.0.0"
type DeviceModel struct {
DeviceType string `xml:"deviceType"`
DeviceAddress string `xml:"deviceAddress"`
Description string `xml:"description"`
Entities []*EntityModel `xml:"entities"`
}
type EntityModel struct {
EntityType string `xml:"entityType"`
EntityAddress int `xml:"entityAddress"`
Description string `xml:"description"`
Features []*FeatureModel `xml:"features"`
}
type FeatureModel struct {
FeatureType string `xml:"featureType"`
FeatureAddress int `xml:"featureAddress"`
Role string `xml:"role"`
Description string `xml:"description"`
Functions []*FunctionModel `xml:"functions"`
BindingTo []string
SubscriptionTo []string
MaxBindings int
MaxSubscriptions int
}
type FunctionModel struct {
FunctionName string `xml:"functionName"`
ChangeNotify Notifier `xml:"changeNotify"`
Function interface{} `xml:"function"`
}
type DatagramType struct {
Header *HeaderType `xml:"header"`
Payload *PayloadType `xml:"payload"`
}
type PayloadType struct {
Cmd *CmdType `xml:"cmd"`
}
type CmdType struct {
FunctionName string `xml:"functionName"`
Function string `xml:"function"`
}
type HeaderType struct {
SpecificationVersion string `xml:"specificationVersion"`
AddressSource *FeatureAddressType `xml:"addressSource"`
AddressDestination *FeatureAddressType `xml:"addressDestination"`
MsgCounter int `xml:"msgCounter"`
CmdClassifier string `xml:"cmdClassifier"`
Timestamp string `xml:"timestamp"`
AckRequest bool `xml:"ackRequest"`
}
type ComissioningNewSkis struct {
Skis string `xml:"skis"`
Devices string `xml:"devices"`
}
func (device *DeviceModel) CreateNodeManagement(isGateway bool) *FeatureModel {
subscriptions := []string{}
bindings := []string{}
if isGateway {
subscriptions = append(subscriptions, []string{"ActuatorSwitch", "MeasurementTemp", "MeasurementSolar", "MeasurementBattery", "Measurement", "NodeManagement", "ActuatorSwitch1", "ActuatorSwitch2"}...)
bindings = append(bindings, []string{"ActuatorSwitch", "ActuatorSwitch1", "ActuatorSwitch2"}...)
}
return &FeatureModel{
FeatureType: "NodeManagement",
FeatureAddress: 0,
Role: "special",
SubscriptionTo: subscriptions,
BindingTo: bindings,
MaxBindings: 128,
MaxSubscriptions: 128,
Functions: []*FunctionModel{
{
FunctionName: "nodeManagementDetailedDiscoveryData",
Function: &NodeManagementDetailedDiscovery{
SpecificationVersionList: []*NodeManagementSpecificationVersionListType{
{
SpecificationVersion: SPECIFICATION_VERSION,
},
},
DeviceInformation: &NodeManagementDetailedDiscoveryDeviceInformationType{
Description: &NetworkManagementDeviceDescriptionDataType{
DeviceAddress: &DeviceAddressType{
Device: device.DeviceAddress,
},
DeviceType: device.DeviceType,
Description: device.Description,
},
},
EntityInformation: makeEntities(device),
FeatureInformation: makeFeatures(device),
},
},
{
FunctionName: "nodeManagementBindingData",
Function: &NodeManagementBindingData{},
},
{
FunctionName: "nodeManagementSubscriptionData",
Function: &NodeManagementSubscriptionData{},
},
},
}
}