diff --git a/cores/nRF5/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c b/cores/nRF5/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c index ad5c5c58e..79440a957 100644 --- a/cores/nRF5/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c +++ b/cores/nRF5/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c @@ -189,6 +189,12 @@ void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime ) (void) __get_FPSCR(); NVIC_ClearPendingIRQ(FPU_IRQn); #endif + +#ifdef NRF_CRYPTOCELL + // manually clear CryptoCell else it could prevent low power mode + NVIC_ClearPendingIRQ(CRYPTOCELL_IRQn); +#endif + #ifdef SOFTDEVICE_PRESENT // TODO uint8_t sd_en = 0; (void) sd_softdevice_is_enabled(&sd_en); diff --git a/cores/nRF5/wiring.c b/cores/nRF5/wiring.c index 61dc56d5a..134ee5399 100644 --- a/cores/nRF5/wiring.c +++ b/cores/nRF5/wiring.c @@ -96,6 +96,11 @@ void waitForEvent(void) uint8_t sd_en = 0; (void) sd_softdevice_is_enabled(&sd_en); +#ifdef NRF_CRYPTOCELL + // manually clear CryptoCell else it could prevent low power mode + NVIC_ClearPendingIRQ(CRYPTOCELL_IRQn); +#endif + if ( sd_en ) { (void) sd_app_evt_wait(); diff --git a/libraries/Adafruit_LittleFS/src/Adafruit_LittleFS.cpp b/libraries/Adafruit_LittleFS/src/Adafruit_LittleFS.cpp index b70bad572..ec5ef73af 100644 --- a/libraries/Adafruit_LittleFS/src/Adafruit_LittleFS.cpp +++ b/libraries/Adafruit_LittleFS/src/Adafruit_LittleFS.cpp @@ -26,6 +26,8 @@ #include #include "Adafruit_LittleFS.h" +#include // for Serial + using namespace Adafruit_LittleFS_Namespace; diff --git a/libraries/Adafruit_nRFCrypto b/libraries/Adafruit_nRFCrypto index 01de30c89..3686f2413 160000 --- a/libraries/Adafruit_nRFCrypto +++ b/libraries/Adafruit_nRFCrypto @@ -1 +1 @@ -Subproject commit 01de30c89bc2da783c77fda2a53f650e40fe541e +Subproject commit 3686f2413672ec72e8f8a163d6c69fe7faa0b743 diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/pairing_passkey/pairing_passkey.ino b/libraries/Bluefruit52Lib/examples/Peripheral/pairing_passkey/pairing_passkey.ino index b1f45758e..6ca54bc41 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/pairing_passkey/pairing_passkey.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/pairing_passkey/pairing_passkey.ino @@ -23,40 +23,37 @@ * - https://www.bluetooth.com/blog/bluetooth-pairing-passkey-entry/ * - https://www.bluetooth.com/blog/bluetooth-pairing-part-4/ * - * IF TFT enabled board such as CLUE is used, the passkey will also display on the - * TFT. Following boards with TFT are supported - * - Adafruit CLUE : https://www.adafruit.com/product/4500 - * - Circuit Playground Bluefruit: https://www.adafruit.com/product/4333 - * - TFT Gizmo : https://www.adafruit.com/product/4367 + * This example will "display" (print) passkey to Serial, and get digital input for yes/no + * therefore the IO Capacities is set to Display = true, Yes/No = true, Keypad = false. + * + * Note For TFT enabled board such as CLUE, Circuit Play Bluefruit with Gizmo please use the `pairing_passkey_arcada` example. + * Where the passkey is displayed on the TFT for better experience. */ -#if defined(ARDUINO_NRF52840_CIRCUITPLAY) || defined(ARDUINO_NRF52840_CLUE) - #define USE_ARCADA -#endif - #include #include #include -#ifdef USE_ARCADA - #include +#include - Adafruit_Arcada arcada; - Adafruit_SPITFT* tft; +// Use built-in buttons if available, else use A0, A1 +#ifdef PIN_BUTTON1 + #define BUTTON_YES PIN_BUTTON1 +#else + #define BUTTON_YES A0 +#endif +#ifdef PIN_BUTTON2 + #define BUTTON_NO PIN_BUTTON2 #else - // Use built-in buttons if available, else use A0, A1 - #ifdef PIN_BUTTON1 - #define BUTTON_YES PIN_BUTTON1 - #else - #define BUTTON_YES A0 - #endif - - #ifdef PIN_BUTTON2 - #define BUTTON_NO PIN_BUTTON2 - #else - #define BUTTON_NO A1 - #endif + #define BUTTON_NO A1 +#endif + +// Circuit Play Bluefruit has button active state = high +#ifdef ARDUINO_NRF52840_CIRCUITPLAY + uint32_t const button_active_state = HIGH; +#else + uint32_t const button_active_state = LOW; #endif // BLE Service @@ -69,19 +66,16 @@ void setup() Serial.println("Bluefruit52 Pairing Display Example"); Serial.println("-----------------------------------\n"); -#ifdef USE_ARCADA - arcada.arcadaBegin(); - arcada.displayBegin(); - arcada.setBacklight(255); - - tft = arcada.display; - tft->setCursor(0, 0); - tft->setTextWrap(true); - tft->setTextSize(2); -#else - pinMode(BUTTON_YES, INPUT_PULLUP); - pinMode(BUTTON_NO, INPUT_PULLUP); -#endif + // pull high for active low, or pull low for active high + if (button_active_state == HIGH) + { + pinMode(BUTTON_YES, INPUT_PULLDOWN); + pinMode(BUTTON_NO, INPUT_PULLDOWN); + }else + { + pinMode(BUTTON_YES, INPUT_PULLUP); + pinMode(BUTTON_NO, INPUT_PULLUP); + } // Setup the BLE LED to be enabled on CONNECT // Note: This is actually the default behavior, but provided @@ -125,14 +119,6 @@ void setup() bleuart.setPermission(SECMODE_ENC_WITH_MITM, SECMODE_ENC_WITH_MITM); bleuart.begin(); -#ifdef USE_ARCADA - tft->fillScreen(ARCADA_BLACK); - tft->setTextColor(ARCADA_WHITE); - tft->setTextSize(2); - tft->setCursor(0, 0); - tft->print("Advertising..."); -#endif - Serial.println("Please use Adafruit's Bluefruit LE app to connect in UART mode"); Serial.println("Your phone should pop-up PIN input"); Serial.println("Once connected, enter character(s) that you wish to send"); @@ -203,13 +189,6 @@ void connect_callback(uint16_t conn_handle) Serial.print("Connected to "); Serial.println(central_name); - -#ifdef USE_ARCADA - tft->fillScreen(ARCADA_BLACK); - tft->setTextSize(2); - tft->setCursor(0, 0); - tft->println("Connected"); -#endif } // callback invoked when pairing passkey is generated @@ -222,84 +201,48 @@ bool pairing_passkey_callback(uint16_t conn_handle, uint8_t const passkey[6], bo Serial.println("Pairing Passkey"); Serial.printf(" %.3s %.3s\n", passkey, passkey+3); -#ifdef USE_ARCADA - tft->fillScreen(ARCADA_BLACK); - tft->println("Pairing Passkey\n"); - tft->setTextColor(ARCADA_YELLOW); - tft->setTextSize(4); - tft->printf(" %.3s %.3s\n", passkey, passkey+3); - - tft->setTextColor(ARCADA_WHITE); - tft->setTextSize(2); -#endif - - // match_request means peer wait for our approval (return true) + // match_request means peer wait for our approval + // return true to accept, false to decline if (match_request) { + bool accept_pairing = false; + Serial.println("Do you want to pair"); - Serial.println("Press Button Left to decline, Button Right to Accept"); + Serial.printf("Press button <%u> to Decline, button <%u> to Accept\n", BUTTON_YES, BUTTON_NO); // timeout for pressing button uint32_t start_time = millis(); -#ifdef USE_ARCADA - tft->println("\nDo you accept ?\n\n"); - tft->setTextSize(3); - - // Yes <-> No on CPB is reversed since GIZMO TFT is on the back of CPB - #if ARDUINO_NRF52840_CIRCUITPLAY - tft->setTextColor(ARCADA_GREEN); - tft->print("< Yes"); - tft->setTextColor(ARCADA_RED); - tft->println(" No >"); - #else - tft->setTextColor(ARCADA_RED); - tft->print("< No"); - tft->setTextColor(ARCADA_GREEN); - tft->println(" Yes >"); - #endif - - tft->setTextColor(ARCADA_WHITE); - tft->setTextSize(2); - tft->println(); - // wait until either button is pressed (30 seconds timeout) - uint32_t justReleased; - do + while( millis() < start_time + 30000 ) { - // Peer is disconnected while waiting for input - if ( !Bluefruit.connected(conn_handle) ) break; + // user press YES + if (digitalRead(BUTTON_YES) == button_active_state) + { + accept_pairing = true; + break; + } + + // user press NO + if (digitalRead(BUTTON_NO) == button_active_state) + { + accept_pairing = false; + break; + } - // time out - if ( millis() > start_time + 30000 ) break; - - arcada.readButtons(); - justReleased = arcada.justReleasedButtons(); - } while ( !(justReleased & (ARCADA_BUTTONMASK_LEFT | ARCADA_BUTTONMASK_RIGHT) ) ); - - // Right = accept - if (justReleased & ARCADA_BUTTONMASK_RIGHT) return true; - - // Left = decline - if (justReleased & ARCADA_BUTTONMASK_LEFT) return false; - -#else - // wait until either button is pressed (30 seconds timeout) - while( digitalRead(BUTTON_YES) && digitalRead(BUTTON_NO) ) - { // Peer is disconnected while waiting for input if ( !Bluefruit.connected(conn_handle) ) break; - - // time out - if ( millis() > start_time + 30000 ) break; } - if ( 0 == digitalRead(BUTTON_YES) ) return true; - - if ( 0 == digitalRead(BUTTON_NO) ) return false; -#endif + if (accept_pairing) + { + Serial.println("Accepted"); + }else + { + Serial.println("Declined"); + } - return false; + return accept_pairing; } return true; @@ -314,32 +257,11 @@ void pairing_complete_callback(uint16_t conn_handle, uint8_t auth_status) { Serial.println("Failed"); } - -#ifdef USE_ARCADA - if (auth_status == BLE_GAP_SEC_STATUS_SUCCESS) - { - tft->setTextColor(ARCADA_GREEN); - tft->println("Succeeded"); - }else - { - tft->setTextColor(ARCADA_RED); - tft->println("Failed"); - } - - tft->setTextColor(ARCADA_WHITE); - tft->setTextSize(2); -#endif } void connection_secured_callback(uint16_t conn_handle) { Serial.println("Secured"); - -#ifdef USE_ARCADA - tft->setTextColor(ARCADA_YELLOW); - tft->println("secured"); - tft->setTextColor(ARCADA_WHITE); -#endif } /** @@ -354,11 +276,4 @@ void disconnect_callback(uint16_t conn_handle, uint8_t reason) Serial.println(); Serial.print("Disconnected, reason = 0x"); Serial.println(reason, HEX); - -#ifdef USE_ARCADA - tft->fillScreen(ARCADA_BLACK); - tft->setTextSize(2); - tft->setCursor(0, 0); - tft->println("Advertising ..."); -#endif } diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/pairing_passkey_arcada/.cluenrf52840.test.only b/libraries/Bluefruit52Lib/examples/Peripheral/pairing_passkey_arcada/.cluenrf52840.test.only new file mode 100644 index 000000000..e69de29bb diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/pairing_passkey_arcada/.cplaynrf52840.test.only b/libraries/Bluefruit52Lib/examples/Peripheral/pairing_passkey_arcada/.cplaynrf52840.test.only new file mode 100644 index 000000000..e69de29bb diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/pairing_passkey_arcada/pairing_passkey_arcada.ino b/libraries/Bluefruit52Lib/examples/Peripheral/pairing_passkey_arcada/pairing_passkey_arcada.ino new file mode 100644 index 000000000..02cfb34e1 --- /dev/null +++ b/libraries/Bluefruit52Lib/examples/Peripheral/pairing_passkey_arcada/pairing_passkey_arcada.ino @@ -0,0 +1,296 @@ +/********************************************************************* + This is an example for our nRF52 based Bluefruit LE modules + + Pick one up today in the adafruit shop! + + Adafruit invests time and resources providing this open source code, + please support Adafruit and open-source hardware by purchasing + products from Adafruit! + + MIT license, check LICENSE for more information + All text above, and the splash screen below must be included in + any redistribution +*********************************************************************/ + +/* This sketch demonstrates Pairing process using dynamic Passkey. + * This sketch is essentially the same as bleuart.ino except the BLE Uart + * service requires Security Mode with Man-In-The-Middle protection i.e + * + * BLE Pairing procedure is complicated, it is advisable for users to go through + * these articles to get familiar with the procedure and terminology + * - https://www.bluetooth.com/blog/bluetooth-pairing-part-1-pairing-feature-exchange/ + * - https://www.bluetooth.com/blog/bluetooth-pairing-part-2-key-generation-methods/ + * - https://www.bluetooth.com/blog/bluetooth-pairing-passkey-entry/ + * - https://www.bluetooth.com/blog/bluetooth-pairing-part-4/ + * + * This example will display Passkey on the TFT and wait for user input to accept or decline + * the pairing. Therefore the IO Capacities is set to Display = true, Yes/No = true, Keypad = false. + * + * Following boards with TFT are supported + * - Adafruit CLUE : https://www.adafruit.com/product/4500 + * - Circuit Playground Bluefruit: https://www.adafruit.com/product/4333 + * - TFT Gizmo : https://www.adafruit.com/product/4367 + * + * Note: If your board does not have TFT, please use the 'pairing_passkey' where it uses Serial + * to display the passkey + */ + +#include +#include +#include + +#include +#include + +Adafruit_Arcada arcada; +Adafruit_SPITFT* tft; + +// BLE Service +BLEUart bleuart; // uart over ble + +void setup() +{ + Serial.begin(115200); + + Serial.println("Bluefruit52 Pairing Display Example"); + Serial.println("-----------------------------------\n"); + + arcada.arcadaBegin(); + arcada.displayBegin(); + arcada.setBacklight(255); + + tft = arcada.display; + tft->setCursor(0, 0); + tft->setTextWrap(true); + tft->setTextSize(2); + + // Setup the BLE LED to be enabled on CONNECT + // Note: This is actually the default behavior, but provided + // here in case you want to control this LED manually via PIN 19 + Bluefruit.autoConnLed(true); + + // Config the peripheral connection with maximum bandwidth + // more SRAM required by SoftDevice + // Note: All config***() function must be called before begin() + Bluefruit.configPrphBandwidth(BANDWIDTH_MAX); + + Bluefruit.begin(); + Bluefruit.setTxPower(4); // Check bluefruit.h for supported values + + /* To use dynamic PassKey for pairing, we need to have + * - IO capacities at least DISPPLAY + * - Display only: user have to enter 6-digit passkey on their phone + * - DIsplay + Yes/No: user ony need to press Accept on both central and device + * - Register callback to display/print dynamic passkey for central + * + * For complete mapping of the IO Capabilities to Key Generation Method, check out this article + * https://www.bluetooth.com/blog/bluetooth-pairing-part-2-key-generation-methods/ + */ + Bluefruit.Security.setIOCaps(true, true, false); // display = true, yes/no = true, keyboard = false + Bluefruit.Security.setPairPasskeyCallback(pairing_passkey_callback); + + // Set complete callback to print the pairing result + Bluefruit.Security.setPairCompleteCallback(pairing_complete_callback); + + // Set connection secured callback, invoked when connection is encrypted + Bluefruit.Security.setSecuredCallback(connection_secured_callback); + + Bluefruit.Periph.setConnectCallback(connect_callback); + Bluefruit.Periph.setDisconnectCallback(disconnect_callback); + + // Configure and Start BLE Uart Service + // Set Permission to access BLE Uart is to require man-in-the-middle protection + // This will cause central to perform pairing with a generated passkey, the passkey will + // be printed on display or Serial and wait for our input + Serial.println("Configure BLE Uart to require man-in-the-middle protection for PIN pairing"); + bleuart.setPermission(SECMODE_ENC_WITH_MITM, SECMODE_ENC_WITH_MITM); + bleuart.begin(); + + tft->fillScreen(ARCADA_BLACK); + tft->setTextColor(ARCADA_WHITE); + tft->setTextSize(2); + tft->setCursor(0, 0); + tft->print("Advertising..."); + + Serial.println("Please use Adafruit's Bluefruit LE app to connect in UART mode"); + Serial.println("Your phone should pop-up PIN input"); + Serial.println("Once connected, enter character(s) that you wish to send"); + + // Set up and start advertising + startAdv(); +} + +void startAdv(void) +{ + // Advertising packet + Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE); + Bluefruit.Advertising.addTxPower(); + + // Include bleuart 128-bit uuid + Bluefruit.Advertising.addService(bleuart); + + // Secondary Scan Response packet (optional) + // Since there is no room for 'Name' in Advertising packet + Bluefruit.ScanResponse.addName(); + + /* Start Advertising + * - Enable auto advertising if disconnected + * - Interval: fast mode = 20 ms, slow mode = 152.5 ms + * - Timeout for fast mode is 30 seconds + * - Start(timeout) with timeout = 0 will advertise forever (until connected) + * + * For recommended advertising interval + * https://developer.apple.com/library/content/qa/qa1931/_index.html + */ + Bluefruit.Advertising.restartOnDisconnect(true); + Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms + Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode + Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds +} + +void loop() +{ + // Forward data from HW Serial to BLEUART + while (Serial.available()) + { + // Delay to wait for enough input, since we have a limited transmission buffer + delay(2); + + uint8_t buf[64]; + int count = Serial.readBytes(buf, sizeof(buf)); + bleuart.write( buf, count ); + } + + // Forward from BLEUART to HW Serial + while ( bleuart.available() ) + { + uint8_t ch; + ch = (uint8_t) bleuart.read(); + Serial.write(ch); + } +} + + +// callback invoked when central connects +void connect_callback(uint16_t conn_handle) +{ + // Get the reference to current connection + BLEConnection* connection = Bluefruit.Connection(conn_handle); + + char central_name[32] = { 0 }; + connection->getPeerName(central_name, sizeof(central_name)); + + tft->fillScreen(ARCADA_BLACK); + tft->setTextSize(2); + tft->setCursor(0, 0); + tft->println("Connected"); +} + +// callback invoked when pairing passkey is generated +// - passkey: 6 keys (without null terminator) for displaying +// - match_request: true when authentication method is Numberic Comparison. +// Then this callback's return value is used to accept (true) or +// reject (false) the pairing process. Otherwise, return value has no effect +bool pairing_passkey_callback(uint16_t conn_handle, uint8_t const passkey[6], bool match_request) +{ + tft->fillScreen(ARCADA_BLACK); + tft->println("Pairing Passkey\n"); + tft->setTextColor(ARCADA_YELLOW); + tft->setTextSize(4); + tft->printf(" %.3s %.3s\n", passkey, passkey+3); + + tft->setTextColor(ARCADA_WHITE); + tft->setTextSize(2); + + // match_request means peer wait for our approval (return true) + if (match_request) + { + // timeout for pressing button + uint32_t start_time = millis(); + + tft->println("\nDo you accept ?\n\n"); + tft->setTextSize(3); + + // Yes <-> No on CPB is reversed since GIZMO TFT is on the back of CPB + #if ARDUINO_NRF52840_CIRCUITPLAY + tft->setTextColor(ARCADA_GREEN); + tft->print("< Yes"); + tft->setTextColor(ARCADA_RED); + tft->println(" No >"); + #else + tft->setTextColor(ARCADA_RED); + tft->print("< No"); + tft->setTextColor(ARCADA_GREEN); + tft->println(" Yes >"); + #endif + + tft->setTextColor(ARCADA_WHITE); + tft->setTextSize(2); + tft->println(); + + // wait until either button is pressed (30 seconds timeout) + uint32_t justReleased; + while( millis() < start_time + 30000 ) + { + // Peer is disconnected while waiting for input + if ( !Bluefruit.connected(conn_handle) ) break; + + arcada.readButtons(); + justReleased = arcada.justReleasedButtons(); + + // user press either button + if (justReleased) break; + } + + // Right = accept + if (justReleased & ARCADA_BUTTONMASK_RIGHT) return true; + + // Left = decline + if (justReleased & ARCADA_BUTTONMASK_LEFT) return false; + + return false; + } + + return true; +} + +void pairing_complete_callback(uint16_t conn_handle, uint8_t auth_status) +{ + if (auth_status == BLE_GAP_SEC_STATUS_SUCCESS) + { + tft->setTextColor(ARCADA_GREEN); + tft->println("Succeeded"); + }else + { + tft->setTextColor(ARCADA_RED); + tft->println("Failed"); + } + + tft->setTextColor(ARCADA_WHITE); + tft->setTextSize(2); +} + +void connection_secured_callback(uint16_t conn_handle) +{ + tft->setTextColor(ARCADA_YELLOW); + tft->println("secured"); + tft->setTextColor(ARCADA_WHITE); +} + +/** + * Callback invoked when a connection is dropped + * @param conn_handle connection where this event happens + * @param reason is a BLE_HCI_STATUS_CODE which can be found in ble_hci.h + */ +void disconnect_callback(uint16_t conn_handle, uint8_t reason) +{ + (void) conn_handle; + + Serial.println(); + Serial.print("Disconnected, reason = 0x"); Serial.println(reason, HEX); + + tft->fillScreen(ARCADA_BLACK); + tft->setTextSize(2); + tft->setCursor(0, 0); + tft->println("Advertising ..."); +} diff --git a/libraries/Bluefruit52Lib/src/bluefruit.cpp b/libraries/Bluefruit52Lib/src/bluefruit.cpp index a7ddcc11d..e509de56d 100644 --- a/libraries/Bluefruit52Lib/src/bluefruit.cpp +++ b/libraries/Bluefruit52Lib/src/bluefruit.cpp @@ -1051,7 +1051,7 @@ void AdafruitBluefruit::printInfo(void) Periph.printInfo(); - /*------------- List the paried device -------------*/ + /*------------- List the paired devices -------------*/ if ( _prph_count ) { logger.printf(title_fmt, "Peripheral Paired Devices"); diff --git a/libraries/Bluefruit52Lib/src/bluefruit.h b/libraries/Bluefruit52Lib/src/bluefruit.h index 1d9143406..fda5ba0e8 100644 --- a/libraries/Bluefruit52Lib/src/bluefruit.h +++ b/libraries/Bluefruit52Lib/src/bluefruit.h @@ -26,7 +26,6 @@ #include #include "bluefruit_common.h" -#include // for Serial #define CFG_ADV_BLINKY_INTERVAL 500 @@ -180,7 +179,7 @@ class AdafruitBluefruit *------------------------------------------------------------------*/ void setMultiprotocolSemaphore(SemaphoreHandle_t mprot_event_semaphore) { - _mprot_event_sem= mprot_event_semaphore; + _mprot_event_sem= mprot_event_semaphore; } #endif diff --git a/libraries/Bluefruit52Lib/src/services/BLEHidAdafruit.cpp b/libraries/Bluefruit52Lib/src/services/BLEHidAdafruit.cpp index c51ccd724..a30cb4282 100644 --- a/libraries/Bluefruit52Lib/src/services/BLEHidAdafruit.cpp +++ b/libraries/Bluefruit52Lib/src/services/BLEHidAdafruit.cpp @@ -63,7 +63,8 @@ BLEHidAdafruit::BLEHidAdafruit(void) err_t BLEHidAdafruit::begin(void) { - uint16_t input_len [] = { sizeof(hid_keyboard_report_t), sizeof(hid_consumer_control_report_t), sizeof(hid_mouse_report_t) }; + // keyboard, consumer, mouse + uint16_t input_len [] = { sizeof(hid_keyboard_report_t), 2, sizeof(hid_mouse_report_t) }; uint16_t output_len[] = { 1 }; setReportLen(input_len, output_len, NULL); diff --git a/libraries/Bluefruit52Lib/src/services/BLEHidAdafruit.h b/libraries/Bluefruit52Lib/src/services/BLEHidAdafruit.h index 2414547da..f4a6120ee 100644 --- a/libraries/Bluefruit52Lib/src/services/BLEHidAdafruit.h +++ b/libraries/Bluefruit52Lib/src/services/BLEHidAdafruit.h @@ -42,7 +42,6 @@ #include "BLEHidGeneric.h" #include "BLEService.h" - class BLEHidAdafruit : public BLEHidGeneric { public: diff --git a/libraries/Bluefruit52Lib/src/services/BLEHidGeneric.h b/libraries/Bluefruit52Lib/src/services/BLEHidGeneric.h index 4327f7e4a..e874d45e5 100644 --- a/libraries/Bluefruit52Lib/src/services/BLEHidGeneric.h +++ b/libraries/Bluefruit52Lib/src/services/BLEHidGeneric.h @@ -41,18 +41,13 @@ #include "BLECharacteristic.h" #include "BLEService.h" -// include usb hid definitions +// include for usb hid definitions +#include #include "class/hid/hid.h" extern const uint8_t hid_ascii_to_keycode[128][2]; extern const uint8_t hid_keycode_to_ascii[128][2]; -/// HID Consumer Control Report -typedef struct ATTR_PACKED -{ - uint16_t usage_value; ///< Usage value of the pressed control -} hid_consumer_control_report_t; - class BLEHidGeneric : public BLEService { public: diff --git a/libraries/PDM/src/PDM.cpp b/libraries/PDM/src/PDM.cpp index 0350d976f..6b8d4deff 100644 --- a/libraries/PDM/src/PDM.cpp +++ b/libraries/PDM/src/PDM.cpp @@ -23,6 +23,8 @@ #include "PDM.h" #include +#include // for Serial + #define DEFAULT_PDM_GAIN 20 #define PDM_IRQ_PRIORITY 7 diff --git a/libraries/RotaryEncoder/RotaryEncoder.cpp b/libraries/RotaryEncoder/RotaryEncoder.cpp index 6bbda91bf..8243b8d19 100644 --- a/libraries/RotaryEncoder/RotaryEncoder.cpp +++ b/libraries/RotaryEncoder/RotaryEncoder.cpp @@ -36,6 +36,8 @@ #include "RotaryEncoder.h" +#include // for Serial + class HwRotaryEncoder RotaryEncoder; extern "C" diff --git a/libraries/SPI/SPI.cpp b/libraries/SPI/SPI.cpp index acab625f5..8315d8279 100644 --- a/libraries/SPI/SPI.cpp +++ b/libraries/SPI/SPI.cpp @@ -28,6 +28,8 @@ #include #include +#include // for Serial + SPIClass::SPIClass(NRF_SPIM_Type *p_spi, uint8_t uc_pinMISO, uint8_t uc_pinSCK, uint8_t uc_pinMOSI) { initialized = false; diff --git a/libraries/SPI/SPI.h b/libraries/SPI/SPI.h index 5f0b3bb8d..590240a93 100644 --- a/libraries/SPI/SPI.h +++ b/libraries/SPI/SPI.h @@ -22,7 +22,6 @@ #define _SPI_H_INCLUDED #include -#include // for Serial #include "nrfx_spim.h" // SPI_HAS_TRANSACTION means SPI has diff --git a/libraries/SPI/SPI_nrf52832.cpp b/libraries/SPI/SPI_nrf52832.cpp index e15a55df7..b1cfa0e2b 100644 --- a/libraries/SPI/SPI_nrf52832.cpp +++ b/libraries/SPI/SPI_nrf52832.cpp @@ -28,6 +28,7 @@ #include #include +#include // for Serial const SPISettings DEFAULT_SPI_SETTINGS = SPISettings(); diff --git a/libraries/Servo/src/nrf52/Servo.cpp b/libraries/Servo/src/nrf52/Servo.cpp index 4103c43f4..168710b02 100644 --- a/libraries/Servo/src/nrf52/Servo.cpp +++ b/libraries/Servo/src/nrf52/Servo.cpp @@ -24,6 +24,8 @@ #include #include +#include // for Serial + enum { SERVO_TOKEN = 0x76726553 // 'S' 'e' 'r' 'v' diff --git a/libraries/SoftwareSerial/SoftwareSerial.cpp b/libraries/SoftwareSerial/SoftwareSerial.cpp index cd3209298..fdfa69978 100644 --- a/libraries/SoftwareSerial/SoftwareSerial.cpp +++ b/libraries/SoftwareSerial/SoftwareSerial.cpp @@ -23,6 +23,8 @@ #include #include +#include // for Serial + SoftwareSerial *SoftwareSerial::active_object = 0; char SoftwareSerial::_receive_buffer[_SS_MAX_RX_BUFF]; volatile uint8_t SoftwareSerial::_receive_buffer_tail = 0; diff --git a/libraries/Wire/Wire.h b/libraries/Wire/Wire.h index 50977d546..c2158282c 100755 --- a/libraries/Wire/Wire.h +++ b/libraries/Wire/Wire.h @@ -27,8 +27,6 @@ #include "variant.h" #include "RingBuffer.h" -#include // for Serial - // WIRE_HAS_END means Wire has end() #define WIRE_HAS_END 1 diff --git a/libraries/Wire/Wire_nRF52.cpp b/libraries/Wire/Wire_nRF52.cpp index 3875039e2..cfd172611 100755 --- a/libraries/Wire/Wire_nRF52.cpp +++ b/libraries/Wire/Wire_nRF52.cpp @@ -29,6 +29,8 @@ extern "C" { #include "Wire.h" +#include // for Serial + static volatile uint32_t* pincfg_reg(uint32_t pin) { NRF_GPIO_Type * port = nrf_gpio_pin_port_decode(&pin); diff --git a/variants/feather_nrf52840_express/variant.h b/variants/feather_nrf52840_express/variant.h index c4d3d9475..f112e0f8b 100644 --- a/variants/feather_nrf52840_express/variant.h +++ b/variants/feather_nrf52840_express/variant.h @@ -59,7 +59,7 @@ extern "C" /* * Buttons */ -#define PIN_BUTTON1 (7) +#define PIN_BUTTON1 (7) /* * Analog pins