14
14
#include " ConfiguratorAgents/agents/BoardConfigurationProtocol/cbor/CBORInstances.h"
15
15
#include " Utility/LEDFeedback/LEDFeedback.h"
16
16
17
- class SerialAgentClass : public ConfiguratorAgent , BoardConfigurationProtocol { // TODO put private BoardConfigurationProtocol
17
+ class SerialAgentClass : public ConfiguratorAgent , private BoardConfigurationProtocol {
18
18
public:
19
19
SerialAgentClass ();
20
20
AgentConfiguratorStates begin ();
@@ -37,10 +37,10 @@ class SerialAgentClass : public ConfiguratorAgent, BoardConfigurationProtocol {
37
37
AgentConfiguratorStates handlePeerConnected ();
38
38
39
39
/* BoardConfigurationProtocol pure virtual methods implementation*/
40
- bool hasReceivedBytes ();
41
- size_t receivedBytes ();
42
- uint8_t readByte ();
43
- int writeBytes (const uint8_t *data, size_t len);
40
+ bool received ();
41
+ size_t available ();
42
+ uint8_t read ();
43
+ int write (const uint8_t *data, size_t len);
44
44
void handleDisconnectRequest ();
45
45
void clearInputBuffer ();
46
46
};
@@ -109,7 +109,7 @@ inline bool SerialAgentClass::receivedMsgAvailable() {
109
109
}
110
110
111
111
inline bool SerialAgentClass::sendMsg (ProvisioningOutputMessage &msg) {
112
- return BoardConfigurationProtocol::sendNewMsg (msg);
112
+ return BoardConfigurationProtocol::sendMsg (msg);
113
113
}
114
114
115
115
inline bool SerialAgentClass::isPeerConnected () {
@@ -127,15 +127,14 @@ inline ConfiguratorAgent::AgentConfiguratorStates SerialAgentClass::handleInit()
127
127
PacketManager::ReceivingState res = PacketManager::PacketReceiver::getInstance ().handleReceivedByte (_packet, byte);
128
128
if (res == PacketManager::ReceivingState::RECEIVED) {
129
129
if (_packet.Type == PacketManager::MessageType::TRANSMISSION_CONTROL) {
130
- if (_packet.Payload .len () == 1 && _packet.Payload [0 ] == 0x01 ) { // TODO use define
130
+ if (_packet.Payload .len () == 1 && _packet.Payload [0 ] == ( uint8_t )PacketManager::TransmissionControlMessage::CONNECT) {
131
131
// CONNECT
132
132
nextState = AgentConfiguratorStates::PEER_CONNECTED;
133
- PacketManager::PacketReceiver::getInstance ().clear (_packet);
134
133
}
135
134
}
135
+ PacketManager::PacketReceiver::getInstance ().clear (_packet);
136
136
} else if (res == PacketManager::ReceivingState::ERROR) {
137
137
DEBUG_DEBUG (" SerialAgentClass::%s Error receiving packet" , __FUNCTION__);
138
- PacketManager::PacketReceiver::getInstance ().clear (_packet);
139
138
clearInputBuffer ();
140
139
}
141
140
}
@@ -163,19 +162,19 @@ inline ConfiguratorAgent::AgentConfiguratorStates SerialAgentClass::handlePeerCo
163
162
return nextState;
164
163
}
165
164
166
- inline bool SerialAgentClass::hasReceivedBytes () {
165
+ inline bool SerialAgentClass::received () {
167
166
return Serial.available () > 0 ;
168
167
}
169
168
170
- inline size_t SerialAgentClass::receivedBytes () {
169
+ inline size_t SerialAgentClass::available () {
171
170
return Serial.available ();
172
171
}
173
172
174
- inline uint8_t SerialAgentClass::readByte () {
173
+ inline uint8_t SerialAgentClass::read () {
175
174
return Serial.read ();
176
175
}
177
176
178
- inline int SerialAgentClass::writeBytes (const uint8_t *data, size_t len) {
177
+ inline int SerialAgentClass::write (const uint8_t *data, size_t len) {
179
178
return Serial.write (data, len);
180
179
}
181
180
0 commit comments