summaryrefslogtreecommitdiff
path: root/drivers/bluetooth
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2022-09-08 04:59:24 +1000
committerGitHub <noreply@github.com>2022-09-07 19:59:24 +0100
commitf7d2b001bc4f79164e9ea3a4ff7faa54be0b7d82 (patch)
tree304a51de5cb8a64958645812941b0ebfe65223d9 /drivers/bluetooth
parentcf8cdd19920b1810f3d3ecc987943ad8d59023b4 (diff)
Move Bluetooth-related function calls up to host/keyboard level (#18274)
* Move Bluetooth-related function calls up to host/keyboard level * Remove pointless set_output() call * Move bluetooth (rn42) init to end of keyboard_init() * Enable SPI/UART for ChibiOS targets * Some more slight tweaks
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r--drivers/bluetooth/bluefruit_le.cpp8
-rw-r--r--drivers/bluetooth/bluefruit_le.h2
2 files changed, 3 insertions, 7 deletions
diff --git a/drivers/bluetooth/bluefruit_le.cpp b/drivers/bluetooth/bluefruit_le.cpp
index 19310767cf..50170b83fe 100644
--- a/drivers/bluetooth/bluefruit_le.cpp
+++ b/drivers/bluetooth/bluefruit_le.cpp
@@ -79,9 +79,7 @@ struct sdep_msg {
79enum queue_type { 79enum queue_type {
80 QTKeyReport, // 1-byte modifier + 6-byte key report 80 QTKeyReport, // 1-byte modifier + 6-byte key report
81 QTConsumer, // 16-bit key code 81 QTConsumer, // 16-bit key code
82#ifdef MOUSE_ENABLE
83 QTMouseMove, // 4-byte mouse report 82 QTMouseMove, // 4-byte mouse report
84#endif
85}; 83};
86 84
87struct queue_item { 85struct queue_item {
@@ -442,7 +440,7 @@ bool bluefruit_le_enable_keyboard(void) {
442 // Disable command echo 440 // Disable command echo
443 static const char kEcho[] PROGMEM = "ATE=0"; 441 static const char kEcho[] PROGMEM = "ATE=0";
444 // Make the advertised name match the keyboard 442 // Make the advertised name match the keyboard
445 static const char kGapDevName[] PROGMEM = "AT+GAPDEVNAME=" STR(PRODUCT); 443 static const char kGapDevName[] PROGMEM = "AT+GAPDEVNAME=" PRODUCT;
446 // Turn on keyboard support 444 // Turn on keyboard support
447 static const char kHidEnOn[] PROGMEM = "AT+BLEHIDEN=1"; 445 static const char kHidEnOn[] PROGMEM = "AT+BLEHIDEN=1";
448 446
@@ -581,10 +579,12 @@ static bool process_queue_item(struct queue_item *item, uint16_t timeout) {
581 snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->key.modifier, item->key.keys[0], item->key.keys[1], item->key.keys[2], item->key.keys[3], item->key.keys[4], item->key.keys[5]); 579 snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->key.modifier, item->key.keys[0], item->key.keys[1], item->key.keys[2], item->key.keys[3], item->key.keys[4], item->key.keys[5]);
582 return at_command(cmdbuf, NULL, 0, true, timeout); 580 return at_command(cmdbuf, NULL, 0, true, timeout);
583 581
582#ifdef EXTRAKEY_ENABLE
584 case QTConsumer: 583 case QTConsumer:
585 strcpy_P(fmtbuf, PSTR("AT+BLEHIDCONTROLKEY=0x%04x")); 584 strcpy_P(fmtbuf, PSTR("AT+BLEHIDCONTROLKEY=0x%04x"));
586 snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->consumer); 585 snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->consumer);
587 return at_command(cmdbuf, NULL, 0, true, timeout); 586 return at_command(cmdbuf, NULL, 0, true, timeout);
587#endif
588 588
589#ifdef MOUSE_ENABLE 589#ifdef MOUSE_ENABLE
590 case QTMouseMove: 590 case QTMouseMove:
@@ -658,7 +658,6 @@ void bluefruit_le_send_consumer_key(uint16_t usage) {
658 } 658 }
659} 659}
660 660
661#ifdef MOUSE_ENABLE
662void bluefruit_le_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons) { 661void bluefruit_le_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons) {
663 struct queue_item item; 662 struct queue_item item;
664 663
@@ -673,7 +672,6 @@ void bluefruit_le_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan,
673 send_buf_send_one(); 672 send_buf_send_one();
674 } 673 }
675} 674}
676#endif
677 675
678uint32_t bluefruit_le_read_battery_voltage(void) { 676uint32_t bluefruit_le_read_battery_voltage(void) {
679 return state.vbat; 677 return state.vbat;
diff --git a/drivers/bluetooth/bluefruit_le.h b/drivers/bluetooth/bluefruit_le.h
index de301c6167..731ba2e370 100644
--- a/drivers/bluetooth/bluefruit_le.h
+++ b/drivers/bluetooth/bluefruit_le.h
@@ -40,12 +40,10 @@ extern void bluefruit_le_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uin
40 * (milliseconds) */ 40 * (milliseconds) */
41extern void bluefruit_le_send_consumer_key(uint16_t usage); 41extern void bluefruit_le_send_consumer_key(uint16_t usage);
42 42
43#ifdef MOUSE_ENABLE
44/* Send a mouse/wheel movement report. 43/* Send a mouse/wheel movement report.
45 * The parameters are signed and indicate positive or negative direction 44 * The parameters are signed and indicate positive or negative direction
46 * change. */ 45 * change. */
47extern void bluefruit_le_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons); 46extern void bluefruit_le_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons);
48#endif
49 47
50/* Compute battery voltage by reading an analog pin. 48/* Compute battery voltage by reading an analog pin.
51 * Returns the integer number of millivolts */ 49 * Returns the integer number of millivolts */