-
Notifications
You must be signed in to change notification settings - Fork 0
/
topic.go
110 lines (90 loc) · 2.39 KB
/
topic.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
package topic
import (
"github.com/galenliu/gateway/pkg/addon/actions"
"github.com/galenliu/gateway/pkg/addon/devices"
"github.com/galenliu/gateway/pkg/addon/properties"
)
const (
SetProperty = "SetProperty"
GetDevices = "GetDevices"
GetThings = "GetMapOfThings"
Pair = "pair"
Unpair = "unpair"
Pending = "pending"
)
type Topic string
const (
ThingAdded Topic = "thingAdded"
ThingRemoved Topic = "thingRemoved"
ThingConnected Topic = "thingConnected"
ThingModify Topic = "thingModify"
ThingPropertyChanged Topic = "thingPropertyChanged"
ThingEvent Topic = "thingEvent"
ThingActionStatus Topic = "thingActionStatus"
DeviceAdded Topic = "deviceAdded"
DevicePropertyChanged Topic = "devicePropertyChanged"
DeviceActionStatus Topic = "deviceActionStatus"
DeviceEvent Topic = "deviceEvent"
DeviceRemoved Topic = "deviceRemoved"
DeviceConnected Topic = "deviceConnected"
AdapterAdded Topic = "adapterAdded"
PairingTimeout Topic = "pairingTimeout"
)
type DeviceAddedMessage struct {
DeviceId string
devices.Device
}
type DevicePropertyChangedMessage struct {
DeviceId string
PropertyName string
properties.PropertyDescription
}
type DeviceActionStatusMessage struct {
DeviceId string
Action actions.ActionDescription
}
type DeviceConnectedMessage struct {
DeviceId string
Connected bool
}
type ThingAddedMessage struct {
ThingId string
Data []byte
}
type ThingRemovedMessage struct {
ThingId string
}
type ThingActionDescription struct {
Id string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Input map[string]any `json:"input,omitempty"`
Status string `json:"status,omitempty"`
TimeRequested string `json:"timeRequested,omitempty"`
TimeCompleted string `json:"timeCompleted,omitempty"`
}
type ThingActionStatusMessage struct {
ThingId string
Action ThingActionDescription
}
type ThingPropertyChangedMessage struct {
ThingId string
PropertyName string
Value any
}
type ThingConnectedMessage struct {
ThingId string
Connected bool
}
type ThingModifyMessage struct {
ThingId string
}
type ThingEventMessage struct {
ThingId string
}
func (t Topic) ToString() string {
return string(t)
}
const (
ValueChanged Topic = "valueChanged"
StateChanged Topic = "stateChanged"
)