Added connection management
This commit is contained in:
+13
-4
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user