Added connection management

This commit is contained in:
2022-07-08 16:33:42 -07:00
parent fe00a30268
commit 4aa558eda7
4 changed files with 141 additions and 52 deletions
+13 -4
View File
@@ -32,15 +32,22 @@ class Ergodox {
~Ergodox();
int write(uint8_t cmd, const uint8_t* data, uint8_t data_len) const;
bool try_connect();
void disconnect();
void test_connection();
bool read();
bool write(uint8_t cmd, const uint8_t* data, uint8_t data_len);
// Read buffer, len = packet_size.
// Filled by read().
uint8_t read_buf[RAW_EPSIZE];
// Getter methods
uint8_t get_animation_mode() const { return animation_mode; }
bool is_connected() const { return connected; }
private:
Ergodox(
@@ -55,14 +62,16 @@ class Ergodox {
//Ergodox(Ergodox& other);
//Ergodox& operator=(Ergodox& other);
void open();
void close();
// HID device.
// NULL if not opened.
hid_device* handle;
// Keyboard state variables.
// Updated by read().
// Which animation is the keyboard running right now?
// See CMD_SEND_STATE in commands.h for docs.
uint8_t animation_mode;
// Are we connected to a keyboard right now?
bool connected;
};