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
114
115
116
117
118
119
use value_classes::value_id::ValueID;
use libc::c_char;
use utils::RustStringCreator;
#[derive(Debug, Eq, PartialEq)]
#[repr(C)]
pub enum NotificationType {
Type_ValueAdded = 0,
Type_ValueRemoved,
Type_ValueChanged,
Type_ValueRefreshed,
Type_Group,
Type_NodeNew,
Type_NodeAdded,
Type_NodeRemoved,
Type_NodeProtocolInfo,
Type_NodeNaming,
Type_NodeEvent,
Type_PollingDisabled,
Type_PollingEnabled,
Type_SceneEvent,
Type_CreateButton,
Type_DeleteButton,
Type_ButtonOn,
Type_ButtonOff,
Type_DriverReady,
Type_DriverFailed,
Type_DriverReset,
Type_EssentialNodeQueriesComplete,
Type_NodeQueriesComplete,
Type_AwakeNodesQueried,
Type_AllNodesQueriedSomeDead,
Type_AllNodesQueried,
Type_Notification,
Type_DriverRemoved,
Type_ControllerCommand,
Type_NodeReset
}
c_like_enum! {
NotificationCode {
MsgComplete = 0,
Timeout = 1,
NoOperation = 2,
Awake = 3,
Sleep = 4,
Dead = 5,
Alive = 6
}
}
use std::fmt;
impl fmt::Display for NotificationCode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(self, f)
}
}
c_like_enum! {
ControllerState {
Normal = 0,
Starting = 1,
Cancel = 2,
Error = 3,
Waiting = 4,
Sleeping = 5,
InProgress = 6,
Completed = 7,
Failed = 8,
NodeOK = 9,
NodeFailed = 10
}
}
impl fmt::Display for ControllerState {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad(&format!("{:?}", self))
}
}
c_like_enum! {
ControllerError {
None = 0,
ButtonNotFound = 1,
NodeNotFound = 2,
NotBridge = 3,
NotSUC = 4,
NotSecondary = 5,
NotPrimary = 6,
IsPrimary = 7,
NotFound = 8,
Busy = 9,
Failed = 10,
Disabled = 11,
Overflow = 12
}
}
impl fmt::Display for ControllerError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad(&format!("{:?}", self))
}
}
pub enum Notification {}
extern {
pub fn notification_get_type(notification: *const Notification) -> NotificationType;
pub fn notification_get_home_id(notification: *const Notification) -> u32;
pub fn notification_get_node_id(notification: *const Notification) -> u8;
pub fn notification_get_value_id(notification: *const Notification) -> ValueID;
pub fn notification_get_group_idx(notification: *const Notification) -> u8;
pub fn notification_get_event(notification: *const Notification) -> u8;
pub fn notification_get_button_id(notification: *const Notification) -> u8;
pub fn notification_get_scene_id(notification: *const Notification) -> u8;
pub fn notification_get_notification(notification: *const Notification) -> u8;
pub fn notification_get_byte(notification: *const Notification) -> u8;
pub fn notification_get_as_string(notification: *const Notification, rust_string_creator: RustStringCreator) -> *const c_char;
}