11#ifndef PROTOCOLHANDLER_H
22#define PROTOCOLHANDLER_H
33
4- #include < arpa/inet.h >
4+ #include < cstdint >
55#include < cstring>
6- #include < iostream>
76#include < vector>
8- #include " motorsController.h"
97
10- #define ID_GET_API_VERSION 0x01
11- #define ID_SET_MOTOR_SPEED 0x02
12- #define ID_SET_ALL_MOTORS_SPEED 0x03
13- #define ID_GET_ENCODER 0x04
14- #define ID_GET_ALL_ENCODERS 0x05
8+ #include " motorsController.h"
159
1610class ProtocolHanlder {
1711 public:
18-
12+ static constexpr uint8_t kApiVersion = 0x01 ;
13+ static constexpr uint8_t kIdGetApiVersion = 0x01 ;
14+ static constexpr uint8_t kIdSetMotorSpeed = 0x02 ;
15+ static constexpr uint8_t kIdSetAllMotorsSpeed = 0x03 ;
16+ static constexpr uint8_t kIdGetEncoder = 0x04 ;
17+ static constexpr uint8_t kIdGetAllEncoders = 0x05 ;
1918
20- ProtocolHanlder (MotorController* motorDriver);
19+ explicit ProtocolHanlder (MotorController* motorDriver);
2120
22- vector<uint8_t > HandleMessage (vector<uint8_t > message);
23- vector<uint8_t > MotorsStopMessage ();
21+ std:: vector<uint8_t > HandleMessage (const std:: vector<uint8_t >& message);
22+ std:: vector<uint8_t > MotorsStopMessage ();
2423
2524 private:
2625 MotorController* main_controller_;
27- vector<uint8_t > HandleSetMotorSpeed (vector<uint8_t > message);
28- vector<uint8_t > HandleGetApiVersion (vector<uint8_t > message) const ;
29- vector<uint8_t > HandleSetAllMotorsSpeed (vector<uint8_t > message);
30- vector<uint8_t > HandleGetEncoder (vector<uint8_t > message);
31- vector<uint8_t > HandleGetAllEncoders (vector<uint8_t > message) const ;
26+ std:: vector<uint8_t > HandleSetMotorSpeed (const std:: vector<uint8_t >& message);
27+ std:: vector<uint8_t > HandleGetApiVersion (const std:: vector<uint8_t >& message);
28+ std:: vector<uint8_t > HandleSetAllMotorsSpeed (const std:: vector<uint8_t >& message);
29+ std:: vector<uint8_t > HandleGetEncoder (const std:: vector<uint8_t >& message);
30+ std:: vector<uint8_t > HandleGetAllEncoders (const std:: vector<uint8_t >& message) const ;
3231};
3332
3433#endif
0 commit comments