@@ -62,25 +62,26 @@ void BaseProfile::pushChannelConfig() {
62
62
63
63
void BaseProfile::openChannel () {
64
64
OpenChannel oc = OpenChannel (_channel);
65
+ _channelStatus = CHANNEL_STATUS_SEARCHING;
65
66
_router->send (oc);
66
67
}
67
68
68
69
void BaseProfile::closeChannel () {
69
70
CloseChannel cc = CloseChannel (_channel);
71
+ _channelStatus = CHANNEL_STATUS_ASSIGNED;
70
72
_router->send (cc);
71
73
}
72
74
73
75
void BaseProfile::onChannelEventResponse (ChannelEventResponse& msg) {
74
76
uint8_t event = msg.getCode ();
75
- // TODO maybe define an explicit state enum?
77
+
76
78
switch (event) {
77
79
case STATUS_EVENT_CHANNEL_CLOSED:
78
- _channelStatus = STATUS_EVENT_CHANNEL_CLOSED;
79
- break ;
80
80
case STATUS_EVENT_RX_FAIL_GO_TO_SEARCH:
81
- _channelStatus = STATUS_EVENT_RX_FAIL_GO_TO_SEARCH ;
81
+ _channelStatus = CHANNEL_STATUS_ASSIGNED ;
82
82
break ;
83
83
}
84
+
84
85
_onChannelEvent.call (msg);
85
86
}
86
87
@@ -110,11 +111,19 @@ void BaseProfile::onBurstTransferData(BurstTransferData& msg) {
110
111
_onDataPage.call (msg);
111
112
}
112
113
114
+ void BaseProfile::onChannelStatus (ChannelStatus& msg) {
115
+ _channelStatus = msg.getChannelState ();
116
+ }
117
+
113
118
void BaseProfile::checkProfileStatus () {
114
119
if (!getDeviceNumber () || !getTransmissionType ()) {
115
120
RequestMessage rm = RequestMessage (CHANNEL_ID, _channel);
116
121
send (rm);
117
122
}
123
+ if (_channelStatus == CHANNEL_STATUS_SEARCHING) {
124
+ RequestMessage rm = RequestMessage (CHANNEL_STATUS, _channel);
125
+ send (rm);
126
+ }
118
127
}
119
128
120
129
void BaseProfile::send (AntRequest& msg) {
@@ -127,4 +136,8 @@ uint8_t BaseProfile::getTransmissionType() {
127
136
128
137
uint16_t BaseProfile::getDeviceNumber () {
129
138
return _deviceNumber;
139
+ }
140
+
141
+ void BaseProfile::loop () {
142
+ _router->loop ();
130
143
}
0 commit comments