-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathSerialPABotBase2_Connection.h
More file actions
60 lines (42 loc) · 1.53 KB
/
SerialPABotBase2_Connection.h
File metadata and controls
60 lines (42 loc) · 1.53 KB
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
/* Serial Port (PABotBase2) Connection
*
* From: https://github.com/PokemonAutomation/
*
*/
#ifndef PokemonAutomation_Controllers_SerialPABotBase2_Connection_H
#define PokemonAutomation_Controllers_SerialPABotBase2_Connection_H
#include "Common/Cpp/Concurrency/AsyncTask.h"
#include "Common/Cpp/SerialConnection/SerialConnection.h"
#include "Common/PABotBase2/ReliableConnectionLayer/PABotBase2CC_ReliableStreamConnection.h"
#include "Controllers/PABotBase2/PABotBase2_Connection.h"
#include "Controllers/SerialPABotBase/Connection/MessageLogger.h"
namespace PokemonAutomation{
namespace SerialPABotBase{
class SerialPABotBase2_Connection final : public PABotBase2::Connection{
public:
SerialPABotBase2_Connection(
Logger& logger,
std::string name,
bool set_to_null_controller
);
~SerialPABotBase2_Connection();
virtual bool cancel(std::exception_ptr exception = nullptr) noexcept override;
public:
ControllerType refresh_controller_type();
private:
bool open_serial_port();
bool connect_to_device();
bool open_serial_connection();
bool open_device_connection(bool set_to_null_controller);
void connect_thread_body(bool set_to_null_controller);
private:
SerialLogger m_logger;
std::string m_device_name;
// Mutex m_lock;
AsyncTask m_connect_thread;
std::unique_ptr<SerialConnection> m_unreliable_connection;
std::unique_ptr<PABotBase2::ReliableStreamConnection> m_stream_connection;
};
}
}
#endif