commit 501164811b809eb90a48dd9390917a2fb6ef1d39 Author: ClemensFritze Date: Wed Feb 7 11:25:05 2024 +0100 update diff --git a/Dokumentation.odt b/Dokumentation.odt new file mode 100644 index 0000000..7bd05a9 Binary files /dev/null and b/Dokumentation.odt differ diff --git a/Dokumentation.pdf b/Dokumentation.pdf new file mode 100644 index 0000000..46b190f Binary files /dev/null and b/Dokumentation.pdf differ diff --git a/ESP32DatabaseInsert_SetUp/Credentials.h b/ESP32DatabaseInsert_SetUp/Credentials.h new file mode 100644 index 0000000..3398734 --- /dev/null +++ b/ESP32DatabaseInsert_SetUp/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "cpsNUCwifi"; // your network SSID (name) +char pass[] = "ips999CPS"; // your network password + +char user[] = "db_user"; // MySQL user login username - db_user - DoItLabUser +char password[] = "db_password"; // MySQL user login password - db_password - DoItLabDBPasswd + +#endif //Credentials_h diff --git a/ESP32DatabaseInsert_SetUp/ESP32DatabaseInsert_SetUp.ino b/ESP32DatabaseInsert_SetUp/ESP32DatabaseInsert_SetUp.ino new file mode 100644 index 0000000..e58d17b --- /dev/null +++ b/ESP32DatabaseInsert_SetUp/ESP32DatabaseInsert_SetUp.ino @@ -0,0 +1,192 @@ +/********************************************************************************************************************************* + Basic_Insert_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : basic insert + + This example demonstrates how to issue an INSERT query to store data in a + table. For this, we will create a special database and table for testing. + The following are the SQL commands you will need to run in order to setup + your database for running this sketch. + + CREATE DATABASE test_arduino; + CREATE TABLE test_arduino.hello_arduino ( + num integer primary key auto_increment, + message char(40), + recorded timestamp + ); + + Here we see one database and a table with three fields; a primary key that + is an auto_increment, a string, and a timestamp. This will demonstrate how + to save a date and time of when the row was inserted, which can help you + determine when data was recorded or updated. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Create the database and table as shown above. + 2) Change the address of the server to the IP address of the MySQL server + 3) Change the user and password to a valid MySQL user and password + 4) Connect a USB cable to your Arduino + 5) Select the correct board and port + 6) Compile and upload the sketch to your Arduino + 7) Once uploaded, open Serial Monitor (use 115200 speed) and observe + 8) After the sketch has run for some time, open a mysql client and issue + the command: "SELECT * FROM test_arduino.hello_arduino" to see the data + recorded. Note the field values and how the database handles both the + auto_increment and timestamp fields for us. You can clear the data with + "DELETE FROM test_arduino.hello_arduino". + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME false + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(10, 42, 0, 1); +#endif + +uint16_t server_port = 3306; //5698; + +char default_database[] = "myTestDb"; //DoItLabDB +char default_table[] = "myTestTable"; //QRCodeTable + +String default_value = "ESP32_TestString"; + +// Sample query +String INSERT_SQL = String("INSERT INTO ") + default_database + "." + default_table + + " (qrCodeText) VALUES ('" + default_value + "')"; + + + + +MySQL_Connection conn((Client *)&client); + +MySQL_Query *query_mem; + +//################################################################################### +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Basic_Insert_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // Remember to initialize your WiFi module +#if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #if ( USING_WIFI_ESP8266_AT ) + MYSQL_DISPLAY("Using ESP8266_AT/ESP8266_AT_WebServer Library"); + #elif ( USING_WIFIESPAT_LIB ) + MYSQL_DISPLAY("Using WiFiEspAT Library"); + #endif + + // initialize serial for ESP module + EspSerial.begin(115200); + // initialize ESP module + WiFi.init(&EspSerial); + + MYSQL_DISPLAY(F("WiFi shield init done")); + + // check for the presence of the shield + if (WiFi.status() == WL_NO_SHIELD) + { + MYSQL_DISPLAY(F("WiFi shield not present")); + // don't continue + while (true); + } +#endif + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +//################################################################################### +void runInsert() +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + MYSQL_DISPLAY(INSERT_SQL); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(INSERT_SQL.c_str()) ) + { + MYSQL_DISPLAY("Insert error"); + } + else + { + MYSQL_DISPLAY("Data Inserted."); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + } +} + + +//################################################################################### +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/ESP32DatabaseInsert_SetUp/defines.h b/ESP32DatabaseInsert_SetUp/defines.h new file mode 100644 index 0000000..ed63a72 --- /dev/null +++ b/ESP32DatabaseInsert_SetUp/defines.h @@ -0,0 +1,381 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define DEBUG_ESP8266_AT_WEBSERVER_PORT Serial + +// Debug Level from 0 to 4 +#define _ESP_AT_LOGLEVEL_ 1 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ! (ESP8266 || ESP32 ) + // Select only one of these libraries, only for boards other than ESP8266/ESP32 + #define USING_WIFI_ESP8266_AT false + #define USING_WIFININA_GENERIC false + #define USING_WIFININA false + #define USING_WIFIESPAT_LIB true + #define USING_WIFI_CUSTOM false +#endif + +#if defined(ARDUINO_SAMD_MKR1000) + #if defined(USE_WIFI_NINA) + #undef USE_WIFI_NINA + #endif + #define USE_WIFI_NINA false + #define USE_WIFI101 true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX + #endif + #define WIFI_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD + #endif + #define WIFI_USE_SAMD true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFI_USE_SAM_DUE) + #undef WIFI_USE_SAM_DUE + #endif + #define WIFI_USE_SAM_DUE true + #warning Use SAM_DUE architecture +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 + #endif + #define WIFI_USE_STM32 true +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFI_USE_RP2040) + #undef WIFI_USE_RP2040 + #endif + #define WIFI_USE_RP2040 true +#endif + +#ifdef CORE_TEENSY + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For Teensy 4.1/4.0 + #define EspSerial Serial2 //Serial2, Pin RX2 : 7, TX2 : 8 + #endif + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" +#endif + +#elif defined(WIFI_USE_NRF528XX) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif defined(WIFI_USE_SAMD) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For SAMD + #define EspSerial Serial1 + #endif + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif defined(WIFI_USE_STM32) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For STM32 + #if defined(ARDUINO_NUCLEO_F767ZI) + #warning Nucleo-144 NUCLEO_F767ZI board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); + #elif defined(ARDUINO_NUCLEO_L053R8) + #warning Nucleo-64 NUCLEO_L053R8 board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); // (PA3, PA2); + #endif + + #warning EspSerial using SERIAL_PORT_HARDWARE, can be Serial or Serial1. See your board variant.h + #define EspSerial SERIAL_PORT_HARDWARE //Serial1 + #endif + + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif (ESP8266) + #warning ESP8266 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif (ESP32) + #warning ESP32 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif defined(WIFI_USE_RP2040) && !defined(ARDUINO_ARCH_MBED) + + // For RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + +#elif defined(WIFI_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + // For MBED RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#else + // For Mega + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #define BOARD_TYPE "AVR Mega" +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +#endif //defines_h diff --git a/ESP32QRCodeReader_Page/ESP32QRCodeReader_Page.ino b/ESP32QRCodeReader_Page/ESP32QRCodeReader_Page.ino new file mode 100644 index 0000000..696b21b --- /dev/null +++ b/ESP32QRCodeReader_Page/ESP32QRCodeReader_Page.ino @@ -0,0 +1,583 @@ +/* +ESP32-CAM QR code Reader +Author : ChungYi Fu (Kaohsiung, Taiwan) 2021-8-13 20:00 +https://www.facebook.com/francefu + +Refer to the code +https://github.com/alvarowolfx/ESP32QRCodeReader + +自訂指令格式 http://192.168.xxx.xxx/control?cmd=P1;P2;P3;P4;P5;P6;P7;P8;P9 + +http://192.168.xxx.xxx/?ip //取得APIP, STAIP +http://192.168.xxx.xxx/?mac //取得MAC位址 +http://192.168.xxx.xxx/?digitalwrite=pin;value //數位輸出 +http://192.168.xxx.xxx/?analogwrite=pin;value //類比輸出 +http://192.168.xxx.xxx/?digitalread=pin //數位讀取 +http://192.168.xxx.xxx/?analogread=pin //類比讀取 +http://192.168.xxx.xxx/?touchread=pin //觸碰讀取 +http://192.168.xxx.xxx/?restart //重啟電源 +http://192.168.xxx.xxx/?flash=value //閃光燈 value= 0~255 +http://192.168.xxx.xxx/?servo=pin;value //伺服馬達 value= 0~180 +http://192.168.xxx.xxx/?relay=pin;value //繼電器 value = 0, 1 +http://192.168.xxx.xxx/?uart=value //序列埠 +*/ + +//輸入WIFI連線帳號密碼 +const char* ssid = "cpsNUCwifi"; +const char* password = "ips999CPS"; + +//輸入AP端連線帳號密碼 http://192.168.4.1 +const char* apssid = "esp32-cam"; +const char* appassword = "12345678"; //AP密碼至少要8個字元以上 + +String Feedback=""; //回傳客戶端訊息 +//指令參數值 +String Command="",cmd="",P1="",P2="",P3="",P4="",P5="",P6="",P7="",P8="",P9=""; +//指令拆解狀態值 +byte ReceiveState=0,cmdState=1,strState=1,questionstate=0,equalstate=0,semicolonstate=0; + +#include +#include "esp_camera.h" //視訊函式 +#include "soc/soc.h" //用於電源不穩不重開機 +#include "soc/rtc_cntl_reg.h" //用於電源不穩不重開機 +#include "quirc.h" + +TaskHandle_t Task; + +//ESP32-CAM 安信可模組腳位設定 +#define PWDN_GPIO_NUM 32 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 0 +#define SIOD_GPIO_NUM 26 +#define SIOC_GPIO_NUM 27 +#define Y9_GPIO_NUM 35 +#define Y8_GPIO_NUM 34 +#define Y7_GPIO_NUM 39 +#define Y6_GPIO_NUM 36 +#define Y5_GPIO_NUM 21 +#define Y4_GPIO_NUM 19 +#define Y3_GPIO_NUM 18 +#define Y2_GPIO_NUM 5 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 23 +#define PCLK_GPIO_NUM 22 + +struct QRCodeData +{ + bool valid; + int dataType; + uint8_t payload[1024]; + int payloadLen; +}; + +struct quirc *q = NULL; +uint8_t *image = NULL; +camera_fb_t * fb = NULL; +struct quirc_code code; +struct quirc_data data; +quirc_decode_error_t err; +struct QRCodeData qrCodeData; +String QRCodeResult = ""; + +WiFiServer server(80); +WiFiClient client; + +camera_config_t config; + +void setup() { + WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //關閉電源不穩就重開機的設定 + + Serial.begin(115200); + Serial.setDebugOutput(true); //開啟診斷輸出 + Serial.println(); + +//視訊組態設定 https://github.com/espressif/esp32-camera/blob/master/driver/include/esp_camera.h + config.ledc_channel = LEDC_CHANNEL_0; + config.ledc_timer = LEDC_TIMER_0; + config.pin_d0 = Y2_GPIO_NUM; + config.pin_d1 = Y3_GPIO_NUM; + config.pin_d2 = Y4_GPIO_NUM; + config.pin_d3 = Y5_GPIO_NUM; + config.pin_d4 = Y6_GPIO_NUM; + config.pin_d5 = Y7_GPIO_NUM; + config.pin_d6 = Y8_GPIO_NUM; + config.pin_d7 = Y9_GPIO_NUM; + config.pin_xclk = XCLK_GPIO_NUM; + config.pin_pclk = PCLK_GPIO_NUM; + config.pin_vsync = VSYNC_GPIO_NUM; + config.pin_href = HREF_GPIO_NUM; + config.pin_sscb_sda = SIOD_GPIO_NUM; + config.pin_sscb_scl = SIOC_GPIO_NUM; + config.pin_pwdn = PWDN_GPIO_NUM; + config.pin_reset = RESET_GPIO_NUM; + config.xclk_freq_hz = 10000000; + config.pixel_format = PIXFORMAT_GRAYSCALE; + config.frame_size = FRAMESIZE_QVGA; + config.jpeg_quality = 15; + config.fb_count = 1; + + //視訊初始化 + esp_err_t err = esp_camera_init(&config); + if (err != ESP_OK) { + Serial.printf("Camera init failed with error 0x%x", err); + ESP.restart(); + } + + sensor_t * s = esp_camera_sensor_get(); + s->set_framesize(s, FRAMESIZE_QVGA); + + //s->set_vflip(s, 1); //垂直翻轉 + //s->set_hmirror(s, 1); //水平鏡像 + + //閃光燈(GPIO4) + ledcAttachPin(4, 4); + ledcSetup(4, 5000, 8); + + WiFi.mode(WIFI_AP_STA); //其他模式 WiFi.mode(WIFI_AP); WiFi.mode(WIFI_STA); + + //指定Client端靜態IP + //WiFi.config(IPAddress(192, 168, 201, 100), IPAddress(192, 168, 201, 2), IPAddress(255, 255, 255, 0)); + + for (int i=0;i<2;i++) { + WiFi.begin(ssid, password); //執行網路連線 + + delay(1000); + Serial.println(""); + Serial.print("Connecting to "); + Serial.println(ssid); + + long int StartTime=millis(); + while (WiFi.status() != WL_CONNECTED) { + delay(500); + if ((StartTime+5000) < millis()) break; //等待10秒連線 + } + + if (WiFi.status() == WL_CONNECTED) { //若連線成功 + WiFi.softAP((WiFi.localIP().toString()+"_"+(String)apssid).c_str(), appassword); //設定SSID顯示客戶端IP + Serial.println(""); + Serial.println("STAIP address: "); + Serial.println(WiFi.localIP()); + Serial.println(""); + + for (int i=0;i<5;i++) { //若連上WIFI設定閃光燈快速閃爍 + ledcWrite(4,10); + delay(200); + ledcWrite(4,0); + delay(200); + } + break; + } + } + + if (WiFi.status() != WL_CONNECTED) { //若連線失敗 + WiFi.softAP((WiFi.softAPIP().toString()+"_"+(String)apssid).c_str(), appassword); + + for (int i=0;i<2;i++) { //若連不上WIFI設定閃光燈慢速閃爍 + ledcWrite(4,10); + delay(1000); + ledcWrite(4,0); + delay(1000); + } + } + + //指定AP端IP + //WiFi.softAPConfig(IPAddress(192, 168, 4, 1), IPAddress(192, 168, 4, 1), IPAddress(255, 255, 255, 0)); + Serial.println(""); + Serial.println("APIP address: "); + Serial.println(WiFi.softAPIP()); + Serial.println(""); + + //設定閃光燈為低電位 + pinMode(4, OUTPUT); + digitalWrite(4, LOW); + + server.begin(); + + xTaskCreatePinnedToCore( + QRCodeReader, /* Task function. */ + "Task", /* name of task. */ + 10000, /* Stack size of task */ + NULL, /* parameter of the task */ + 1, /* priority of the task */ + &Task, /* Task handle to keep track of created task */ + 0); /* pin task to core 0 */ + + Serial.print("listenConnection running on core "); + Serial.println(xPortGetCoreID()); +} + +void loop() { + listenConnection(); +} + +void QRCodeReader( void * pvParameters ){ + Serial.print("QRCodeReader running on core "); + Serial.println(xPortGetCoreID()); + + while(1){ + q = quirc_new(); + if (q == NULL){ + Serial.print("can't create quirc object\r\n"); + continue; + } + + fb = esp_camera_fb_get(); + if (!fb) + { + Serial.println("Camera capture failed"); + continue; + } + + //Serial.printf("quirc_begin\r\n"); + quirc_resize(q, fb->width, fb->height); + image = quirc_begin(q, NULL, NULL); + //Serial.printf("Frame w h len: %d, %d, %d \r\n", fb->width, fb->height, fb->len); + memcpy(image, fb->buf, fb->len); + quirc_end(q); + //Serial.printf("quirc_end\r\n"); + + int count = quirc_count(q); + if (count > 0) { + Serial.println(count); + quirc_extract(q, 0, &code); + err = quirc_decode(&code, &data); + + if (err){ + Serial.println("Decoding FAILED"); + QRCodeResult = "Decoding FAILED"; + } else { + Serial.printf("Decoding successful:\n"); + dumpData(&data); + /* + qrCodeData.dataType = data.data_type; + for (int j = 0; j < data.payload_len; j++) + { + qrCodeData.payload[j] = data.payload[j]; + } + qrCodeData.valid = true; + qrCodeData.payload[data.payload_len] = '\0'; + qrCodeData.payloadLen = data.payload_len; + */ + //vTaskDelay(3000/portTICK_RATE_MS); + } + Serial.println(); + } + + esp_camera_fb_return(fb); + fb = NULL; + image = NULL; + quirc_destroy(q); + } +} + +void dumpData(const struct quirc_data *data) +{ + Serial.printf("Version: %d\n", data->version); + Serial.printf("ECC level: %c\n", "MLHQ"[data->ecc_level]); + Serial.printf("Mask: %d\n", data->mask); + Serial.printf("Length: %d\n", data->payload_len); + Serial.printf("Payload: %s\n", data->payload); + + QRCodeResult = (const char *)data->payload; +} + +//執行自訂指令 +void ExecuteCommand() { + //Serial.println(""); + //Serial.println("Command: "+Command); + if (cmd!="getstill") { + Serial.println("cmd= "+cmd+" ,P1= "+P1+" ,P2= "+P2+" ,P3= "+P3+" ,P4= "+P4+" ,P5= "+P5+" ,P6= "+P6+" ,P7= "+P7+" ,P8= "+P8+" ,P9= "+P9); + Serial.println(""); + } + + //自訂指令區塊 http://192.168.xxx.xxx?cmd=P1;P2;P3;P4;P5;P6;P7;P8;P9 + if (cmd=="your cmd") { + // You can do anything + // Feedback="Hello World"; //可為一般文字或HTML語法 + } + else if (cmd=="ip") { //查詢APIP, STAIP + Feedback="AP IP: "+WiFi.softAPIP().toString(); + Feedback+="
"; + Feedback+="STA IP: "+WiFi.localIP().toString(); + } + else if (cmd=="mac") { //查詢MAC位址 + Feedback="STA MAC: "+WiFi.macAddress(); + } + else if (cmd=="restart") { //重設WIFI連線 + ESP.restart(); + } + else if (cmd=="digitalwrite") { //數位輸出 + ledcDetachPin(P1.toInt()); + pinMode(P1.toInt(), OUTPUT); + digitalWrite(P1.toInt(), P2.toInt()); + } + else if (cmd=="digitalread") { //數位輸入 + Feedback=String(digitalRead(P1.toInt())); + } + else if (cmd=="analogwrite") { //類比輸出 + if (P1=="4") { + ledcAttachPin(4, 4); + ledcSetup(4, 5000, 8); + ledcWrite(4,P2.toInt()); + } + else { + ledcAttachPin(P1.toInt(), 9); + ledcSetup(9, 5000, 8); + ledcWrite(9,P2.toInt()); + } + } + else if (cmd=="analogread") { //類比讀取 + Feedback=String(analogRead(P1.toInt())); + } + else if (cmd=="touchread") { //觸碰讀取 + Feedback=String(touchRead(P1.toInt())); + } + else if (cmd=="framesize") { //解析度 + sensor_t * s = esp_camera_sensor_get(); + int val = P1.toInt(); + s->set_framesize(s, (framesize_t)val); + } + else if (cmd=="quality") { //畫質 + sensor_t * s = esp_camera_sensor_get(); + int val = P1.toInt(); + s->set_quality(s, val); + } + else if (cmd=="contrast") { //對比 + sensor_t * s = esp_camera_sensor_get(); + int val = P1.toInt(); + s->set_contrast(s, val); + } + else if (cmd=="brightness") { //亮度 + sensor_t * s = esp_camera_sensor_get(); + int val = P1.toInt(); + s->set_brightness(s, val); + } + else if (cmd=="hmirror") { //水平鏡像 + sensor_t * s = esp_camera_sensor_get(); + int val = P1.toInt(); + s->set_hmirror(s, val); + } + else if (cmd=="vflip") { //垂直翻轉 + sensor_t * s = esp_camera_sensor_get(); + int val = P1.toInt(); + s->set_vflip(s, val); + } + else if (cmd=="serial") { //序列埠 + Serial.print(P1); + } + else if (cmd=="restart") { //重啟電源 + ESP.restart(); + } + else if (cmd=="flash") { //閃光燈 + ledcAttachPin(4, 4); + ledcSetup(4, 5000, 8); + int val = P1.toInt(); + ledcWrite(4,val); + } + else if(cmd=="servo") { //伺服馬達 (0-180) + ledcAttachPin(P1.toInt(), 3); + ledcSetup(3, 50, 16); + + int val = 7864-P2.toInt()*34.59; + if (val > 7864) + val = 7864; + else if (val < 1638) + val = 1638; + ledcWrite(3, val); + } + else if (cmd=="relay") { //繼電器 + pinMode(P1.toInt(), OUTPUT); + digitalWrite(13, P2.toInt()); + } + else { + Feedback="Command is not defined."; + } + + if (Feedback=="") Feedback=Command; +} + + +//自訂網頁首頁管理介面 +static const char PROGMEM INDEX_HTML[] = R"rawliteral( + + + + + + + +
+Flash +
+
+ + + + +)rawliteral"; + +void listenConnection() { + Feedback="";Command="";cmd="";P1="";P2="";P3="";P4="";P5="";P6="";P7="";P8="";P9=""; + ReceiveState=0,cmdState=1,strState=1,questionstate=0,equalstate=0,semicolonstate=0; + + client = server.available(); + + if (client) { + String currentLine = ""; + + while (client.connected()) { + if (client.available()) { + char c = client.read(); + getCommand(c); //將緩衝區取得的字元拆解出指令參數 + if (c == '\n') { + if (currentLine.length() == 0) { + if (cmd=="getstill") { + getStill(); + } else { + mainPage(); + } + Feedback=""; + break; + } else { + currentLine = ""; + } + } else if (c != '\r') { + currentLine += c; + } + + if ((currentLine.indexOf("?")!=-1)&&(currentLine.indexOf(" HTTP")!=-1)) { + if (Command.indexOf("stop")!=-1) { //若指令中含關鍵字stop立即斷線 -> http://192.168.xxx.xxx?cmd=aaa;bbb;ccc;stop + client.println(); + client.println(); + client.stop(); + } + currentLine=""; + Feedback=""; + ExecuteCommand(); + } + } + } + delay(1); + client.stop(); + } +} + +void mainPage() { + //回傳HTML首頁或Feedback + client.println("HTTP/1.1 200 OK"); + client.println("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); + client.println("Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS"); + client.println("Content-Type: text/html; charset=utf-8"); + client.println("Access-Control-Allow-Origin: *"); + client.println("Connection: close"); + client.println(); + + String Data=""; + if (cmd!="") + Data = Feedback; + else { + Data = String((const char *)INDEX_HTML); + } + int Index; + for (Index = 0; Index < Data.length(); Index = Index+1024) { + client.print(Data.substring(Index, Index+1024)); + } +} + +void getStill() { + camera_fb_t * fb = NULL; + fb = esp_camera_fb_get(); + if(!fb) { + Serial.println("Camera capture failed"); + return; + } + uint8_t *fbBuf = fb->buf; + size_t fbLen = fb->len; + + client.println("HTTP/1.1 200 OK"); + client.println("Access-Control-Allow-Origin: *"); + client.println("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); + client.println("Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS"); + client.println("Content-Type: application/octet-stream"); + client.println(); + + for (size_t n=0;n0) { + size_t remainder = fbLen%1024; + client.write(fbBuf, remainder); + } + } + esp_camera_fb_return(fb); + + pinMode(4, OUTPUT); + digitalWrite(4, LOW); +} + +//拆解命令字串置入變數 +void getCommand(char c) { + if (c=='?') ReceiveState=1; + if ((c==' ')||(c=='\r')||(c=='\n')) ReceiveState=0; + + if (ReceiveState==1) + { + Command=Command+String(c); + + if (c=='=') cmdState=0; + if (c==';') strState++; + + if ((cmdState==1)&&((c!='?')||(questionstate==1))) cmd=cmd+String(c); + if ((cmdState==0)&&(strState==1)&&((c!='=')||(equalstate==1))) P1=P1+String(c); + if ((cmdState==0)&&(strState==2)&&(c!=';')) P2=P2+String(c); + if ((cmdState==0)&&(strState==3)&&(c!=';')) P3=P3+String(c); + if ((cmdState==0)&&(strState==4)&&(c!=';')) P4=P4+String(c); + if ((cmdState==0)&&(strState==5)&&(c!=';')) P5=P5+String(c); + if ((cmdState==0)&&(strState==6)&&(c!=';')) P6=P6+String(c); + if ((cmdState==0)&&(strState==7)&&(c!=';')) P7=P7+String(c); + if ((cmdState==0)&&(strState==8)&&(c!=';')) P8=P8+String(c); + if ((cmdState==0)&&(strState>=9)&&((c!=';')||(semicolonstate==1))) P9=P9+String(c); + + if (c=='?') questionstate=1; + if (c=='=') equalstate=1; + if ((strState>=9)&&(c==';')) semicolonstate=1; + } +} diff --git a/ESP32QRCodeReader_Page/LICENSE b/ESP32QRCodeReader_Page/LICENSE new file mode 100644 index 0000000..d47c026 --- /dev/null +++ b/ESP32QRCodeReader_Page/LICENSE @@ -0,0 +1,16 @@ +quirc -- QR-code recognition library +Copyright (C) 2010-2012 Daniel Beer + +Permission to use, copy, modify, and/or distribute this software for +any purpose with or without fee is hereby granted, provided that the +above copyright notice and this permission notice appear in all +copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR +PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/ESP32QRCodeReader_Page/README.md b/ESP32QRCodeReader_Page/README.md new file mode 100644 index 0000000..d70c5c3 --- /dev/null +++ b/ESP32QRCodeReader_Page/README.md @@ -0,0 +1,193 @@ +Quirc +===== + +QR codes are a type of high-density matrix barcodes, and quirc is a library for +extracting and decoding them from images. It has several features which make it +a good choice for this purpose: + +* It is fast enough to be used with realtime video: extracting and decoding + from VGA frame takes about 50 ms on a modern x86 core. + +* It has a robust and tolerant recognition algorithm. It can correctly + recognise and decode QR codes which are rotated and/or oblique to the camera. + It can also distinguish and decode multiple codes within the same image. + +* It is easy to use, with a simple API described in a single commented header + file (see below for an overview). + +* It is small and easily embeddable, with no dependencies other than standard C + functions. + +* It has a very small memory footprint: one byte per image pixel, plus a few kB + per decoder object. + +* It uses no global mutable state, and is safe to use in a multithreaded + application. + +* BSD-licensed, with almost no restrictions regarding use and/or modification. + +The distribution comes with, in addition to the library, several test programs. +While the core library is very portable, these programs have some additional +dependencies. All of them require libjpeg, and two (`quirc-demo` and `inspect`) +require SDL. The camera demos use Linux-specific APIs: + +### quirc-demo + +This is an real-time demo which requires a camera and a graphical display. The +video stream is displayed on screen as it's received, and any QR codes +recognised are highlighted in the image, with the decoded information both +displayed on the image and printed on stdout. + +### quirc-scanner + +This program turns your camera into a barcode scanner. It's almost the same as +the `demo` application, but it doesn't display the video stream, and thus +doesn't require a graphical display. + +### qrtest + +This test is used to evaluate the performance of library. Given a directory +tree containing a bunch of JPEG images, it will attempt to locate and decode QR +codes in each image. Speed and success statistics are collected and printed on +stdout. + +### inspect + +This test is used for debugging. Given a single JPEG image, it will display a +diagram showing the internal state of the decoder as well as printing +additional information on stdout. + +Installation +------------ +To build the library and associated demos/tests, type `make`. If you need to +decode "large" image files build with `CFLAGS="-DQUIRC_MAX_REGIONS=65534" make` +instead. Note that this will increase the memory usage, it is discouraged for +low resource devices (i.e. embedded). + +Type `make install` to install the library, header file and camera demos. + +You can specify one or several of the following targets if you don't want, or +are unable to build everything: + +* libquirc.a +* libquirc.so +* qrtest +* inspect +* quirc-scanner +* quirc-demo + +Library use +----------- +All of the library's functionality is exposed through a single header file, +which you should include: + +```C +#include +``` + +To decode images, you'll need to instantiate a `struct quirc` object, which is +done with the `quirc_new` function. Later, when you no longer need to decode +anything, you should release the allocated memory with `quirc_destroy`: + +```C +struct quirc *qr; + +qr = quirc_new(); +if (!qr) { + perror("Failed to allocate memory"); + abort(); +} + +/* ... */ + +quirc_destroy(qr); +``` + +Having obtained a decoder object, you need to set the image size that you'll be +working with, which is done using `quirc_resize`: + +```C +if (quirc_resize(qr, 640, 480) < 0) { + perror("Failed to allocate video memory"); + abort(); +} +``` + +`quirc_resize` and `quirc_new` are the only library functions which allocate +memory. If you plan to process a series of frames (or a video stream), you +probably want to allocate and size a single decoder and hold onto it to process +each frame. + +Processing frames is done in two stages. The first stage is an +image-recognition stage called identification, which takes a grayscale image +and searches for QR codes. Using `quirc_begin` and `quirc_end`, you can feed a +grayscale image directly into the buffer that `quirc` uses for image +processing: + +```C +uint8_t *image; +int w, h; + +image = quirc_begin(qr, &w, &h); + +/* Fill out the image buffer here. + * image is a pointer to a w*h bytes. + * One byte per pixel, w pixels per line, h lines in the buffer. + */ + +quirc_end(qr); +``` + +Note that `quirc_begin` simply returns a pointer to a previously allocated +buffer. The buffer will contain uninitialized data. After the call to +`quirc_end`, the decoder holds a list of detected QR codes which can be queried +via `quirc_count` and `quirc_extract`. + +At this point, the second stage of processing occurs -- decoding. This is done +via the call to `quirc_decode`, which is not associated with a decoder object. + +```C +int num_codes; +int i; + +/* We've previously fed an image to the decoder via +* quirc_begin/quirc_end. +*/ + +num_codes = quirc_count(qr); +for (i = 0; i < num_codes; i++) { + struct quirc_code code; + struct quirc_data data; + quirc_decode_error_t err; + + quirc_extract(qr, i, &code); + + /* Decoding stage */ + err = quirc_decode(&code, &data); + if (err) + printf("DECODE FAILED: %s\n", quirc_strerror(err)); + else + printf("Data: %s\n", data.payload); +} +``` + +`quirc_code` and `quirc_data` are flat structures which don't need to be +initialized or freed after use. + +Copyright +--------- +Copyright (C) 2010-2012 Daniel Beer <> + +Permission to use, copy, modify, and/or distribute this software for +any purpose with or without fee is hereby granted, provided that the +above copyright notice and this permission notice appear in all +copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR +PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/ESP32QRCodeReader_Page/collections.c b/ESP32QRCodeReader_Page/collections.c new file mode 100644 index 0000000..ea0073d --- /dev/null +++ b/ESP32QRCodeReader_Page/collections.c @@ -0,0 +1,85 @@ +/* This file is part of the OpenMV project. + * Copyright (c) 2013-2017 Ibrahim Abdelkader & Kwabena W. Agyeman + * This work is licensed under the MIT license, see the file LICENSE for details. + */ + +#include "collections.h" +#define CHAR_BITS (sizeof(char) * 8) +#define CHAR_MASK (CHAR_BITS - 1) +#define CHAR_SHIFT IM_LOG2(CHAR_MASK) + +////////// +// lifo // +////////// + +void lifo_alloc(lifo_t *ptr, size_t size, size_t data_len) +{ + ptr->len = 0; + ptr->size = size; + ptr->data_len = data_len; + ptr->data = (char *)ps_malloc(size * data_len); +} + +void lifo_alloc_all(lifo_t *ptr, size_t *size, size_t data_len) +{ + ptr->data = (char *)ps_malloc(255); + ptr->data_len = data_len; + ptr->size = 255 / data_len; + ptr->len = 0; + *size = ptr->size; +} + +void lifo_free(lifo_t *ptr) +{ + if (ptr->data) + { + free(ptr->data); + } +} + +void lifo_clear(lifo_t *ptr) +{ + ptr->len = 0; +} + +size_t lifo_size(lifo_t *ptr) +{ + return ptr->len; +} + +bool lifo_is_not_empty(lifo_t *ptr) +{ + return ptr->len; +} + +bool lifo_is_not_full(lifo_t *ptr) +{ + return ptr->len != ptr->size; +} + +void lifo_enqueue(lifo_t *ptr, void *data) +{ + memcpy(ptr->data + (ptr->len * ptr->data_len), data, ptr->data_len); + + ptr->len += 1; +} + +void lifo_dequeue(lifo_t *ptr, void *data) +{ + if (data) + { + memcpy(data, ptr->data + ((ptr->len - 1) * ptr->data_len), ptr->data_len); + } + + ptr->len -= 1; +} + +void lifo_poke(lifo_t *ptr, void *data) +{ + memcpy(ptr->data + (ptr->len * ptr->data_len), data, ptr->data_len); +} + +void lifo_peek(lifo_t *ptr, void *data) +{ + memcpy(data, ptr->data + ((ptr->len - 1) * ptr->data_len), ptr->data_len); +} diff --git a/ESP32QRCodeReader_Page/collections.h b/ESP32QRCodeReader_Page/collections.h new file mode 100644 index 0000000..711cafa --- /dev/null +++ b/ESP32QRCodeReader_Page/collections.h @@ -0,0 +1,33 @@ +/* This file is part of the OpenMV project. + * Copyright (c) 2013-2017 Ibrahim Abdelkader & Kwabena W. Agyeman + * This work is licensed under the MIT license, see the file LICENSE for details. + */ + +#ifndef __COLLECTIONS_H__ +#define __COLLECTIONS_H__ +#include +#include +////////// +// lifo // +////////// + +typedef struct lifo +{ + size_t len, size, data_len; + char *data; +} +__attribute__((aligned(8))) lifo_t; + +void lifo_alloc(lifo_t *ptr, size_t size, size_t data_len); +void lifo_alloc_all(lifo_t *ptr, size_t *size, size_t data_len); +void lifo_free(lifo_t *ptr); +void lifo_clear(lifo_t *ptr); +size_t lifo_size(lifo_t *ptr); +bool lifo_is_not_empty(lifo_t *ptr); +bool lifo_is_not_full(lifo_t *ptr); +void lifo_enqueue(lifo_t *ptr, void *data); +void lifo_dequeue(lifo_t *ptr, void *data); +void lifo_poke(lifo_t *ptr, void *data); +void lifo_peek(lifo_t *ptr, void *data); + +#endif /* __COLLECTIONS_H__ */ \ No newline at end of file diff --git a/ESP32QRCodeReader_Page/decode.c b/ESP32QRCodeReader_Page/decode.c new file mode 100644 index 0000000..67c8ed5 --- /dev/null +++ b/ESP32QRCodeReader_Page/decode.c @@ -0,0 +1,983 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "quirc_internal.h" + +#include +#include + +#define MAX_POLY 64 + +/************************************************************************ + * Galois fields + */ + +struct galois_field +{ + int p; + const uint8_t *log; + const uint8_t *exp; +} __attribute__((aligned(8))); + +static const uint8_t gf16_exp[16] = { + 0x01, 0x02, 0x04, 0x08, 0x03, 0x06, 0x0c, 0x0b, + 0x05, 0x0a, 0x07, 0x0e, 0x0f, 0x0d, 0x09, 0x01}; + +static const uint8_t gf16_log[16] = { + 0x00, 0x0f, 0x01, 0x04, 0x02, 0x08, 0x05, 0x0a, + 0x03, 0x0e, 0x09, 0x07, 0x06, 0x0d, 0x0b, 0x0c}; + +static const struct galois_field gf16 = { + .p = 15, + .log = gf16_log, + .exp = gf16_exp}; + +static const uint8_t gf256_exp[256] = { + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, + 0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26, + 0x4c, 0x98, 0x2d, 0x5a, 0xb4, 0x75, 0xea, 0xc9, + 0x8f, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, + 0x9d, 0x27, 0x4e, 0x9c, 0x25, 0x4a, 0x94, 0x35, + 0x6a, 0xd4, 0xb5, 0x77, 0xee, 0xc1, 0x9f, 0x23, + 0x46, 0x8c, 0x05, 0x0a, 0x14, 0x28, 0x50, 0xa0, + 0x5d, 0xba, 0x69, 0xd2, 0xb9, 0x6f, 0xde, 0xa1, + 0x5f, 0xbe, 0x61, 0xc2, 0x99, 0x2f, 0x5e, 0xbc, + 0x65, 0xca, 0x89, 0x0f, 0x1e, 0x3c, 0x78, 0xf0, + 0xfd, 0xe7, 0xd3, 0xbb, 0x6b, 0xd6, 0xb1, 0x7f, + 0xfe, 0xe1, 0xdf, 0xa3, 0x5b, 0xb6, 0x71, 0xe2, + 0xd9, 0xaf, 0x43, 0x86, 0x11, 0x22, 0x44, 0x88, + 0x0d, 0x1a, 0x34, 0x68, 0xd0, 0xbd, 0x67, 0xce, + 0x81, 0x1f, 0x3e, 0x7c, 0xf8, 0xed, 0xc7, 0x93, + 0x3b, 0x76, 0xec, 0xc5, 0x97, 0x33, 0x66, 0xcc, + 0x85, 0x17, 0x2e, 0x5c, 0xb8, 0x6d, 0xda, 0xa9, + 0x4f, 0x9e, 0x21, 0x42, 0x84, 0x15, 0x2a, 0x54, + 0xa8, 0x4d, 0x9a, 0x29, 0x52, 0xa4, 0x55, 0xaa, + 0x49, 0x92, 0x39, 0x72, 0xe4, 0xd5, 0xb7, 0x73, + 0xe6, 0xd1, 0xbf, 0x63, 0xc6, 0x91, 0x3f, 0x7e, + 0xfc, 0xe5, 0xd7, 0xb3, 0x7b, 0xf6, 0xf1, 0xff, + 0xe3, 0xdb, 0xab, 0x4b, 0x96, 0x31, 0x62, 0xc4, + 0x95, 0x37, 0x6e, 0xdc, 0xa5, 0x57, 0xae, 0x41, + 0x82, 0x19, 0x32, 0x64, 0xc8, 0x8d, 0x07, 0x0e, + 0x1c, 0x38, 0x70, 0xe0, 0xdd, 0xa7, 0x53, 0xa6, + 0x51, 0xa2, 0x59, 0xb2, 0x79, 0xf2, 0xf9, 0xef, + 0xc3, 0x9b, 0x2b, 0x56, 0xac, 0x45, 0x8a, 0x09, + 0x12, 0x24, 0x48, 0x90, 0x3d, 0x7a, 0xf4, 0xf5, + 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16, + 0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, + 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x01}; + +static const uint8_t gf256_log[256] = { + 0x00, 0xff, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, + 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b, + 0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, + 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, 0x4c, 0x71, + 0x05, 0x8a, 0x65, 0x2f, 0xe1, 0x24, 0x0f, 0x21, + 0x35, 0x93, 0x8e, 0xda, 0xf0, 0x12, 0x82, 0x45, + 0x1d, 0xb5, 0xc2, 0x7d, 0x6a, 0x27, 0xf9, 0xb9, + 0xc9, 0x9a, 0x09, 0x78, 0x4d, 0xe4, 0x72, 0xa6, + 0x06, 0xbf, 0x8b, 0x62, 0x66, 0xdd, 0x30, 0xfd, + 0xe2, 0x98, 0x25, 0xb3, 0x10, 0x91, 0x22, 0x88, + 0x36, 0xd0, 0x94, 0xce, 0x8f, 0x96, 0xdb, 0xbd, + 0xf1, 0xd2, 0x13, 0x5c, 0x83, 0x38, 0x46, 0x40, + 0x1e, 0x42, 0xb6, 0xa3, 0xc3, 0x48, 0x7e, 0x6e, + 0x6b, 0x3a, 0x28, 0x54, 0xfa, 0x85, 0xba, 0x3d, + 0xca, 0x5e, 0x9b, 0x9f, 0x0a, 0x15, 0x79, 0x2b, + 0x4e, 0xd4, 0xe5, 0xac, 0x73, 0xf3, 0xa7, 0x57, + 0x07, 0x70, 0xc0, 0xf7, 0x8c, 0x80, 0x63, 0x0d, + 0x67, 0x4a, 0xde, 0xed, 0x31, 0xc5, 0xfe, 0x18, + 0xe3, 0xa5, 0x99, 0x77, 0x26, 0xb8, 0xb4, 0x7c, + 0x11, 0x44, 0x92, 0xd9, 0x23, 0x20, 0x89, 0x2e, + 0x37, 0x3f, 0xd1, 0x5b, 0x95, 0xbc, 0xcf, 0xcd, + 0x90, 0x87, 0x97, 0xb2, 0xdc, 0xfc, 0xbe, 0x61, + 0xf2, 0x56, 0xd3, 0xab, 0x14, 0x2a, 0x5d, 0x9e, + 0x84, 0x3c, 0x39, 0x53, 0x47, 0x6d, 0x41, 0xa2, + 0x1f, 0x2d, 0x43, 0xd8, 0xb7, 0x7b, 0xa4, 0x76, + 0xc4, 0x17, 0x49, 0xec, 0x7f, 0x0c, 0x6f, 0xf6, + 0x6c, 0xa1, 0x3b, 0x52, 0x29, 0x9d, 0x55, 0xaa, + 0xfb, 0x60, 0x86, 0xb1, 0xbb, 0xcc, 0x3e, 0x5a, + 0xcb, 0x59, 0x5f, 0xb0, 0x9c, 0xa9, 0xa0, 0x51, + 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7, + 0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, + 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf}; + +const static struct galois_field gf256 = { + .p = 255, + .log = gf256_log, + .exp = gf256_exp}; + +/************************************************************************ + * Polynomial operations + */ + +static void poly_add(uint8_t *dst, const uint8_t *src, uint8_t c, + int shift, const struct galois_field *gf) +{ + int i; + int log_c = gf->log[c]; + + if (!c) + return; + + for (i = 0; i < MAX_POLY; i++) + { + int p = i + shift; + uint8_t v = src[i]; + + if (p < 0 || p >= MAX_POLY) + continue; + if (!v) + continue; + + dst[p] ^= gf->exp[(gf->log[v] + log_c) % gf->p]; + } +} + +static uint8_t poly_eval(const uint8_t *s, uint8_t x, + const struct galois_field *gf) +{ + int i; + uint8_t sum = 0; + uint8_t log_x = gf->log[x]; + + if (!x) + return s[0]; + + for (i = 0; i < MAX_POLY; i++) + { + uint8_t c = s[i]; + + if (!c) + continue; + + sum ^= gf->exp[(gf->log[c] + log_x * i) % gf->p]; + } + + return sum; +} + +/************************************************************************ + * Berlekamp-Massey algorithm for finding error locator polynomials. + */ + +static void berlekamp_massey(const uint8_t *s, int N, + const struct galois_field *gf, + uint8_t *sigma) +{ + uint8_t C[MAX_POLY]; + uint8_t B[MAX_POLY]; + int L = 0; + int m = 1; + uint8_t b = 1; + int n; + + memset(B, 0, sizeof(B)); + memset(C, 0, sizeof(C)); + B[0] = 1; + C[0] = 1; + + for (n = 0; n < N; n++) + { + uint8_t d = s[n]; + uint8_t mult; + int i; + + for (i = 1; i <= L; i++) + { + if (!(C[i] && s[n - i])) + continue; + + d ^= gf->exp[(gf->log[C[i]] + + gf->log[s[n - i]]) % + gf->p]; + } + + mult = gf->exp[(gf->p - gf->log[b] + gf->log[d]) % gf->p]; + + if (!d) + { + m++; + } + else if (L * 2 <= n) + { + uint8_t T[MAX_POLY]; + + memcpy(T, C, sizeof(T)); + poly_add(C, B, mult, m, gf); + memcpy(B, T, sizeof(B)); + L = n + 1 - L; + b = d; + m = 1; + } + else + { + poly_add(C, B, mult, m, gf); + m++; + } + } + + memcpy(sigma, C, MAX_POLY); +} + +/************************************************************************ + * Code stream error correction + * + * Generator polynomial for GF(2^8) is x^8 + x^4 + x^3 + x^2 + 1 + */ + +static int block_syndromes(const uint8_t *data, int bs, int npar, uint8_t *s) +{ + int nonzero = 0; + int i; + + memset(s, 0, MAX_POLY); + + for (i = 0; i < npar; i++) + { + int j; + + for (j = 0; j < bs; j++) + { + uint8_t c = data[bs - j - 1]; + + if (!c) + continue; + + s[i] ^= gf256_exp[((int)gf256_log[c] + + i * j) % + 255]; + } + + if (s[i]) + nonzero = 1; + } + + return nonzero; +} + +static void eloc_poly(uint8_t *omega, + const uint8_t *s, const uint8_t *sigma, + int npar) +{ + int i; + + memset(omega, 0, MAX_POLY); + + for (i = 0; i < npar; i++) + { + const uint8_t a = sigma[i]; + const uint8_t log_a = gf256_log[a]; + int j; + + if (!a) + continue; + + for (j = 0; j + 1 < MAX_POLY; j++) + { + const uint8_t b = s[j + 1]; + + if (i + j >= npar) + break; + + if (!b) + continue; + + omega[i + j] ^= + gf256_exp[(log_a + gf256_log[b]) % 255]; + } + } +} + +static quirc_decode_error_t correct_block(uint8_t *data, + const struct quirc_rs_params *ecc) +{ + int npar = ecc->bs - ecc->dw; + uint8_t s[MAX_POLY]; + uint8_t sigma[MAX_POLY]; + uint8_t sigma_deriv[MAX_POLY]; + uint8_t omega[MAX_POLY]; + int i; + + /* Compute syndrome vector */ + if (!block_syndromes(data, ecc->bs, npar, s)) + return QUIRC_SUCCESS; + + berlekamp_massey(s, npar, &gf256, sigma); + + /* Compute derivative of sigma */ + memset(sigma_deriv, 0, MAX_POLY); + for (i = 0; i + 1 < MAX_POLY; i += 2) + sigma_deriv[i] = sigma[i + 1]; + + /* Compute error evaluator polynomial */ + eloc_poly(omega, s, sigma, npar - 1); + + /* Find error locations and magnitudes */ + for (i = 0; i < ecc->bs; i++) + { + uint8_t xinv = gf256_exp[255 - i]; + + if (!poly_eval(sigma, xinv, &gf256)) + { + uint8_t sd_x = poly_eval(sigma_deriv, xinv, &gf256); + uint8_t omega_x = poly_eval(omega, xinv, &gf256); + uint8_t error = gf256_exp[(255 - gf256_log[sd_x] + + gf256_log[omega_x]) % + 255]; + + data[ecc->bs - i - 1] ^= error; + } + } + + if (block_syndromes(data, ecc->bs, npar, s)) + return QUIRC_ERROR_DATA_ECC; + + return QUIRC_SUCCESS; +} + +/************************************************************************ + * Format value error correction + * + * Generator polynomial for GF(2^4) is x^4 + x + 1 + */ + +#define FORMAT_MAX_ERROR 3 +#define FORMAT_SYNDROMES (FORMAT_MAX_ERROR * 2) +#define FORMAT_BITS 15 + +static int format_syndromes(uint16_t u, uint8_t *s) +{ + int i; + int nonzero = 0; + + memset(s, 0, MAX_POLY); + + for (i = 0; i < FORMAT_SYNDROMES; i++) + { + int j; + + s[i] = 0; + for (j = 0; j < FORMAT_BITS; j++) + if (u & (1 << j)) + s[i] ^= gf16_exp[((i + 1) * j) % 15]; + + if (s[i]) + nonzero = 1; + } + + return nonzero; +} + +static quirc_decode_error_t correct_format(uint16_t *f_ret) +{ + uint16_t u = *f_ret; + int i; + uint8_t s[MAX_POLY]; + uint8_t sigma[MAX_POLY]; + + /* Evaluate U (received codeword) at each of alpha_1 .. alpha_6 + * to get S_1 .. S_6 (but we index them from 0). + */ + if (!format_syndromes(u, s)) + return QUIRC_SUCCESS; + + berlekamp_massey(s, FORMAT_SYNDROMES, &gf16, sigma); + + /* Now, find the roots of the polynomial */ + for (i = 0; i < 15; i++) + if (!poly_eval(sigma, gf16_exp[15 - i], &gf16)) + u ^= (1 << i); + + if (format_syndromes(u, s)) + return QUIRC_ERROR_FORMAT_ECC; + + *f_ret = u; + return QUIRC_SUCCESS; +} + +/************************************************************************ + * Decoder algorithm + */ + +struct datastream +{ + uint8_t raw[QUIRC_MAX_PAYLOAD]; + int data_bits; + int ptr; + + uint8_t data[QUIRC_MAX_PAYLOAD]; +} __attribute__((aligned(8))); + +static inline int grid_bit(const struct quirc_code *code, int x, int y) +{ + int p = y * code->size + x; + + return (code->cell_bitmap[p >> 3] >> (p & 7)) & 1; +} + +static quirc_decode_error_t read_format(const struct quirc_code *code, + struct quirc_data *data, int which) +{ + int i; + uint16_t format = 0; + uint16_t fdata; + quirc_decode_error_t err; + + if (which) + { + for (i = 0; i < 7; i++) + format = (format << 1) | + grid_bit(code, 8, code->size - 1 - i); + for (i = 0; i < 8; i++) + format = (format << 1) | + grid_bit(code, code->size - 8 + i, 8); + } + else + { + static const int xs[15] = { + 8, 8, 8, 8, 8, 8, 8, 8, 7, 5, 4, 3, 2, 1, 0}; + static const int ys[15] = { + 0, 1, 2, 3, 4, 5, 7, 8, 8, 8, 8, 8, 8, 8, 8}; + + for (i = 14; i >= 0; i--) + format = (format << 1) | grid_bit(code, xs[i], ys[i]); + } + + format ^= 0x5412; + + err = correct_format(&format); + if (err) + return err; + + fdata = format >> 10; + data->ecc_level = fdata >> 3; + data->mask = fdata & 7; + + return QUIRC_SUCCESS; +} + +static int mask_bit(int mask, int i, int j) +{ + switch (mask) + { + case 0: + return !((i + j) % 2); + case 1: + return !(i % 2); + case 2: + return !(j % 3); + case 3: + return !((i + j) % 3); + case 4: + return !(((i / 2) + (j / 3)) % 2); + case 5: + return !((i * j) % 2 + (i * j) % 3); + case 6: + return !(((i * j) % 2 + (i * j) % 3) % 2); + case 7: + return !(((i * j) % 3 + (i + j) % 2) % 2); + } + + return 0; +} + +static int reserved_cell(int version, int i, int j) +{ + const struct quirc_version_info *ver = &quirc_version_db[version]; + int size = version * 4 + 17; + int ai = -1, aj = -1, a; + + /* Finder + format: top left */ + if (i < 9 && j < 9) + return 1; + + /* Finder + format: bottom left */ + if (i + 8 >= size && j < 9) + return 1; + + /* Finder + format: top right */ + if (i < 9 && j + 8 >= size) + return 1; + + /* Exclude timing patterns */ + if (i == 6 || j == 6) + return 1; + + /* Exclude version info, if it exists. Version info sits adjacent to + * the top-right and bottom-left finders in three rows, bounded by + * the timing pattern. + */ + if (version >= 7) + { + if (i < 6 && j + 11 >= size) + return 1; + if (i + 11 >= size && j < 6) + return 1; + } + + /* Exclude alignment patterns */ + for (a = 0; a < QUIRC_MAX_ALIGNMENT && ver->apat[a]; a++) + { + int p = ver->apat[a]; + + if (abs(p - i) < 3) + ai = a; + if (abs(p - j) < 3) + aj = a; + } + + if (ai >= 0 && aj >= 0) + { + a--; + if (ai > 0 && ai < a) + return 1; + if (aj > 0 && aj < a) + return 1; + if (aj == a && ai == a) + return 1; + } + + return 0; +} + +static void read_bit(const struct quirc_code *code, + struct quirc_data *data, + struct datastream *ds, int i, int j) +{ + int bitpos = ds->data_bits & 7; + int bytepos = ds->data_bits >> 3; + int v = grid_bit(code, j, i); + + if (mask_bit(data->mask, i, j)) + v ^= 1; + + if (v) + ds->raw[bytepos] |= (0x80 >> bitpos); + + ds->data_bits++; +} + +static void read_data(const struct quirc_code *code, + struct quirc_data *data, + struct datastream *ds) +{ + int y = code->size - 1; + int x = code->size - 1; + int dir = -1; + + while (x > 0) + { + if (x == 6) + x--; + + if (!reserved_cell(data->version, y, x)) + read_bit(code, data, ds, y, x); + + if (!reserved_cell(data->version, y, x - 1)) + read_bit(code, data, ds, y, x - 1); + + y += dir; + if (y < 0 || y >= code->size) + { + dir = -dir; + x -= 2; + y += dir; + } + } +} + +static quirc_decode_error_t codestream_ecc(struct quirc_data *data, + struct datastream *ds) +{ + const struct quirc_version_info *ver = + &quirc_version_db[data->version]; + const struct quirc_rs_params *sb_ecc = &ver->ecc[data->ecc_level]; + struct quirc_rs_params lb_ecc; + const int lb_count = + (ver->data_bytes - sb_ecc->bs * sb_ecc->ns) / (sb_ecc->bs + 1); + const int bc = lb_count + sb_ecc->ns; + const int ecc_offset = sb_ecc->dw * bc + lb_count; + int dst_offset = 0; + int i; + + memcpy(&lb_ecc, sb_ecc, sizeof(lb_ecc)); + lb_ecc.dw++; + lb_ecc.bs++; + + for (i = 0; i < bc; i++) + { + uint8_t *dst = ds->data + dst_offset; + const struct quirc_rs_params *ecc = + (i < sb_ecc->ns) ? sb_ecc : &lb_ecc; + const int num_ec = ecc->bs - ecc->dw; + quirc_decode_error_t err; + int j; + + for (j = 0; j < ecc->dw; j++) + dst[j] = ds->raw[j * bc + i]; + for (j = 0; j < num_ec; j++) + dst[ecc->dw + j] = ds->raw[ecc_offset + j * bc + i]; + + err = correct_block(dst, ecc); + if (err) + return err; + + dst_offset += ecc->dw; + } + + ds->data_bits = dst_offset * 8; + + return QUIRC_SUCCESS; +} + +static inline int bits_remaining(const struct datastream *ds) +{ + return ds->data_bits - ds->ptr; +} + +static int take_bits(struct datastream *ds, int len) +{ + int ret = 0; + + while (len && (ds->ptr < ds->data_bits)) + { + uint8_t b = ds->data[ds->ptr >> 3]; + int bitpos = ds->ptr & 7; + + ret <<= 1; + if ((b << bitpos) & 0x80) + ret |= 1; + + ds->ptr++; + len--; + } + + return ret; +} + +static int numeric_tuple(struct quirc_data *data, + struct datastream *ds, + int bits, int digits) +{ + int tuple; + int i; + + if (bits_remaining(ds) < bits) + return -1; + + tuple = take_bits(ds, bits); + + for (i = digits - 1; i >= 0; i--) + { + data->payload[data->payload_len + i] = tuple % 10 + '0'; + tuple /= 10; + } + + data->payload_len += digits; + return 0; +} + +static quirc_decode_error_t decode_numeric(struct quirc_data *data, + struct datastream *ds) +{ + int bits = 14; + int count; + + if (data->version < 10) + bits = 10; + else if (data->version < 27) + bits = 12; + + count = take_bits(ds, bits); + if (data->payload_len + count + 1 > QUIRC_MAX_PAYLOAD) + return QUIRC_ERROR_DATA_OVERFLOW; + + while (count >= 3) + { + if (numeric_tuple(data, ds, 10, 3) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count -= 3; + } + + if (count >= 2) + { + if (numeric_tuple(data, ds, 7, 2) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count -= 2; + } + + if (count) + { + if (numeric_tuple(data, ds, 4, 1) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count--; + } + + return QUIRC_SUCCESS; +} + +static int alpha_tuple(struct quirc_data *data, + struct datastream *ds, + int bits, int digits) +{ + int tuple; + int i; + + if (bits_remaining(ds) < bits) + return -1; + + tuple = take_bits(ds, bits); + + for (i = 0; i < digits; i++) + { + static const char *alpha_map = + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"; + + data->payload[data->payload_len + digits - i - 1] = + alpha_map[tuple % 45]; + tuple /= 45; + } + + data->payload_len += digits; + return 0; +} + +static quirc_decode_error_t decode_alpha(struct quirc_data *data, + struct datastream *ds) +{ + int bits = 13; + int count; + + if (data->version < 10) + bits = 9; + else if (data->version < 27) + bits = 11; + + count = take_bits(ds, bits); + if (data->payload_len + count + 1 > QUIRC_MAX_PAYLOAD) + return QUIRC_ERROR_DATA_OVERFLOW; + + while (count >= 2) + { + if (alpha_tuple(data, ds, 11, 2) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count -= 2; + } + + if (count) + { + if (alpha_tuple(data, ds, 6, 1) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count--; + } + + return QUIRC_SUCCESS; +} + +static quirc_decode_error_t decode_byte(struct quirc_data *data, + struct datastream *ds) +{ + int bits = 16; + int count; + int i; + + if (data->version < 10) + bits = 8; + + count = take_bits(ds, bits); + if (data->payload_len + count + 1 > QUIRC_MAX_PAYLOAD) + return QUIRC_ERROR_DATA_OVERFLOW; + if (bits_remaining(ds) < count * 8) + return QUIRC_ERROR_DATA_UNDERFLOW; + + for (i = 0; i < count; i++) + data->payload[data->payload_len++] = take_bits(ds, 8); + + return QUIRC_SUCCESS; +} + +static quirc_decode_error_t decode_kanji(struct quirc_data *data, + struct datastream *ds) +{ + int bits = 12; + int count; + int i; + + if (data->version < 10) + bits = 8; + else if (data->version < 27) + bits = 10; + + count = take_bits(ds, bits); + if (data->payload_len + count * 2 + 1 > QUIRC_MAX_PAYLOAD) + return QUIRC_ERROR_DATA_OVERFLOW; + if (bits_remaining(ds) < count * 13) + return QUIRC_ERROR_DATA_UNDERFLOW; + + for (i = 0; i < count; i++) + { + int d = take_bits(ds, 13); + int msB = d / 0xc0; + int lsB = d % 0xc0; + int intermediate = (msB << 8) | lsB; + uint16_t sjw; + + if (intermediate + 0x8140 <= 0x9ffc) + { + /* bytes are in the range 0x8140 to 0x9FFC */ + sjw = intermediate + 0x8140; + } + else + { + /* bytes are in the range 0xE040 to 0xEBBF */ + sjw = intermediate + 0xc140; + } + + data->payload[data->payload_len++] = sjw >> 8; + data->payload[data->payload_len++] = sjw & 0xff; + } + + return QUIRC_SUCCESS; +} + +static quirc_decode_error_t decode_eci(struct quirc_data *data, + struct datastream *ds) +{ + if (bits_remaining(ds) < 8) + return QUIRC_ERROR_DATA_UNDERFLOW; + + data->eci = take_bits(ds, 8); + + if ((data->eci & 0xc0) == 0x80) + { + if (bits_remaining(ds) < 8) + return QUIRC_ERROR_DATA_UNDERFLOW; + + data->eci = (data->eci << 8) | take_bits(ds, 8); + } + else if ((data->eci & 0xe0) == 0xc0) + { + if (bits_remaining(ds) < 16) + return QUIRC_ERROR_DATA_UNDERFLOW; + + data->eci = (data->eci << 16) | take_bits(ds, 16); + } + + return QUIRC_SUCCESS; +} + +static quirc_decode_error_t decode_payload(struct quirc_data *data, + struct datastream *ds) +{ + while (bits_remaining(ds) >= 4) + { + quirc_decode_error_t err = QUIRC_SUCCESS; + int type = take_bits(ds, 4); + + switch (type) + { + case QUIRC_DATA_TYPE_NUMERIC: + err = decode_numeric(data, ds); + break; + + case QUIRC_DATA_TYPE_ALPHA: + err = decode_alpha(data, ds); + break; + + case QUIRC_DATA_TYPE_BYTE: + err = decode_byte(data, ds); + break; + + case QUIRC_DATA_TYPE_KANJI: + err = decode_kanji(data, ds); + break; + + case 7: + err = decode_eci(data, ds); + break; + + default: + goto done; + } + + if (err) + return err; + + if (!(type & (type - 1)) && (type > data->data_type)) + data->data_type = type; + } + +done: + + /* Add nul terminator to all payloads */ + if (data->payload_len >= sizeof(data->payload)) + data->payload_len--; + data->payload[data->payload_len] = 0; + + return QUIRC_SUCCESS; +} + +quirc_decode_error_t quirc_decode(const struct quirc_code *code, + struct quirc_data *data) +{ + quirc_decode_error_t err; + struct datastream *ds = ps_malloc(sizeof(struct datastream)); + + if ((code->size - 17) % 4) + { + free(ds); + return QUIRC_ERROR_INVALID_GRID_SIZE; + } + + memset(data, 0, sizeof(*data)); + memset(ds, 0, sizeof(*ds)); + + data->version = (code->size - 17) / 4; + + if (data->version < 1 || + data->version > QUIRC_MAX_VERSION) + { + free(ds); + return QUIRC_ERROR_INVALID_VERSION; + } + + /* Read format information -- try both locations */ + err = read_format(code, data, 0); + if (err) + err = read_format(code, data, 1); + if (err) + { + free(ds); + return err; + } + + read_data(code, data, ds); + err = codestream_ecc(data, ds); + if (err) + { + free(ds); + return err; + } + + err = decode_payload(data, ds); + if (err) + { + free(ds); + return err; + } + + free(ds); + return QUIRC_SUCCESS; +} \ No newline at end of file diff --git a/ESP32QRCodeReader_Page/fmath.h b/ESP32QRCodeReader_Page/fmath.h new file mode 100644 index 0000000..76c3b93 --- /dev/null +++ b/ESP32QRCodeReader_Page/fmath.h @@ -0,0 +1,70 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * Fast approximate math functions. + * + */ +#ifndef __FMATH_H +#define __FMATH_H +#include +#include + +static inline float fast_sqrtf(float x) +{ + //return sqrtf(x); + asm("fsqrt.s %0, %1" + : "=f"(x) + : "f"(x)); + return x; +} +static inline int fast_floorf(float x) +{ + return (int)(x); +} + +static inline int fast_ceilf(float x) +{ + return (int)(x + 0.9999f); +} + +static inline int fast_roundf(float x) +{ + return (int)(x); +} + +static inline float fast_fabsf(float d) +{ + return fabsf(d); +} + +extern int fast_floorf(float x); +extern int fast_ceilf(float x); +extern int fast_roundf(float x); +extern float fast_atanf(float x); +extern float fast_atan2f(float y, float x); +extern float fast_expf(float x); +extern float fast_cbrtf(float d); +extern float fast_fabsf(float d); +extern float fast_log(float x); +extern float fast_log2(float x); +extern float fast_powf(float a, float b); + +/*#define fast_sqrtf(x) (sqrtf(x)) +#define fast_floorf(x) ((int)floorf(x)) +#define fast_ceilf(x) ((int)ceilf(x)) +#define fast_roundf(x) ((int)roundf(x)) +#define fast_atanf(x) (atanf(x)) +#define fast_atan2f(x,y) (atan2f((x),(y))) +#define fast_expf(x) (expf(x)) +#define fast_cbrtf(x) (cbrtf(x)) +#define fast_fabsf(x) (fabsf(x)) +#define fast_log(x) (log(x)) +#define fast_log2(x) (log2(x)) +#define fast_powf(x,y) (powf((x),(y))) +*/ + +extern const float cos_table[360]; +extern const float sin_table[360]; +#endif // __FMATH_H \ No newline at end of file diff --git a/ESP32QRCodeReader_Page/identify.c b/ESP32QRCodeReader_Page/identify.c new file mode 100644 index 0000000..d0d0316 --- /dev/null +++ b/ESP32QRCodeReader_Page/identify.c @@ -0,0 +1,1286 @@ +/* quirc - QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + +#include "fmath.h" +#include "collections.h" +#include "quirc_internal.h" + +/************************************************************************ + * Linear algebra routines + */ + +static int line_intersect(const struct quirc_point *p0, + const struct quirc_point *p1, + const struct quirc_point *q0, + const struct quirc_point *q1, + struct quirc_point *r) +{ + /* (a, b) is perpendicular to line p */ + int a = -(p1->y - p0->y); + int b = p1->x - p0->x; + + /* (c, d) is perpendicular to line q */ + int c = -(q1->y - q0->y); + int d = q1->x - q0->x; + + /* e and f are dot products of the respective vectors with p and q */ + int e = a * p1->x + b * p1->y; + int f = c * q1->x + d * q1->y; + + /* Now we need to solve: + * [a b] [rx] [e] + * [c d] [ry] = [f] + * + * We do this by inverting the matrix and applying it to (e, f): + * [ d -b] [e] [rx] + * 1/det [-c a] [f] = [ry] + */ + int det = (a * d) - (b * c); + + if (!det) + return 0; + + r->x = (d * e - b * f) / det; + r->y = (-c * e + a * f) / det; + + return 1; +} + +static void perspective_setup(float *c, + const struct quirc_point *rect, + float w, float h) +{ + float x0 = rect[0].x; + float y0 = rect[0].y; + float x1 = rect[1].x; + float y1 = rect[1].y; + float x2 = rect[2].x; + float y2 = rect[2].y; + float x3 = rect[3].x; + float y3 = rect[3].y; + + float wden = w * (x2 * y3 - x3 * y2 + (x3 - x2) * y1 + x1 * (y2 - y3)); + float hden = h * (x2 * y3 + x1 * (y2 - y3) - x3 * y2 + (x3 - x2) * y1); + + c[0] = (x1 * (x2 * y3 - x3 * y2) + x0 * (-x2 * y3 + x3 * y2 + (x2 - x3) * y1) + + x1 * (x3 - x2) * y0) / + wden; + c[1] = -(x0 * (x2 * y3 + x1 * (y2 - y3) - x2 * y1) - x1 * x3 * y2 + x2 * x3 * y1 + (x1 * x3 - x2 * x3) * y0) / hden; + c[2] = x0; + c[3] = (y0 * (x1 * (y3 - y2) - x2 * y3 + x3 * y2) + y1 * (x2 * y3 - x3 * y2) + + x0 * y1 * (y2 - y3)) / + wden; + c[4] = (x0 * (y1 * y3 - y2 * y3) + x1 * y2 * y3 - x2 * y1 * y3 + + y0 * (x3 * y2 - x1 * y2 + (x2 - x3) * y1)) / + hden; + c[5] = y0; + c[6] = (x1 * (y3 - y2) + x0 * (y2 - y3) + (x2 - x3) * y1 + (x3 - x2) * y0) / wden; + c[7] = (-x2 * y3 + x1 * y3 + x3 * y2 + x0 * (y1 - y2) - x3 * y1 + (x2 - x1) * y0) / + hden; +} + +static void perspective_map(const float *c, + float u, float v, struct quirc_point *ret) +{ + float den = c[6] * u + c[7] * v + 1.0; + float x = (c[0] * u + c[1] * v + c[2]) / den; + float y = (c[3] * u + c[4] * v + c[5]) / den; + + ret->x = fast_roundf(x); + ret->y = fast_roundf(y); +} + +static void perspective_unmap(const float *c, + const struct quirc_point *in, + float *u, float *v) +{ + float x = in->x; + float y = in->y; + float den = -c[0] * c[7] * y + c[1] * c[6] * y + (c[3] * c[7] - c[4] * c[6]) * x + + c[0] * c[4] - c[1] * c[3]; + + *u = -(c[1] * (y - c[5]) - c[2] * c[7] * y + (c[5] * c[7] - c[4]) * x + c[2] * c[4]) / + den; + *v = (c[0] * (y - c[5]) - c[2] * c[6] * y + (c[5] * c[6] - c[3]) * x + c[2] * c[3]) / + den; +} + +/************************************************************************ + * Span-based floodfill routine + */ + +typedef void (*span_func_t)(void *user_data, int y, int left, int right); + +typedef struct xylf +{ + int16_t x, y, l, r; +} __attribute__((aligned(8))) +xylf_t; + +//计算该区域的面积,from是像素颜色,to是区块标号,user_data是申请的区块结构体,func是计算面积的函数 +static void flood_fill_seed(struct quirc *q, int x, int y, int from, int to, + span_func_t func, void *user_data, + int depth) +{ + (void)depth; // unused + + lifo_t lifo; + size_t lifo_len; + lifo_alloc_all(&lifo, &lifo_len, sizeof(xylf_t)); + //late in first out. 申请xylf_t的lifo,一次申请完,长度存储在lifo_len中 + + for (;;) + { + int left = x; + int right = x; + int i; + quirc_pixel_t *row = q->pixels + y * q->w; //行起始地址 + //查找左右边界 + while (left > 0 && row[left - 1] == from) + left--; + + while (right < q->w - 1 && row[right + 1] == from) + right++; + + /* Fill the extent 对应像素标记为区块号*/ + for (i = left; i <= right; i++) + row[i] = to; + //累加区域内的像素点数作为面积 + if (func) + func(user_data, y, left, right); + + for (;;) + { + if (lifo_size(&lifo) < lifo_len) + { //栈中的数量 + /* Seed new flood-fills */ + if (y > 0) + { //查找上一行有没有在同一区域的点 + row = q->pixels + (y - 1) * q->w; + + bool recurse = false; + for (i = left; i <= right; i++) + if (row[i] == from) + { //相同区域,则入栈原来的区块 + xylf_t context; + context.x = x; + context.y = y; + context.l = left; + context.r = right; + lifo_enqueue(&lifo, &context); + //mp_printf(&mp_plat_print, "#x=%x,y=%d;x1=%d,y1=%d\n",x,y,i,y-1); + x = i; + y = y - 1; + recurse = true; + break; + } + if (recurse) + break; + } + //查找下一行有没有在同一区域的点 + if (y < q->h - 1) + { + row = q->pixels + (y + 1) * q->w; + + bool recurse = false; + for (i = left; i <= right; i++) + if (row[i] == from) + { + xylf_t context; + context.x = x; + context.y = y; + context.l = left; + context.r = right; + lifo_enqueue(&lifo, &context); + //mp_printf(&mp_plat_print, "#x=%x,y=%d;x1=%d,y1=%d\n",x,y,i,y+1); + x = i; + y = y + 1; + recurse = true; + break; + } + if (recurse) + break; + } + } + + if (!lifo_size(&lifo)) + { + lifo_free(&lifo); //如果最起始为止就没找到,那么返回 + return; + } + //本次迭代,往上,往下找边界(相同颜色像素点),直到找不到为止 + //找到边界后,出栈上层像素点,回退回去 + xylf_t context; + lifo_dequeue(&lifo, &context); //这里存疑,如果都没有的话,dequeue就会反向溢出吧。。 + x = context.x; + y = context.y; + left = context.l; + right = context.r; + //mp_printf(&mp_plat_print, "#deq: x=%x,y=%d\n",x,y); + } //找到相同from,break到这外面 + } +} + +/************************************************************************ + * Adaptive thresholding + */ + +#define THRESHOLD_S_MIN 1 +#define THRESHOLD_S_DEN 8 +#define THRESHOLD_T 5 + +static void threshold(struct quirc *q) +{ + int x, y; + int avg_w = 0; + int avg_u = 0; + int threshold_s = q->w / THRESHOLD_S_DEN; + quirc_pixel_t *row = q->pixels; + + /* + * Ensure a sane, non-zero value for threshold_s. + * + * threshold_s can be zero if the image width is small. We need to avoid + * SIGFPE as it will be used as divisor. + */ + if (threshold_s < THRESHOLD_S_MIN) + threshold_s = THRESHOLD_S_MIN; + + for (y = 0; y < q->h; y++) + { + int row_average[q->w]; + + memset(row_average, 0, sizeof(row_average)); + + for (x = 0; x < q->w; x++) + { + int w, u; + + if (y & 1) + { + w = x; + u = q->w - 1 - x; + } + else + { + w = q->w - 1 - x; + u = x; + } + + avg_w = (avg_w * (threshold_s - 1)) / + threshold_s + + row[w]; + avg_u = (avg_u * (threshold_s - 1)) / + threshold_s + + row[u]; + + row_average[w] += avg_w; + row_average[u] += avg_u; + } + + for (x = 0; x < q->w; x++) + { + if (row[x] < row_average[x] * + (100 - THRESHOLD_T) / (200 * threshold_s)) + row[x] = QUIRC_PIXEL_BLACK; + else + row[x] = QUIRC_PIXEL_WHITE; + } + + row += q->w; + } +} + +static void area_count(void *user_data, int y, int left, int right) +{ + ((struct quirc_region *)user_data)->count += right - left + 1; +} + +static int region_code(struct quirc *q, int x, int y) +{ //region指的是QRcode的区域,成员为区域的坐标,像素面积,是否顶点 + int pixel; + struct quirc_region *box; + int region; + + if (x < 0 || y < 0 || x >= q->w || y >= q->h) + return -1; + + pixel = q->pixels[y * q->w + x]; + //预先判断非正常的像素情况,退出 + if (pixel >= QUIRC_PIXEL_REGION) + return pixel; + + if (pixel == QUIRC_PIXEL_WHITE) + return -1; + + if (q->num_regions >= QUIRC_MAX_REGIONS) + return -1; + //新建一个区域 + region = q->num_regions; + box = &q->regions[q->num_regions++]; + + memset(box, 0, sizeof(*box)); + + box->seed.x = x; + box->seed.y = y; + box->capstone = -1; + //计算该区域的面积 + flood_fill_seed(q, x, y, pixel, region, area_count, box, 0); + + return region; +} + +struct polygon_score_data +{ + struct quirc_point ref; + + int scores[4]; + struct quirc_point *corners; +} __attribute__((aligned(8))); + +static void find_one_corner(void *user_data, int y, int left, int right) +{ + struct polygon_score_data *psd = + (struct polygon_score_data *)user_data; + int xs[2] = {left, right}; + int dy = y - psd->ref.y; + int i; + + for (i = 0; i < 2; i++) + { + int dx = xs[i] - psd->ref.x; + int d = dx * dx + dy * dy; + + if (d > psd->scores[0]) + { + psd->scores[0] = d; + psd->corners[0].x = xs[i]; + psd->corners[0].y = y; + } + } +} + +static void find_other_corners(void *user_data, int y, int left, int right) +{ + struct polygon_score_data *psd = + (struct polygon_score_data *)user_data; + int xs[2] = {left, right}; + int i; + + for (i = 0; i < 2; i++) + { + int up = xs[i] * psd->ref.x + y * psd->ref.y; + int right = xs[i] * -psd->ref.y + y * psd->ref.x; + int scores[4] = {up, right, -up, -right}; + int j; + + for (j = 0; j < 4; j++) + { + if (scores[j] > psd->scores[j]) + { + psd->scores[j] = scores[j]; + psd->corners[j].x = xs[i]; + psd->corners[j].y = y; + } + } + } +} + +static void find_region_corners(struct quirc *q, + int rcode, const struct quirc_point *ref, + struct quirc_point *corners) +{ + struct quirc_region *region = &q->regions[rcode]; + struct polygon_score_data psd; + int i; + + memset(&psd, 0, sizeof(psd)); + psd.corners = corners; + + memcpy(&psd.ref, ref, sizeof(psd.ref)); + psd.scores[0] = -1; + flood_fill_seed(q, region->seed.x, region->seed.y, + rcode, QUIRC_PIXEL_BLACK, + find_one_corner, &psd, 0); + + psd.ref.x = psd.corners[0].x - psd.ref.x; + psd.ref.y = psd.corners[0].y - psd.ref.y; + + for (i = 0; i < 4; i++) + memcpy(&psd.corners[i], ®ion->seed, + sizeof(psd.corners[i])); + + i = region->seed.x * psd.ref.x + region->seed.y * psd.ref.y; + psd.scores[0] = i; + psd.scores[2] = -i; + i = region->seed.x * -psd.ref.y + region->seed.y * psd.ref.x; + psd.scores[1] = i; + psd.scores[3] = -i; + + flood_fill_seed(q, region->seed.x, region->seed.y, + QUIRC_PIXEL_BLACK, rcode, + find_other_corners, &psd, 0); +} + +static void record_capstone(struct quirc *q, int ring, int stone) +{ + struct quirc_region *stone_reg = &q->regions[stone]; + struct quirc_region *ring_reg = &q->regions[ring]; + struct quirc_capstone *capstone; + int cs_index; + + if (q->num_capstones >= QUIRC_MAX_CAPSTONES) + return; + + cs_index = q->num_capstones; + capstone = &q->capstones[q->num_capstones++]; + + memset(capstone, 0, sizeof(*capstone)); + + capstone->qr_grid = -1; + capstone->ring = ring; + capstone->stone = stone; + stone_reg->capstone = cs_index; + ring_reg->capstone = cs_index; + + /* Find the corners of the ring */ + find_region_corners(q, ring, &stone_reg->seed, capstone->corners); + + /* Set up the perspective transform and find the center */ + perspective_setup(capstone->c, capstone->corners, 7.0, 7.0); + perspective_map(capstone->c, 3.5, 3.5, &capstone->center); +} + +static void test_capstone(struct quirc *q, int x, int y, int *pb) +{ + int ring_right = region_code(q, x - pb[4], y); //x-pb[4]是标记环右边的左侧 + int stone = region_code(q, x - pb[4] - pb[3] - pb[2], y); //实心点左侧 + int ring_left = region_code(q, x - pb[4] - pb[3] - pb[2] - pb[1] - pb[0], y); //环左侧 + struct quirc_region *stone_reg; + struct quirc_region *ring_reg; + int ratio; + //以下检测顶点标记是否符合规范,环称为ring,中间称为stone + if (ring_left < 0 || ring_right < 0 || stone < 0) + return; + + /* Left and ring of ring should be connected */ + if (ring_left != ring_right) + return; + + /* Ring should be disconnected from stone */ + if (ring_left == stone) + return; + + stone_reg = &q->regions[stone]; + ring_reg = &q->regions[ring_left]; + + /* Already detected */ + if (stone_reg->capstone >= 0 || ring_reg->capstone >= 0) + return; + + /* Ratio should ideally be 37.5 中间实心点占面积比例应该在37.5%左右*/ + ratio = stone_reg->count * 100 / ring_reg->count; + if (ratio < 10 || ratio > 70) + return; + + record_capstone(q, ring_left, stone); +} + +static void finder_scan(struct quirc *q, int y) +{ + quirc_pixel_t *row = q->pixels + y * q->w; + int x; + int last_color = 0; + int run_length = 0; + int run_count = 0; + int pb[5]; //means QRcode's pixel width + + memset(pb, 0, sizeof(pb)); + for (x = 0; x < q->w; x++) + { + int color = row[x] ? 1 : 0; + + if (x && color != last_color) + { // color is different + memmove(pb, pb + 1, sizeof(pb[0]) * 4); //left move in one data + pb[4] = run_length; //run how many pix to get different color + run_length = 0; + run_count++; //get more than 5 time color jump + + if (!color && run_count >= 5) + { // find the marker of QRcode(three corner's marker) + static int check[5] = {1, 1, 3, 1, 1}; + int avg, err; + int i; + int ok = 1; + + avg = (pb[0] + pb[1] + pb[3] + pb[4]) / 4; + err = avg * 3 / 4; + + for (i = 0; i < 5; i++) + if (pb[i] < check[i] * avg - err || + pb[i] > check[i] * avg + err) + ok = 0; + + if (ok) + test_capstone(q, x, y, pb); + } + } + + run_length++; + last_color = color; + } +} + +static void find_alignment_pattern(struct quirc *q, int index) +{ + struct quirc_grid *qr = &q->grids[index]; + struct quirc_capstone *c0 = &q->capstones[qr->caps[0]]; + struct quirc_capstone *c2 = &q->capstones[qr->caps[2]]; + struct quirc_point a; + struct quirc_point b; + struct quirc_point c; + int size_estimate; + int step_size = 1; + int dir = 0; + float u, v; + + /* Grab our previous estimate of the alignment pattern corner */ + memcpy(&b, &qr->align, sizeof(b)); + + /* Guess another two corners of the alignment pattern so that we + * can estimate its size. + */ + perspective_unmap(c0->c, &b, &u, &v); + perspective_map(c0->c, u, v + 1.0, &a); + perspective_unmap(c2->c, &b, &u, &v); + perspective_map(c2->c, u + 1.0, v, &c); + + size_estimate = abs((a.x - b.x) * -(c.y - b.y) + + (a.y - b.y) * (c.x - b.x)); + + /* Spiral outwards from the estimate point until we find something + * roughly the right size. Don't look too far from the estimate + * point. + */ + while (step_size * step_size < size_estimate * 100) + { + static const int dx_map[] = {1, 0, -1, 0}; + static const int dy_map[] = {0, -1, 0, 1}; + int i; + + for (i = 0; i < step_size; i++) + { + int code = region_code(q, b.x, b.y); + + if (code >= 0) + { + struct quirc_region *reg = &q->regions[code]; + + if (reg->count >= size_estimate / 2 && + reg->count <= size_estimate * 2) + { + qr->align_region = code; + return; + } + } + + b.x += dx_map[dir]; + b.y += dy_map[dir]; + } + + dir = (dir + 1) % 4; + if (!(dir & 1)) + step_size++; + } +} + +static void find_leftmost_to_line(void *user_data, int y, int left, int right) +{ + struct polygon_score_data *psd = + (struct polygon_score_data *)user_data; + int xs[2] = {left, right}; + int i; + + for (i = 0; i < 2; i++) + { + int d = -psd->ref.y * xs[i] + psd->ref.x * y; + + if (d < psd->scores[0]) + { + psd->scores[0] = d; + psd->corners[0].x = xs[i]; + psd->corners[0].y = y; + } + } +} + +/* Do a Bresenham scan from one point to another and count the number + * of black/white transitions. + */ +static int timing_scan(const struct quirc *q, + const struct quirc_point *p0, + const struct quirc_point *p1) +{ + int n = p1->x - p0->x; + int d = p1->y - p0->y; + int x = p0->x; + int y = p0->y; + int *dom, *nondom; + int dom_step; + int nondom_step; + int a = 0; + int i; + int run_length = 0; + int count = 0; + + if (p0->x < 0 || p0->y < 0 || p0->x >= q->w || p0->y >= q->h) + return -1; + if (p1->x < 0 || p1->y < 0 || p1->x >= q->w || p1->y >= q->h) + return -1; + + if (abs(n) > abs(d)) + { + int swap = n; + + n = d; + d = swap; + + dom = &x; + nondom = &y; + } + else + { + dom = &y; + nondom = &x; + } + + if (n < 0) + { + n = -n; + nondom_step = -1; + } + else + { + nondom_step = 1; + } + + if (d < 0) + { + d = -d; + dom_step = -1; + } + else + { + dom_step = 1; + } + + x = p0->x; + y = p0->y; + for (i = 0; i <= d; i++) + { + int pixel; + + if (y < 0 || y >= q->h || x < 0 || x >= q->w) + break; + + pixel = q->pixels[y * q->w + x]; + + if (pixel) + { + if (run_length >= 2) + count++; + run_length = 0; + } + else + { + run_length++; + } + + a += n; + *dom += dom_step; + if (a >= d) + { + *nondom += nondom_step; + a -= d; + } + } + + return count; +} + +/* Try the measure the timing pattern for a given QR code. This does + * not require the global perspective to have been set up, but it + * does require that the capstone corners have been set to their + * canonical rotation. + * + * For each capstone, we find a point in the middle of the ring band + * which is nearest the centre of the code. Using these points, we do + * a horizontal and a vertical timing scan. + */ +static int measure_timing_pattern(struct quirc *q, int index) +{ + struct quirc_grid *qr = &q->grids[index]; + int i; + int scan; + int ver; + int size; + + for (i = 0; i < 3; i++) + { + static const float us[] = {6.5, 6.5, 0.5}; + static const float vs[] = {0.5, 6.5, 6.5}; + struct quirc_capstone *cap = &q->capstones[qr->caps[i]]; + + perspective_map(cap->c, us[i], vs[i], &qr->tpep[i]); + } + + qr->hscan = timing_scan(q, &qr->tpep[1], &qr->tpep[2]); + qr->vscan = timing_scan(q, &qr->tpep[1], &qr->tpep[0]); + + scan = qr->hscan; + if (qr->vscan > scan) + scan = qr->vscan; + + /* If neither scan worked, we can't go any further. */ + if (scan < 0) + return -1; + + /* Choose the nearest allowable grid size */ + size = scan * 2 + 13; + ver = (size - 15) / 4; + qr->grid_size = ver * 4 + 17; + + return 0; +} + +/* Read a cell from a grid using the currently set perspective + * transform. Returns +/- 1 for black/white, 0 for cells which are + * out of image bounds. + */ +static int read_cell(const struct quirc *q, int index, int x, int y) +{ + const struct quirc_grid *qr = &q->grids[index]; + struct quirc_point p; + + perspective_map(qr->c, x + 0.5, y + 0.5, &p); + if (p.y < 0 || p.y >= q->h || p.x < 0 || p.x >= q->w) + return 0; + + return q->pixels[p.y * q->w + p.x] ? 1 : -1; +} + +static int fitness_cell(const struct quirc *q, int index, int x, int y) +{ + const struct quirc_grid *qr = &q->grids[index]; + int score = 0; + int u, v; + + for (v = 0; v < 3; v++) + for (u = 0; u < 3; u++) + { + static const float offsets[] = {0.3, 0.5, 0.7}; + struct quirc_point p; + + perspective_map(qr->c, x + offsets[u], + y + offsets[v], &p); + if (p.y < 0 || p.y >= q->h || p.x < 0 || p.x >= q->w) + continue; + + if (q->pixels[p.y * q->w + p.x]) + score++; + else + score--; + } + + return score; +} + +static int fitness_ring(const struct quirc *q, int index, int cx, int cy, + int radius) +{ + int i; + int score = 0; + + for (i = 0; i < radius * 2; i++) + { + score += fitness_cell(q, index, cx - radius + i, cy - radius); + score += fitness_cell(q, index, cx - radius, cy + radius - i); + score += fitness_cell(q, index, cx + radius, cy - radius + i); + score += fitness_cell(q, index, cx + radius - i, cy + radius); + } + + return score; +} + +static int fitness_apat(const struct quirc *q, int index, int cx, int cy) +{ + return fitness_cell(q, index, cx, cy) - + fitness_ring(q, index, cx, cy, 1) + + fitness_ring(q, index, cx, cy, 2); +} + +static int fitness_capstone(const struct quirc *q, int index, int x, int y) +{ + x += 3; + y += 3; + + return fitness_cell(q, index, x, y) + + fitness_ring(q, index, x, y, 1) - + fitness_ring(q, index, x, y, 2) + + fitness_ring(q, index, x, y, 3); +} + +/* Compute a fitness score for the currently configured perspective + * transform, using the features we expect to find by scanning the + * grid. + */ +static int fitness_all(const struct quirc *q, int index) +{ + const struct quirc_grid *qr = &q->grids[index]; + int version = (qr->grid_size - 17) / 4; + const struct quirc_version_info *info = &quirc_version_db[version]; + int score = 0; + int i, j; + int ap_count; + + /* Check the timing pattern */ + for (i = 0; i < qr->grid_size - 14; i++) + { + int expect = (i & 1) ? 1 : -1; + + score += fitness_cell(q, index, i + 7, 6) * expect; + score += fitness_cell(q, index, 6, i + 7) * expect; + } + + /* Check capstones */ + score += fitness_capstone(q, index, 0, 0); + score += fitness_capstone(q, index, qr->grid_size - 7, 0); + score += fitness_capstone(q, index, 0, qr->grid_size - 7); + + if (version < 0 || version > QUIRC_MAX_VERSION) + return score; + + /* Check alignment patterns */ + ap_count = 0; + while ((ap_count < QUIRC_MAX_ALIGNMENT) && info->apat[ap_count]) + ap_count++; + + for (i = 1; i + 1 < ap_count; i++) + { + score += fitness_apat(q, index, 6, info->apat[i]); + score += fitness_apat(q, index, info->apat[i], 6); + } + + for (i = 1; i < ap_count; i++) + for (j = 1; j < ap_count; j++) + score += fitness_apat(q, index, + info->apat[i], info->apat[j]); + //mp_printf(&mp_plat_print, "##score=%d\n",score); + return score; +} + +static void jiggle_perspective(struct quirc *q, int index) +{ + struct quirc_grid *qr = &q->grids[index]; + int best = fitness_all(q, index); + int pass; + float adjustments[8]; + int i; + + for (i = 0; i < 8; i++) + adjustments[i] = qr->c[i] * 0.02; + + for (pass = 0; pass < 5; pass++) + { + for (i = 0; i < 16; i++) + { + int j = i >> 1; + int test; + float old = qr->c[j]; + float step = adjustments[j]; + float new; + + if (i & 1) + new = old + step; + else + new = old - step; + + qr->c[j] = new; + test = fitness_all(q, index); + + if (test > best) + best = test; + else + qr->c[j] = old; + } + + for (i = 0; i < 8; i++) + adjustments[i] *= 0.5; + } +} + +/* Once the capstones are in place and an alignment point has been + * chosen, we call this function to set up a grid-reading perspective + * transform. + */ +static void setup_qr_perspective(struct quirc *q, int index) +{ + struct quirc_grid *qr = &q->grids[index]; + struct quirc_point rect[4]; + + /* Set up the perspective map for reading the grid */ + memcpy(&rect[0], &q->capstones[qr->caps[1]].corners[0], + sizeof(rect[0])); + memcpy(&rect[1], &q->capstones[qr->caps[2]].corners[0], + sizeof(rect[0])); + memcpy(&rect[2], &qr->align, sizeof(rect[0])); + memcpy(&rect[3], &q->capstones[qr->caps[0]].corners[0], + sizeof(rect[0])); + perspective_setup(qr->c, rect, qr->grid_size - 7, qr->grid_size - 7); + + jiggle_perspective(q, index); +} + +/* Rotate the capstone with so that corner 0 is the leftmost with respect + * to the given reference line. + */ +static void rotate_capstone(struct quirc_capstone *cap, + const struct quirc_point *h0, + const struct quirc_point *hd) +{ + struct quirc_point copy[4]; + int j; + int best = 0; + int best_score = 0; + + for (j = 0; j < 4; j++) + { + struct quirc_point *p = &cap->corners[j]; + int score = (p->x - h0->x) * -hd->y + + (p->y - h0->y) * hd->x; + + if (!j || score < best_score) + { + best = j; + best_score = score; + } + } + + /* Rotate the capstone */ + for (j = 0; j < 4; j++) + memcpy(©[j], &cap->corners[(j + best) % 4], + sizeof(copy[j])); + memcpy(cap->corners, copy, sizeof(cap->corners)); + perspective_setup(cap->c, cap->corners, 7.0, 7.0); +} + +static void record_qr_grid(struct quirc *q, int a, int b, int c) +{ + struct quirc_point h0, hd; + int i; + int qr_index; + struct quirc_grid *qr; + + if (q->num_grids >= QUIRC_MAX_GRIDS) + return; + + /* Construct the hypotenuse line from A to C. B should be to + * the left of this line. + */ + memcpy(&h0, &q->capstones[a].center, sizeof(h0)); + hd.x = q->capstones[c].center.x - q->capstones[a].center.x; + hd.y = q->capstones[c].center.y - q->capstones[a].center.y; + + /* Make sure A-B-C is clockwise */ + if ((q->capstones[b].center.x - h0.x) * -hd.y + + (q->capstones[b].center.y - h0.y) * hd.x > + 0) + { + int swap = a; + + a = c; + c = swap; + hd.x = -hd.x; + hd.y = -hd.y; + } + + /* Record the grid and its components */ + qr_index = q->num_grids; + qr = &q->grids[q->num_grids++]; + + memset(qr, 0, sizeof(*qr)); + qr->caps[0] = a; + qr->caps[1] = b; + qr->caps[2] = c; + qr->align_region = -1; + + /* Rotate each capstone so that corner 0 is top-left with respect + * to the grid. + */ + for (i = 0; i < 3; i++) + { + struct quirc_capstone *cap = &q->capstones[qr->caps[i]]; + + rotate_capstone(cap, &h0, &hd); + cap->qr_grid = qr_index; + } + + /* Check the timing pattern. This doesn't require a perspective + * transform. + */ + if (measure_timing_pattern(q, qr_index) < 0) + goto fail; + + /* Make an estimate based for the alignment pattern based on extending + * lines from capstones A and C. + */ + if (!line_intersect(&q->capstones[a].corners[0], + &q->capstones[a].corners[1], + &q->capstones[c].corners[0], + &q->capstones[c].corners[3], + &qr->align)) + goto fail; + + /* On V2+ grids, we should use the alignment pattern. */ + if (qr->grid_size > 21) + { + /* Try to find the actual location of the alignment pattern. */ + find_alignment_pattern(q, qr_index); + + /* Find the point of the alignment pattern closest to the + * top-left of the QR grid. + */ + if (qr->align_region >= 0) + { + struct polygon_score_data psd; + struct quirc_region *reg = + &q->regions[qr->align_region]; + + /* Start from some point inside the alignment pattern */ + memcpy(&qr->align, ®->seed, sizeof(qr->align)); + + memcpy(&psd.ref, &hd, sizeof(psd.ref)); + psd.corners = &qr->align; + psd.scores[0] = -hd.y * qr->align.x + + hd.x * qr->align.y; + + flood_fill_seed(q, reg->seed.x, reg->seed.y, + qr->align_region, QUIRC_PIXEL_BLACK, + NULL, NULL, 0); + flood_fill_seed(q, reg->seed.x, reg->seed.y, + QUIRC_PIXEL_BLACK, qr->align_region, + find_leftmost_to_line, &psd, 0); + } + } + + setup_qr_perspective(q, qr_index); + return; + +fail: + /* We've been unable to complete setup for this grid. Undo what we've + * recorded and pretend it never happened. + */ + for (i = 0; i < 3; i++) + q->capstones[qr->caps[i]].qr_grid = -1; + q->num_grids--; +} + +struct neighbour +{ + int index; + float distance; +} __attribute__((aligned(8))); + +struct neighbour_list +{ + struct neighbour n[QUIRC_MAX_CAPSTONES]; + int count; +} __attribute__((aligned(8))); + +static void test_neighbours(struct quirc *q, int i, + const struct neighbour_list *hlist, + const struct neighbour_list *vlist) +{ + int j, k; + float best_score = 0.0; + int best_h = -1, best_v = -1; + + /* Test each possible grouping */ + for (j = 0; j < hlist->count; j++) + for (k = 0; k < vlist->count; k++) + { + const struct neighbour *hn = &hlist->n[j]; + const struct neighbour *vn = &vlist->n[k]; + float score = fast_fabsf(1.0 - hn->distance / vn->distance); + + if (score > 2.5) + continue; + + if (best_h < 0 || score < best_score) + { + best_h = hn->index; + best_v = vn->index; + best_score = score; + } + } + + if (best_h < 0 || best_v < 0) + return; + + record_qr_grid(q, best_h, i, best_v); +} + +static void test_grouping(struct quirc *q, int i) +{ + struct quirc_capstone *c1 = &q->capstones[i]; + int j; + struct neighbour_list hlist; + struct neighbour_list vlist; + + if (c1->qr_grid >= 0) + return; + + hlist.count = 0; + vlist.count = 0; + + /* Look for potential neighbours by examining the relative gradients + * from this capstone to others. + */ + for (j = 0; j < q->num_capstones; j++) + { + struct quirc_capstone *c2 = &q->capstones[j]; + float u, v; + + if (i == j || c2->qr_grid >= 0) + continue; + + perspective_unmap(c1->c, &c2->center, &u, &v); + + u = fast_fabsf(u - 3.5); + v = fast_fabsf(v - 3.5); + + if (u < 0.2 * v) + { + struct neighbour *n = &hlist.n[hlist.count++]; + + n->index = j; + n->distance = v; + } + + if (v < 0.2 * u) + { + struct neighbour *n = &vlist.n[vlist.count++]; + + n->index = j; + n->distance = u; + } + } + + if (!(hlist.count && vlist.count)) + return; + + test_neighbours(q, i, &hlist, &vlist); +} + +static void pixels_setup(struct quirc *q) +{ + if (sizeof(*q->image) == sizeof(*q->pixels)) + { + q->pixels = (quirc_pixel_t *)q->image; + } + else + { + int x, y; + for (y = 0; y < q->h; y++) + { + for (x = 0; x < q->w; x++) + { + q->pixels[y * q->w + x] = q->image[y * q->w + x]; + } + } + } +} + +uint8_t *quirc_begin(struct quirc *q, int *w, int *h) +{ + q->num_regions = QUIRC_PIXEL_REGION; + q->num_capstones = 0; + q->num_grids = 0; + + if (w) + *w = q->w; + if (h) + *h = q->h; + + return q->image; +} + +void quirc_end(struct quirc *q) +{ + int i; + pixels_setup(q); + threshold(q); + + for (i = 0; i < q->h; i++) + { + finder_scan(q, i); + } + + for (i = 0; i < q->num_capstones; i++) + { + test_grouping(q, i); + } +} + +void quirc_extract(const struct quirc *q, int index, + struct quirc_code *code) +{ + const struct quirc_grid *qr = &q->grids[index]; + int y; + int i = 0; + + if (index < 0 || index > q->num_grids) + return; + + memset(code, 0, sizeof(*code)); + + perspective_map(qr->c, 0.0, 0.0, &code->corners[0]); + perspective_map(qr->c, qr->grid_size, 0.0, &code->corners[1]); + perspective_map(qr->c, qr->grid_size, qr->grid_size, + &code->corners[2]); + perspective_map(qr->c, 0.0, qr->grid_size, &code->corners[3]); + + code->size = qr->grid_size; + + for (y = 0; y < qr->grid_size; y++) + { + int x; + + for (x = 0; x < qr->grid_size; x++) + { + if (read_cell(q, index, x, y) > 0) + code->cell_bitmap[i >> 3] |= (1 << (i & 7)); + + i++; + } + } +} diff --git a/ESP32QRCodeReader_Page/quirc.c b/ESP32QRCodeReader_Page/quirc.c new file mode 100644 index 0000000..e5a30fb --- /dev/null +++ b/ESP32QRCodeReader_Page/quirc.c @@ -0,0 +1,104 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include "quirc_internal.h" +#include + +const char *quirc_version(void) +{ + return "1.0"; +} + +//static struct quirc _q; +struct quirc *quirc_new(void) +{ + struct quirc *q = ps_malloc(sizeof(*q)); + + if (!q) + return NULL; + + memset(q, 0, sizeof(*q)); + return q; +} + +void quirc_destroy(struct quirc *q) +{ + if (q->image) + if (q->image) + free(q->image); + if (sizeof(*q->image) != sizeof(*q->pixels)) + if (q->pixels) + free(q->pixels); + + if (q) + free(q); +} + +//static quirc_pixel_t img_buf[320*240]; +int quirc_resize(struct quirc *q, int w, int h) +{ + if (q->image) + { + free(q->image); + } + uint8_t *new_image = ps_malloc(w * h); + + if (!new_image) + return -1; + + if (sizeof(*q->image) != sizeof(*q->pixels)) + { //should gray, 1==1 + size_t new_size = w * h * sizeof(quirc_pixel_t); + if (q->pixels) + free(q->pixels); + quirc_pixel_t *new_pixels = ps_malloc(new_size); + if (!new_pixels) + { + free(new_image); + return -1; + } + q->pixels = new_pixels; + } + q->image = new_image; + q->w = w; + q->h = h; + return 0; +} + +int quirc_count(const struct quirc *q) +{ + return q->num_grids; +} + +static const char *const error_table[] = { + [QUIRC_SUCCESS] = "Success", + [QUIRC_ERROR_INVALID_GRID_SIZE] = "Invalid grid size", + [QUIRC_ERROR_INVALID_VERSION] = "Invalid version", + [QUIRC_ERROR_FORMAT_ECC] = "Format data ECC failure", + [QUIRC_ERROR_DATA_ECC] = "ECC failure", + [QUIRC_ERROR_UNKNOWN_DATA_TYPE] = "Unknown data type", + [QUIRC_ERROR_DATA_OVERFLOW] = "Data overflow", + [QUIRC_ERROR_DATA_UNDERFLOW] = "Data underflow"}; + +const char *quirc_strerror(quirc_decode_error_t err) +{ + if (err >= 0 && err < sizeof(error_table) / sizeof(error_table[0])) + return error_table[err]; + + return "Unknown error"; +} diff --git a/ESP32QRCodeReader_Page/quirc.h b/ESP32QRCodeReader_Page/quirc.h new file mode 100644 index 0000000..ecdc172 --- /dev/null +++ b/ESP32QRCodeReader_Page/quirc.h @@ -0,0 +1,178 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef QUIRC_H_ +#define QUIRC_H_ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + struct quirc; + + /* Obtain the library version string. */ + const char *quirc_version(void); + + /* Construct a new QR-code recognizer. This function will return NULL + * if sufficient memory could not be allocated. + */ + struct quirc *quirc_new(void); + + /* Destroy a QR-code recognizer. */ + void quirc_destroy(struct quirc *q); + + /* Resize the QR-code recognizer. The size of an image must be + * specified before codes can be analyzed. + * + * This function returns 0 on success, or -1 if sufficient memory could + * not be allocated. + */ + int quirc_resize(struct quirc *q, int w, int h); + + /* These functions are used to process images for QR-code recognition. + * quirc_begin() must first be called to obtain access to a buffer into + * which the input image should be placed. Optionally, the current + * width and height may be returned. + * + * After filling the buffer, quirc_end() should be called to process + * the image for QR-code recognition. The locations and content of each + * code may be obtained using accessor functions described below. + */ + uint8_t *quirc_begin(struct quirc *q, int *w, int *h); + void quirc_end(struct quirc *q); + + /* This structure describes a location in the input image buffer. */ + struct quirc_point + { + int x; + int y; + } __attribute__((aligned(8))); + + /* This enum describes the various decoder errors which may occur. */ + typedef enum + { + QUIRC_SUCCESS = 0, + QUIRC_ERROR_INVALID_GRID_SIZE, + QUIRC_ERROR_INVALID_VERSION, + QUIRC_ERROR_FORMAT_ECC, + QUIRC_ERROR_DATA_ECC, + QUIRC_ERROR_UNKNOWN_DATA_TYPE, + QUIRC_ERROR_DATA_OVERFLOW, + QUIRC_ERROR_DATA_UNDERFLOW + } quirc_decode_error_t; + + /* Return a string error message for an error code. */ + const char *quirc_strerror(quirc_decode_error_t err); + +/* Limits on the maximum size of QR-codes and their content. */ +#define QUIRC_MAX_BITMAP 3917 +#define QUIRC_MAX_PAYLOAD 8896 + +/* QR-code ECC types. */ +#define QUIRC_ECC_LEVEL_M 0 +#define QUIRC_ECC_LEVEL_L 1 +#define QUIRC_ECC_LEVEL_H 2 +#define QUIRC_ECC_LEVEL_Q 3 + +/* QR-code data types. */ +#define QUIRC_DATA_TYPE_NUMERIC 1 +#define QUIRC_DATA_TYPE_ALPHA 2 +#define QUIRC_DATA_TYPE_BYTE 4 +#define QUIRC_DATA_TYPE_KANJI 8 + +/* Common character encodings */ +#define QUIRC_ECI_ISO_8859_1 1 +#define QUIRC_ECI_IBM437 2 +#define QUIRC_ECI_ISO_8859_2 4 +#define QUIRC_ECI_ISO_8859_3 5 +#define QUIRC_ECI_ISO_8859_4 6 +#define QUIRC_ECI_ISO_8859_5 7 +#define QUIRC_ECI_ISO_8859_6 8 +#define QUIRC_ECI_ISO_8859_7 9 +#define QUIRC_ECI_ISO_8859_8 10 +#define QUIRC_ECI_ISO_8859_9 11 +#define QUIRC_ECI_WINDOWS_874 13 +#define QUIRC_ECI_ISO_8859_13 15 +#define QUIRC_ECI_ISO_8859_15 17 +#define QUIRC_ECI_SHIFT_JIS 20 +#define QUIRC_ECI_UTF_8 26 + + /* This structure is used to return information about detected QR codes + * in the input image. + */ + struct quirc_code + { + /* The four corners of the QR-code, from top left, clockwise */ + struct quirc_point corners[4]; + + /* The number of cells across in the QR-code. The cell bitmap + * is a bitmask giving the actual values of cells. If the cell + * at (x, y) is black, then the following bit is set: + * + * cell_bitmap[i >> 3] & (1 << (i & 7)) + * + * where i = (y * size) + x. + */ + int size; + uint8_t cell_bitmap[QUIRC_MAX_BITMAP]; + } __attribute__((aligned(8))); + + /* This structure holds the decoded QR-code data */ + struct quirc_data + { + /* Various parameters of the QR-code. These can mostly be + * ignored if you only care about the data. + */ + int version; + int ecc_level; + int mask; + + /* This field is the highest-valued data type found in the QR + * code. + */ + int data_type; + + /* Data payload. For the Kanji datatype, payload is encoded as + * Shift-JIS. For all other datatypes, payload is ASCII text. + */ + uint8_t payload[QUIRC_MAX_PAYLOAD]; + int payload_len; + + /* ECI assignment number */ + uint32_t eci; + } __attribute__((aligned(8))); + + /* Return the number of QR-codes identified in the last processed + * image. + */ + int quirc_count(const struct quirc *q); + + /* Extract the QR-code specified by the given index. */ + void quirc_extract(const struct quirc *q, int index, + struct quirc_code *code); + + /* Decode a QR-code, returning the payload data. */ + quirc_decode_error_t quirc_decode(const struct quirc_code *code, + struct quirc_data *data); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/ESP32QRCodeReader_Page/quirc_internal.h b/ESP32QRCodeReader_Page/quirc_internal.h new file mode 100644 index 0000000..3fa075c --- /dev/null +++ b/ESP32QRCodeReader_Page/quirc_internal.h @@ -0,0 +1,121 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef QUIRC_INTERNAL_H_ +#define QUIRC_INTERNAL_H_ + +#include "quirc.h" + +#define QUIRC_PIXEL_WHITE 0 +#define QUIRC_PIXEL_BLACK 1 +#define QUIRC_PIXEL_REGION 2 + +#ifndef QUIRC_MAX_REGIONS +#define QUIRC_MAX_REGIONS 254 +#endif + +#define QUIRC_MAX_CAPSTONES 32 +#define QUIRC_MAX_GRIDS 8 + +#define QUIRC_PERSPECTIVE_PARAMS 8 + +#if QUIRC_MAX_REGIONS < UINT8_MAX +typedef uint8_t quirc_pixel_t; +#elif QUIRC_MAX_REGIONS < UINT16_MAX +typedef uint16_t quirc_pixel_t; +#else +#error "QUIRC_MAX_REGIONS > 65534 is not supported" +#endif + +struct quirc_region +{ + struct quirc_point seed; + int count; + int capstone; +} __attribute__((aligned(8))); + +struct quirc_capstone +{ + int ring; + int stone; + + struct quirc_point corners[4]; + struct quirc_point center; + float c[QUIRC_PERSPECTIVE_PARAMS]; + + int qr_grid; +} __attribute__((aligned(8))); + +struct quirc_grid +{ + /* Capstone indices */ + int caps[3]; + + /* Alignment pattern region and corner */ + int align_region; + struct quirc_point align; + + /* Timing pattern endpoints */ + struct quirc_point tpep[3]; + int hscan; + int vscan; + + /* Grid size and perspective transform */ + int grid_size; + float c[QUIRC_PERSPECTIVE_PARAMS]; +} __attribute__((aligned(8))); + +struct quirc +{ + uint8_t *image; + quirc_pixel_t *pixels; + int w; + int h; + + int num_regions; + struct quirc_region regions[QUIRC_MAX_REGIONS]; + + int num_capstones; + struct quirc_capstone capstones[QUIRC_MAX_CAPSTONES]; + + int num_grids; + struct quirc_grid grids[QUIRC_MAX_GRIDS]; +} __attribute__((aligned(8))); + +/************************************************************************ + * QR-code version information database + */ + +#define QUIRC_MAX_VERSION 40 +#define QUIRC_MAX_ALIGNMENT 7 + +struct quirc_rs_params +{ + uint8_t bs; /* Small block size */ + uint8_t dw; /* Small data words */ + uint8_t ns; /* Number of small blocks */ +} __attribute__((aligned(8))); + +struct quirc_version_info +{ + uint16_t data_bytes; + uint8_t apat[QUIRC_MAX_ALIGNMENT]; + struct quirc_rs_params ecc[4]; +} __attribute__((aligned(8))); + +extern const struct quirc_version_info quirc_version_db[QUIRC_MAX_VERSION + 1]; + +#endif \ No newline at end of file diff --git a/ESP32QRCodeReader_Page/version_db.c b/ESP32QRCodeReader_Page/version_db.c new file mode 100644 index 0000000..0da2d07 --- /dev/null +++ b/ESP32QRCodeReader_Page/version_db.c @@ -0,0 +1,184 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "quirc_internal.h" + +const struct quirc_version_info quirc_version_db[QUIRC_MAX_VERSION + 1] = { + {0}, + {/* Version 1 */ + .data_bytes = 26, + .apat = {0}, + .ecc = { + {.bs = 26, .dw = 16, .ns = 1}, + {.bs = 26, .dw = 19, .ns = 1}, + {.bs = 26, .dw = 9, .ns = 1}, + {.bs = 26, .dw = 13, .ns = 1}}}, + {/* Version 2 */ + .data_bytes = 44, + .apat = {6, 18, 0}, + .ecc = {{.bs = 44, .dw = 28, .ns = 1}, {.bs = 44, .dw = 34, .ns = 1}, {.bs = 44, .dw = 16, .ns = 1}, {.bs = 44, .dw = 22, .ns = 1}}}, + {/* Version 3 */ + .data_bytes = 70, + .apat = {6, 22, 0}, + .ecc = {{.bs = 70, .dw = 44, .ns = 1}, {.bs = 70, .dw = 55, .ns = 1}, {.bs = 35, .dw = 13, .ns = 2}, {.bs = 35, .dw = 17, .ns = 2}}}, + {/* Version 4 */ + .data_bytes = 100, + .apat = {6, 26, 0}, + .ecc = {{.bs = 50, .dw = 32, .ns = 2}, {.bs = 100, .dw = 80, .ns = 1}, {.bs = 25, .dw = 9, .ns = 4}, {.bs = 50, .dw = 24, .ns = 2}}}, + {/* Version 5 */ + .data_bytes = 134, + .apat = {6, 30, 0}, + .ecc = {{.bs = 67, .dw = 43, .ns = 2}, {.bs = 134, .dw = 108, .ns = 1}, {.bs = 33, .dw = 11, .ns = 2}, {.bs = 33, .dw = 15, .ns = 2}}}, + {/* Version 6 */ + .data_bytes = 172, + .apat = {6, 34, 0}, + .ecc = {{.bs = 43, .dw = 27, .ns = 4}, {.bs = 86, .dw = 68, .ns = 2}, {.bs = 43, .dw = 15, .ns = 4}, {.bs = 43, .dw = 19, .ns = 4}}}, + {/* Version 7 */ + .data_bytes = 196, + .apat = {6, 22, 38, 0}, + .ecc = {{.bs = 49, .dw = 31, .ns = 4}, {.bs = 98, .dw = 78, .ns = 2}, {.bs = 39, .dw = 13, .ns = 4}, {.bs = 32, .dw = 14, .ns = 2}}}, + {/* Version 8 */ + .data_bytes = 242, + .apat = {6, 24, 42, 0}, + .ecc = {{.bs = 60, .dw = 38, .ns = 2}, {.bs = 121, .dw = 97, .ns = 2}, {.bs = 40, .dw = 14, .ns = 4}, {.bs = 40, .dw = 18, .ns = 4}}}, + {/* Version 9 */ + .data_bytes = 292, + .apat = {6, 26, 46, 0}, + .ecc = {{.bs = 58, .dw = 36, .ns = 3}, {.bs = 146, .dw = 116, .ns = 2}, {.bs = 36, .dw = 12, .ns = 4}, {.bs = 36, .dw = 16, .ns = 4}}}, + {/* Version 10 */ + .data_bytes = 346, + .apat = {6, 28, 50, 0}, + .ecc = {{.bs = 69, .dw = 43, .ns = 4}, {.bs = 86, .dw = 68, .ns = 2}, {.bs = 43, .dw = 15, .ns = 6}, {.bs = 43, .dw = 19, .ns = 6}}}, + {/* Version 11 */ + .data_bytes = 404, + .apat = {6, 30, 54, 0}, + .ecc = {{.bs = 80, .dw = 50, .ns = 1}, {.bs = 101, .dw = 81, .ns = 4}, {.bs = 36, .dw = 12, .ns = 3}, {.bs = 50, .dw = 22, .ns = 4}}}, + {/* Version 12 */ + .data_bytes = 466, + .apat = {6, 32, 58, 0}, + .ecc = {{.bs = 58, .dw = 36, .ns = 6}, {.bs = 116, .dw = 92, .ns = 2}, {.bs = 42, .dw = 14, .ns = 7}, {.bs = 46, .dw = 20, .ns = 4}}}, + {/* Version 13 */ + .data_bytes = 532, + .apat = {6, 34, 62, 0}, + .ecc = {{.bs = 59, .dw = 37, .ns = 8}, {.bs = 133, .dw = 107, .ns = 4}, {.bs = 33, .dw = 11, .ns = 12}, {.bs = 44, .dw = 20, .ns = 8}}}, + {/* Version 14 */ + .data_bytes = 581, + .apat = {6, 26, 46, 66, 0}, + .ecc = {{.bs = 64, .dw = 40, .ns = 4}, {.bs = 145, .dw = 115, .ns = 3}, {.bs = 36, .dw = 12, .ns = 11}, {.bs = 36, .dw = 16, .ns = 11}}}, + {/* Version 15 */ + .data_bytes = 655, + .apat = {6, 26, 48, 70, 0}, + .ecc = {{.bs = 65, .dw = 41, .ns = 5}, {.bs = 109, .dw = 87, .ns = 5}, {.bs = 36, .dw = 12, .ns = 11}, {.bs = 54, .dw = 24, .ns = 5}}}, + {/* Version 16 */ + .data_bytes = 733, + .apat = {6, 26, 50, 74, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 7}, {.bs = 122, .dw = 98, .ns = 5}, {.bs = 45, .dw = 15, .ns = 3}, {.bs = 43, .dw = 19, .ns = 15}}}, + {/* Version 17 */ + .data_bytes = 815, + .apat = {6, 30, 54, 78, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 10}, {.bs = 135, .dw = 107, .ns = 1}, {.bs = 42, .dw = 14, .ns = 2}, {.bs = 50, .dw = 22, .ns = 1}}}, + {/* Version 18 */ + .data_bytes = 901, + .apat = {6, 30, 56, 82, 0}, + .ecc = {{.bs = 69, .dw = 43, .ns = 9}, {.bs = 150, .dw = 120, .ns = 5}, {.bs = 42, .dw = 14, .ns = 2}, {.bs = 50, .dw = 22, .ns = 17}}}, + {/* Version 19 */ + .data_bytes = 991, + .apat = {6, 30, 58, 86, 0}, + .ecc = {{.bs = 70, .dw = 44, .ns = 3}, {.bs = 141, .dw = 113, .ns = 3}, {.bs = 39, .dw = 13, .ns = 9}, {.bs = 47, .dw = 21, .ns = 17}}}, + {/* Version 20 */ + .data_bytes = 1085, + .apat = {6, 34, 62, 90, 0}, + .ecc = {{.bs = 67, .dw = 41, .ns = 3}, {.bs = 135, .dw = 107, .ns = 3}, {.bs = 43, .dw = 15, .ns = 15}, {.bs = 54, .dw = 24, .ns = 15}}}, + {/* Version 21 */ + .data_bytes = 1156, + .apat = {6, 28, 50, 72, 92, 0}, + .ecc = {{.bs = 68, .dw = 42, .ns = 17}, {.bs = 144, .dw = 116, .ns = 4}, {.bs = 46, .dw = 16, .ns = 19}, {.bs = 50, .dw = 22, .ns = 17}}}, + {/* Version 22 */ + .data_bytes = 1258, + .apat = {6, 26, 50, 74, 98, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 17}, {.bs = 139, .dw = 111, .ns = 2}, {.bs = 37, .dw = 13, .ns = 34}, {.bs = 54, .dw = 24, .ns = 7}}}, + {/* Version 23 */ + .data_bytes = 1364, + .apat = {6, 30, 54, 78, 102, 0}, + .ecc = {{.bs = 75, .dw = 47, .ns = 4}, {.bs = 151, .dw = 121, .ns = 4}, {.bs = 45, .dw = 15, .ns = 16}, {.bs = 54, .dw = 24, .ns = 11}}}, + {/* Version 24 */ + .data_bytes = 1474, + .apat = {6, 28, 54, 80, 106, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 6}, {.bs = 147, .dw = 117, .ns = 6}, {.bs = 46, .dw = 16, .ns = 30}, {.bs = 54, .dw = 24, .ns = 11}}}, + {/* Version 25 */ + .data_bytes = 1588, + .apat = {6, 32, 58, 84, 110, 0}, + .ecc = {{.bs = 75, .dw = 47, .ns = 8}, {.bs = 132, .dw = 106, .ns = 8}, {.bs = 45, .dw = 15, .ns = 22}, {.bs = 54, .dw = 24, .ns = 7}}}, + {/* Version 26 */ + .data_bytes = 1706, + .apat = {6, 30, 58, 86, 114, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 19}, {.bs = 142, .dw = 114, .ns = 10}, {.bs = 46, .dw = 16, .ns = 33}, {.bs = 50, .dw = 22, .ns = 28}}}, + {/* Version 27 */ + .data_bytes = 1828, + .apat = {6, 34, 62, 90, 118, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 22}, {.bs = 152, .dw = 122, .ns = 8}, {.bs = 45, .dw = 15, .ns = 12}, {.bs = 53, .dw = 23, .ns = 8}}}, + {/* Version 28 */ + .data_bytes = 1921, + .apat = {6, 26, 50, 74, 98, 122, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 3}, {.bs = 147, .dw = 117, .ns = 3}, {.bs = 45, .dw = 15, .ns = 11}, {.bs = 54, .dw = 24, .ns = 4}}}, + {/* Version 29 */ + .data_bytes = 2051, + .apat = {6, 30, 54, 78, 102, 126, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 21}, {.bs = 146, .dw = 116, .ns = 7}, {.bs = 45, .dw = 15, .ns = 19}, {.bs = 53, .dw = 23, .ns = 1}}}, + {/* Version 30 */ + .data_bytes = 2185, + .apat = {6, 26, 52, 78, 104, 130, 0}, + .ecc = {{.bs = 75, .dw = 47, .ns = 19}, {.bs = 145, .dw = 115, .ns = 5}, {.bs = 45, .dw = 15, .ns = 23}, {.bs = 54, .dw = 24, .ns = 15}}}, + {/* Version 31 */ + .data_bytes = 2323, + .apat = {6, 30, 56, 82, 108, 134, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 2}, {.bs = 145, .dw = 115, .ns = 13}, {.bs = 45, .dw = 15, .ns = 23}, {.bs = 54, .dw = 24, .ns = 42}}}, + {/* Version 32 */ + .data_bytes = 2465, + .apat = {6, 34, 60, 86, 112, 138, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 10}, {.bs = 145, .dw = 115, .ns = 17}, {.bs = 45, .dw = 15, .ns = 19}, {.bs = 54, .dw = 24, .ns = 10}}}, + {/* Version 33 */ + .data_bytes = 2611, + .apat = {6, 30, 58, 86, 114, 142, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 14}, {.bs = 145, .dw = 115, .ns = 17}, {.bs = 45, .dw = 15, .ns = 11}, {.bs = 54, .dw = 24, .ns = 29}}}, + {/* Version 34 */ + .data_bytes = 2761, + .apat = {6, 34, 62, 90, 118, 146, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 14}, {.bs = 145, .dw = 115, .ns = 13}, {.bs = 46, .dw = 16, .ns = 59}, {.bs = 54, .dw = 24, .ns = 44}}}, + {/* Version 35 */ + .data_bytes = 2876, + .apat = {6, 30, 54, 78, 102, 126, 150}, + .ecc = {{.bs = 75, .dw = 47, .ns = 12}, {.bs = 151, .dw = 121, .ns = 12}, {.bs = 45, .dw = 15, .ns = 22}, {.bs = 54, .dw = 24, .ns = 39}}}, + {/* Version 36 */ + .data_bytes = 3034, + .apat = {6, 24, 50, 76, 102, 128, 154}, + .ecc = {{.bs = 75, .dw = 47, .ns = 6}, {.bs = 151, .dw = 121, .ns = 6}, {.bs = 45, .dw = 15, .ns = 2}, {.bs = 54, .dw = 24, .ns = 46}}}, + {/* Version 37 */ + .data_bytes = 3196, + .apat = {6, 28, 54, 80, 106, 132, 158}, + .ecc = {{.bs = 74, .dw = 46, .ns = 29}, {.bs = 152, .dw = 122, .ns = 17}, {.bs = 45, .dw = 15, .ns = 24}, {.bs = 54, .dw = 24, .ns = 49}}}, + {/* Version 38 */ + .data_bytes = 3362, + .apat = {6, 32, 58, 84, 110, 136, 162}, + .ecc = {{.bs = 74, .dw = 46, .ns = 13}, {.bs = 152, .dw = 122, .ns = 4}, {.bs = 45, .dw = 15, .ns = 42}, {.bs = 54, .dw = 24, .ns = 48}}}, + {/* Version 39 */ + .data_bytes = 3532, + .apat = {6, 26, 54, 82, 110, 138, 166}, + .ecc = {{.bs = 75, .dw = 47, .ns = 40}, {.bs = 147, .dw = 117, .ns = 20}, {.bs = 45, .dw = 15, .ns = 10}, {.bs = 54, .dw = 24, .ns = 43}}}, + {/* Version 40 */ + .data_bytes = 3706, + .apat = {6, 30, 58, 86, 114, 142, 170}, + .ecc = {{.bs = 75, .dw = 47, .ns = 18}, {.bs = 148, .dw = 118, .ns = 19}, {.bs = 45, .dw = 15, .ns = 20}, {.bs = 54, .dw = 24, .ns = 34}}}}; diff --git a/ESP32QRReaderDBWriter/Credentials.h b/ESP32QRReaderDBWriter/Credentials.h new file mode 100644 index 0000000..a84ee28 --- /dev/null +++ b/ESP32QRReaderDBWriter/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "cpsNUCwifi"; // your network SSID (name) +char pass[] = "ips999CPS"; // your network password + +char user[] = "db_user"; // MySQL user login username +char password[] = "db_password"; // MySQL user login password + +#endif //Credentials_h diff --git a/ESP32QRReaderDBWriter/ESP32QRReaderDBWriter.ino b/ESP32QRReaderDBWriter/ESP32QRReaderDBWriter.ino new file mode 100644 index 0000000..fea48dd --- /dev/null +++ b/ESP32QRReaderDBWriter/ESP32QRReaderDBWriter.ino @@ -0,0 +1,413 @@ +/* +ESP32-CAM QR code Reader +Author : ChungYi Fu (Kaohsiung, Taiwan) 2021-8-13 20:00 +https://www.facebook.com/francefu + +Refer to the code +https://github.com/alvarowolfx/ESP32QRCodeReader + +自訂指令格式 http://192.168.xxx.xxx/control?cmd=P1;P2;P3;P4;P5;P6;P7;P8;P9 + +http://192.168.xxx.xxx/?ip //取得APIP, STAIP +http://192.168.xxx.xxx/?mac //取得MAC位址 +http://192.168.xxx.xxx/?digitalwrite=pin;value //數位輸出 +http://192.168.xxx.xxx/?analogwrite=pin;value //類比輸出 +http://192.168.xxx.xxx/?digitalread=pin //數位讀取 +http://192.168.xxx.xxx/?analogread=pin //類比讀取 +http://192.168.xxx.xxx/?touchread=pin //觸碰讀取 +http://192.168.xxx.xxx/?restart //重啟電源 +http://192.168.xxx.xxx/?flash=value //閃光燈 value= 0~255 +http://192.168.xxx.xxx/?servo=pin;value //伺服馬達 value= 0~180 +http://192.168.xxx.xxx/?relay=pin;value //繼電器 value = 0, 1 +http://192.168.xxx.xxx/?uart=value //序列埠 +*/ + + + +// Serial.printf(); kann anscheinend keine Strings ausgeben, die länger als 13 Zeichen sind -> dadurch gehts: Serial.printf("Insertcommand: %s\n:", INSERT_SQL.c_str()); + +#include "esp_camera.h" +//#include "soc/soc.h" +#include "soc/rtc_cntl_reg.h" +#include "quirc.h" + +//Includes&defines etc für den MariaDB Entry ########################################################### +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME false + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(10, 42, 0, 1); +#endif + +uint16_t server_port = 3306; //5698; + +char default_database[] = "myTestDb"; //"test_arduino"; +char default_table[] = "myTestTable"; //"test_arduino"; + +String default_value = "defaultString"; + +// Sample query +String INSERT_SQL = String("INSERT INTO ") + default_database + "." + default_table + + " (qrCodeText) VALUES ('" + default_value + "')"; + + +#define LED_BUILTIN 4 //die Zeile wird für das LED benötigt + + +MySQL_Connection conn((Client *)&client); + +MySQL_Query *query_mem; +//Includes&defines etc für den MariaDB Entry - ENDE #################################################### + +TaskHandle_t Task; + +//ESP32-CAM +#define PWDN_GPIO_NUM 32 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 0 +#define SIOD_GPIO_NUM 26 +#define SIOC_GPIO_NUM 27 +#define Y9_GPIO_NUM 35 +#define Y8_GPIO_NUM 34 +#define Y7_GPIO_NUM 39 +#define Y6_GPIO_NUM 36 +#define Y5_GPIO_NUM 21 +#define Y4_GPIO_NUM 19 +#define Y3_GPIO_NUM 18 +#define Y2_GPIO_NUM 5 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 23 +#define PCLK_GPIO_NUM 22 + +struct QRCodeData +{ + bool valid; + int dataType; + uint8_t payload[1024]; + int payloadLen; +}; + +struct quirc *q = NULL; +uint8_t *image = NULL; +camera_fb_t * fb = NULL; +struct quirc_code code; +struct quirc_data data; +quirc_decode_error_t err; +struct QRCodeData qrCodeData; +String QRCodeResult = ""; + + + +camera_config_t config; + +//############################################################################################### +void setup() { + //WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); + + Serial.begin(115200); + //Serial.setDebugOutput(false); + Serial.println(); + + Serial.println("--------------------------Starting the EPS32-QR-Code-Reader--------------------------"); + + pinMode(LED_BUILTIN, OUTPUT); //die Zeile wird für das LED benötigt + +https://github.com/espressif/esp32-camera/blob/master/driver/include/esp_camera.h + config.ledc_channel = LEDC_CHANNEL_0; + config.ledc_timer = LEDC_TIMER_0; + config.pin_d0 = Y2_GPIO_NUM; + config.pin_d1 = Y3_GPIO_NUM; + config.pin_d2 = Y4_GPIO_NUM; + config.pin_d3 = Y5_GPIO_NUM; + config.pin_d4 = Y6_GPIO_NUM; + config.pin_d5 = Y7_GPIO_NUM; + config.pin_d6 = Y8_GPIO_NUM; + config.pin_d7 = Y9_GPIO_NUM; + config.pin_xclk = XCLK_GPIO_NUM; + config.pin_pclk = PCLK_GPIO_NUM; + config.pin_vsync = VSYNC_GPIO_NUM; + config.pin_href = HREF_GPIO_NUM; + config.pin_sscb_sda = SIOD_GPIO_NUM; + config.pin_sscb_scl = SIOC_GPIO_NUM; + config.pin_pwdn = PWDN_GPIO_NUM; + config.pin_reset = RESET_GPIO_NUM; + config.xclk_freq_hz = 10000000; + config.pixel_format = PIXFORMAT_GRAYSCALE; + config.frame_size = FRAMESIZE_QVGA; + config.jpeg_quality = 15; + config.fb_count = 1; + + + esp_err_t err = esp_camera_init(&config); + if (err != ESP_OK) { + Serial.printf("Camera init failed with error 0x%x", err); + ESP.restart(); + } + + sensor_t * s = esp_camera_sensor_get(); + s->set_framesize(s, FRAMESIZE_QVGA); + + + xTaskCreatePinnedToCore( + QRCodeReader, // Task function. + "Task", // name of task. + 10000, // Stack size of task + NULL, // parameter of the task + 1, // priority of the task + &Task, // Task handle to keep track of created task + 0); // pin task to core 0 + + //Serial.print("listenConnection running on core "); + //Serial.println(xPortGetCoreID()); + +//Setup für insert in MariaDB ######################################################### +Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + +/* Infoausgabe + MYSQL_DISPLAY1("\n starting QR-Code reader on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); +*/ + + // Remember to initialize your WiFi module +#if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + /* Infoausgabe + #if ( USING_WIFI_ESP8266_AT ) + MYSQL_DISPLAY("Using ESP8266_AT/ESP8266_AT_WebServer Library"); + #elif ( USING_WIFIESPAT_LIB ) + MYSQL_DISPLAY("Using WiFiEspAT Library"); + #endif + */ + + // initialize serial for ESP module + EspSerial.begin(115200); + // initialize ESP module + WiFi.init(&EspSerial); + + MYSQL_DISPLAY(F("WiFi shield init done")); + + // check for the presence of the shield + if (WiFi.status() == WL_NO_SHIELD) + { + MYSQL_DISPLAY(F("WiFi shield not present")); + // don't continue + while (true); + } +#endif + + + + // Begin WiFi section + Serial.printf("Connecting to %s. \n", ssid); + //MYSQL_DISPLAY1("Connecting to", ssid); + + //WiFi.begin(ssid, pass); + WiFi.begin(ssid); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + //MYSQL_DISPLAY0("."); + + //ESP32-LED Output, dass es nicht mit dem WLAN verbunden ist + digitalWrite(LED_BUILTIN, HIGH); + delay(100); + digitalWrite(LED_BUILTIN, LOW); + delay(1000); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); + + + //ESP32-LED Output, dass es mit dem WLAN verbunden ist + for(int i=0; i<3;i++){ + digitalWrite(LED_BUILTIN, HIGH); + delay(100); + digitalWrite(LED_BUILTIN, LOW); + delay(300); + } + + + + +//Setup für insert in MariaDB - Ende ######################################################### +} + +void ledOutputError(){ + + //ESP32 LED Ausgabe, dass etwas nicht funktioniert hat + digitalWrite(LED_BUILTIN, HIGH); + delay(100); + digitalWrite(LED_BUILTIN, LOW); + delay(100); + digitalWrite(LED_BUILTIN, HIGH); + delay(1000); + digitalWrite(LED_BUILTIN, LOW); + delay(100); + digitalWrite(LED_BUILTIN, HIGH); + delay(100); + digitalWrite(LED_BUILTIN, LOW); + +} + + +//################################################################################### +void runInsert() // MariaDB-Insert-Funktion +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + MYSQL_DISPLAY(INSERT_SQL); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(INSERT_SQL.c_str()) ) + { + MYSQL_DISPLAY("Insert error"); + ledOutputError(); + } + else + { + MYSQL_DISPLAY("Data Inserted."); + + //ESP32 LED Ausgabe, dass etwas inserted wurde + digitalWrite(LED_BUILTIN, HIGH); + delay(1000); + digitalWrite(LED_BUILTIN, LOW); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + ledOutputError(); + } +} + + + +//###############################################################################################---------------------------- +void loop() { + +} + + +void charToString(const char *str, String &dbInsertString){ + + dbInsertString = ""; //max Länge 13 Zeichen für eine Ausgabe in Serial.printf + size_t len = strlen(str); + dbInsertString.reserve(len); + + for(size_t i=0;iwidth, fb->height); + image = quirc_begin(q, NULL, NULL); + //Serial.printf("Frame w h len: %d, %d, %d \r\n", fb->width, fb->height, fb->len); + memcpy(image, fb->buf, fb->len); + quirc_end(q); + //Serial.printf("quirc_end\r\n"); + + int count = quirc_count(q); + if (count > 0) { + //Serial.println(count); + quirc_extract(q, 0, &code); + err = quirc_decode(&code, &data); + + if (err){ + Serial.println("Decoding FAILED"); + QRCodeResult = "Decoding FAILED"; + } else { + Serial.printf("Decoding successful:\n"); + dumpData(&data); + + //MariaDb-part #################-------------------- + MYSQL_DISPLAY("Connecting..."); + + + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + + char * str = (char *) &data.payload[0]; //nicht sicher ob man die Umwandlung braucht + charToString(str,default_value); + + INSERT_SQL = String("INSERT INTO ") + default_database + "." + default_table + " (qrCodeText) VALUES ('" + default_value + "')"; + //Serial.printf("Insertcommand: %s\n:", INSERT_SQL.c_str()); + + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + ledOutputError(); + } + + + //MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + delay(2000); //um nicht den gleichen Eintrag sofort doppelt drinnen zu haben + //MariaDb-part-Ende #################-------------------- + + } + Serial.println(); + } + + + esp_camera_fb_return(fb); + fb = NULL; + image = NULL; + quirc_destroy(q); + } +} + +//############################################################################################### +void dumpData(const struct quirc_data *data) +{ + //Serial.printf("Version: %d\n", data->version); + //Serial.printf("ECC level: %c\n", "MLHQ"[data->ecc_level]); + //Serial.printf("Mask: %d\n", data->mask); + //Serial.printf("Length: %d\n", data->payload_len); + Serial.printf("Inhalt des QR-Codes: %s\n", data->payload); + +} diff --git a/ESP32QRReaderDBWriter/LICENSE b/ESP32QRReaderDBWriter/LICENSE new file mode 100644 index 0000000..d47c026 --- /dev/null +++ b/ESP32QRReaderDBWriter/LICENSE @@ -0,0 +1,16 @@ +quirc -- QR-code recognition library +Copyright (C) 2010-2012 Daniel Beer + +Permission to use, copy, modify, and/or distribute this software for +any purpose with or without fee is hereby granted, provided that the +above copyright notice and this permission notice appear in all +copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR +PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/ESP32QRReaderDBWriter/README.md b/ESP32QRReaderDBWriter/README.md new file mode 100644 index 0000000..d70c5c3 --- /dev/null +++ b/ESP32QRReaderDBWriter/README.md @@ -0,0 +1,193 @@ +Quirc +===== + +QR codes are a type of high-density matrix barcodes, and quirc is a library for +extracting and decoding them from images. It has several features which make it +a good choice for this purpose: + +* It is fast enough to be used with realtime video: extracting and decoding + from VGA frame takes about 50 ms on a modern x86 core. + +* It has a robust and tolerant recognition algorithm. It can correctly + recognise and decode QR codes which are rotated and/or oblique to the camera. + It can also distinguish and decode multiple codes within the same image. + +* It is easy to use, with a simple API described in a single commented header + file (see below for an overview). + +* It is small and easily embeddable, with no dependencies other than standard C + functions. + +* It has a very small memory footprint: one byte per image pixel, plus a few kB + per decoder object. + +* It uses no global mutable state, and is safe to use in a multithreaded + application. + +* BSD-licensed, with almost no restrictions regarding use and/or modification. + +The distribution comes with, in addition to the library, several test programs. +While the core library is very portable, these programs have some additional +dependencies. All of them require libjpeg, and two (`quirc-demo` and `inspect`) +require SDL. The camera demos use Linux-specific APIs: + +### quirc-demo + +This is an real-time demo which requires a camera and a graphical display. The +video stream is displayed on screen as it's received, and any QR codes +recognised are highlighted in the image, with the decoded information both +displayed on the image and printed on stdout. + +### quirc-scanner + +This program turns your camera into a barcode scanner. It's almost the same as +the `demo` application, but it doesn't display the video stream, and thus +doesn't require a graphical display. + +### qrtest + +This test is used to evaluate the performance of library. Given a directory +tree containing a bunch of JPEG images, it will attempt to locate and decode QR +codes in each image. Speed and success statistics are collected and printed on +stdout. + +### inspect + +This test is used for debugging. Given a single JPEG image, it will display a +diagram showing the internal state of the decoder as well as printing +additional information on stdout. + +Installation +------------ +To build the library and associated demos/tests, type `make`. If you need to +decode "large" image files build with `CFLAGS="-DQUIRC_MAX_REGIONS=65534" make` +instead. Note that this will increase the memory usage, it is discouraged for +low resource devices (i.e. embedded). + +Type `make install` to install the library, header file and camera demos. + +You can specify one or several of the following targets if you don't want, or +are unable to build everything: + +* libquirc.a +* libquirc.so +* qrtest +* inspect +* quirc-scanner +* quirc-demo + +Library use +----------- +All of the library's functionality is exposed through a single header file, +which you should include: + +```C +#include +``` + +To decode images, you'll need to instantiate a `struct quirc` object, which is +done with the `quirc_new` function. Later, when you no longer need to decode +anything, you should release the allocated memory with `quirc_destroy`: + +```C +struct quirc *qr; + +qr = quirc_new(); +if (!qr) { + perror("Failed to allocate memory"); + abort(); +} + +/* ... */ + +quirc_destroy(qr); +``` + +Having obtained a decoder object, you need to set the image size that you'll be +working with, which is done using `quirc_resize`: + +```C +if (quirc_resize(qr, 640, 480) < 0) { + perror("Failed to allocate video memory"); + abort(); +} +``` + +`quirc_resize` and `quirc_new` are the only library functions which allocate +memory. If you plan to process a series of frames (or a video stream), you +probably want to allocate and size a single decoder and hold onto it to process +each frame. + +Processing frames is done in two stages. The first stage is an +image-recognition stage called identification, which takes a grayscale image +and searches for QR codes. Using `quirc_begin` and `quirc_end`, you can feed a +grayscale image directly into the buffer that `quirc` uses for image +processing: + +```C +uint8_t *image; +int w, h; + +image = quirc_begin(qr, &w, &h); + +/* Fill out the image buffer here. + * image is a pointer to a w*h bytes. + * One byte per pixel, w pixels per line, h lines in the buffer. + */ + +quirc_end(qr); +``` + +Note that `quirc_begin` simply returns a pointer to a previously allocated +buffer. The buffer will contain uninitialized data. After the call to +`quirc_end`, the decoder holds a list of detected QR codes which can be queried +via `quirc_count` and `quirc_extract`. + +At this point, the second stage of processing occurs -- decoding. This is done +via the call to `quirc_decode`, which is not associated with a decoder object. + +```C +int num_codes; +int i; + +/* We've previously fed an image to the decoder via +* quirc_begin/quirc_end. +*/ + +num_codes = quirc_count(qr); +for (i = 0; i < num_codes; i++) { + struct quirc_code code; + struct quirc_data data; + quirc_decode_error_t err; + + quirc_extract(qr, i, &code); + + /* Decoding stage */ + err = quirc_decode(&code, &data); + if (err) + printf("DECODE FAILED: %s\n", quirc_strerror(err)); + else + printf("Data: %s\n", data.payload); +} +``` + +`quirc_code` and `quirc_data` are flat structures which don't need to be +initialized or freed after use. + +Copyright +--------- +Copyright (C) 2010-2012 Daniel Beer <> + +Permission to use, copy, modify, and/or distribute this software for +any purpose with or without fee is hereby granted, provided that the +above copyright notice and this permission notice appear in all +copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR +PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/ESP32QRReaderDBWriter/collections.c b/ESP32QRReaderDBWriter/collections.c new file mode 100644 index 0000000..ea0073d --- /dev/null +++ b/ESP32QRReaderDBWriter/collections.c @@ -0,0 +1,85 @@ +/* This file is part of the OpenMV project. + * Copyright (c) 2013-2017 Ibrahim Abdelkader & Kwabena W. Agyeman + * This work is licensed under the MIT license, see the file LICENSE for details. + */ + +#include "collections.h" +#define CHAR_BITS (sizeof(char) * 8) +#define CHAR_MASK (CHAR_BITS - 1) +#define CHAR_SHIFT IM_LOG2(CHAR_MASK) + +////////// +// lifo // +////////// + +void lifo_alloc(lifo_t *ptr, size_t size, size_t data_len) +{ + ptr->len = 0; + ptr->size = size; + ptr->data_len = data_len; + ptr->data = (char *)ps_malloc(size * data_len); +} + +void lifo_alloc_all(lifo_t *ptr, size_t *size, size_t data_len) +{ + ptr->data = (char *)ps_malloc(255); + ptr->data_len = data_len; + ptr->size = 255 / data_len; + ptr->len = 0; + *size = ptr->size; +} + +void lifo_free(lifo_t *ptr) +{ + if (ptr->data) + { + free(ptr->data); + } +} + +void lifo_clear(lifo_t *ptr) +{ + ptr->len = 0; +} + +size_t lifo_size(lifo_t *ptr) +{ + return ptr->len; +} + +bool lifo_is_not_empty(lifo_t *ptr) +{ + return ptr->len; +} + +bool lifo_is_not_full(lifo_t *ptr) +{ + return ptr->len != ptr->size; +} + +void lifo_enqueue(lifo_t *ptr, void *data) +{ + memcpy(ptr->data + (ptr->len * ptr->data_len), data, ptr->data_len); + + ptr->len += 1; +} + +void lifo_dequeue(lifo_t *ptr, void *data) +{ + if (data) + { + memcpy(data, ptr->data + ((ptr->len - 1) * ptr->data_len), ptr->data_len); + } + + ptr->len -= 1; +} + +void lifo_poke(lifo_t *ptr, void *data) +{ + memcpy(ptr->data + (ptr->len * ptr->data_len), data, ptr->data_len); +} + +void lifo_peek(lifo_t *ptr, void *data) +{ + memcpy(data, ptr->data + ((ptr->len - 1) * ptr->data_len), ptr->data_len); +} diff --git a/ESP32QRReaderDBWriter/collections.h b/ESP32QRReaderDBWriter/collections.h new file mode 100644 index 0000000..711cafa --- /dev/null +++ b/ESP32QRReaderDBWriter/collections.h @@ -0,0 +1,33 @@ +/* This file is part of the OpenMV project. + * Copyright (c) 2013-2017 Ibrahim Abdelkader & Kwabena W. Agyeman + * This work is licensed under the MIT license, see the file LICENSE for details. + */ + +#ifndef __COLLECTIONS_H__ +#define __COLLECTIONS_H__ +#include +#include +////////// +// lifo // +////////// + +typedef struct lifo +{ + size_t len, size, data_len; + char *data; +} +__attribute__((aligned(8))) lifo_t; + +void lifo_alloc(lifo_t *ptr, size_t size, size_t data_len); +void lifo_alloc_all(lifo_t *ptr, size_t *size, size_t data_len); +void lifo_free(lifo_t *ptr); +void lifo_clear(lifo_t *ptr); +size_t lifo_size(lifo_t *ptr); +bool lifo_is_not_empty(lifo_t *ptr); +bool lifo_is_not_full(lifo_t *ptr); +void lifo_enqueue(lifo_t *ptr, void *data); +void lifo_dequeue(lifo_t *ptr, void *data); +void lifo_poke(lifo_t *ptr, void *data); +void lifo_peek(lifo_t *ptr, void *data); + +#endif /* __COLLECTIONS_H__ */ \ No newline at end of file diff --git a/ESP32QRReaderDBWriter/decode.c b/ESP32QRReaderDBWriter/decode.c new file mode 100644 index 0000000..67c8ed5 --- /dev/null +++ b/ESP32QRReaderDBWriter/decode.c @@ -0,0 +1,983 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "quirc_internal.h" + +#include +#include + +#define MAX_POLY 64 + +/************************************************************************ + * Galois fields + */ + +struct galois_field +{ + int p; + const uint8_t *log; + const uint8_t *exp; +} __attribute__((aligned(8))); + +static const uint8_t gf16_exp[16] = { + 0x01, 0x02, 0x04, 0x08, 0x03, 0x06, 0x0c, 0x0b, + 0x05, 0x0a, 0x07, 0x0e, 0x0f, 0x0d, 0x09, 0x01}; + +static const uint8_t gf16_log[16] = { + 0x00, 0x0f, 0x01, 0x04, 0x02, 0x08, 0x05, 0x0a, + 0x03, 0x0e, 0x09, 0x07, 0x06, 0x0d, 0x0b, 0x0c}; + +static const struct galois_field gf16 = { + .p = 15, + .log = gf16_log, + .exp = gf16_exp}; + +static const uint8_t gf256_exp[256] = { + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, + 0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26, + 0x4c, 0x98, 0x2d, 0x5a, 0xb4, 0x75, 0xea, 0xc9, + 0x8f, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, + 0x9d, 0x27, 0x4e, 0x9c, 0x25, 0x4a, 0x94, 0x35, + 0x6a, 0xd4, 0xb5, 0x77, 0xee, 0xc1, 0x9f, 0x23, + 0x46, 0x8c, 0x05, 0x0a, 0x14, 0x28, 0x50, 0xa0, + 0x5d, 0xba, 0x69, 0xd2, 0xb9, 0x6f, 0xde, 0xa1, + 0x5f, 0xbe, 0x61, 0xc2, 0x99, 0x2f, 0x5e, 0xbc, + 0x65, 0xca, 0x89, 0x0f, 0x1e, 0x3c, 0x78, 0xf0, + 0xfd, 0xe7, 0xd3, 0xbb, 0x6b, 0xd6, 0xb1, 0x7f, + 0xfe, 0xe1, 0xdf, 0xa3, 0x5b, 0xb6, 0x71, 0xe2, + 0xd9, 0xaf, 0x43, 0x86, 0x11, 0x22, 0x44, 0x88, + 0x0d, 0x1a, 0x34, 0x68, 0xd0, 0xbd, 0x67, 0xce, + 0x81, 0x1f, 0x3e, 0x7c, 0xf8, 0xed, 0xc7, 0x93, + 0x3b, 0x76, 0xec, 0xc5, 0x97, 0x33, 0x66, 0xcc, + 0x85, 0x17, 0x2e, 0x5c, 0xb8, 0x6d, 0xda, 0xa9, + 0x4f, 0x9e, 0x21, 0x42, 0x84, 0x15, 0x2a, 0x54, + 0xa8, 0x4d, 0x9a, 0x29, 0x52, 0xa4, 0x55, 0xaa, + 0x49, 0x92, 0x39, 0x72, 0xe4, 0xd5, 0xb7, 0x73, + 0xe6, 0xd1, 0xbf, 0x63, 0xc6, 0x91, 0x3f, 0x7e, + 0xfc, 0xe5, 0xd7, 0xb3, 0x7b, 0xf6, 0xf1, 0xff, + 0xe3, 0xdb, 0xab, 0x4b, 0x96, 0x31, 0x62, 0xc4, + 0x95, 0x37, 0x6e, 0xdc, 0xa5, 0x57, 0xae, 0x41, + 0x82, 0x19, 0x32, 0x64, 0xc8, 0x8d, 0x07, 0x0e, + 0x1c, 0x38, 0x70, 0xe0, 0xdd, 0xa7, 0x53, 0xa6, + 0x51, 0xa2, 0x59, 0xb2, 0x79, 0xf2, 0xf9, 0xef, + 0xc3, 0x9b, 0x2b, 0x56, 0xac, 0x45, 0x8a, 0x09, + 0x12, 0x24, 0x48, 0x90, 0x3d, 0x7a, 0xf4, 0xf5, + 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16, + 0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, + 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x01}; + +static const uint8_t gf256_log[256] = { + 0x00, 0xff, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, + 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b, + 0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, + 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, 0x4c, 0x71, + 0x05, 0x8a, 0x65, 0x2f, 0xe1, 0x24, 0x0f, 0x21, + 0x35, 0x93, 0x8e, 0xda, 0xf0, 0x12, 0x82, 0x45, + 0x1d, 0xb5, 0xc2, 0x7d, 0x6a, 0x27, 0xf9, 0xb9, + 0xc9, 0x9a, 0x09, 0x78, 0x4d, 0xe4, 0x72, 0xa6, + 0x06, 0xbf, 0x8b, 0x62, 0x66, 0xdd, 0x30, 0xfd, + 0xe2, 0x98, 0x25, 0xb3, 0x10, 0x91, 0x22, 0x88, + 0x36, 0xd0, 0x94, 0xce, 0x8f, 0x96, 0xdb, 0xbd, + 0xf1, 0xd2, 0x13, 0x5c, 0x83, 0x38, 0x46, 0x40, + 0x1e, 0x42, 0xb6, 0xa3, 0xc3, 0x48, 0x7e, 0x6e, + 0x6b, 0x3a, 0x28, 0x54, 0xfa, 0x85, 0xba, 0x3d, + 0xca, 0x5e, 0x9b, 0x9f, 0x0a, 0x15, 0x79, 0x2b, + 0x4e, 0xd4, 0xe5, 0xac, 0x73, 0xf3, 0xa7, 0x57, + 0x07, 0x70, 0xc0, 0xf7, 0x8c, 0x80, 0x63, 0x0d, + 0x67, 0x4a, 0xde, 0xed, 0x31, 0xc5, 0xfe, 0x18, + 0xe3, 0xa5, 0x99, 0x77, 0x26, 0xb8, 0xb4, 0x7c, + 0x11, 0x44, 0x92, 0xd9, 0x23, 0x20, 0x89, 0x2e, + 0x37, 0x3f, 0xd1, 0x5b, 0x95, 0xbc, 0xcf, 0xcd, + 0x90, 0x87, 0x97, 0xb2, 0xdc, 0xfc, 0xbe, 0x61, + 0xf2, 0x56, 0xd3, 0xab, 0x14, 0x2a, 0x5d, 0x9e, + 0x84, 0x3c, 0x39, 0x53, 0x47, 0x6d, 0x41, 0xa2, + 0x1f, 0x2d, 0x43, 0xd8, 0xb7, 0x7b, 0xa4, 0x76, + 0xc4, 0x17, 0x49, 0xec, 0x7f, 0x0c, 0x6f, 0xf6, + 0x6c, 0xa1, 0x3b, 0x52, 0x29, 0x9d, 0x55, 0xaa, + 0xfb, 0x60, 0x86, 0xb1, 0xbb, 0xcc, 0x3e, 0x5a, + 0xcb, 0x59, 0x5f, 0xb0, 0x9c, 0xa9, 0xa0, 0x51, + 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7, + 0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, + 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf}; + +const static struct galois_field gf256 = { + .p = 255, + .log = gf256_log, + .exp = gf256_exp}; + +/************************************************************************ + * Polynomial operations + */ + +static void poly_add(uint8_t *dst, const uint8_t *src, uint8_t c, + int shift, const struct galois_field *gf) +{ + int i; + int log_c = gf->log[c]; + + if (!c) + return; + + for (i = 0; i < MAX_POLY; i++) + { + int p = i + shift; + uint8_t v = src[i]; + + if (p < 0 || p >= MAX_POLY) + continue; + if (!v) + continue; + + dst[p] ^= gf->exp[(gf->log[v] + log_c) % gf->p]; + } +} + +static uint8_t poly_eval(const uint8_t *s, uint8_t x, + const struct galois_field *gf) +{ + int i; + uint8_t sum = 0; + uint8_t log_x = gf->log[x]; + + if (!x) + return s[0]; + + for (i = 0; i < MAX_POLY; i++) + { + uint8_t c = s[i]; + + if (!c) + continue; + + sum ^= gf->exp[(gf->log[c] + log_x * i) % gf->p]; + } + + return sum; +} + +/************************************************************************ + * Berlekamp-Massey algorithm for finding error locator polynomials. + */ + +static void berlekamp_massey(const uint8_t *s, int N, + const struct galois_field *gf, + uint8_t *sigma) +{ + uint8_t C[MAX_POLY]; + uint8_t B[MAX_POLY]; + int L = 0; + int m = 1; + uint8_t b = 1; + int n; + + memset(B, 0, sizeof(B)); + memset(C, 0, sizeof(C)); + B[0] = 1; + C[0] = 1; + + for (n = 0; n < N; n++) + { + uint8_t d = s[n]; + uint8_t mult; + int i; + + for (i = 1; i <= L; i++) + { + if (!(C[i] && s[n - i])) + continue; + + d ^= gf->exp[(gf->log[C[i]] + + gf->log[s[n - i]]) % + gf->p]; + } + + mult = gf->exp[(gf->p - gf->log[b] + gf->log[d]) % gf->p]; + + if (!d) + { + m++; + } + else if (L * 2 <= n) + { + uint8_t T[MAX_POLY]; + + memcpy(T, C, sizeof(T)); + poly_add(C, B, mult, m, gf); + memcpy(B, T, sizeof(B)); + L = n + 1 - L; + b = d; + m = 1; + } + else + { + poly_add(C, B, mult, m, gf); + m++; + } + } + + memcpy(sigma, C, MAX_POLY); +} + +/************************************************************************ + * Code stream error correction + * + * Generator polynomial for GF(2^8) is x^8 + x^4 + x^3 + x^2 + 1 + */ + +static int block_syndromes(const uint8_t *data, int bs, int npar, uint8_t *s) +{ + int nonzero = 0; + int i; + + memset(s, 0, MAX_POLY); + + for (i = 0; i < npar; i++) + { + int j; + + for (j = 0; j < bs; j++) + { + uint8_t c = data[bs - j - 1]; + + if (!c) + continue; + + s[i] ^= gf256_exp[((int)gf256_log[c] + + i * j) % + 255]; + } + + if (s[i]) + nonzero = 1; + } + + return nonzero; +} + +static void eloc_poly(uint8_t *omega, + const uint8_t *s, const uint8_t *sigma, + int npar) +{ + int i; + + memset(omega, 0, MAX_POLY); + + for (i = 0; i < npar; i++) + { + const uint8_t a = sigma[i]; + const uint8_t log_a = gf256_log[a]; + int j; + + if (!a) + continue; + + for (j = 0; j + 1 < MAX_POLY; j++) + { + const uint8_t b = s[j + 1]; + + if (i + j >= npar) + break; + + if (!b) + continue; + + omega[i + j] ^= + gf256_exp[(log_a + gf256_log[b]) % 255]; + } + } +} + +static quirc_decode_error_t correct_block(uint8_t *data, + const struct quirc_rs_params *ecc) +{ + int npar = ecc->bs - ecc->dw; + uint8_t s[MAX_POLY]; + uint8_t sigma[MAX_POLY]; + uint8_t sigma_deriv[MAX_POLY]; + uint8_t omega[MAX_POLY]; + int i; + + /* Compute syndrome vector */ + if (!block_syndromes(data, ecc->bs, npar, s)) + return QUIRC_SUCCESS; + + berlekamp_massey(s, npar, &gf256, sigma); + + /* Compute derivative of sigma */ + memset(sigma_deriv, 0, MAX_POLY); + for (i = 0; i + 1 < MAX_POLY; i += 2) + sigma_deriv[i] = sigma[i + 1]; + + /* Compute error evaluator polynomial */ + eloc_poly(omega, s, sigma, npar - 1); + + /* Find error locations and magnitudes */ + for (i = 0; i < ecc->bs; i++) + { + uint8_t xinv = gf256_exp[255 - i]; + + if (!poly_eval(sigma, xinv, &gf256)) + { + uint8_t sd_x = poly_eval(sigma_deriv, xinv, &gf256); + uint8_t omega_x = poly_eval(omega, xinv, &gf256); + uint8_t error = gf256_exp[(255 - gf256_log[sd_x] + + gf256_log[omega_x]) % + 255]; + + data[ecc->bs - i - 1] ^= error; + } + } + + if (block_syndromes(data, ecc->bs, npar, s)) + return QUIRC_ERROR_DATA_ECC; + + return QUIRC_SUCCESS; +} + +/************************************************************************ + * Format value error correction + * + * Generator polynomial for GF(2^4) is x^4 + x + 1 + */ + +#define FORMAT_MAX_ERROR 3 +#define FORMAT_SYNDROMES (FORMAT_MAX_ERROR * 2) +#define FORMAT_BITS 15 + +static int format_syndromes(uint16_t u, uint8_t *s) +{ + int i; + int nonzero = 0; + + memset(s, 0, MAX_POLY); + + for (i = 0; i < FORMAT_SYNDROMES; i++) + { + int j; + + s[i] = 0; + for (j = 0; j < FORMAT_BITS; j++) + if (u & (1 << j)) + s[i] ^= gf16_exp[((i + 1) * j) % 15]; + + if (s[i]) + nonzero = 1; + } + + return nonzero; +} + +static quirc_decode_error_t correct_format(uint16_t *f_ret) +{ + uint16_t u = *f_ret; + int i; + uint8_t s[MAX_POLY]; + uint8_t sigma[MAX_POLY]; + + /* Evaluate U (received codeword) at each of alpha_1 .. alpha_6 + * to get S_1 .. S_6 (but we index them from 0). + */ + if (!format_syndromes(u, s)) + return QUIRC_SUCCESS; + + berlekamp_massey(s, FORMAT_SYNDROMES, &gf16, sigma); + + /* Now, find the roots of the polynomial */ + for (i = 0; i < 15; i++) + if (!poly_eval(sigma, gf16_exp[15 - i], &gf16)) + u ^= (1 << i); + + if (format_syndromes(u, s)) + return QUIRC_ERROR_FORMAT_ECC; + + *f_ret = u; + return QUIRC_SUCCESS; +} + +/************************************************************************ + * Decoder algorithm + */ + +struct datastream +{ + uint8_t raw[QUIRC_MAX_PAYLOAD]; + int data_bits; + int ptr; + + uint8_t data[QUIRC_MAX_PAYLOAD]; +} __attribute__((aligned(8))); + +static inline int grid_bit(const struct quirc_code *code, int x, int y) +{ + int p = y * code->size + x; + + return (code->cell_bitmap[p >> 3] >> (p & 7)) & 1; +} + +static quirc_decode_error_t read_format(const struct quirc_code *code, + struct quirc_data *data, int which) +{ + int i; + uint16_t format = 0; + uint16_t fdata; + quirc_decode_error_t err; + + if (which) + { + for (i = 0; i < 7; i++) + format = (format << 1) | + grid_bit(code, 8, code->size - 1 - i); + for (i = 0; i < 8; i++) + format = (format << 1) | + grid_bit(code, code->size - 8 + i, 8); + } + else + { + static const int xs[15] = { + 8, 8, 8, 8, 8, 8, 8, 8, 7, 5, 4, 3, 2, 1, 0}; + static const int ys[15] = { + 0, 1, 2, 3, 4, 5, 7, 8, 8, 8, 8, 8, 8, 8, 8}; + + for (i = 14; i >= 0; i--) + format = (format << 1) | grid_bit(code, xs[i], ys[i]); + } + + format ^= 0x5412; + + err = correct_format(&format); + if (err) + return err; + + fdata = format >> 10; + data->ecc_level = fdata >> 3; + data->mask = fdata & 7; + + return QUIRC_SUCCESS; +} + +static int mask_bit(int mask, int i, int j) +{ + switch (mask) + { + case 0: + return !((i + j) % 2); + case 1: + return !(i % 2); + case 2: + return !(j % 3); + case 3: + return !((i + j) % 3); + case 4: + return !(((i / 2) + (j / 3)) % 2); + case 5: + return !((i * j) % 2 + (i * j) % 3); + case 6: + return !(((i * j) % 2 + (i * j) % 3) % 2); + case 7: + return !(((i * j) % 3 + (i + j) % 2) % 2); + } + + return 0; +} + +static int reserved_cell(int version, int i, int j) +{ + const struct quirc_version_info *ver = &quirc_version_db[version]; + int size = version * 4 + 17; + int ai = -1, aj = -1, a; + + /* Finder + format: top left */ + if (i < 9 && j < 9) + return 1; + + /* Finder + format: bottom left */ + if (i + 8 >= size && j < 9) + return 1; + + /* Finder + format: top right */ + if (i < 9 && j + 8 >= size) + return 1; + + /* Exclude timing patterns */ + if (i == 6 || j == 6) + return 1; + + /* Exclude version info, if it exists. Version info sits adjacent to + * the top-right and bottom-left finders in three rows, bounded by + * the timing pattern. + */ + if (version >= 7) + { + if (i < 6 && j + 11 >= size) + return 1; + if (i + 11 >= size && j < 6) + return 1; + } + + /* Exclude alignment patterns */ + for (a = 0; a < QUIRC_MAX_ALIGNMENT && ver->apat[a]; a++) + { + int p = ver->apat[a]; + + if (abs(p - i) < 3) + ai = a; + if (abs(p - j) < 3) + aj = a; + } + + if (ai >= 0 && aj >= 0) + { + a--; + if (ai > 0 && ai < a) + return 1; + if (aj > 0 && aj < a) + return 1; + if (aj == a && ai == a) + return 1; + } + + return 0; +} + +static void read_bit(const struct quirc_code *code, + struct quirc_data *data, + struct datastream *ds, int i, int j) +{ + int bitpos = ds->data_bits & 7; + int bytepos = ds->data_bits >> 3; + int v = grid_bit(code, j, i); + + if (mask_bit(data->mask, i, j)) + v ^= 1; + + if (v) + ds->raw[bytepos] |= (0x80 >> bitpos); + + ds->data_bits++; +} + +static void read_data(const struct quirc_code *code, + struct quirc_data *data, + struct datastream *ds) +{ + int y = code->size - 1; + int x = code->size - 1; + int dir = -1; + + while (x > 0) + { + if (x == 6) + x--; + + if (!reserved_cell(data->version, y, x)) + read_bit(code, data, ds, y, x); + + if (!reserved_cell(data->version, y, x - 1)) + read_bit(code, data, ds, y, x - 1); + + y += dir; + if (y < 0 || y >= code->size) + { + dir = -dir; + x -= 2; + y += dir; + } + } +} + +static quirc_decode_error_t codestream_ecc(struct quirc_data *data, + struct datastream *ds) +{ + const struct quirc_version_info *ver = + &quirc_version_db[data->version]; + const struct quirc_rs_params *sb_ecc = &ver->ecc[data->ecc_level]; + struct quirc_rs_params lb_ecc; + const int lb_count = + (ver->data_bytes - sb_ecc->bs * sb_ecc->ns) / (sb_ecc->bs + 1); + const int bc = lb_count + sb_ecc->ns; + const int ecc_offset = sb_ecc->dw * bc + lb_count; + int dst_offset = 0; + int i; + + memcpy(&lb_ecc, sb_ecc, sizeof(lb_ecc)); + lb_ecc.dw++; + lb_ecc.bs++; + + for (i = 0; i < bc; i++) + { + uint8_t *dst = ds->data + dst_offset; + const struct quirc_rs_params *ecc = + (i < sb_ecc->ns) ? sb_ecc : &lb_ecc; + const int num_ec = ecc->bs - ecc->dw; + quirc_decode_error_t err; + int j; + + for (j = 0; j < ecc->dw; j++) + dst[j] = ds->raw[j * bc + i]; + for (j = 0; j < num_ec; j++) + dst[ecc->dw + j] = ds->raw[ecc_offset + j * bc + i]; + + err = correct_block(dst, ecc); + if (err) + return err; + + dst_offset += ecc->dw; + } + + ds->data_bits = dst_offset * 8; + + return QUIRC_SUCCESS; +} + +static inline int bits_remaining(const struct datastream *ds) +{ + return ds->data_bits - ds->ptr; +} + +static int take_bits(struct datastream *ds, int len) +{ + int ret = 0; + + while (len && (ds->ptr < ds->data_bits)) + { + uint8_t b = ds->data[ds->ptr >> 3]; + int bitpos = ds->ptr & 7; + + ret <<= 1; + if ((b << bitpos) & 0x80) + ret |= 1; + + ds->ptr++; + len--; + } + + return ret; +} + +static int numeric_tuple(struct quirc_data *data, + struct datastream *ds, + int bits, int digits) +{ + int tuple; + int i; + + if (bits_remaining(ds) < bits) + return -1; + + tuple = take_bits(ds, bits); + + for (i = digits - 1; i >= 0; i--) + { + data->payload[data->payload_len + i] = tuple % 10 + '0'; + tuple /= 10; + } + + data->payload_len += digits; + return 0; +} + +static quirc_decode_error_t decode_numeric(struct quirc_data *data, + struct datastream *ds) +{ + int bits = 14; + int count; + + if (data->version < 10) + bits = 10; + else if (data->version < 27) + bits = 12; + + count = take_bits(ds, bits); + if (data->payload_len + count + 1 > QUIRC_MAX_PAYLOAD) + return QUIRC_ERROR_DATA_OVERFLOW; + + while (count >= 3) + { + if (numeric_tuple(data, ds, 10, 3) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count -= 3; + } + + if (count >= 2) + { + if (numeric_tuple(data, ds, 7, 2) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count -= 2; + } + + if (count) + { + if (numeric_tuple(data, ds, 4, 1) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count--; + } + + return QUIRC_SUCCESS; +} + +static int alpha_tuple(struct quirc_data *data, + struct datastream *ds, + int bits, int digits) +{ + int tuple; + int i; + + if (bits_remaining(ds) < bits) + return -1; + + tuple = take_bits(ds, bits); + + for (i = 0; i < digits; i++) + { + static const char *alpha_map = + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"; + + data->payload[data->payload_len + digits - i - 1] = + alpha_map[tuple % 45]; + tuple /= 45; + } + + data->payload_len += digits; + return 0; +} + +static quirc_decode_error_t decode_alpha(struct quirc_data *data, + struct datastream *ds) +{ + int bits = 13; + int count; + + if (data->version < 10) + bits = 9; + else if (data->version < 27) + bits = 11; + + count = take_bits(ds, bits); + if (data->payload_len + count + 1 > QUIRC_MAX_PAYLOAD) + return QUIRC_ERROR_DATA_OVERFLOW; + + while (count >= 2) + { + if (alpha_tuple(data, ds, 11, 2) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count -= 2; + } + + if (count) + { + if (alpha_tuple(data, ds, 6, 1) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count--; + } + + return QUIRC_SUCCESS; +} + +static quirc_decode_error_t decode_byte(struct quirc_data *data, + struct datastream *ds) +{ + int bits = 16; + int count; + int i; + + if (data->version < 10) + bits = 8; + + count = take_bits(ds, bits); + if (data->payload_len + count + 1 > QUIRC_MAX_PAYLOAD) + return QUIRC_ERROR_DATA_OVERFLOW; + if (bits_remaining(ds) < count * 8) + return QUIRC_ERROR_DATA_UNDERFLOW; + + for (i = 0; i < count; i++) + data->payload[data->payload_len++] = take_bits(ds, 8); + + return QUIRC_SUCCESS; +} + +static quirc_decode_error_t decode_kanji(struct quirc_data *data, + struct datastream *ds) +{ + int bits = 12; + int count; + int i; + + if (data->version < 10) + bits = 8; + else if (data->version < 27) + bits = 10; + + count = take_bits(ds, bits); + if (data->payload_len + count * 2 + 1 > QUIRC_MAX_PAYLOAD) + return QUIRC_ERROR_DATA_OVERFLOW; + if (bits_remaining(ds) < count * 13) + return QUIRC_ERROR_DATA_UNDERFLOW; + + for (i = 0; i < count; i++) + { + int d = take_bits(ds, 13); + int msB = d / 0xc0; + int lsB = d % 0xc0; + int intermediate = (msB << 8) | lsB; + uint16_t sjw; + + if (intermediate + 0x8140 <= 0x9ffc) + { + /* bytes are in the range 0x8140 to 0x9FFC */ + sjw = intermediate + 0x8140; + } + else + { + /* bytes are in the range 0xE040 to 0xEBBF */ + sjw = intermediate + 0xc140; + } + + data->payload[data->payload_len++] = sjw >> 8; + data->payload[data->payload_len++] = sjw & 0xff; + } + + return QUIRC_SUCCESS; +} + +static quirc_decode_error_t decode_eci(struct quirc_data *data, + struct datastream *ds) +{ + if (bits_remaining(ds) < 8) + return QUIRC_ERROR_DATA_UNDERFLOW; + + data->eci = take_bits(ds, 8); + + if ((data->eci & 0xc0) == 0x80) + { + if (bits_remaining(ds) < 8) + return QUIRC_ERROR_DATA_UNDERFLOW; + + data->eci = (data->eci << 8) | take_bits(ds, 8); + } + else if ((data->eci & 0xe0) == 0xc0) + { + if (bits_remaining(ds) < 16) + return QUIRC_ERROR_DATA_UNDERFLOW; + + data->eci = (data->eci << 16) | take_bits(ds, 16); + } + + return QUIRC_SUCCESS; +} + +static quirc_decode_error_t decode_payload(struct quirc_data *data, + struct datastream *ds) +{ + while (bits_remaining(ds) >= 4) + { + quirc_decode_error_t err = QUIRC_SUCCESS; + int type = take_bits(ds, 4); + + switch (type) + { + case QUIRC_DATA_TYPE_NUMERIC: + err = decode_numeric(data, ds); + break; + + case QUIRC_DATA_TYPE_ALPHA: + err = decode_alpha(data, ds); + break; + + case QUIRC_DATA_TYPE_BYTE: + err = decode_byte(data, ds); + break; + + case QUIRC_DATA_TYPE_KANJI: + err = decode_kanji(data, ds); + break; + + case 7: + err = decode_eci(data, ds); + break; + + default: + goto done; + } + + if (err) + return err; + + if (!(type & (type - 1)) && (type > data->data_type)) + data->data_type = type; + } + +done: + + /* Add nul terminator to all payloads */ + if (data->payload_len >= sizeof(data->payload)) + data->payload_len--; + data->payload[data->payload_len] = 0; + + return QUIRC_SUCCESS; +} + +quirc_decode_error_t quirc_decode(const struct quirc_code *code, + struct quirc_data *data) +{ + quirc_decode_error_t err; + struct datastream *ds = ps_malloc(sizeof(struct datastream)); + + if ((code->size - 17) % 4) + { + free(ds); + return QUIRC_ERROR_INVALID_GRID_SIZE; + } + + memset(data, 0, sizeof(*data)); + memset(ds, 0, sizeof(*ds)); + + data->version = (code->size - 17) / 4; + + if (data->version < 1 || + data->version > QUIRC_MAX_VERSION) + { + free(ds); + return QUIRC_ERROR_INVALID_VERSION; + } + + /* Read format information -- try both locations */ + err = read_format(code, data, 0); + if (err) + err = read_format(code, data, 1); + if (err) + { + free(ds); + return err; + } + + read_data(code, data, ds); + err = codestream_ecc(data, ds); + if (err) + { + free(ds); + return err; + } + + err = decode_payload(data, ds); + if (err) + { + free(ds); + return err; + } + + free(ds); + return QUIRC_SUCCESS; +} \ No newline at end of file diff --git a/ESP32QRReaderDBWriter/defines.h b/ESP32QRReaderDBWriter/defines.h new file mode 100644 index 0000000..ed63a72 --- /dev/null +++ b/ESP32QRReaderDBWriter/defines.h @@ -0,0 +1,381 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define DEBUG_ESP8266_AT_WEBSERVER_PORT Serial + +// Debug Level from 0 to 4 +#define _ESP_AT_LOGLEVEL_ 1 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ! (ESP8266 || ESP32 ) + // Select only one of these libraries, only for boards other than ESP8266/ESP32 + #define USING_WIFI_ESP8266_AT false + #define USING_WIFININA_GENERIC false + #define USING_WIFININA false + #define USING_WIFIESPAT_LIB true + #define USING_WIFI_CUSTOM false +#endif + +#if defined(ARDUINO_SAMD_MKR1000) + #if defined(USE_WIFI_NINA) + #undef USE_WIFI_NINA + #endif + #define USE_WIFI_NINA false + #define USE_WIFI101 true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX + #endif + #define WIFI_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD + #endif + #define WIFI_USE_SAMD true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFI_USE_SAM_DUE) + #undef WIFI_USE_SAM_DUE + #endif + #define WIFI_USE_SAM_DUE true + #warning Use SAM_DUE architecture +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 + #endif + #define WIFI_USE_STM32 true +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFI_USE_RP2040) + #undef WIFI_USE_RP2040 + #endif + #define WIFI_USE_RP2040 true +#endif + +#ifdef CORE_TEENSY + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For Teensy 4.1/4.0 + #define EspSerial Serial2 //Serial2, Pin RX2 : 7, TX2 : 8 + #endif + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" +#endif + +#elif defined(WIFI_USE_NRF528XX) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif defined(WIFI_USE_SAMD) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For SAMD + #define EspSerial Serial1 + #endif + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif defined(WIFI_USE_STM32) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For STM32 + #if defined(ARDUINO_NUCLEO_F767ZI) + #warning Nucleo-144 NUCLEO_F767ZI board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); + #elif defined(ARDUINO_NUCLEO_L053R8) + #warning Nucleo-64 NUCLEO_L053R8 board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); // (PA3, PA2); + #endif + + #warning EspSerial using SERIAL_PORT_HARDWARE, can be Serial or Serial1. See your board variant.h + #define EspSerial SERIAL_PORT_HARDWARE //Serial1 + #endif + + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif (ESP8266) + #warning ESP8266 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif (ESP32) + #warning ESP32 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif defined(WIFI_USE_RP2040) && !defined(ARDUINO_ARCH_MBED) + + // For RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + +#elif defined(WIFI_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + // For MBED RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#else + // For Mega + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #define BOARD_TYPE "AVR Mega" +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +#endif //defines_h diff --git a/ESP32QRReaderDBWriter/fmath.h b/ESP32QRReaderDBWriter/fmath.h new file mode 100644 index 0000000..76c3b93 --- /dev/null +++ b/ESP32QRReaderDBWriter/fmath.h @@ -0,0 +1,70 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * Fast approximate math functions. + * + */ +#ifndef __FMATH_H +#define __FMATH_H +#include +#include + +static inline float fast_sqrtf(float x) +{ + //return sqrtf(x); + asm("fsqrt.s %0, %1" + : "=f"(x) + : "f"(x)); + return x; +} +static inline int fast_floorf(float x) +{ + return (int)(x); +} + +static inline int fast_ceilf(float x) +{ + return (int)(x + 0.9999f); +} + +static inline int fast_roundf(float x) +{ + return (int)(x); +} + +static inline float fast_fabsf(float d) +{ + return fabsf(d); +} + +extern int fast_floorf(float x); +extern int fast_ceilf(float x); +extern int fast_roundf(float x); +extern float fast_atanf(float x); +extern float fast_atan2f(float y, float x); +extern float fast_expf(float x); +extern float fast_cbrtf(float d); +extern float fast_fabsf(float d); +extern float fast_log(float x); +extern float fast_log2(float x); +extern float fast_powf(float a, float b); + +/*#define fast_sqrtf(x) (sqrtf(x)) +#define fast_floorf(x) ((int)floorf(x)) +#define fast_ceilf(x) ((int)ceilf(x)) +#define fast_roundf(x) ((int)roundf(x)) +#define fast_atanf(x) (atanf(x)) +#define fast_atan2f(x,y) (atan2f((x),(y))) +#define fast_expf(x) (expf(x)) +#define fast_cbrtf(x) (cbrtf(x)) +#define fast_fabsf(x) (fabsf(x)) +#define fast_log(x) (log(x)) +#define fast_log2(x) (log2(x)) +#define fast_powf(x,y) (powf((x),(y))) +*/ + +extern const float cos_table[360]; +extern const float sin_table[360]; +#endif // __FMATH_H \ No newline at end of file diff --git a/ESP32QRReaderDBWriter/identify.c b/ESP32QRReaderDBWriter/identify.c new file mode 100644 index 0000000..d0d0316 --- /dev/null +++ b/ESP32QRReaderDBWriter/identify.c @@ -0,0 +1,1286 @@ +/* quirc - QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + +#include "fmath.h" +#include "collections.h" +#include "quirc_internal.h" + +/************************************************************************ + * Linear algebra routines + */ + +static int line_intersect(const struct quirc_point *p0, + const struct quirc_point *p1, + const struct quirc_point *q0, + const struct quirc_point *q1, + struct quirc_point *r) +{ + /* (a, b) is perpendicular to line p */ + int a = -(p1->y - p0->y); + int b = p1->x - p0->x; + + /* (c, d) is perpendicular to line q */ + int c = -(q1->y - q0->y); + int d = q1->x - q0->x; + + /* e and f are dot products of the respective vectors with p and q */ + int e = a * p1->x + b * p1->y; + int f = c * q1->x + d * q1->y; + + /* Now we need to solve: + * [a b] [rx] [e] + * [c d] [ry] = [f] + * + * We do this by inverting the matrix and applying it to (e, f): + * [ d -b] [e] [rx] + * 1/det [-c a] [f] = [ry] + */ + int det = (a * d) - (b * c); + + if (!det) + return 0; + + r->x = (d * e - b * f) / det; + r->y = (-c * e + a * f) / det; + + return 1; +} + +static void perspective_setup(float *c, + const struct quirc_point *rect, + float w, float h) +{ + float x0 = rect[0].x; + float y0 = rect[0].y; + float x1 = rect[1].x; + float y1 = rect[1].y; + float x2 = rect[2].x; + float y2 = rect[2].y; + float x3 = rect[3].x; + float y3 = rect[3].y; + + float wden = w * (x2 * y3 - x3 * y2 + (x3 - x2) * y1 + x1 * (y2 - y3)); + float hden = h * (x2 * y3 + x1 * (y2 - y3) - x3 * y2 + (x3 - x2) * y1); + + c[0] = (x1 * (x2 * y3 - x3 * y2) + x0 * (-x2 * y3 + x3 * y2 + (x2 - x3) * y1) + + x1 * (x3 - x2) * y0) / + wden; + c[1] = -(x0 * (x2 * y3 + x1 * (y2 - y3) - x2 * y1) - x1 * x3 * y2 + x2 * x3 * y1 + (x1 * x3 - x2 * x3) * y0) / hden; + c[2] = x0; + c[3] = (y0 * (x1 * (y3 - y2) - x2 * y3 + x3 * y2) + y1 * (x2 * y3 - x3 * y2) + + x0 * y1 * (y2 - y3)) / + wden; + c[4] = (x0 * (y1 * y3 - y2 * y3) + x1 * y2 * y3 - x2 * y1 * y3 + + y0 * (x3 * y2 - x1 * y2 + (x2 - x3) * y1)) / + hden; + c[5] = y0; + c[6] = (x1 * (y3 - y2) + x0 * (y2 - y3) + (x2 - x3) * y1 + (x3 - x2) * y0) / wden; + c[7] = (-x2 * y3 + x1 * y3 + x3 * y2 + x0 * (y1 - y2) - x3 * y1 + (x2 - x1) * y0) / + hden; +} + +static void perspective_map(const float *c, + float u, float v, struct quirc_point *ret) +{ + float den = c[6] * u + c[7] * v + 1.0; + float x = (c[0] * u + c[1] * v + c[2]) / den; + float y = (c[3] * u + c[4] * v + c[5]) / den; + + ret->x = fast_roundf(x); + ret->y = fast_roundf(y); +} + +static void perspective_unmap(const float *c, + const struct quirc_point *in, + float *u, float *v) +{ + float x = in->x; + float y = in->y; + float den = -c[0] * c[7] * y + c[1] * c[6] * y + (c[3] * c[7] - c[4] * c[6]) * x + + c[0] * c[4] - c[1] * c[3]; + + *u = -(c[1] * (y - c[5]) - c[2] * c[7] * y + (c[5] * c[7] - c[4]) * x + c[2] * c[4]) / + den; + *v = (c[0] * (y - c[5]) - c[2] * c[6] * y + (c[5] * c[6] - c[3]) * x + c[2] * c[3]) / + den; +} + +/************************************************************************ + * Span-based floodfill routine + */ + +typedef void (*span_func_t)(void *user_data, int y, int left, int right); + +typedef struct xylf +{ + int16_t x, y, l, r; +} __attribute__((aligned(8))) +xylf_t; + +//计算该区域的面积,from是像素颜色,to是区块标号,user_data是申请的区块结构体,func是计算面积的函数 +static void flood_fill_seed(struct quirc *q, int x, int y, int from, int to, + span_func_t func, void *user_data, + int depth) +{ + (void)depth; // unused + + lifo_t lifo; + size_t lifo_len; + lifo_alloc_all(&lifo, &lifo_len, sizeof(xylf_t)); + //late in first out. 申请xylf_t的lifo,一次申请完,长度存储在lifo_len中 + + for (;;) + { + int left = x; + int right = x; + int i; + quirc_pixel_t *row = q->pixels + y * q->w; //行起始地址 + //查找左右边界 + while (left > 0 && row[left - 1] == from) + left--; + + while (right < q->w - 1 && row[right + 1] == from) + right++; + + /* Fill the extent 对应像素标记为区块号*/ + for (i = left; i <= right; i++) + row[i] = to; + //累加区域内的像素点数作为面积 + if (func) + func(user_data, y, left, right); + + for (;;) + { + if (lifo_size(&lifo) < lifo_len) + { //栈中的数量 + /* Seed new flood-fills */ + if (y > 0) + { //查找上一行有没有在同一区域的点 + row = q->pixels + (y - 1) * q->w; + + bool recurse = false; + for (i = left; i <= right; i++) + if (row[i] == from) + { //相同区域,则入栈原来的区块 + xylf_t context; + context.x = x; + context.y = y; + context.l = left; + context.r = right; + lifo_enqueue(&lifo, &context); + //mp_printf(&mp_plat_print, "#x=%x,y=%d;x1=%d,y1=%d\n",x,y,i,y-1); + x = i; + y = y - 1; + recurse = true; + break; + } + if (recurse) + break; + } + //查找下一行有没有在同一区域的点 + if (y < q->h - 1) + { + row = q->pixels + (y + 1) * q->w; + + bool recurse = false; + for (i = left; i <= right; i++) + if (row[i] == from) + { + xylf_t context; + context.x = x; + context.y = y; + context.l = left; + context.r = right; + lifo_enqueue(&lifo, &context); + //mp_printf(&mp_plat_print, "#x=%x,y=%d;x1=%d,y1=%d\n",x,y,i,y+1); + x = i; + y = y + 1; + recurse = true; + break; + } + if (recurse) + break; + } + } + + if (!lifo_size(&lifo)) + { + lifo_free(&lifo); //如果最起始为止就没找到,那么返回 + return; + } + //本次迭代,往上,往下找边界(相同颜色像素点),直到找不到为止 + //找到边界后,出栈上层像素点,回退回去 + xylf_t context; + lifo_dequeue(&lifo, &context); //这里存疑,如果都没有的话,dequeue就会反向溢出吧。。 + x = context.x; + y = context.y; + left = context.l; + right = context.r; + //mp_printf(&mp_plat_print, "#deq: x=%x,y=%d\n",x,y); + } //找到相同from,break到这外面 + } +} + +/************************************************************************ + * Adaptive thresholding + */ + +#define THRESHOLD_S_MIN 1 +#define THRESHOLD_S_DEN 8 +#define THRESHOLD_T 5 + +static void threshold(struct quirc *q) +{ + int x, y; + int avg_w = 0; + int avg_u = 0; + int threshold_s = q->w / THRESHOLD_S_DEN; + quirc_pixel_t *row = q->pixels; + + /* + * Ensure a sane, non-zero value for threshold_s. + * + * threshold_s can be zero if the image width is small. We need to avoid + * SIGFPE as it will be used as divisor. + */ + if (threshold_s < THRESHOLD_S_MIN) + threshold_s = THRESHOLD_S_MIN; + + for (y = 0; y < q->h; y++) + { + int row_average[q->w]; + + memset(row_average, 0, sizeof(row_average)); + + for (x = 0; x < q->w; x++) + { + int w, u; + + if (y & 1) + { + w = x; + u = q->w - 1 - x; + } + else + { + w = q->w - 1 - x; + u = x; + } + + avg_w = (avg_w * (threshold_s - 1)) / + threshold_s + + row[w]; + avg_u = (avg_u * (threshold_s - 1)) / + threshold_s + + row[u]; + + row_average[w] += avg_w; + row_average[u] += avg_u; + } + + for (x = 0; x < q->w; x++) + { + if (row[x] < row_average[x] * + (100 - THRESHOLD_T) / (200 * threshold_s)) + row[x] = QUIRC_PIXEL_BLACK; + else + row[x] = QUIRC_PIXEL_WHITE; + } + + row += q->w; + } +} + +static void area_count(void *user_data, int y, int left, int right) +{ + ((struct quirc_region *)user_data)->count += right - left + 1; +} + +static int region_code(struct quirc *q, int x, int y) +{ //region指的是QRcode的区域,成员为区域的坐标,像素面积,是否顶点 + int pixel; + struct quirc_region *box; + int region; + + if (x < 0 || y < 0 || x >= q->w || y >= q->h) + return -1; + + pixel = q->pixels[y * q->w + x]; + //预先判断非正常的像素情况,退出 + if (pixel >= QUIRC_PIXEL_REGION) + return pixel; + + if (pixel == QUIRC_PIXEL_WHITE) + return -1; + + if (q->num_regions >= QUIRC_MAX_REGIONS) + return -1; + //新建一个区域 + region = q->num_regions; + box = &q->regions[q->num_regions++]; + + memset(box, 0, sizeof(*box)); + + box->seed.x = x; + box->seed.y = y; + box->capstone = -1; + //计算该区域的面积 + flood_fill_seed(q, x, y, pixel, region, area_count, box, 0); + + return region; +} + +struct polygon_score_data +{ + struct quirc_point ref; + + int scores[4]; + struct quirc_point *corners; +} __attribute__((aligned(8))); + +static void find_one_corner(void *user_data, int y, int left, int right) +{ + struct polygon_score_data *psd = + (struct polygon_score_data *)user_data; + int xs[2] = {left, right}; + int dy = y - psd->ref.y; + int i; + + for (i = 0; i < 2; i++) + { + int dx = xs[i] - psd->ref.x; + int d = dx * dx + dy * dy; + + if (d > psd->scores[0]) + { + psd->scores[0] = d; + psd->corners[0].x = xs[i]; + psd->corners[0].y = y; + } + } +} + +static void find_other_corners(void *user_data, int y, int left, int right) +{ + struct polygon_score_data *psd = + (struct polygon_score_data *)user_data; + int xs[2] = {left, right}; + int i; + + for (i = 0; i < 2; i++) + { + int up = xs[i] * psd->ref.x + y * psd->ref.y; + int right = xs[i] * -psd->ref.y + y * psd->ref.x; + int scores[4] = {up, right, -up, -right}; + int j; + + for (j = 0; j < 4; j++) + { + if (scores[j] > psd->scores[j]) + { + psd->scores[j] = scores[j]; + psd->corners[j].x = xs[i]; + psd->corners[j].y = y; + } + } + } +} + +static void find_region_corners(struct quirc *q, + int rcode, const struct quirc_point *ref, + struct quirc_point *corners) +{ + struct quirc_region *region = &q->regions[rcode]; + struct polygon_score_data psd; + int i; + + memset(&psd, 0, sizeof(psd)); + psd.corners = corners; + + memcpy(&psd.ref, ref, sizeof(psd.ref)); + psd.scores[0] = -1; + flood_fill_seed(q, region->seed.x, region->seed.y, + rcode, QUIRC_PIXEL_BLACK, + find_one_corner, &psd, 0); + + psd.ref.x = psd.corners[0].x - psd.ref.x; + psd.ref.y = psd.corners[0].y - psd.ref.y; + + for (i = 0; i < 4; i++) + memcpy(&psd.corners[i], ®ion->seed, + sizeof(psd.corners[i])); + + i = region->seed.x * psd.ref.x + region->seed.y * psd.ref.y; + psd.scores[0] = i; + psd.scores[2] = -i; + i = region->seed.x * -psd.ref.y + region->seed.y * psd.ref.x; + psd.scores[1] = i; + psd.scores[3] = -i; + + flood_fill_seed(q, region->seed.x, region->seed.y, + QUIRC_PIXEL_BLACK, rcode, + find_other_corners, &psd, 0); +} + +static void record_capstone(struct quirc *q, int ring, int stone) +{ + struct quirc_region *stone_reg = &q->regions[stone]; + struct quirc_region *ring_reg = &q->regions[ring]; + struct quirc_capstone *capstone; + int cs_index; + + if (q->num_capstones >= QUIRC_MAX_CAPSTONES) + return; + + cs_index = q->num_capstones; + capstone = &q->capstones[q->num_capstones++]; + + memset(capstone, 0, sizeof(*capstone)); + + capstone->qr_grid = -1; + capstone->ring = ring; + capstone->stone = stone; + stone_reg->capstone = cs_index; + ring_reg->capstone = cs_index; + + /* Find the corners of the ring */ + find_region_corners(q, ring, &stone_reg->seed, capstone->corners); + + /* Set up the perspective transform and find the center */ + perspective_setup(capstone->c, capstone->corners, 7.0, 7.0); + perspective_map(capstone->c, 3.5, 3.5, &capstone->center); +} + +static void test_capstone(struct quirc *q, int x, int y, int *pb) +{ + int ring_right = region_code(q, x - pb[4], y); //x-pb[4]是标记环右边的左侧 + int stone = region_code(q, x - pb[4] - pb[3] - pb[2], y); //实心点左侧 + int ring_left = region_code(q, x - pb[4] - pb[3] - pb[2] - pb[1] - pb[0], y); //环左侧 + struct quirc_region *stone_reg; + struct quirc_region *ring_reg; + int ratio; + //以下检测顶点标记是否符合规范,环称为ring,中间称为stone + if (ring_left < 0 || ring_right < 0 || stone < 0) + return; + + /* Left and ring of ring should be connected */ + if (ring_left != ring_right) + return; + + /* Ring should be disconnected from stone */ + if (ring_left == stone) + return; + + stone_reg = &q->regions[stone]; + ring_reg = &q->regions[ring_left]; + + /* Already detected */ + if (stone_reg->capstone >= 0 || ring_reg->capstone >= 0) + return; + + /* Ratio should ideally be 37.5 中间实心点占面积比例应该在37.5%左右*/ + ratio = stone_reg->count * 100 / ring_reg->count; + if (ratio < 10 || ratio > 70) + return; + + record_capstone(q, ring_left, stone); +} + +static void finder_scan(struct quirc *q, int y) +{ + quirc_pixel_t *row = q->pixels + y * q->w; + int x; + int last_color = 0; + int run_length = 0; + int run_count = 0; + int pb[5]; //means QRcode's pixel width + + memset(pb, 0, sizeof(pb)); + for (x = 0; x < q->w; x++) + { + int color = row[x] ? 1 : 0; + + if (x && color != last_color) + { // color is different + memmove(pb, pb + 1, sizeof(pb[0]) * 4); //left move in one data + pb[4] = run_length; //run how many pix to get different color + run_length = 0; + run_count++; //get more than 5 time color jump + + if (!color && run_count >= 5) + { // find the marker of QRcode(three corner's marker) + static int check[5] = {1, 1, 3, 1, 1}; + int avg, err; + int i; + int ok = 1; + + avg = (pb[0] + pb[1] + pb[3] + pb[4]) / 4; + err = avg * 3 / 4; + + for (i = 0; i < 5; i++) + if (pb[i] < check[i] * avg - err || + pb[i] > check[i] * avg + err) + ok = 0; + + if (ok) + test_capstone(q, x, y, pb); + } + } + + run_length++; + last_color = color; + } +} + +static void find_alignment_pattern(struct quirc *q, int index) +{ + struct quirc_grid *qr = &q->grids[index]; + struct quirc_capstone *c0 = &q->capstones[qr->caps[0]]; + struct quirc_capstone *c2 = &q->capstones[qr->caps[2]]; + struct quirc_point a; + struct quirc_point b; + struct quirc_point c; + int size_estimate; + int step_size = 1; + int dir = 0; + float u, v; + + /* Grab our previous estimate of the alignment pattern corner */ + memcpy(&b, &qr->align, sizeof(b)); + + /* Guess another two corners of the alignment pattern so that we + * can estimate its size. + */ + perspective_unmap(c0->c, &b, &u, &v); + perspective_map(c0->c, u, v + 1.0, &a); + perspective_unmap(c2->c, &b, &u, &v); + perspective_map(c2->c, u + 1.0, v, &c); + + size_estimate = abs((a.x - b.x) * -(c.y - b.y) + + (a.y - b.y) * (c.x - b.x)); + + /* Spiral outwards from the estimate point until we find something + * roughly the right size. Don't look too far from the estimate + * point. + */ + while (step_size * step_size < size_estimate * 100) + { + static const int dx_map[] = {1, 0, -1, 0}; + static const int dy_map[] = {0, -1, 0, 1}; + int i; + + for (i = 0; i < step_size; i++) + { + int code = region_code(q, b.x, b.y); + + if (code >= 0) + { + struct quirc_region *reg = &q->regions[code]; + + if (reg->count >= size_estimate / 2 && + reg->count <= size_estimate * 2) + { + qr->align_region = code; + return; + } + } + + b.x += dx_map[dir]; + b.y += dy_map[dir]; + } + + dir = (dir + 1) % 4; + if (!(dir & 1)) + step_size++; + } +} + +static void find_leftmost_to_line(void *user_data, int y, int left, int right) +{ + struct polygon_score_data *psd = + (struct polygon_score_data *)user_data; + int xs[2] = {left, right}; + int i; + + for (i = 0; i < 2; i++) + { + int d = -psd->ref.y * xs[i] + psd->ref.x * y; + + if (d < psd->scores[0]) + { + psd->scores[0] = d; + psd->corners[0].x = xs[i]; + psd->corners[0].y = y; + } + } +} + +/* Do a Bresenham scan from one point to another and count the number + * of black/white transitions. + */ +static int timing_scan(const struct quirc *q, + const struct quirc_point *p0, + const struct quirc_point *p1) +{ + int n = p1->x - p0->x; + int d = p1->y - p0->y; + int x = p0->x; + int y = p0->y; + int *dom, *nondom; + int dom_step; + int nondom_step; + int a = 0; + int i; + int run_length = 0; + int count = 0; + + if (p0->x < 0 || p0->y < 0 || p0->x >= q->w || p0->y >= q->h) + return -1; + if (p1->x < 0 || p1->y < 0 || p1->x >= q->w || p1->y >= q->h) + return -1; + + if (abs(n) > abs(d)) + { + int swap = n; + + n = d; + d = swap; + + dom = &x; + nondom = &y; + } + else + { + dom = &y; + nondom = &x; + } + + if (n < 0) + { + n = -n; + nondom_step = -1; + } + else + { + nondom_step = 1; + } + + if (d < 0) + { + d = -d; + dom_step = -1; + } + else + { + dom_step = 1; + } + + x = p0->x; + y = p0->y; + for (i = 0; i <= d; i++) + { + int pixel; + + if (y < 0 || y >= q->h || x < 0 || x >= q->w) + break; + + pixel = q->pixels[y * q->w + x]; + + if (pixel) + { + if (run_length >= 2) + count++; + run_length = 0; + } + else + { + run_length++; + } + + a += n; + *dom += dom_step; + if (a >= d) + { + *nondom += nondom_step; + a -= d; + } + } + + return count; +} + +/* Try the measure the timing pattern for a given QR code. This does + * not require the global perspective to have been set up, but it + * does require that the capstone corners have been set to their + * canonical rotation. + * + * For each capstone, we find a point in the middle of the ring band + * which is nearest the centre of the code. Using these points, we do + * a horizontal and a vertical timing scan. + */ +static int measure_timing_pattern(struct quirc *q, int index) +{ + struct quirc_grid *qr = &q->grids[index]; + int i; + int scan; + int ver; + int size; + + for (i = 0; i < 3; i++) + { + static const float us[] = {6.5, 6.5, 0.5}; + static const float vs[] = {0.5, 6.5, 6.5}; + struct quirc_capstone *cap = &q->capstones[qr->caps[i]]; + + perspective_map(cap->c, us[i], vs[i], &qr->tpep[i]); + } + + qr->hscan = timing_scan(q, &qr->tpep[1], &qr->tpep[2]); + qr->vscan = timing_scan(q, &qr->tpep[1], &qr->tpep[0]); + + scan = qr->hscan; + if (qr->vscan > scan) + scan = qr->vscan; + + /* If neither scan worked, we can't go any further. */ + if (scan < 0) + return -1; + + /* Choose the nearest allowable grid size */ + size = scan * 2 + 13; + ver = (size - 15) / 4; + qr->grid_size = ver * 4 + 17; + + return 0; +} + +/* Read a cell from a grid using the currently set perspective + * transform. Returns +/- 1 for black/white, 0 for cells which are + * out of image bounds. + */ +static int read_cell(const struct quirc *q, int index, int x, int y) +{ + const struct quirc_grid *qr = &q->grids[index]; + struct quirc_point p; + + perspective_map(qr->c, x + 0.5, y + 0.5, &p); + if (p.y < 0 || p.y >= q->h || p.x < 0 || p.x >= q->w) + return 0; + + return q->pixels[p.y * q->w + p.x] ? 1 : -1; +} + +static int fitness_cell(const struct quirc *q, int index, int x, int y) +{ + const struct quirc_grid *qr = &q->grids[index]; + int score = 0; + int u, v; + + for (v = 0; v < 3; v++) + for (u = 0; u < 3; u++) + { + static const float offsets[] = {0.3, 0.5, 0.7}; + struct quirc_point p; + + perspective_map(qr->c, x + offsets[u], + y + offsets[v], &p); + if (p.y < 0 || p.y >= q->h || p.x < 0 || p.x >= q->w) + continue; + + if (q->pixels[p.y * q->w + p.x]) + score++; + else + score--; + } + + return score; +} + +static int fitness_ring(const struct quirc *q, int index, int cx, int cy, + int radius) +{ + int i; + int score = 0; + + for (i = 0; i < radius * 2; i++) + { + score += fitness_cell(q, index, cx - radius + i, cy - radius); + score += fitness_cell(q, index, cx - radius, cy + radius - i); + score += fitness_cell(q, index, cx + radius, cy - radius + i); + score += fitness_cell(q, index, cx + radius - i, cy + radius); + } + + return score; +} + +static int fitness_apat(const struct quirc *q, int index, int cx, int cy) +{ + return fitness_cell(q, index, cx, cy) - + fitness_ring(q, index, cx, cy, 1) + + fitness_ring(q, index, cx, cy, 2); +} + +static int fitness_capstone(const struct quirc *q, int index, int x, int y) +{ + x += 3; + y += 3; + + return fitness_cell(q, index, x, y) + + fitness_ring(q, index, x, y, 1) - + fitness_ring(q, index, x, y, 2) + + fitness_ring(q, index, x, y, 3); +} + +/* Compute a fitness score for the currently configured perspective + * transform, using the features we expect to find by scanning the + * grid. + */ +static int fitness_all(const struct quirc *q, int index) +{ + const struct quirc_grid *qr = &q->grids[index]; + int version = (qr->grid_size - 17) / 4; + const struct quirc_version_info *info = &quirc_version_db[version]; + int score = 0; + int i, j; + int ap_count; + + /* Check the timing pattern */ + for (i = 0; i < qr->grid_size - 14; i++) + { + int expect = (i & 1) ? 1 : -1; + + score += fitness_cell(q, index, i + 7, 6) * expect; + score += fitness_cell(q, index, 6, i + 7) * expect; + } + + /* Check capstones */ + score += fitness_capstone(q, index, 0, 0); + score += fitness_capstone(q, index, qr->grid_size - 7, 0); + score += fitness_capstone(q, index, 0, qr->grid_size - 7); + + if (version < 0 || version > QUIRC_MAX_VERSION) + return score; + + /* Check alignment patterns */ + ap_count = 0; + while ((ap_count < QUIRC_MAX_ALIGNMENT) && info->apat[ap_count]) + ap_count++; + + for (i = 1; i + 1 < ap_count; i++) + { + score += fitness_apat(q, index, 6, info->apat[i]); + score += fitness_apat(q, index, info->apat[i], 6); + } + + for (i = 1; i < ap_count; i++) + for (j = 1; j < ap_count; j++) + score += fitness_apat(q, index, + info->apat[i], info->apat[j]); + //mp_printf(&mp_plat_print, "##score=%d\n",score); + return score; +} + +static void jiggle_perspective(struct quirc *q, int index) +{ + struct quirc_grid *qr = &q->grids[index]; + int best = fitness_all(q, index); + int pass; + float adjustments[8]; + int i; + + for (i = 0; i < 8; i++) + adjustments[i] = qr->c[i] * 0.02; + + for (pass = 0; pass < 5; pass++) + { + for (i = 0; i < 16; i++) + { + int j = i >> 1; + int test; + float old = qr->c[j]; + float step = adjustments[j]; + float new; + + if (i & 1) + new = old + step; + else + new = old - step; + + qr->c[j] = new; + test = fitness_all(q, index); + + if (test > best) + best = test; + else + qr->c[j] = old; + } + + for (i = 0; i < 8; i++) + adjustments[i] *= 0.5; + } +} + +/* Once the capstones are in place and an alignment point has been + * chosen, we call this function to set up a grid-reading perspective + * transform. + */ +static void setup_qr_perspective(struct quirc *q, int index) +{ + struct quirc_grid *qr = &q->grids[index]; + struct quirc_point rect[4]; + + /* Set up the perspective map for reading the grid */ + memcpy(&rect[0], &q->capstones[qr->caps[1]].corners[0], + sizeof(rect[0])); + memcpy(&rect[1], &q->capstones[qr->caps[2]].corners[0], + sizeof(rect[0])); + memcpy(&rect[2], &qr->align, sizeof(rect[0])); + memcpy(&rect[3], &q->capstones[qr->caps[0]].corners[0], + sizeof(rect[0])); + perspective_setup(qr->c, rect, qr->grid_size - 7, qr->grid_size - 7); + + jiggle_perspective(q, index); +} + +/* Rotate the capstone with so that corner 0 is the leftmost with respect + * to the given reference line. + */ +static void rotate_capstone(struct quirc_capstone *cap, + const struct quirc_point *h0, + const struct quirc_point *hd) +{ + struct quirc_point copy[4]; + int j; + int best = 0; + int best_score = 0; + + for (j = 0; j < 4; j++) + { + struct quirc_point *p = &cap->corners[j]; + int score = (p->x - h0->x) * -hd->y + + (p->y - h0->y) * hd->x; + + if (!j || score < best_score) + { + best = j; + best_score = score; + } + } + + /* Rotate the capstone */ + for (j = 0; j < 4; j++) + memcpy(©[j], &cap->corners[(j + best) % 4], + sizeof(copy[j])); + memcpy(cap->corners, copy, sizeof(cap->corners)); + perspective_setup(cap->c, cap->corners, 7.0, 7.0); +} + +static void record_qr_grid(struct quirc *q, int a, int b, int c) +{ + struct quirc_point h0, hd; + int i; + int qr_index; + struct quirc_grid *qr; + + if (q->num_grids >= QUIRC_MAX_GRIDS) + return; + + /* Construct the hypotenuse line from A to C. B should be to + * the left of this line. + */ + memcpy(&h0, &q->capstones[a].center, sizeof(h0)); + hd.x = q->capstones[c].center.x - q->capstones[a].center.x; + hd.y = q->capstones[c].center.y - q->capstones[a].center.y; + + /* Make sure A-B-C is clockwise */ + if ((q->capstones[b].center.x - h0.x) * -hd.y + + (q->capstones[b].center.y - h0.y) * hd.x > + 0) + { + int swap = a; + + a = c; + c = swap; + hd.x = -hd.x; + hd.y = -hd.y; + } + + /* Record the grid and its components */ + qr_index = q->num_grids; + qr = &q->grids[q->num_grids++]; + + memset(qr, 0, sizeof(*qr)); + qr->caps[0] = a; + qr->caps[1] = b; + qr->caps[2] = c; + qr->align_region = -1; + + /* Rotate each capstone so that corner 0 is top-left with respect + * to the grid. + */ + for (i = 0; i < 3; i++) + { + struct quirc_capstone *cap = &q->capstones[qr->caps[i]]; + + rotate_capstone(cap, &h0, &hd); + cap->qr_grid = qr_index; + } + + /* Check the timing pattern. This doesn't require a perspective + * transform. + */ + if (measure_timing_pattern(q, qr_index) < 0) + goto fail; + + /* Make an estimate based for the alignment pattern based on extending + * lines from capstones A and C. + */ + if (!line_intersect(&q->capstones[a].corners[0], + &q->capstones[a].corners[1], + &q->capstones[c].corners[0], + &q->capstones[c].corners[3], + &qr->align)) + goto fail; + + /* On V2+ grids, we should use the alignment pattern. */ + if (qr->grid_size > 21) + { + /* Try to find the actual location of the alignment pattern. */ + find_alignment_pattern(q, qr_index); + + /* Find the point of the alignment pattern closest to the + * top-left of the QR grid. + */ + if (qr->align_region >= 0) + { + struct polygon_score_data psd; + struct quirc_region *reg = + &q->regions[qr->align_region]; + + /* Start from some point inside the alignment pattern */ + memcpy(&qr->align, ®->seed, sizeof(qr->align)); + + memcpy(&psd.ref, &hd, sizeof(psd.ref)); + psd.corners = &qr->align; + psd.scores[0] = -hd.y * qr->align.x + + hd.x * qr->align.y; + + flood_fill_seed(q, reg->seed.x, reg->seed.y, + qr->align_region, QUIRC_PIXEL_BLACK, + NULL, NULL, 0); + flood_fill_seed(q, reg->seed.x, reg->seed.y, + QUIRC_PIXEL_BLACK, qr->align_region, + find_leftmost_to_line, &psd, 0); + } + } + + setup_qr_perspective(q, qr_index); + return; + +fail: + /* We've been unable to complete setup for this grid. Undo what we've + * recorded and pretend it never happened. + */ + for (i = 0; i < 3; i++) + q->capstones[qr->caps[i]].qr_grid = -1; + q->num_grids--; +} + +struct neighbour +{ + int index; + float distance; +} __attribute__((aligned(8))); + +struct neighbour_list +{ + struct neighbour n[QUIRC_MAX_CAPSTONES]; + int count; +} __attribute__((aligned(8))); + +static void test_neighbours(struct quirc *q, int i, + const struct neighbour_list *hlist, + const struct neighbour_list *vlist) +{ + int j, k; + float best_score = 0.0; + int best_h = -1, best_v = -1; + + /* Test each possible grouping */ + for (j = 0; j < hlist->count; j++) + for (k = 0; k < vlist->count; k++) + { + const struct neighbour *hn = &hlist->n[j]; + const struct neighbour *vn = &vlist->n[k]; + float score = fast_fabsf(1.0 - hn->distance / vn->distance); + + if (score > 2.5) + continue; + + if (best_h < 0 || score < best_score) + { + best_h = hn->index; + best_v = vn->index; + best_score = score; + } + } + + if (best_h < 0 || best_v < 0) + return; + + record_qr_grid(q, best_h, i, best_v); +} + +static void test_grouping(struct quirc *q, int i) +{ + struct quirc_capstone *c1 = &q->capstones[i]; + int j; + struct neighbour_list hlist; + struct neighbour_list vlist; + + if (c1->qr_grid >= 0) + return; + + hlist.count = 0; + vlist.count = 0; + + /* Look for potential neighbours by examining the relative gradients + * from this capstone to others. + */ + for (j = 0; j < q->num_capstones; j++) + { + struct quirc_capstone *c2 = &q->capstones[j]; + float u, v; + + if (i == j || c2->qr_grid >= 0) + continue; + + perspective_unmap(c1->c, &c2->center, &u, &v); + + u = fast_fabsf(u - 3.5); + v = fast_fabsf(v - 3.5); + + if (u < 0.2 * v) + { + struct neighbour *n = &hlist.n[hlist.count++]; + + n->index = j; + n->distance = v; + } + + if (v < 0.2 * u) + { + struct neighbour *n = &vlist.n[vlist.count++]; + + n->index = j; + n->distance = u; + } + } + + if (!(hlist.count && vlist.count)) + return; + + test_neighbours(q, i, &hlist, &vlist); +} + +static void pixels_setup(struct quirc *q) +{ + if (sizeof(*q->image) == sizeof(*q->pixels)) + { + q->pixels = (quirc_pixel_t *)q->image; + } + else + { + int x, y; + for (y = 0; y < q->h; y++) + { + for (x = 0; x < q->w; x++) + { + q->pixels[y * q->w + x] = q->image[y * q->w + x]; + } + } + } +} + +uint8_t *quirc_begin(struct quirc *q, int *w, int *h) +{ + q->num_regions = QUIRC_PIXEL_REGION; + q->num_capstones = 0; + q->num_grids = 0; + + if (w) + *w = q->w; + if (h) + *h = q->h; + + return q->image; +} + +void quirc_end(struct quirc *q) +{ + int i; + pixels_setup(q); + threshold(q); + + for (i = 0; i < q->h; i++) + { + finder_scan(q, i); + } + + for (i = 0; i < q->num_capstones; i++) + { + test_grouping(q, i); + } +} + +void quirc_extract(const struct quirc *q, int index, + struct quirc_code *code) +{ + const struct quirc_grid *qr = &q->grids[index]; + int y; + int i = 0; + + if (index < 0 || index > q->num_grids) + return; + + memset(code, 0, sizeof(*code)); + + perspective_map(qr->c, 0.0, 0.0, &code->corners[0]); + perspective_map(qr->c, qr->grid_size, 0.0, &code->corners[1]); + perspective_map(qr->c, qr->grid_size, qr->grid_size, + &code->corners[2]); + perspective_map(qr->c, 0.0, qr->grid_size, &code->corners[3]); + + code->size = qr->grid_size; + + for (y = 0; y < qr->grid_size; y++) + { + int x; + + for (x = 0; x < qr->grid_size; x++) + { + if (read_cell(q, index, x, y) > 0) + code->cell_bitmap[i >> 3] |= (1 << (i & 7)); + + i++; + } + } +} diff --git a/ESP32QRReaderDBWriter/quirc.c b/ESP32QRReaderDBWriter/quirc.c new file mode 100644 index 0000000..e5a30fb --- /dev/null +++ b/ESP32QRReaderDBWriter/quirc.c @@ -0,0 +1,104 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include "quirc_internal.h" +#include + +const char *quirc_version(void) +{ + return "1.0"; +} + +//static struct quirc _q; +struct quirc *quirc_new(void) +{ + struct quirc *q = ps_malloc(sizeof(*q)); + + if (!q) + return NULL; + + memset(q, 0, sizeof(*q)); + return q; +} + +void quirc_destroy(struct quirc *q) +{ + if (q->image) + if (q->image) + free(q->image); + if (sizeof(*q->image) != sizeof(*q->pixels)) + if (q->pixels) + free(q->pixels); + + if (q) + free(q); +} + +//static quirc_pixel_t img_buf[320*240]; +int quirc_resize(struct quirc *q, int w, int h) +{ + if (q->image) + { + free(q->image); + } + uint8_t *new_image = ps_malloc(w * h); + + if (!new_image) + return -1; + + if (sizeof(*q->image) != sizeof(*q->pixels)) + { //should gray, 1==1 + size_t new_size = w * h * sizeof(quirc_pixel_t); + if (q->pixels) + free(q->pixels); + quirc_pixel_t *new_pixels = ps_malloc(new_size); + if (!new_pixels) + { + free(new_image); + return -1; + } + q->pixels = new_pixels; + } + q->image = new_image; + q->w = w; + q->h = h; + return 0; +} + +int quirc_count(const struct quirc *q) +{ + return q->num_grids; +} + +static const char *const error_table[] = { + [QUIRC_SUCCESS] = "Success", + [QUIRC_ERROR_INVALID_GRID_SIZE] = "Invalid grid size", + [QUIRC_ERROR_INVALID_VERSION] = "Invalid version", + [QUIRC_ERROR_FORMAT_ECC] = "Format data ECC failure", + [QUIRC_ERROR_DATA_ECC] = "ECC failure", + [QUIRC_ERROR_UNKNOWN_DATA_TYPE] = "Unknown data type", + [QUIRC_ERROR_DATA_OVERFLOW] = "Data overflow", + [QUIRC_ERROR_DATA_UNDERFLOW] = "Data underflow"}; + +const char *quirc_strerror(quirc_decode_error_t err) +{ + if (err >= 0 && err < sizeof(error_table) / sizeof(error_table[0])) + return error_table[err]; + + return "Unknown error"; +} diff --git a/ESP32QRReaderDBWriter/quirc.h b/ESP32QRReaderDBWriter/quirc.h new file mode 100644 index 0000000..ecdc172 --- /dev/null +++ b/ESP32QRReaderDBWriter/quirc.h @@ -0,0 +1,178 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef QUIRC_H_ +#define QUIRC_H_ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + struct quirc; + + /* Obtain the library version string. */ + const char *quirc_version(void); + + /* Construct a new QR-code recognizer. This function will return NULL + * if sufficient memory could not be allocated. + */ + struct quirc *quirc_new(void); + + /* Destroy a QR-code recognizer. */ + void quirc_destroy(struct quirc *q); + + /* Resize the QR-code recognizer. The size of an image must be + * specified before codes can be analyzed. + * + * This function returns 0 on success, or -1 if sufficient memory could + * not be allocated. + */ + int quirc_resize(struct quirc *q, int w, int h); + + /* These functions are used to process images for QR-code recognition. + * quirc_begin() must first be called to obtain access to a buffer into + * which the input image should be placed. Optionally, the current + * width and height may be returned. + * + * After filling the buffer, quirc_end() should be called to process + * the image for QR-code recognition. The locations and content of each + * code may be obtained using accessor functions described below. + */ + uint8_t *quirc_begin(struct quirc *q, int *w, int *h); + void quirc_end(struct quirc *q); + + /* This structure describes a location in the input image buffer. */ + struct quirc_point + { + int x; + int y; + } __attribute__((aligned(8))); + + /* This enum describes the various decoder errors which may occur. */ + typedef enum + { + QUIRC_SUCCESS = 0, + QUIRC_ERROR_INVALID_GRID_SIZE, + QUIRC_ERROR_INVALID_VERSION, + QUIRC_ERROR_FORMAT_ECC, + QUIRC_ERROR_DATA_ECC, + QUIRC_ERROR_UNKNOWN_DATA_TYPE, + QUIRC_ERROR_DATA_OVERFLOW, + QUIRC_ERROR_DATA_UNDERFLOW + } quirc_decode_error_t; + + /* Return a string error message for an error code. */ + const char *quirc_strerror(quirc_decode_error_t err); + +/* Limits on the maximum size of QR-codes and their content. */ +#define QUIRC_MAX_BITMAP 3917 +#define QUIRC_MAX_PAYLOAD 8896 + +/* QR-code ECC types. */ +#define QUIRC_ECC_LEVEL_M 0 +#define QUIRC_ECC_LEVEL_L 1 +#define QUIRC_ECC_LEVEL_H 2 +#define QUIRC_ECC_LEVEL_Q 3 + +/* QR-code data types. */ +#define QUIRC_DATA_TYPE_NUMERIC 1 +#define QUIRC_DATA_TYPE_ALPHA 2 +#define QUIRC_DATA_TYPE_BYTE 4 +#define QUIRC_DATA_TYPE_KANJI 8 + +/* Common character encodings */ +#define QUIRC_ECI_ISO_8859_1 1 +#define QUIRC_ECI_IBM437 2 +#define QUIRC_ECI_ISO_8859_2 4 +#define QUIRC_ECI_ISO_8859_3 5 +#define QUIRC_ECI_ISO_8859_4 6 +#define QUIRC_ECI_ISO_8859_5 7 +#define QUIRC_ECI_ISO_8859_6 8 +#define QUIRC_ECI_ISO_8859_7 9 +#define QUIRC_ECI_ISO_8859_8 10 +#define QUIRC_ECI_ISO_8859_9 11 +#define QUIRC_ECI_WINDOWS_874 13 +#define QUIRC_ECI_ISO_8859_13 15 +#define QUIRC_ECI_ISO_8859_15 17 +#define QUIRC_ECI_SHIFT_JIS 20 +#define QUIRC_ECI_UTF_8 26 + + /* This structure is used to return information about detected QR codes + * in the input image. + */ + struct quirc_code + { + /* The four corners of the QR-code, from top left, clockwise */ + struct quirc_point corners[4]; + + /* The number of cells across in the QR-code. The cell bitmap + * is a bitmask giving the actual values of cells. If the cell + * at (x, y) is black, then the following bit is set: + * + * cell_bitmap[i >> 3] & (1 << (i & 7)) + * + * where i = (y * size) + x. + */ + int size; + uint8_t cell_bitmap[QUIRC_MAX_BITMAP]; + } __attribute__((aligned(8))); + + /* This structure holds the decoded QR-code data */ + struct quirc_data + { + /* Various parameters of the QR-code. These can mostly be + * ignored if you only care about the data. + */ + int version; + int ecc_level; + int mask; + + /* This field is the highest-valued data type found in the QR + * code. + */ + int data_type; + + /* Data payload. For the Kanji datatype, payload is encoded as + * Shift-JIS. For all other datatypes, payload is ASCII text. + */ + uint8_t payload[QUIRC_MAX_PAYLOAD]; + int payload_len; + + /* ECI assignment number */ + uint32_t eci; + } __attribute__((aligned(8))); + + /* Return the number of QR-codes identified in the last processed + * image. + */ + int quirc_count(const struct quirc *q); + + /* Extract the QR-code specified by the given index. */ + void quirc_extract(const struct quirc *q, int index, + struct quirc_code *code); + + /* Decode a QR-code, returning the payload data. */ + quirc_decode_error_t quirc_decode(const struct quirc_code *code, + struct quirc_data *data); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/ESP32QRReaderDBWriter/quirc_internal.h b/ESP32QRReaderDBWriter/quirc_internal.h new file mode 100644 index 0000000..3fa075c --- /dev/null +++ b/ESP32QRReaderDBWriter/quirc_internal.h @@ -0,0 +1,121 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef QUIRC_INTERNAL_H_ +#define QUIRC_INTERNAL_H_ + +#include "quirc.h" + +#define QUIRC_PIXEL_WHITE 0 +#define QUIRC_PIXEL_BLACK 1 +#define QUIRC_PIXEL_REGION 2 + +#ifndef QUIRC_MAX_REGIONS +#define QUIRC_MAX_REGIONS 254 +#endif + +#define QUIRC_MAX_CAPSTONES 32 +#define QUIRC_MAX_GRIDS 8 + +#define QUIRC_PERSPECTIVE_PARAMS 8 + +#if QUIRC_MAX_REGIONS < UINT8_MAX +typedef uint8_t quirc_pixel_t; +#elif QUIRC_MAX_REGIONS < UINT16_MAX +typedef uint16_t quirc_pixel_t; +#else +#error "QUIRC_MAX_REGIONS > 65534 is not supported" +#endif + +struct quirc_region +{ + struct quirc_point seed; + int count; + int capstone; +} __attribute__((aligned(8))); + +struct quirc_capstone +{ + int ring; + int stone; + + struct quirc_point corners[4]; + struct quirc_point center; + float c[QUIRC_PERSPECTIVE_PARAMS]; + + int qr_grid; +} __attribute__((aligned(8))); + +struct quirc_grid +{ + /* Capstone indices */ + int caps[3]; + + /* Alignment pattern region and corner */ + int align_region; + struct quirc_point align; + + /* Timing pattern endpoints */ + struct quirc_point tpep[3]; + int hscan; + int vscan; + + /* Grid size and perspective transform */ + int grid_size; + float c[QUIRC_PERSPECTIVE_PARAMS]; +} __attribute__((aligned(8))); + +struct quirc +{ + uint8_t *image; + quirc_pixel_t *pixels; + int w; + int h; + + int num_regions; + struct quirc_region regions[QUIRC_MAX_REGIONS]; + + int num_capstones; + struct quirc_capstone capstones[QUIRC_MAX_CAPSTONES]; + + int num_grids; + struct quirc_grid grids[QUIRC_MAX_GRIDS]; +} __attribute__((aligned(8))); + +/************************************************************************ + * QR-code version information database + */ + +#define QUIRC_MAX_VERSION 40 +#define QUIRC_MAX_ALIGNMENT 7 + +struct quirc_rs_params +{ + uint8_t bs; /* Small block size */ + uint8_t dw; /* Small data words */ + uint8_t ns; /* Number of small blocks */ +} __attribute__((aligned(8))); + +struct quirc_version_info +{ + uint16_t data_bytes; + uint8_t apat[QUIRC_MAX_ALIGNMENT]; + struct quirc_rs_params ecc[4]; +} __attribute__((aligned(8))); + +extern const struct quirc_version_info quirc_version_db[QUIRC_MAX_VERSION + 1]; + +#endif \ No newline at end of file diff --git a/ESP32QRReaderDBWriter/version_db.c b/ESP32QRReaderDBWriter/version_db.c new file mode 100644 index 0000000..0da2d07 --- /dev/null +++ b/ESP32QRReaderDBWriter/version_db.c @@ -0,0 +1,184 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "quirc_internal.h" + +const struct quirc_version_info quirc_version_db[QUIRC_MAX_VERSION + 1] = { + {0}, + {/* Version 1 */ + .data_bytes = 26, + .apat = {0}, + .ecc = { + {.bs = 26, .dw = 16, .ns = 1}, + {.bs = 26, .dw = 19, .ns = 1}, + {.bs = 26, .dw = 9, .ns = 1}, + {.bs = 26, .dw = 13, .ns = 1}}}, + {/* Version 2 */ + .data_bytes = 44, + .apat = {6, 18, 0}, + .ecc = {{.bs = 44, .dw = 28, .ns = 1}, {.bs = 44, .dw = 34, .ns = 1}, {.bs = 44, .dw = 16, .ns = 1}, {.bs = 44, .dw = 22, .ns = 1}}}, + {/* Version 3 */ + .data_bytes = 70, + .apat = {6, 22, 0}, + .ecc = {{.bs = 70, .dw = 44, .ns = 1}, {.bs = 70, .dw = 55, .ns = 1}, {.bs = 35, .dw = 13, .ns = 2}, {.bs = 35, .dw = 17, .ns = 2}}}, + {/* Version 4 */ + .data_bytes = 100, + .apat = {6, 26, 0}, + .ecc = {{.bs = 50, .dw = 32, .ns = 2}, {.bs = 100, .dw = 80, .ns = 1}, {.bs = 25, .dw = 9, .ns = 4}, {.bs = 50, .dw = 24, .ns = 2}}}, + {/* Version 5 */ + .data_bytes = 134, + .apat = {6, 30, 0}, + .ecc = {{.bs = 67, .dw = 43, .ns = 2}, {.bs = 134, .dw = 108, .ns = 1}, {.bs = 33, .dw = 11, .ns = 2}, {.bs = 33, .dw = 15, .ns = 2}}}, + {/* Version 6 */ + .data_bytes = 172, + .apat = {6, 34, 0}, + .ecc = {{.bs = 43, .dw = 27, .ns = 4}, {.bs = 86, .dw = 68, .ns = 2}, {.bs = 43, .dw = 15, .ns = 4}, {.bs = 43, .dw = 19, .ns = 4}}}, + {/* Version 7 */ + .data_bytes = 196, + .apat = {6, 22, 38, 0}, + .ecc = {{.bs = 49, .dw = 31, .ns = 4}, {.bs = 98, .dw = 78, .ns = 2}, {.bs = 39, .dw = 13, .ns = 4}, {.bs = 32, .dw = 14, .ns = 2}}}, + {/* Version 8 */ + .data_bytes = 242, + .apat = {6, 24, 42, 0}, + .ecc = {{.bs = 60, .dw = 38, .ns = 2}, {.bs = 121, .dw = 97, .ns = 2}, {.bs = 40, .dw = 14, .ns = 4}, {.bs = 40, .dw = 18, .ns = 4}}}, + {/* Version 9 */ + .data_bytes = 292, + .apat = {6, 26, 46, 0}, + .ecc = {{.bs = 58, .dw = 36, .ns = 3}, {.bs = 146, .dw = 116, .ns = 2}, {.bs = 36, .dw = 12, .ns = 4}, {.bs = 36, .dw = 16, .ns = 4}}}, + {/* Version 10 */ + .data_bytes = 346, + .apat = {6, 28, 50, 0}, + .ecc = {{.bs = 69, .dw = 43, .ns = 4}, {.bs = 86, .dw = 68, .ns = 2}, {.bs = 43, .dw = 15, .ns = 6}, {.bs = 43, .dw = 19, .ns = 6}}}, + {/* Version 11 */ + .data_bytes = 404, + .apat = {6, 30, 54, 0}, + .ecc = {{.bs = 80, .dw = 50, .ns = 1}, {.bs = 101, .dw = 81, .ns = 4}, {.bs = 36, .dw = 12, .ns = 3}, {.bs = 50, .dw = 22, .ns = 4}}}, + {/* Version 12 */ + .data_bytes = 466, + .apat = {6, 32, 58, 0}, + .ecc = {{.bs = 58, .dw = 36, .ns = 6}, {.bs = 116, .dw = 92, .ns = 2}, {.bs = 42, .dw = 14, .ns = 7}, {.bs = 46, .dw = 20, .ns = 4}}}, + {/* Version 13 */ + .data_bytes = 532, + .apat = {6, 34, 62, 0}, + .ecc = {{.bs = 59, .dw = 37, .ns = 8}, {.bs = 133, .dw = 107, .ns = 4}, {.bs = 33, .dw = 11, .ns = 12}, {.bs = 44, .dw = 20, .ns = 8}}}, + {/* Version 14 */ + .data_bytes = 581, + .apat = {6, 26, 46, 66, 0}, + .ecc = {{.bs = 64, .dw = 40, .ns = 4}, {.bs = 145, .dw = 115, .ns = 3}, {.bs = 36, .dw = 12, .ns = 11}, {.bs = 36, .dw = 16, .ns = 11}}}, + {/* Version 15 */ + .data_bytes = 655, + .apat = {6, 26, 48, 70, 0}, + .ecc = {{.bs = 65, .dw = 41, .ns = 5}, {.bs = 109, .dw = 87, .ns = 5}, {.bs = 36, .dw = 12, .ns = 11}, {.bs = 54, .dw = 24, .ns = 5}}}, + {/* Version 16 */ + .data_bytes = 733, + .apat = {6, 26, 50, 74, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 7}, {.bs = 122, .dw = 98, .ns = 5}, {.bs = 45, .dw = 15, .ns = 3}, {.bs = 43, .dw = 19, .ns = 15}}}, + {/* Version 17 */ + .data_bytes = 815, + .apat = {6, 30, 54, 78, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 10}, {.bs = 135, .dw = 107, .ns = 1}, {.bs = 42, .dw = 14, .ns = 2}, {.bs = 50, .dw = 22, .ns = 1}}}, + {/* Version 18 */ + .data_bytes = 901, + .apat = {6, 30, 56, 82, 0}, + .ecc = {{.bs = 69, .dw = 43, .ns = 9}, {.bs = 150, .dw = 120, .ns = 5}, {.bs = 42, .dw = 14, .ns = 2}, {.bs = 50, .dw = 22, .ns = 17}}}, + {/* Version 19 */ + .data_bytes = 991, + .apat = {6, 30, 58, 86, 0}, + .ecc = {{.bs = 70, .dw = 44, .ns = 3}, {.bs = 141, .dw = 113, .ns = 3}, {.bs = 39, .dw = 13, .ns = 9}, {.bs = 47, .dw = 21, .ns = 17}}}, + {/* Version 20 */ + .data_bytes = 1085, + .apat = {6, 34, 62, 90, 0}, + .ecc = {{.bs = 67, .dw = 41, .ns = 3}, {.bs = 135, .dw = 107, .ns = 3}, {.bs = 43, .dw = 15, .ns = 15}, {.bs = 54, .dw = 24, .ns = 15}}}, + {/* Version 21 */ + .data_bytes = 1156, + .apat = {6, 28, 50, 72, 92, 0}, + .ecc = {{.bs = 68, .dw = 42, .ns = 17}, {.bs = 144, .dw = 116, .ns = 4}, {.bs = 46, .dw = 16, .ns = 19}, {.bs = 50, .dw = 22, .ns = 17}}}, + {/* Version 22 */ + .data_bytes = 1258, + .apat = {6, 26, 50, 74, 98, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 17}, {.bs = 139, .dw = 111, .ns = 2}, {.bs = 37, .dw = 13, .ns = 34}, {.bs = 54, .dw = 24, .ns = 7}}}, + {/* Version 23 */ + .data_bytes = 1364, + .apat = {6, 30, 54, 78, 102, 0}, + .ecc = {{.bs = 75, .dw = 47, .ns = 4}, {.bs = 151, .dw = 121, .ns = 4}, {.bs = 45, .dw = 15, .ns = 16}, {.bs = 54, .dw = 24, .ns = 11}}}, + {/* Version 24 */ + .data_bytes = 1474, + .apat = {6, 28, 54, 80, 106, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 6}, {.bs = 147, .dw = 117, .ns = 6}, {.bs = 46, .dw = 16, .ns = 30}, {.bs = 54, .dw = 24, .ns = 11}}}, + {/* Version 25 */ + .data_bytes = 1588, + .apat = {6, 32, 58, 84, 110, 0}, + .ecc = {{.bs = 75, .dw = 47, .ns = 8}, {.bs = 132, .dw = 106, .ns = 8}, {.bs = 45, .dw = 15, .ns = 22}, {.bs = 54, .dw = 24, .ns = 7}}}, + {/* Version 26 */ + .data_bytes = 1706, + .apat = {6, 30, 58, 86, 114, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 19}, {.bs = 142, .dw = 114, .ns = 10}, {.bs = 46, .dw = 16, .ns = 33}, {.bs = 50, .dw = 22, .ns = 28}}}, + {/* Version 27 */ + .data_bytes = 1828, + .apat = {6, 34, 62, 90, 118, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 22}, {.bs = 152, .dw = 122, .ns = 8}, {.bs = 45, .dw = 15, .ns = 12}, {.bs = 53, .dw = 23, .ns = 8}}}, + {/* Version 28 */ + .data_bytes = 1921, + .apat = {6, 26, 50, 74, 98, 122, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 3}, {.bs = 147, .dw = 117, .ns = 3}, {.bs = 45, .dw = 15, .ns = 11}, {.bs = 54, .dw = 24, .ns = 4}}}, + {/* Version 29 */ + .data_bytes = 2051, + .apat = {6, 30, 54, 78, 102, 126, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 21}, {.bs = 146, .dw = 116, .ns = 7}, {.bs = 45, .dw = 15, .ns = 19}, {.bs = 53, .dw = 23, .ns = 1}}}, + {/* Version 30 */ + .data_bytes = 2185, + .apat = {6, 26, 52, 78, 104, 130, 0}, + .ecc = {{.bs = 75, .dw = 47, .ns = 19}, {.bs = 145, .dw = 115, .ns = 5}, {.bs = 45, .dw = 15, .ns = 23}, {.bs = 54, .dw = 24, .ns = 15}}}, + {/* Version 31 */ + .data_bytes = 2323, + .apat = {6, 30, 56, 82, 108, 134, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 2}, {.bs = 145, .dw = 115, .ns = 13}, {.bs = 45, .dw = 15, .ns = 23}, {.bs = 54, .dw = 24, .ns = 42}}}, + {/* Version 32 */ + .data_bytes = 2465, + .apat = {6, 34, 60, 86, 112, 138, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 10}, {.bs = 145, .dw = 115, .ns = 17}, {.bs = 45, .dw = 15, .ns = 19}, {.bs = 54, .dw = 24, .ns = 10}}}, + {/* Version 33 */ + .data_bytes = 2611, + .apat = {6, 30, 58, 86, 114, 142, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 14}, {.bs = 145, .dw = 115, .ns = 17}, {.bs = 45, .dw = 15, .ns = 11}, {.bs = 54, .dw = 24, .ns = 29}}}, + {/* Version 34 */ + .data_bytes = 2761, + .apat = {6, 34, 62, 90, 118, 146, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 14}, {.bs = 145, .dw = 115, .ns = 13}, {.bs = 46, .dw = 16, .ns = 59}, {.bs = 54, .dw = 24, .ns = 44}}}, + {/* Version 35 */ + .data_bytes = 2876, + .apat = {6, 30, 54, 78, 102, 126, 150}, + .ecc = {{.bs = 75, .dw = 47, .ns = 12}, {.bs = 151, .dw = 121, .ns = 12}, {.bs = 45, .dw = 15, .ns = 22}, {.bs = 54, .dw = 24, .ns = 39}}}, + {/* Version 36 */ + .data_bytes = 3034, + .apat = {6, 24, 50, 76, 102, 128, 154}, + .ecc = {{.bs = 75, .dw = 47, .ns = 6}, {.bs = 151, .dw = 121, .ns = 6}, {.bs = 45, .dw = 15, .ns = 2}, {.bs = 54, .dw = 24, .ns = 46}}}, + {/* Version 37 */ + .data_bytes = 3196, + .apat = {6, 28, 54, 80, 106, 132, 158}, + .ecc = {{.bs = 74, .dw = 46, .ns = 29}, {.bs = 152, .dw = 122, .ns = 17}, {.bs = 45, .dw = 15, .ns = 24}, {.bs = 54, .dw = 24, .ns = 49}}}, + {/* Version 38 */ + .data_bytes = 3362, + .apat = {6, 32, 58, 84, 110, 136, 162}, + .ecc = {{.bs = 74, .dw = 46, .ns = 13}, {.bs = 152, .dw = 122, .ns = 4}, {.bs = 45, .dw = 15, .ns = 42}, {.bs = 54, .dw = 24, .ns = 48}}}, + {/* Version 39 */ + .data_bytes = 3532, + .apat = {6, 26, 54, 82, 110, 138, 166}, + .ecc = {{.bs = 75, .dw = 47, .ns = 40}, {.bs = 147, .dw = 117, .ns = 20}, {.bs = 45, .dw = 15, .ns = 10}, {.bs = 54, .dw = 24, .ns = 43}}}, + {/* Version 40 */ + .data_bytes = 3706, + .apat = {6, 30, 58, 86, 114, 142, 170}, + .ecc = {{.bs = 75, .dw = 47, .ns = 18}, {.bs = 148, .dw = 118, .ns = 19}, {.bs = 45, .dw = 15, .ns = 20}, {.bs = 54, .dw = 24, .ns = 34}}}}; diff --git a/ESP32QRReaderDBWriterVideoStreamer/Credentials.h b/ESP32QRReaderDBWriterVideoStreamer/Credentials.h new file mode 100644 index 0000000..a84ee28 --- /dev/null +++ b/ESP32QRReaderDBWriterVideoStreamer/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "cpsNUCwifi"; // your network SSID (name) +char pass[] = "ips999CPS"; // your network password + +char user[] = "db_user"; // MySQL user login username +char password[] = "db_password"; // MySQL user login password + +#endif //Credentials_h diff --git a/ESP32QRReaderDBWriterVideoStreamer/ESP32QRReaderDBWriterVideoStreamer.ino b/ESP32QRReaderDBWriterVideoStreamer/ESP32QRReaderDBWriterVideoStreamer.ino new file mode 100644 index 0000000..b1872cb --- /dev/null +++ b/ESP32QRReaderDBWriterVideoStreamer/ESP32QRReaderDBWriterVideoStreamer.ino @@ -0,0 +1,740 @@ +/* +ESP32-CAM QR code Reader +Author : ChungYi Fu (Kaohsiung, Taiwan) 2021-8-13 20:00 +https://www.facebook.com/francefu + +Refer to the code +https://github.com/alvarowolfx/ESP32QRCodeReader + +自訂指令格式 http://192.168.xxx.xxx/control?cmd=P1;P2;P3;P4;P5;P6;P7;P8;P9 + +http://192.168.xxx.xxx/?ip //取得APIP, STAIP +http://192.168.xxx.xxx/?mac //取得MAC位址 +http://192.168.xxx.xxx/?digitalwrite=pin;value //數位輸出 +http://192.168.xxx.xxx/?analogwrite=pin;value //類比輸出 +http://192.168.xxx.xxx/?digitalread=pin //數位讀取 +http://192.168.xxx.xxx/?analogread=pin //類比讀取 +http://192.168.xxx.xxx/?touchread=pin //觸碰讀取 +http://192.168.xxx.xxx/?restart //重啟電源 +http://192.168.xxx.xxx/?flash=value //閃光燈 value= 0~255 +http://192.168.xxx.xxx/?servo=pin;value //伺服馬達 value= 0~180 +http://192.168.xxx.xxx/?relay=pin;value //繼電器 value = 0, 1 +http://192.168.xxx.xxx/?uart=value //序列埠 +*/ + + +/********* + Rui Santos + Complete project details at https://RandomNerdTutorials.com/esp32-cam-video-streaming-web-server-camera-home-assistant/ + + IMPORTANT!!! + - Select Board "AI Thinker ESP32-CAM" + - GPIO 0 must be connected to GND to upload a sketch + - After connecting GPIO 0 to GND, press the ESP32-CAM on-board RESET button to put your board in flashing mode + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files. + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. +*********/ + + + +// Serial.printf(); kann anscheinend keine Strings ausgeben, die länger als 13 Zeichen sind -> dadurch gehts: Serial.printf("Insertcommand: %s\n:", INSERT_SQL.c_str()); + +#include "esp_camera.h" //視訊函式 +//#include "soc/soc.h" //用於電源不穩不重開機 +#include "soc/rtc_cntl_reg.h" //用於電源不穩不重開機 +#include "quirc.h" + +//Includes&defines etc für den MariaDB Entry ########################################################### +#include "defines.h" +#include "Credentials.h" + + + + + + +#include + +#define USING_HOST_NAME false + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(10, 42, 0, 1); +#endif + +uint16_t server_port = 3306; //5698; + +char default_database[] = "myTestDb"; //"test_arduino"; +char default_table[] = "myTestTable"; //"test_arduino"; + +String default_value = "defaultString"; + +// Sample query +String INSERT_SQL = String("INSERT INTO ") + default_database + "." + default_table + + " (qrCodeText) VALUES ('" + default_value + "')"; + + +#define LED_BUILTIN 4 //die Zeile wird für das LED benötigt + + +MySQL_Connection conn((Client *)&client); + +MySQL_Query *query_mem; +//Includes&defines etc für den MariaDB Entry - ENDE #################################################### + +TaskHandle_t Task; + +//ESP32-CAM 安信可模組腳位設定 +#define PWDN_GPIO_NUM 32 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 0 +#define SIOD_GPIO_NUM 26 +#define SIOC_GPIO_NUM 27 +#define Y9_GPIO_NUM 35 +#define Y8_GPIO_NUM 34 +#define Y7_GPIO_NUM 39 +#define Y6_GPIO_NUM 36 +#define Y5_GPIO_NUM 21 +#define Y4_GPIO_NUM 19 +#define Y3_GPIO_NUM 18 +#define Y2_GPIO_NUM 5 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 23 +#define PCLK_GPIO_NUM 22 + +struct QRCodeData +{ + bool valid; + int dataType; + uint8_t payload[1024]; + int payloadLen; +}; + +struct quirc *q = NULL; +uint8_t *image = NULL; +camera_fb_t * fb = NULL; +struct quirc_code code; +struct quirc_data data; +quirc_decode_error_t err; +struct QRCodeData qrCodeData; +String QRCodeResult = ""; + +camera_config_t config; + + + + + +// Videostreamer - Anfang ################################################ +#include "esp_camera.h" +#include +#include "esp_timer.h" +#include "img_converters.h" +#include "Arduino.h" +#include "fb_gfx.h" +#include "soc/soc.h" //disable brownout problems +#include "soc/rtc_cntl_reg.h" //disable brownout problems +#include "esp_http_server.h" + +//Replace with your network credentials +//const char* ssid = "cpsNUCwifi"; +//const char* pass = "ips999CPS"; + +#define PART_BOUNDARY "123456789000000000000987654321" + +// This project was tested with the AI Thinker Model, M5STACK PSRAM Model and M5STACK WITHOUT PSRAM +#define CAMERA_MODEL_AI_THINKER +//#define CAMERA_MODEL_M5STACK_PSRAM +//#define CAMERA_MODEL_M5STACK_WITHOUT_PSRAM + +// Not tested with this model +//#define CAMERA_MODEL_WROVER_KIT + +#if defined(CAMERA_MODEL_WROVER_KIT) + #define PWDN_GPIO_NUM -1 + #define RESET_GPIO_NUM -1 + #define XCLK_GPIO_NUM 21 + #define SIOD_GPIO_NUM 26 + #define SIOC_GPIO_NUM 27 + + #define Y9_GPIO_NUM 35 + #define Y8_GPIO_NUM 34 + #define Y7_GPIO_NUM 39 + #define Y6_GPIO_NUM 36 + #define Y5_GPIO_NUM 19 + #define Y4_GPIO_NUM 18 + #define Y3_GPIO_NUM 5 + #define Y2_GPIO_NUM 4 + #define VSYNC_GPIO_NUM 25 + #define HREF_GPIO_NUM 23 + #define PCLK_GPIO_NUM 22 + +#elif defined(CAMERA_MODEL_M5STACK_PSRAM) + #define PWDN_GPIO_NUM -1 + #define RESET_GPIO_NUM 15 + #define XCLK_GPIO_NUM 27 + #define SIOD_GPIO_NUM 25 + #define SIOC_GPIO_NUM 23 + + #define Y9_GPIO_NUM 19 + #define Y8_GPIO_NUM 36 + #define Y7_GPIO_NUM 18 + #define Y6_GPIO_NUM 39 + #define Y5_GPIO_NUM 5 + #define Y4_GPIO_NUM 34 + #define Y3_GPIO_NUM 35 + #define Y2_GPIO_NUM 32 + #define VSYNC_GPIO_NUM 22 + #define HREF_GPIO_NUM 26 + #define PCLK_GPIO_NUM 21 + +#elif defined(CAMERA_MODEL_M5STACK_WITHOUT_PSRAM) + #define PWDN_GPIO_NUM -1 + #define RESET_GPIO_NUM 15 + #define XCLK_GPIO_NUM 27 + #define SIOD_GPIO_NUM 25 + #define SIOC_GPIO_NUM 23 + + #define Y9_GPIO_NUM 19 + #define Y8_GPIO_NUM 36 + #define Y7_GPIO_NUM 18 + #define Y6_GPIO_NUM 39 + #define Y5_GPIO_NUM 5 + #define Y4_GPIO_NUM 34 + #define Y3_GPIO_NUM 35 + #define Y2_GPIO_NUM 17 + #define VSYNC_GPIO_NUM 22 + #define HREF_GPIO_NUM 26 + #define PCLK_GPIO_NUM 21 + +#elif defined(CAMERA_MODEL_AI_THINKER) + #define PWDN_GPIO_NUM 32 + #define RESET_GPIO_NUM -1 + #define XCLK_GPIO_NUM 0 + #define SIOD_GPIO_NUM 26 + #define SIOC_GPIO_NUM 27 + + #define Y9_GPIO_NUM 35 + #define Y8_GPIO_NUM 34 + #define Y7_GPIO_NUM 39 + #define Y6_GPIO_NUM 36 + #define Y5_GPIO_NUM 21 + #define Y4_GPIO_NUM 19 + #define Y3_GPIO_NUM 18 + #define Y2_GPIO_NUM 5 + #define VSYNC_GPIO_NUM 25 + #define HREF_GPIO_NUM 23 + #define PCLK_GPIO_NUM 22 +#else + #error "Camera model not selected" +#endif + +static const char* _STREAM_CONTENT_TYPE = "multipart/x-mixed-replace;boundary=" PART_BOUNDARY; +static const char* _STREAM_BOUNDARY = "\r\n--" PART_BOUNDARY "\r\n"; +static const char* _STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %u\r\n\r\n"; + +httpd_handle_t stream_httpd = NULL; + +static esp_err_t stream_handler(httpd_req_t *req){ //wenn via Browser (ip-Adresseingabe) auf den Stream zugegriffen wird, dann wird die Methode aufgerufen + camera_fb_t * fb = NULL; + esp_err_t res = ESP_OK; + size_t _jpg_buf_len = 0; + uint8_t * _jpg_buf = NULL; + char * part_buf[64]; + + res = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE); + if(res != ESP_OK){ + return res; + } + + while(true){ + fb = esp_camera_fb_get(); + if (!fb) { + Serial.println("Camera capture failed"); + res = ESP_FAIL; + } else { + if(fb->width > 400){ + if(fb->format != PIXFORMAT_JPEG){ + bool jpeg_converted = frame2jpg(fb, 80, &_jpg_buf, &_jpg_buf_len); + esp_camera_fb_return(fb); + fb = NULL; + if(!jpeg_converted){ + Serial.println("JPEG compression failed"); + res = ESP_FAIL; + } + } else { + _jpg_buf_len = fb->len; + _jpg_buf = fb->buf; + } + } + } + if(res == ESP_OK){ + size_t hlen = snprintf((char *)part_buf, 64, _STREAM_PART, _jpg_buf_len); + res = httpd_resp_send_chunk(req, (const char *)part_buf, hlen); + } + if(res == ESP_OK){ + res = httpd_resp_send_chunk(req, (const char *)_jpg_buf, _jpg_buf_len); + } + if(res == ESP_OK){ + res = httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY)); + } + if(fb){ + esp_camera_fb_return(fb); + fb = NULL; + _jpg_buf = NULL; + } else if(_jpg_buf){ + free(_jpg_buf); + _jpg_buf = NULL; + } + if(res != ESP_OK){ + break; + } + //Serial.printf("MJPG: %uB\n",(uint32_t)(_jpg_buf_len)); + Serial.println("Ausgabe"); + } + Serial.println("Ausgabe dannach"); + return res; +} + +void startCameraServer(){ + httpd_config_t config = HTTPD_DEFAULT_CONFIG(); + config.server_port = 80; + +Serial.println("davor"); + httpd_uri_t index_uri = { + .uri = "/", + .method = HTTP_GET, + .handler = stream_handler, + .user_ctx = NULL + }; +Serial.println("dannach"); + + //Serial.printf("Starting web server on port: '%d'\n", config.server_port); + if (httpd_start(&stream_httpd, &config) == ESP_OK) { + httpd_register_uri_handler(stream_httpd, &index_uri); + } +} +// Videostreamer ENDE ################################################################### + + + + + +void setup() { + + + WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //關閉電源不穩就重開機的設定 + + Serial.begin(115200); + Serial.setDebugOutput(true); //開啟診斷輸出 + Serial.println(); + + pinMode(LED_BUILTIN, OUTPUT); //die Zeile wird für das LED benötigt + + + + +//Setup für insert in MariaDB ######################################################### + + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Basic_Insert_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // Remember to initialize your WiFi module +#if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #if ( USING_WIFI_ESP8266_AT ) + MYSQL_DISPLAY("Using ESP8266_AT/ESP8266_AT_WebServer Library"); + #elif ( USING_WIFIESPAT_LIB ) + MYSQL_DISPLAY("Using WiFiEspAT Library"); + #endif + + // initialize serial for ESP module + EspSerial.begin(115200); + // initialize ESP module + WiFi.init(&EspSerial); + + MYSQL_DISPLAY(F("WiFi shield init done")); + + // check for the presence of the shield + if (WiFi.status() == WL_NO_SHIELD) + { + MYSQL_DISPLAY(F("WiFi shield not present")); + // don't continue + while (true); + } +#endif + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + + //ESP32-LED Output, dass es nicht mit dem WLAN verbunden ist + digitalWrite(LED_BUILTIN, HIGH); + delay(100); + digitalWrite(LED_BUILTIN, LOW); + delay(1000); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); + + + //ESP32-LED Output, dass es mit dem WLAN verbunden ist + for(int i=0; i<3;i++){ + digitalWrite(LED_BUILTIN, HIGH); + delay(100); + digitalWrite(LED_BUILTIN, LOW); + delay(300); + } + +//Setup für insert in MariaDB - Ende ######################################################### + + +//Setup für den QR-Code Reader ############################################################### + +config.ledc_channel = LEDC_CHANNEL_0; + config.ledc_timer = LEDC_TIMER_0; + config.pin_d0 = Y2_GPIO_NUM; + config.pin_d1 = Y3_GPIO_NUM; + config.pin_d2 = Y4_GPIO_NUM; + config.pin_d3 = Y5_GPIO_NUM; + config.pin_d4 = Y6_GPIO_NUM; + config.pin_d5 = Y7_GPIO_NUM; + config.pin_d6 = Y8_GPIO_NUM; + config.pin_d7 = Y9_GPIO_NUM; + config.pin_xclk = XCLK_GPIO_NUM; + config.pin_pclk = PCLK_GPIO_NUM; + config.pin_vsync = VSYNC_GPIO_NUM; + config.pin_href = HREF_GPIO_NUM; + config.pin_sscb_sda = SIOD_GPIO_NUM; + config.pin_sscb_scl = SIOC_GPIO_NUM; + config.pin_pwdn = PWDN_GPIO_NUM; + config.pin_reset = RESET_GPIO_NUM; + config.xclk_freq_hz = 10000000; // beim QR Reader sind es 10000000 + //config.pixel_format = PIXFORMAT_JPEG; // PIXFORMAT_GRAYSCALE + config.pixel_format = PIXFORMAT_GRAYSCALE; // PIXFORMAT_GRAYSCALE + + config.frame_size = FRAMESIZE_QVGA; + config.jpeg_quality = 15; + config.fb_count = 1; + /* + if(psramFound()){ + config.frame_size = FRAMESIZE_SVGA; // + //config.frame_size = FRAMESIZE_UXGA; // das UXGA Format wirft in Kombination mit anderen Configs errors - FRAMESIZE_QVGA + config.jpeg_quality = 10; //15 + config.fb_count = 2; //1 + //1 + } else { + config.frame_size = FRAMESIZE_SVGA; + config.jpeg_quality = 12; + config.fb_count = 1; + } + */ + + // Camera init + esp_err_t err = esp_camera_init(&config); // wenn der QR-Setup auskommentiert wird, dann muss das einkommentiert werden + if (err != ESP_OK) { + Serial.printf("Camera init failed with error 0x%x", err); + return; + } + + sensor_t * s = esp_camera_sensor_get(); + s->set_framesize(s, FRAMESIZE_VGA); //der FRAMESIZE_QVGA Parameter wurde auf FRAMESIZE_SVGA geändert + + //s->set_vflip(s, 1); //垂直翻轉 + //s->set_hmirror(s, 1); //水平鏡像 + + //閃光燈(GPIO4) + //ledcAttachPin(4, 4); + //ledcSetup(4, 5000, 8); + + + + xTaskCreatePinnedToCore( + QRCodeReader, //Task function. + "Task", // name of task. + 10000, // Stack size of task + NULL, // parameter of the task + 1, // priority of the task + &Task, // Task handle to keep track of created task + 0); // pin task to core 0 + + Serial.print("listenConnection running on core "); + Serial.println(xPortGetCoreID()); +/* */ + +//Setup für den QR-Code Reader ENDE ############################################################### + + + + //Videostreamer Setup Anfang ######################################################################## + //WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector + + //Serial.begin(115200); + //Serial.setDebugOutput(false); + + //Die Konfig wurde in den QR-Code Readerteil kopiert + /* + //camera_config_t config; + config.ledc_channel = LEDC_CHANNEL_0; + config.ledc_timer = LEDC_TIMER_0; + config.pin_d0 = Y2_GPIO_NUM; + config.pin_d1 = Y3_GPIO_NUM; + config.pin_d2 = Y4_GPIO_NUM; + config.pin_d3 = Y5_GPIO_NUM; + config.pin_d4 = Y6_GPIO_NUM; + config.pin_d5 = Y7_GPIO_NUM; + config.pin_d6 = Y8_GPIO_NUM; + config.pin_d7 = Y9_GPIO_NUM; + config.pin_xclk = XCLK_GPIO_NUM; + config.pin_pclk = PCLK_GPIO_NUM; + config.pin_vsync = VSYNC_GPIO_NUM; + config.pin_href = HREF_GPIO_NUM; + config.pin_sscb_sda = SIOD_GPIO_NUM; + config.pin_sscb_scl = SIOC_GPIO_NUM; + config.pin_pwdn = PWDN_GPIO_NUM; + config.pin_reset = RESET_GPIO_NUM; + config.xclk_freq_hz = 20000000; // beim QR Reader sind es 10000000 + //config.pixel_format = PIXFORMAT_JPEG; // PIXFORMAT_GRAYSCALE + config.pixel_format = PIXFORMAT_GRAYSCALE; // PIXFORMAT_GRAYSCALE + + + if(psramFound()){ + config.frame_size = FRAMESIZE_SVGA; // + //config.frame_size = FRAMESIZE_UXGA; // das UXGA Format wirft in Kombination mit anderen Configs errors - FRAMESIZE_QVGA + config.jpeg_quality = 10; //15 + config.fb_count = 2; //1 + //1 + } else { + config.frame_size = FRAMESIZE_SVGA; + config.jpeg_quality = 12; + config.fb_count = 1; + } + + + // Camera init + esp_err_t err = esp_camera_init(&config); // wenn der QR-Setup auskommentiert wird, dann muss das einkommentiert werden + if (err != ESP_OK) { + Serial.printf("Camera init failed with error 0x%x", err); + return; + } + */ + /* + // Wi-Fi connection + WiFi.begin(ssid, pass); + while (WiFi.status() != WL_CONNECTED) { + delay(500); + Serial.print("."); + } + Serial.println(""); + Serial.println("WiFi connected"); + */ + Serial.print("Camera Stream Ready! Go to: http://"); + Serial.print(WiFi.localIP()); + + // Start streaming web server + startCameraServer(); + //Videostreamer Setup ENDE ######################################################################## +} + + + +void ledOutputError(){ + + //ESP32 LED Ausgabe, dass etwas nicht funktioniert hat + digitalWrite(LED_BUILTIN, HIGH); + delay(100); + digitalWrite(LED_BUILTIN, LOW); + delay(100); + digitalWrite(LED_BUILTIN, HIGH); + delay(1000); + digitalWrite(LED_BUILTIN, LOW); + delay(100); + digitalWrite(LED_BUILTIN, HIGH); + delay(100); + digitalWrite(LED_BUILTIN, LOW); + +} + + +//################################################################################### +void runInsert() // MariaDB-Insert-Funktion +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + MYSQL_DISPLAY(INSERT_SQL); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(INSERT_SQL.c_str()) ) + { + MYSQL_DISPLAY("Insert error"); + ledOutputError(); + } + else + { + MYSQL_DISPLAY("Data Inserted."); + + //ESP32 LED Ausgabe, dass etwas inserted wurde + digitalWrite(LED_BUILTIN, HIGH); + delay(1000); + digitalWrite(LED_BUILTIN, LOW); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + ledOutputError(); + } +} + + + +void loop() { + delay(1); +} + + + + + +void charToString(const char *str, String &dbInsertString){ + + dbInsertString = ""; //max Länge 13 Zeichen für eine Ausgabe in Serial.printf + size_t len = strlen(str); + dbInsertString.reserve(len); + + for(size_t i=0;iwidth, fb->height); + image = quirc_begin(q, NULL, NULL); + //Serial.printf("Frame w h len: %d, %d, %d \r\n", fb->width, fb->height, fb->len); + memcpy(image, fb->buf, fb->len); + quirc_end(q); + //Serial.printf("quirc_end\r\n"); + + int count = quirc_count(q); + if (count > 0) { + Serial.println(count); + quirc_extract(q, 0, &code); + err = quirc_decode(&code, &data); + + if (err){ + Serial.println("Decoding FAILED"); + QRCodeResult = "Decoding FAILED"; + } else { + Serial.printf("Decoding successful:\n"); + dumpData(&data); + + //MariaDb-part #################-------------------- + MYSQL_DISPLAY("Connecting..."); + + //Testen des char-Array-String-Konvertierens + //char * str = (char *) &data.payload[0]; + //charToString(str,default_value); + + + + //Der Database-Connect (etc) Teil wirft noch errors + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + + char * str = (char *) &data.payload[0]; //nicht sicher ob man die Umwandlung braucht + charToString(str,default_value); + + INSERT_SQL = String("INSERT INTO ") + default_database + "." + default_table + " (qrCodeText) VALUES ('" + default_value + "')"; + //Serial.printf("Insertcommand: %s\n:", INSERT_SQL.c_str()); + + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + ledOutputError(); + } + + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + delay(2000); //um nicht den gleichen Eintrag sofort doppelt drinnen zu haben + //MariaDb-part-Ende #################-------------------- + + //vTaskDelay(3000/portTICK_RATE_MS); + } + Serial.println(); + } + + + esp_camera_fb_return(fb); + fb = NULL; + image = NULL; + quirc_destroy(q); + } +} + +//############################################################################################### +void dumpData(const struct quirc_data *data) +{ + Serial.printf("Version: %d\n", data->version); + Serial.printf("ECC level: %c\n", "MLHQ"[data->ecc_level]); + Serial.printf("Mask: %d\n", data->mask); + Serial.printf("Length: %d\n", data->payload_len); + Serial.printf("Payload: %s\n", data->payload); + + //QRCodeResult = const_cast(reinterpret_cast(data->payload)); + + //default_value = reinterpret_cast(data.payload); + //Serial.printf("MyTestPayload: %s\n", QRCodeResult); + //Serial.printf("MyTestPayload: %s\n", "testString"); + +} diff --git a/ESP32QRReaderDBWriterVideoStreamer/LICENSE b/ESP32QRReaderDBWriterVideoStreamer/LICENSE new file mode 100644 index 0000000..d47c026 --- /dev/null +++ b/ESP32QRReaderDBWriterVideoStreamer/LICENSE @@ -0,0 +1,16 @@ +quirc -- QR-code recognition library +Copyright (C) 2010-2012 Daniel Beer + +Permission to use, copy, modify, and/or distribute this software for +any purpose with or without fee is hereby granted, provided that the +above copyright notice and this permission notice appear in all +copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR +PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/ESP32QRReaderDBWriterVideoStreamer/README.md b/ESP32QRReaderDBWriterVideoStreamer/README.md new file mode 100644 index 0000000..d70c5c3 --- /dev/null +++ b/ESP32QRReaderDBWriterVideoStreamer/README.md @@ -0,0 +1,193 @@ +Quirc +===== + +QR codes are a type of high-density matrix barcodes, and quirc is a library for +extracting and decoding them from images. It has several features which make it +a good choice for this purpose: + +* It is fast enough to be used with realtime video: extracting and decoding + from VGA frame takes about 50 ms on a modern x86 core. + +* It has a robust and tolerant recognition algorithm. It can correctly + recognise and decode QR codes which are rotated and/or oblique to the camera. + It can also distinguish and decode multiple codes within the same image. + +* It is easy to use, with a simple API described in a single commented header + file (see below for an overview). + +* It is small and easily embeddable, with no dependencies other than standard C + functions. + +* It has a very small memory footprint: one byte per image pixel, plus a few kB + per decoder object. + +* It uses no global mutable state, and is safe to use in a multithreaded + application. + +* BSD-licensed, with almost no restrictions regarding use and/or modification. + +The distribution comes with, in addition to the library, several test programs. +While the core library is very portable, these programs have some additional +dependencies. All of them require libjpeg, and two (`quirc-demo` and `inspect`) +require SDL. The camera demos use Linux-specific APIs: + +### quirc-demo + +This is an real-time demo which requires a camera and a graphical display. The +video stream is displayed on screen as it's received, and any QR codes +recognised are highlighted in the image, with the decoded information both +displayed on the image and printed on stdout. + +### quirc-scanner + +This program turns your camera into a barcode scanner. It's almost the same as +the `demo` application, but it doesn't display the video stream, and thus +doesn't require a graphical display. + +### qrtest + +This test is used to evaluate the performance of library. Given a directory +tree containing a bunch of JPEG images, it will attempt to locate and decode QR +codes in each image. Speed and success statistics are collected and printed on +stdout. + +### inspect + +This test is used for debugging. Given a single JPEG image, it will display a +diagram showing the internal state of the decoder as well as printing +additional information on stdout. + +Installation +------------ +To build the library and associated demos/tests, type `make`. If you need to +decode "large" image files build with `CFLAGS="-DQUIRC_MAX_REGIONS=65534" make` +instead. Note that this will increase the memory usage, it is discouraged for +low resource devices (i.e. embedded). + +Type `make install` to install the library, header file and camera demos. + +You can specify one or several of the following targets if you don't want, or +are unable to build everything: + +* libquirc.a +* libquirc.so +* qrtest +* inspect +* quirc-scanner +* quirc-demo + +Library use +----------- +All of the library's functionality is exposed through a single header file, +which you should include: + +```C +#include +``` + +To decode images, you'll need to instantiate a `struct quirc` object, which is +done with the `quirc_new` function. Later, when you no longer need to decode +anything, you should release the allocated memory with `quirc_destroy`: + +```C +struct quirc *qr; + +qr = quirc_new(); +if (!qr) { + perror("Failed to allocate memory"); + abort(); +} + +/* ... */ + +quirc_destroy(qr); +``` + +Having obtained a decoder object, you need to set the image size that you'll be +working with, which is done using `quirc_resize`: + +```C +if (quirc_resize(qr, 640, 480) < 0) { + perror("Failed to allocate video memory"); + abort(); +} +``` + +`quirc_resize` and `quirc_new` are the only library functions which allocate +memory. If you plan to process a series of frames (or a video stream), you +probably want to allocate and size a single decoder and hold onto it to process +each frame. + +Processing frames is done in two stages. The first stage is an +image-recognition stage called identification, which takes a grayscale image +and searches for QR codes. Using `quirc_begin` and `quirc_end`, you can feed a +grayscale image directly into the buffer that `quirc` uses for image +processing: + +```C +uint8_t *image; +int w, h; + +image = quirc_begin(qr, &w, &h); + +/* Fill out the image buffer here. + * image is a pointer to a w*h bytes. + * One byte per pixel, w pixels per line, h lines in the buffer. + */ + +quirc_end(qr); +``` + +Note that `quirc_begin` simply returns a pointer to a previously allocated +buffer. The buffer will contain uninitialized data. After the call to +`quirc_end`, the decoder holds a list of detected QR codes which can be queried +via `quirc_count` and `quirc_extract`. + +At this point, the second stage of processing occurs -- decoding. This is done +via the call to `quirc_decode`, which is not associated with a decoder object. + +```C +int num_codes; +int i; + +/* We've previously fed an image to the decoder via +* quirc_begin/quirc_end. +*/ + +num_codes = quirc_count(qr); +for (i = 0; i < num_codes; i++) { + struct quirc_code code; + struct quirc_data data; + quirc_decode_error_t err; + + quirc_extract(qr, i, &code); + + /* Decoding stage */ + err = quirc_decode(&code, &data); + if (err) + printf("DECODE FAILED: %s\n", quirc_strerror(err)); + else + printf("Data: %s\n", data.payload); +} +``` + +`quirc_code` and `quirc_data` are flat structures which don't need to be +initialized or freed after use. + +Copyright +--------- +Copyright (C) 2010-2012 Daniel Beer <> + +Permission to use, copy, modify, and/or distribute this software for +any purpose with or without fee is hereby granted, provided that the +above copyright notice and this permission notice appear in all +copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR +PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/ESP32QRReaderDBWriterVideoStreamer/collections.c b/ESP32QRReaderDBWriterVideoStreamer/collections.c new file mode 100644 index 0000000..ea0073d --- /dev/null +++ b/ESP32QRReaderDBWriterVideoStreamer/collections.c @@ -0,0 +1,85 @@ +/* This file is part of the OpenMV project. + * Copyright (c) 2013-2017 Ibrahim Abdelkader & Kwabena W. Agyeman + * This work is licensed under the MIT license, see the file LICENSE for details. + */ + +#include "collections.h" +#define CHAR_BITS (sizeof(char) * 8) +#define CHAR_MASK (CHAR_BITS - 1) +#define CHAR_SHIFT IM_LOG2(CHAR_MASK) + +////////// +// lifo // +////////// + +void lifo_alloc(lifo_t *ptr, size_t size, size_t data_len) +{ + ptr->len = 0; + ptr->size = size; + ptr->data_len = data_len; + ptr->data = (char *)ps_malloc(size * data_len); +} + +void lifo_alloc_all(lifo_t *ptr, size_t *size, size_t data_len) +{ + ptr->data = (char *)ps_malloc(255); + ptr->data_len = data_len; + ptr->size = 255 / data_len; + ptr->len = 0; + *size = ptr->size; +} + +void lifo_free(lifo_t *ptr) +{ + if (ptr->data) + { + free(ptr->data); + } +} + +void lifo_clear(lifo_t *ptr) +{ + ptr->len = 0; +} + +size_t lifo_size(lifo_t *ptr) +{ + return ptr->len; +} + +bool lifo_is_not_empty(lifo_t *ptr) +{ + return ptr->len; +} + +bool lifo_is_not_full(lifo_t *ptr) +{ + return ptr->len != ptr->size; +} + +void lifo_enqueue(lifo_t *ptr, void *data) +{ + memcpy(ptr->data + (ptr->len * ptr->data_len), data, ptr->data_len); + + ptr->len += 1; +} + +void lifo_dequeue(lifo_t *ptr, void *data) +{ + if (data) + { + memcpy(data, ptr->data + ((ptr->len - 1) * ptr->data_len), ptr->data_len); + } + + ptr->len -= 1; +} + +void lifo_poke(lifo_t *ptr, void *data) +{ + memcpy(ptr->data + (ptr->len * ptr->data_len), data, ptr->data_len); +} + +void lifo_peek(lifo_t *ptr, void *data) +{ + memcpy(data, ptr->data + ((ptr->len - 1) * ptr->data_len), ptr->data_len); +} diff --git a/ESP32QRReaderDBWriterVideoStreamer/collections.h b/ESP32QRReaderDBWriterVideoStreamer/collections.h new file mode 100644 index 0000000..711cafa --- /dev/null +++ b/ESP32QRReaderDBWriterVideoStreamer/collections.h @@ -0,0 +1,33 @@ +/* This file is part of the OpenMV project. + * Copyright (c) 2013-2017 Ibrahim Abdelkader & Kwabena W. Agyeman + * This work is licensed under the MIT license, see the file LICENSE for details. + */ + +#ifndef __COLLECTIONS_H__ +#define __COLLECTIONS_H__ +#include +#include +////////// +// lifo // +////////// + +typedef struct lifo +{ + size_t len, size, data_len; + char *data; +} +__attribute__((aligned(8))) lifo_t; + +void lifo_alloc(lifo_t *ptr, size_t size, size_t data_len); +void lifo_alloc_all(lifo_t *ptr, size_t *size, size_t data_len); +void lifo_free(lifo_t *ptr); +void lifo_clear(lifo_t *ptr); +size_t lifo_size(lifo_t *ptr); +bool lifo_is_not_empty(lifo_t *ptr); +bool lifo_is_not_full(lifo_t *ptr); +void lifo_enqueue(lifo_t *ptr, void *data); +void lifo_dequeue(lifo_t *ptr, void *data); +void lifo_poke(lifo_t *ptr, void *data); +void lifo_peek(lifo_t *ptr, void *data); + +#endif /* __COLLECTIONS_H__ */ \ No newline at end of file diff --git a/ESP32QRReaderDBWriterVideoStreamer/decode.c b/ESP32QRReaderDBWriterVideoStreamer/decode.c new file mode 100644 index 0000000..67c8ed5 --- /dev/null +++ b/ESP32QRReaderDBWriterVideoStreamer/decode.c @@ -0,0 +1,983 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "quirc_internal.h" + +#include +#include + +#define MAX_POLY 64 + +/************************************************************************ + * Galois fields + */ + +struct galois_field +{ + int p; + const uint8_t *log; + const uint8_t *exp; +} __attribute__((aligned(8))); + +static const uint8_t gf16_exp[16] = { + 0x01, 0x02, 0x04, 0x08, 0x03, 0x06, 0x0c, 0x0b, + 0x05, 0x0a, 0x07, 0x0e, 0x0f, 0x0d, 0x09, 0x01}; + +static const uint8_t gf16_log[16] = { + 0x00, 0x0f, 0x01, 0x04, 0x02, 0x08, 0x05, 0x0a, + 0x03, 0x0e, 0x09, 0x07, 0x06, 0x0d, 0x0b, 0x0c}; + +static const struct galois_field gf16 = { + .p = 15, + .log = gf16_log, + .exp = gf16_exp}; + +static const uint8_t gf256_exp[256] = { + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, + 0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26, + 0x4c, 0x98, 0x2d, 0x5a, 0xb4, 0x75, 0xea, 0xc9, + 0x8f, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, + 0x9d, 0x27, 0x4e, 0x9c, 0x25, 0x4a, 0x94, 0x35, + 0x6a, 0xd4, 0xb5, 0x77, 0xee, 0xc1, 0x9f, 0x23, + 0x46, 0x8c, 0x05, 0x0a, 0x14, 0x28, 0x50, 0xa0, + 0x5d, 0xba, 0x69, 0xd2, 0xb9, 0x6f, 0xde, 0xa1, + 0x5f, 0xbe, 0x61, 0xc2, 0x99, 0x2f, 0x5e, 0xbc, + 0x65, 0xca, 0x89, 0x0f, 0x1e, 0x3c, 0x78, 0xf0, + 0xfd, 0xe7, 0xd3, 0xbb, 0x6b, 0xd6, 0xb1, 0x7f, + 0xfe, 0xe1, 0xdf, 0xa3, 0x5b, 0xb6, 0x71, 0xe2, + 0xd9, 0xaf, 0x43, 0x86, 0x11, 0x22, 0x44, 0x88, + 0x0d, 0x1a, 0x34, 0x68, 0xd0, 0xbd, 0x67, 0xce, + 0x81, 0x1f, 0x3e, 0x7c, 0xf8, 0xed, 0xc7, 0x93, + 0x3b, 0x76, 0xec, 0xc5, 0x97, 0x33, 0x66, 0xcc, + 0x85, 0x17, 0x2e, 0x5c, 0xb8, 0x6d, 0xda, 0xa9, + 0x4f, 0x9e, 0x21, 0x42, 0x84, 0x15, 0x2a, 0x54, + 0xa8, 0x4d, 0x9a, 0x29, 0x52, 0xa4, 0x55, 0xaa, + 0x49, 0x92, 0x39, 0x72, 0xe4, 0xd5, 0xb7, 0x73, + 0xe6, 0xd1, 0xbf, 0x63, 0xc6, 0x91, 0x3f, 0x7e, + 0xfc, 0xe5, 0xd7, 0xb3, 0x7b, 0xf6, 0xf1, 0xff, + 0xe3, 0xdb, 0xab, 0x4b, 0x96, 0x31, 0x62, 0xc4, + 0x95, 0x37, 0x6e, 0xdc, 0xa5, 0x57, 0xae, 0x41, + 0x82, 0x19, 0x32, 0x64, 0xc8, 0x8d, 0x07, 0x0e, + 0x1c, 0x38, 0x70, 0xe0, 0xdd, 0xa7, 0x53, 0xa6, + 0x51, 0xa2, 0x59, 0xb2, 0x79, 0xf2, 0xf9, 0xef, + 0xc3, 0x9b, 0x2b, 0x56, 0xac, 0x45, 0x8a, 0x09, + 0x12, 0x24, 0x48, 0x90, 0x3d, 0x7a, 0xf4, 0xf5, + 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16, + 0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, + 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x01}; + +static const uint8_t gf256_log[256] = { + 0x00, 0xff, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, + 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b, + 0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, + 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, 0x4c, 0x71, + 0x05, 0x8a, 0x65, 0x2f, 0xe1, 0x24, 0x0f, 0x21, + 0x35, 0x93, 0x8e, 0xda, 0xf0, 0x12, 0x82, 0x45, + 0x1d, 0xb5, 0xc2, 0x7d, 0x6a, 0x27, 0xf9, 0xb9, + 0xc9, 0x9a, 0x09, 0x78, 0x4d, 0xe4, 0x72, 0xa6, + 0x06, 0xbf, 0x8b, 0x62, 0x66, 0xdd, 0x30, 0xfd, + 0xe2, 0x98, 0x25, 0xb3, 0x10, 0x91, 0x22, 0x88, + 0x36, 0xd0, 0x94, 0xce, 0x8f, 0x96, 0xdb, 0xbd, + 0xf1, 0xd2, 0x13, 0x5c, 0x83, 0x38, 0x46, 0x40, + 0x1e, 0x42, 0xb6, 0xa3, 0xc3, 0x48, 0x7e, 0x6e, + 0x6b, 0x3a, 0x28, 0x54, 0xfa, 0x85, 0xba, 0x3d, + 0xca, 0x5e, 0x9b, 0x9f, 0x0a, 0x15, 0x79, 0x2b, + 0x4e, 0xd4, 0xe5, 0xac, 0x73, 0xf3, 0xa7, 0x57, + 0x07, 0x70, 0xc0, 0xf7, 0x8c, 0x80, 0x63, 0x0d, + 0x67, 0x4a, 0xde, 0xed, 0x31, 0xc5, 0xfe, 0x18, + 0xe3, 0xa5, 0x99, 0x77, 0x26, 0xb8, 0xb4, 0x7c, + 0x11, 0x44, 0x92, 0xd9, 0x23, 0x20, 0x89, 0x2e, + 0x37, 0x3f, 0xd1, 0x5b, 0x95, 0xbc, 0xcf, 0xcd, + 0x90, 0x87, 0x97, 0xb2, 0xdc, 0xfc, 0xbe, 0x61, + 0xf2, 0x56, 0xd3, 0xab, 0x14, 0x2a, 0x5d, 0x9e, + 0x84, 0x3c, 0x39, 0x53, 0x47, 0x6d, 0x41, 0xa2, + 0x1f, 0x2d, 0x43, 0xd8, 0xb7, 0x7b, 0xa4, 0x76, + 0xc4, 0x17, 0x49, 0xec, 0x7f, 0x0c, 0x6f, 0xf6, + 0x6c, 0xa1, 0x3b, 0x52, 0x29, 0x9d, 0x55, 0xaa, + 0xfb, 0x60, 0x86, 0xb1, 0xbb, 0xcc, 0x3e, 0x5a, + 0xcb, 0x59, 0x5f, 0xb0, 0x9c, 0xa9, 0xa0, 0x51, + 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7, + 0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, + 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf}; + +const static struct galois_field gf256 = { + .p = 255, + .log = gf256_log, + .exp = gf256_exp}; + +/************************************************************************ + * Polynomial operations + */ + +static void poly_add(uint8_t *dst, const uint8_t *src, uint8_t c, + int shift, const struct galois_field *gf) +{ + int i; + int log_c = gf->log[c]; + + if (!c) + return; + + for (i = 0; i < MAX_POLY; i++) + { + int p = i + shift; + uint8_t v = src[i]; + + if (p < 0 || p >= MAX_POLY) + continue; + if (!v) + continue; + + dst[p] ^= gf->exp[(gf->log[v] + log_c) % gf->p]; + } +} + +static uint8_t poly_eval(const uint8_t *s, uint8_t x, + const struct galois_field *gf) +{ + int i; + uint8_t sum = 0; + uint8_t log_x = gf->log[x]; + + if (!x) + return s[0]; + + for (i = 0; i < MAX_POLY; i++) + { + uint8_t c = s[i]; + + if (!c) + continue; + + sum ^= gf->exp[(gf->log[c] + log_x * i) % gf->p]; + } + + return sum; +} + +/************************************************************************ + * Berlekamp-Massey algorithm for finding error locator polynomials. + */ + +static void berlekamp_massey(const uint8_t *s, int N, + const struct galois_field *gf, + uint8_t *sigma) +{ + uint8_t C[MAX_POLY]; + uint8_t B[MAX_POLY]; + int L = 0; + int m = 1; + uint8_t b = 1; + int n; + + memset(B, 0, sizeof(B)); + memset(C, 0, sizeof(C)); + B[0] = 1; + C[0] = 1; + + for (n = 0; n < N; n++) + { + uint8_t d = s[n]; + uint8_t mult; + int i; + + for (i = 1; i <= L; i++) + { + if (!(C[i] && s[n - i])) + continue; + + d ^= gf->exp[(gf->log[C[i]] + + gf->log[s[n - i]]) % + gf->p]; + } + + mult = gf->exp[(gf->p - gf->log[b] + gf->log[d]) % gf->p]; + + if (!d) + { + m++; + } + else if (L * 2 <= n) + { + uint8_t T[MAX_POLY]; + + memcpy(T, C, sizeof(T)); + poly_add(C, B, mult, m, gf); + memcpy(B, T, sizeof(B)); + L = n + 1 - L; + b = d; + m = 1; + } + else + { + poly_add(C, B, mult, m, gf); + m++; + } + } + + memcpy(sigma, C, MAX_POLY); +} + +/************************************************************************ + * Code stream error correction + * + * Generator polynomial for GF(2^8) is x^8 + x^4 + x^3 + x^2 + 1 + */ + +static int block_syndromes(const uint8_t *data, int bs, int npar, uint8_t *s) +{ + int nonzero = 0; + int i; + + memset(s, 0, MAX_POLY); + + for (i = 0; i < npar; i++) + { + int j; + + for (j = 0; j < bs; j++) + { + uint8_t c = data[bs - j - 1]; + + if (!c) + continue; + + s[i] ^= gf256_exp[((int)gf256_log[c] + + i * j) % + 255]; + } + + if (s[i]) + nonzero = 1; + } + + return nonzero; +} + +static void eloc_poly(uint8_t *omega, + const uint8_t *s, const uint8_t *sigma, + int npar) +{ + int i; + + memset(omega, 0, MAX_POLY); + + for (i = 0; i < npar; i++) + { + const uint8_t a = sigma[i]; + const uint8_t log_a = gf256_log[a]; + int j; + + if (!a) + continue; + + for (j = 0; j + 1 < MAX_POLY; j++) + { + const uint8_t b = s[j + 1]; + + if (i + j >= npar) + break; + + if (!b) + continue; + + omega[i + j] ^= + gf256_exp[(log_a + gf256_log[b]) % 255]; + } + } +} + +static quirc_decode_error_t correct_block(uint8_t *data, + const struct quirc_rs_params *ecc) +{ + int npar = ecc->bs - ecc->dw; + uint8_t s[MAX_POLY]; + uint8_t sigma[MAX_POLY]; + uint8_t sigma_deriv[MAX_POLY]; + uint8_t omega[MAX_POLY]; + int i; + + /* Compute syndrome vector */ + if (!block_syndromes(data, ecc->bs, npar, s)) + return QUIRC_SUCCESS; + + berlekamp_massey(s, npar, &gf256, sigma); + + /* Compute derivative of sigma */ + memset(sigma_deriv, 0, MAX_POLY); + for (i = 0; i + 1 < MAX_POLY; i += 2) + sigma_deriv[i] = sigma[i + 1]; + + /* Compute error evaluator polynomial */ + eloc_poly(omega, s, sigma, npar - 1); + + /* Find error locations and magnitudes */ + for (i = 0; i < ecc->bs; i++) + { + uint8_t xinv = gf256_exp[255 - i]; + + if (!poly_eval(sigma, xinv, &gf256)) + { + uint8_t sd_x = poly_eval(sigma_deriv, xinv, &gf256); + uint8_t omega_x = poly_eval(omega, xinv, &gf256); + uint8_t error = gf256_exp[(255 - gf256_log[sd_x] + + gf256_log[omega_x]) % + 255]; + + data[ecc->bs - i - 1] ^= error; + } + } + + if (block_syndromes(data, ecc->bs, npar, s)) + return QUIRC_ERROR_DATA_ECC; + + return QUIRC_SUCCESS; +} + +/************************************************************************ + * Format value error correction + * + * Generator polynomial for GF(2^4) is x^4 + x + 1 + */ + +#define FORMAT_MAX_ERROR 3 +#define FORMAT_SYNDROMES (FORMAT_MAX_ERROR * 2) +#define FORMAT_BITS 15 + +static int format_syndromes(uint16_t u, uint8_t *s) +{ + int i; + int nonzero = 0; + + memset(s, 0, MAX_POLY); + + for (i = 0; i < FORMAT_SYNDROMES; i++) + { + int j; + + s[i] = 0; + for (j = 0; j < FORMAT_BITS; j++) + if (u & (1 << j)) + s[i] ^= gf16_exp[((i + 1) * j) % 15]; + + if (s[i]) + nonzero = 1; + } + + return nonzero; +} + +static quirc_decode_error_t correct_format(uint16_t *f_ret) +{ + uint16_t u = *f_ret; + int i; + uint8_t s[MAX_POLY]; + uint8_t sigma[MAX_POLY]; + + /* Evaluate U (received codeword) at each of alpha_1 .. alpha_6 + * to get S_1 .. S_6 (but we index them from 0). + */ + if (!format_syndromes(u, s)) + return QUIRC_SUCCESS; + + berlekamp_massey(s, FORMAT_SYNDROMES, &gf16, sigma); + + /* Now, find the roots of the polynomial */ + for (i = 0; i < 15; i++) + if (!poly_eval(sigma, gf16_exp[15 - i], &gf16)) + u ^= (1 << i); + + if (format_syndromes(u, s)) + return QUIRC_ERROR_FORMAT_ECC; + + *f_ret = u; + return QUIRC_SUCCESS; +} + +/************************************************************************ + * Decoder algorithm + */ + +struct datastream +{ + uint8_t raw[QUIRC_MAX_PAYLOAD]; + int data_bits; + int ptr; + + uint8_t data[QUIRC_MAX_PAYLOAD]; +} __attribute__((aligned(8))); + +static inline int grid_bit(const struct quirc_code *code, int x, int y) +{ + int p = y * code->size + x; + + return (code->cell_bitmap[p >> 3] >> (p & 7)) & 1; +} + +static quirc_decode_error_t read_format(const struct quirc_code *code, + struct quirc_data *data, int which) +{ + int i; + uint16_t format = 0; + uint16_t fdata; + quirc_decode_error_t err; + + if (which) + { + for (i = 0; i < 7; i++) + format = (format << 1) | + grid_bit(code, 8, code->size - 1 - i); + for (i = 0; i < 8; i++) + format = (format << 1) | + grid_bit(code, code->size - 8 + i, 8); + } + else + { + static const int xs[15] = { + 8, 8, 8, 8, 8, 8, 8, 8, 7, 5, 4, 3, 2, 1, 0}; + static const int ys[15] = { + 0, 1, 2, 3, 4, 5, 7, 8, 8, 8, 8, 8, 8, 8, 8}; + + for (i = 14; i >= 0; i--) + format = (format << 1) | grid_bit(code, xs[i], ys[i]); + } + + format ^= 0x5412; + + err = correct_format(&format); + if (err) + return err; + + fdata = format >> 10; + data->ecc_level = fdata >> 3; + data->mask = fdata & 7; + + return QUIRC_SUCCESS; +} + +static int mask_bit(int mask, int i, int j) +{ + switch (mask) + { + case 0: + return !((i + j) % 2); + case 1: + return !(i % 2); + case 2: + return !(j % 3); + case 3: + return !((i + j) % 3); + case 4: + return !(((i / 2) + (j / 3)) % 2); + case 5: + return !((i * j) % 2 + (i * j) % 3); + case 6: + return !(((i * j) % 2 + (i * j) % 3) % 2); + case 7: + return !(((i * j) % 3 + (i + j) % 2) % 2); + } + + return 0; +} + +static int reserved_cell(int version, int i, int j) +{ + const struct quirc_version_info *ver = &quirc_version_db[version]; + int size = version * 4 + 17; + int ai = -1, aj = -1, a; + + /* Finder + format: top left */ + if (i < 9 && j < 9) + return 1; + + /* Finder + format: bottom left */ + if (i + 8 >= size && j < 9) + return 1; + + /* Finder + format: top right */ + if (i < 9 && j + 8 >= size) + return 1; + + /* Exclude timing patterns */ + if (i == 6 || j == 6) + return 1; + + /* Exclude version info, if it exists. Version info sits adjacent to + * the top-right and bottom-left finders in three rows, bounded by + * the timing pattern. + */ + if (version >= 7) + { + if (i < 6 && j + 11 >= size) + return 1; + if (i + 11 >= size && j < 6) + return 1; + } + + /* Exclude alignment patterns */ + for (a = 0; a < QUIRC_MAX_ALIGNMENT && ver->apat[a]; a++) + { + int p = ver->apat[a]; + + if (abs(p - i) < 3) + ai = a; + if (abs(p - j) < 3) + aj = a; + } + + if (ai >= 0 && aj >= 0) + { + a--; + if (ai > 0 && ai < a) + return 1; + if (aj > 0 && aj < a) + return 1; + if (aj == a && ai == a) + return 1; + } + + return 0; +} + +static void read_bit(const struct quirc_code *code, + struct quirc_data *data, + struct datastream *ds, int i, int j) +{ + int bitpos = ds->data_bits & 7; + int bytepos = ds->data_bits >> 3; + int v = grid_bit(code, j, i); + + if (mask_bit(data->mask, i, j)) + v ^= 1; + + if (v) + ds->raw[bytepos] |= (0x80 >> bitpos); + + ds->data_bits++; +} + +static void read_data(const struct quirc_code *code, + struct quirc_data *data, + struct datastream *ds) +{ + int y = code->size - 1; + int x = code->size - 1; + int dir = -1; + + while (x > 0) + { + if (x == 6) + x--; + + if (!reserved_cell(data->version, y, x)) + read_bit(code, data, ds, y, x); + + if (!reserved_cell(data->version, y, x - 1)) + read_bit(code, data, ds, y, x - 1); + + y += dir; + if (y < 0 || y >= code->size) + { + dir = -dir; + x -= 2; + y += dir; + } + } +} + +static quirc_decode_error_t codestream_ecc(struct quirc_data *data, + struct datastream *ds) +{ + const struct quirc_version_info *ver = + &quirc_version_db[data->version]; + const struct quirc_rs_params *sb_ecc = &ver->ecc[data->ecc_level]; + struct quirc_rs_params lb_ecc; + const int lb_count = + (ver->data_bytes - sb_ecc->bs * sb_ecc->ns) / (sb_ecc->bs + 1); + const int bc = lb_count + sb_ecc->ns; + const int ecc_offset = sb_ecc->dw * bc + lb_count; + int dst_offset = 0; + int i; + + memcpy(&lb_ecc, sb_ecc, sizeof(lb_ecc)); + lb_ecc.dw++; + lb_ecc.bs++; + + for (i = 0; i < bc; i++) + { + uint8_t *dst = ds->data + dst_offset; + const struct quirc_rs_params *ecc = + (i < sb_ecc->ns) ? sb_ecc : &lb_ecc; + const int num_ec = ecc->bs - ecc->dw; + quirc_decode_error_t err; + int j; + + for (j = 0; j < ecc->dw; j++) + dst[j] = ds->raw[j * bc + i]; + for (j = 0; j < num_ec; j++) + dst[ecc->dw + j] = ds->raw[ecc_offset + j * bc + i]; + + err = correct_block(dst, ecc); + if (err) + return err; + + dst_offset += ecc->dw; + } + + ds->data_bits = dst_offset * 8; + + return QUIRC_SUCCESS; +} + +static inline int bits_remaining(const struct datastream *ds) +{ + return ds->data_bits - ds->ptr; +} + +static int take_bits(struct datastream *ds, int len) +{ + int ret = 0; + + while (len && (ds->ptr < ds->data_bits)) + { + uint8_t b = ds->data[ds->ptr >> 3]; + int bitpos = ds->ptr & 7; + + ret <<= 1; + if ((b << bitpos) & 0x80) + ret |= 1; + + ds->ptr++; + len--; + } + + return ret; +} + +static int numeric_tuple(struct quirc_data *data, + struct datastream *ds, + int bits, int digits) +{ + int tuple; + int i; + + if (bits_remaining(ds) < bits) + return -1; + + tuple = take_bits(ds, bits); + + for (i = digits - 1; i >= 0; i--) + { + data->payload[data->payload_len + i] = tuple % 10 + '0'; + tuple /= 10; + } + + data->payload_len += digits; + return 0; +} + +static quirc_decode_error_t decode_numeric(struct quirc_data *data, + struct datastream *ds) +{ + int bits = 14; + int count; + + if (data->version < 10) + bits = 10; + else if (data->version < 27) + bits = 12; + + count = take_bits(ds, bits); + if (data->payload_len + count + 1 > QUIRC_MAX_PAYLOAD) + return QUIRC_ERROR_DATA_OVERFLOW; + + while (count >= 3) + { + if (numeric_tuple(data, ds, 10, 3) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count -= 3; + } + + if (count >= 2) + { + if (numeric_tuple(data, ds, 7, 2) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count -= 2; + } + + if (count) + { + if (numeric_tuple(data, ds, 4, 1) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count--; + } + + return QUIRC_SUCCESS; +} + +static int alpha_tuple(struct quirc_data *data, + struct datastream *ds, + int bits, int digits) +{ + int tuple; + int i; + + if (bits_remaining(ds) < bits) + return -1; + + tuple = take_bits(ds, bits); + + for (i = 0; i < digits; i++) + { + static const char *alpha_map = + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"; + + data->payload[data->payload_len + digits - i - 1] = + alpha_map[tuple % 45]; + tuple /= 45; + } + + data->payload_len += digits; + return 0; +} + +static quirc_decode_error_t decode_alpha(struct quirc_data *data, + struct datastream *ds) +{ + int bits = 13; + int count; + + if (data->version < 10) + bits = 9; + else if (data->version < 27) + bits = 11; + + count = take_bits(ds, bits); + if (data->payload_len + count + 1 > QUIRC_MAX_PAYLOAD) + return QUIRC_ERROR_DATA_OVERFLOW; + + while (count >= 2) + { + if (alpha_tuple(data, ds, 11, 2) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count -= 2; + } + + if (count) + { + if (alpha_tuple(data, ds, 6, 1) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count--; + } + + return QUIRC_SUCCESS; +} + +static quirc_decode_error_t decode_byte(struct quirc_data *data, + struct datastream *ds) +{ + int bits = 16; + int count; + int i; + + if (data->version < 10) + bits = 8; + + count = take_bits(ds, bits); + if (data->payload_len + count + 1 > QUIRC_MAX_PAYLOAD) + return QUIRC_ERROR_DATA_OVERFLOW; + if (bits_remaining(ds) < count * 8) + return QUIRC_ERROR_DATA_UNDERFLOW; + + for (i = 0; i < count; i++) + data->payload[data->payload_len++] = take_bits(ds, 8); + + return QUIRC_SUCCESS; +} + +static quirc_decode_error_t decode_kanji(struct quirc_data *data, + struct datastream *ds) +{ + int bits = 12; + int count; + int i; + + if (data->version < 10) + bits = 8; + else if (data->version < 27) + bits = 10; + + count = take_bits(ds, bits); + if (data->payload_len + count * 2 + 1 > QUIRC_MAX_PAYLOAD) + return QUIRC_ERROR_DATA_OVERFLOW; + if (bits_remaining(ds) < count * 13) + return QUIRC_ERROR_DATA_UNDERFLOW; + + for (i = 0; i < count; i++) + { + int d = take_bits(ds, 13); + int msB = d / 0xc0; + int lsB = d % 0xc0; + int intermediate = (msB << 8) | lsB; + uint16_t sjw; + + if (intermediate + 0x8140 <= 0x9ffc) + { + /* bytes are in the range 0x8140 to 0x9FFC */ + sjw = intermediate + 0x8140; + } + else + { + /* bytes are in the range 0xE040 to 0xEBBF */ + sjw = intermediate + 0xc140; + } + + data->payload[data->payload_len++] = sjw >> 8; + data->payload[data->payload_len++] = sjw & 0xff; + } + + return QUIRC_SUCCESS; +} + +static quirc_decode_error_t decode_eci(struct quirc_data *data, + struct datastream *ds) +{ + if (bits_remaining(ds) < 8) + return QUIRC_ERROR_DATA_UNDERFLOW; + + data->eci = take_bits(ds, 8); + + if ((data->eci & 0xc0) == 0x80) + { + if (bits_remaining(ds) < 8) + return QUIRC_ERROR_DATA_UNDERFLOW; + + data->eci = (data->eci << 8) | take_bits(ds, 8); + } + else if ((data->eci & 0xe0) == 0xc0) + { + if (bits_remaining(ds) < 16) + return QUIRC_ERROR_DATA_UNDERFLOW; + + data->eci = (data->eci << 16) | take_bits(ds, 16); + } + + return QUIRC_SUCCESS; +} + +static quirc_decode_error_t decode_payload(struct quirc_data *data, + struct datastream *ds) +{ + while (bits_remaining(ds) >= 4) + { + quirc_decode_error_t err = QUIRC_SUCCESS; + int type = take_bits(ds, 4); + + switch (type) + { + case QUIRC_DATA_TYPE_NUMERIC: + err = decode_numeric(data, ds); + break; + + case QUIRC_DATA_TYPE_ALPHA: + err = decode_alpha(data, ds); + break; + + case QUIRC_DATA_TYPE_BYTE: + err = decode_byte(data, ds); + break; + + case QUIRC_DATA_TYPE_KANJI: + err = decode_kanji(data, ds); + break; + + case 7: + err = decode_eci(data, ds); + break; + + default: + goto done; + } + + if (err) + return err; + + if (!(type & (type - 1)) && (type > data->data_type)) + data->data_type = type; + } + +done: + + /* Add nul terminator to all payloads */ + if (data->payload_len >= sizeof(data->payload)) + data->payload_len--; + data->payload[data->payload_len] = 0; + + return QUIRC_SUCCESS; +} + +quirc_decode_error_t quirc_decode(const struct quirc_code *code, + struct quirc_data *data) +{ + quirc_decode_error_t err; + struct datastream *ds = ps_malloc(sizeof(struct datastream)); + + if ((code->size - 17) % 4) + { + free(ds); + return QUIRC_ERROR_INVALID_GRID_SIZE; + } + + memset(data, 0, sizeof(*data)); + memset(ds, 0, sizeof(*ds)); + + data->version = (code->size - 17) / 4; + + if (data->version < 1 || + data->version > QUIRC_MAX_VERSION) + { + free(ds); + return QUIRC_ERROR_INVALID_VERSION; + } + + /* Read format information -- try both locations */ + err = read_format(code, data, 0); + if (err) + err = read_format(code, data, 1); + if (err) + { + free(ds); + return err; + } + + read_data(code, data, ds); + err = codestream_ecc(data, ds); + if (err) + { + free(ds); + return err; + } + + err = decode_payload(data, ds); + if (err) + { + free(ds); + return err; + } + + free(ds); + return QUIRC_SUCCESS; +} \ No newline at end of file diff --git a/ESP32QRReaderDBWriterVideoStreamer/defines.h b/ESP32QRReaderDBWriterVideoStreamer/defines.h new file mode 100644 index 0000000..ed63a72 --- /dev/null +++ b/ESP32QRReaderDBWriterVideoStreamer/defines.h @@ -0,0 +1,381 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define DEBUG_ESP8266_AT_WEBSERVER_PORT Serial + +// Debug Level from 0 to 4 +#define _ESP_AT_LOGLEVEL_ 1 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ! (ESP8266 || ESP32 ) + // Select only one of these libraries, only for boards other than ESP8266/ESP32 + #define USING_WIFI_ESP8266_AT false + #define USING_WIFININA_GENERIC false + #define USING_WIFININA false + #define USING_WIFIESPAT_LIB true + #define USING_WIFI_CUSTOM false +#endif + +#if defined(ARDUINO_SAMD_MKR1000) + #if defined(USE_WIFI_NINA) + #undef USE_WIFI_NINA + #endif + #define USE_WIFI_NINA false + #define USE_WIFI101 true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX + #endif + #define WIFI_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD + #endif + #define WIFI_USE_SAMD true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFI_USE_SAM_DUE) + #undef WIFI_USE_SAM_DUE + #endif + #define WIFI_USE_SAM_DUE true + #warning Use SAM_DUE architecture +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 + #endif + #define WIFI_USE_STM32 true +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFI_USE_RP2040) + #undef WIFI_USE_RP2040 + #endif + #define WIFI_USE_RP2040 true +#endif + +#ifdef CORE_TEENSY + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For Teensy 4.1/4.0 + #define EspSerial Serial2 //Serial2, Pin RX2 : 7, TX2 : 8 + #endif + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" +#endif + +#elif defined(WIFI_USE_NRF528XX) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif defined(WIFI_USE_SAMD) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For SAMD + #define EspSerial Serial1 + #endif + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif defined(WIFI_USE_STM32) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For STM32 + #if defined(ARDUINO_NUCLEO_F767ZI) + #warning Nucleo-144 NUCLEO_F767ZI board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); + #elif defined(ARDUINO_NUCLEO_L053R8) + #warning Nucleo-64 NUCLEO_L053R8 board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); // (PA3, PA2); + #endif + + #warning EspSerial using SERIAL_PORT_HARDWARE, can be Serial or Serial1. See your board variant.h + #define EspSerial SERIAL_PORT_HARDWARE //Serial1 + #endif + + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif (ESP8266) + #warning ESP8266 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif (ESP32) + #warning ESP32 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif defined(WIFI_USE_RP2040) && !defined(ARDUINO_ARCH_MBED) + + // For RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + +#elif defined(WIFI_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + // For MBED RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#else + // For Mega + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #define BOARD_TYPE "AVR Mega" +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +#endif //defines_h diff --git a/ESP32QRReaderDBWriterVideoStreamer/fmath.h b/ESP32QRReaderDBWriterVideoStreamer/fmath.h new file mode 100644 index 0000000..76c3b93 --- /dev/null +++ b/ESP32QRReaderDBWriterVideoStreamer/fmath.h @@ -0,0 +1,70 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * Fast approximate math functions. + * + */ +#ifndef __FMATH_H +#define __FMATH_H +#include +#include + +static inline float fast_sqrtf(float x) +{ + //return sqrtf(x); + asm("fsqrt.s %0, %1" + : "=f"(x) + : "f"(x)); + return x; +} +static inline int fast_floorf(float x) +{ + return (int)(x); +} + +static inline int fast_ceilf(float x) +{ + return (int)(x + 0.9999f); +} + +static inline int fast_roundf(float x) +{ + return (int)(x); +} + +static inline float fast_fabsf(float d) +{ + return fabsf(d); +} + +extern int fast_floorf(float x); +extern int fast_ceilf(float x); +extern int fast_roundf(float x); +extern float fast_atanf(float x); +extern float fast_atan2f(float y, float x); +extern float fast_expf(float x); +extern float fast_cbrtf(float d); +extern float fast_fabsf(float d); +extern float fast_log(float x); +extern float fast_log2(float x); +extern float fast_powf(float a, float b); + +/*#define fast_sqrtf(x) (sqrtf(x)) +#define fast_floorf(x) ((int)floorf(x)) +#define fast_ceilf(x) ((int)ceilf(x)) +#define fast_roundf(x) ((int)roundf(x)) +#define fast_atanf(x) (atanf(x)) +#define fast_atan2f(x,y) (atan2f((x),(y))) +#define fast_expf(x) (expf(x)) +#define fast_cbrtf(x) (cbrtf(x)) +#define fast_fabsf(x) (fabsf(x)) +#define fast_log(x) (log(x)) +#define fast_log2(x) (log2(x)) +#define fast_powf(x,y) (powf((x),(y))) +*/ + +extern const float cos_table[360]; +extern const float sin_table[360]; +#endif // __FMATH_H \ No newline at end of file diff --git a/ESP32QRReaderDBWriterVideoStreamer/identify.c b/ESP32QRReaderDBWriterVideoStreamer/identify.c new file mode 100644 index 0000000..d0d0316 --- /dev/null +++ b/ESP32QRReaderDBWriterVideoStreamer/identify.c @@ -0,0 +1,1286 @@ +/* quirc - QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + +#include "fmath.h" +#include "collections.h" +#include "quirc_internal.h" + +/************************************************************************ + * Linear algebra routines + */ + +static int line_intersect(const struct quirc_point *p0, + const struct quirc_point *p1, + const struct quirc_point *q0, + const struct quirc_point *q1, + struct quirc_point *r) +{ + /* (a, b) is perpendicular to line p */ + int a = -(p1->y - p0->y); + int b = p1->x - p0->x; + + /* (c, d) is perpendicular to line q */ + int c = -(q1->y - q0->y); + int d = q1->x - q0->x; + + /* e and f are dot products of the respective vectors with p and q */ + int e = a * p1->x + b * p1->y; + int f = c * q1->x + d * q1->y; + + /* Now we need to solve: + * [a b] [rx] [e] + * [c d] [ry] = [f] + * + * We do this by inverting the matrix and applying it to (e, f): + * [ d -b] [e] [rx] + * 1/det [-c a] [f] = [ry] + */ + int det = (a * d) - (b * c); + + if (!det) + return 0; + + r->x = (d * e - b * f) / det; + r->y = (-c * e + a * f) / det; + + return 1; +} + +static void perspective_setup(float *c, + const struct quirc_point *rect, + float w, float h) +{ + float x0 = rect[0].x; + float y0 = rect[0].y; + float x1 = rect[1].x; + float y1 = rect[1].y; + float x2 = rect[2].x; + float y2 = rect[2].y; + float x3 = rect[3].x; + float y3 = rect[3].y; + + float wden = w * (x2 * y3 - x3 * y2 + (x3 - x2) * y1 + x1 * (y2 - y3)); + float hden = h * (x2 * y3 + x1 * (y2 - y3) - x3 * y2 + (x3 - x2) * y1); + + c[0] = (x1 * (x2 * y3 - x3 * y2) + x0 * (-x2 * y3 + x3 * y2 + (x2 - x3) * y1) + + x1 * (x3 - x2) * y0) / + wden; + c[1] = -(x0 * (x2 * y3 + x1 * (y2 - y3) - x2 * y1) - x1 * x3 * y2 + x2 * x3 * y1 + (x1 * x3 - x2 * x3) * y0) / hden; + c[2] = x0; + c[3] = (y0 * (x1 * (y3 - y2) - x2 * y3 + x3 * y2) + y1 * (x2 * y3 - x3 * y2) + + x0 * y1 * (y2 - y3)) / + wden; + c[4] = (x0 * (y1 * y3 - y2 * y3) + x1 * y2 * y3 - x2 * y1 * y3 + + y0 * (x3 * y2 - x1 * y2 + (x2 - x3) * y1)) / + hden; + c[5] = y0; + c[6] = (x1 * (y3 - y2) + x0 * (y2 - y3) + (x2 - x3) * y1 + (x3 - x2) * y0) / wden; + c[7] = (-x2 * y3 + x1 * y3 + x3 * y2 + x0 * (y1 - y2) - x3 * y1 + (x2 - x1) * y0) / + hden; +} + +static void perspective_map(const float *c, + float u, float v, struct quirc_point *ret) +{ + float den = c[6] * u + c[7] * v + 1.0; + float x = (c[0] * u + c[1] * v + c[2]) / den; + float y = (c[3] * u + c[4] * v + c[5]) / den; + + ret->x = fast_roundf(x); + ret->y = fast_roundf(y); +} + +static void perspective_unmap(const float *c, + const struct quirc_point *in, + float *u, float *v) +{ + float x = in->x; + float y = in->y; + float den = -c[0] * c[7] * y + c[1] * c[6] * y + (c[3] * c[7] - c[4] * c[6]) * x + + c[0] * c[4] - c[1] * c[3]; + + *u = -(c[1] * (y - c[5]) - c[2] * c[7] * y + (c[5] * c[7] - c[4]) * x + c[2] * c[4]) / + den; + *v = (c[0] * (y - c[5]) - c[2] * c[6] * y + (c[5] * c[6] - c[3]) * x + c[2] * c[3]) / + den; +} + +/************************************************************************ + * Span-based floodfill routine + */ + +typedef void (*span_func_t)(void *user_data, int y, int left, int right); + +typedef struct xylf +{ + int16_t x, y, l, r; +} __attribute__((aligned(8))) +xylf_t; + +//计算该区域的面积,from是像素颜色,to是区块标号,user_data是申请的区块结构体,func是计算面积的函数 +static void flood_fill_seed(struct quirc *q, int x, int y, int from, int to, + span_func_t func, void *user_data, + int depth) +{ + (void)depth; // unused + + lifo_t lifo; + size_t lifo_len; + lifo_alloc_all(&lifo, &lifo_len, sizeof(xylf_t)); + //late in first out. 申请xylf_t的lifo,一次申请完,长度存储在lifo_len中 + + for (;;) + { + int left = x; + int right = x; + int i; + quirc_pixel_t *row = q->pixels + y * q->w; //行起始地址 + //查找左右边界 + while (left > 0 && row[left - 1] == from) + left--; + + while (right < q->w - 1 && row[right + 1] == from) + right++; + + /* Fill the extent 对应像素标记为区块号*/ + for (i = left; i <= right; i++) + row[i] = to; + //累加区域内的像素点数作为面积 + if (func) + func(user_data, y, left, right); + + for (;;) + { + if (lifo_size(&lifo) < lifo_len) + { //栈中的数量 + /* Seed new flood-fills */ + if (y > 0) + { //查找上一行有没有在同一区域的点 + row = q->pixels + (y - 1) * q->w; + + bool recurse = false; + for (i = left; i <= right; i++) + if (row[i] == from) + { //相同区域,则入栈原来的区块 + xylf_t context; + context.x = x; + context.y = y; + context.l = left; + context.r = right; + lifo_enqueue(&lifo, &context); + //mp_printf(&mp_plat_print, "#x=%x,y=%d;x1=%d,y1=%d\n",x,y,i,y-1); + x = i; + y = y - 1; + recurse = true; + break; + } + if (recurse) + break; + } + //查找下一行有没有在同一区域的点 + if (y < q->h - 1) + { + row = q->pixels + (y + 1) * q->w; + + bool recurse = false; + for (i = left; i <= right; i++) + if (row[i] == from) + { + xylf_t context; + context.x = x; + context.y = y; + context.l = left; + context.r = right; + lifo_enqueue(&lifo, &context); + //mp_printf(&mp_plat_print, "#x=%x,y=%d;x1=%d,y1=%d\n",x,y,i,y+1); + x = i; + y = y + 1; + recurse = true; + break; + } + if (recurse) + break; + } + } + + if (!lifo_size(&lifo)) + { + lifo_free(&lifo); //如果最起始为止就没找到,那么返回 + return; + } + //本次迭代,往上,往下找边界(相同颜色像素点),直到找不到为止 + //找到边界后,出栈上层像素点,回退回去 + xylf_t context; + lifo_dequeue(&lifo, &context); //这里存疑,如果都没有的话,dequeue就会反向溢出吧。。 + x = context.x; + y = context.y; + left = context.l; + right = context.r; + //mp_printf(&mp_plat_print, "#deq: x=%x,y=%d\n",x,y); + } //找到相同from,break到这外面 + } +} + +/************************************************************************ + * Adaptive thresholding + */ + +#define THRESHOLD_S_MIN 1 +#define THRESHOLD_S_DEN 8 +#define THRESHOLD_T 5 + +static void threshold(struct quirc *q) +{ + int x, y; + int avg_w = 0; + int avg_u = 0; + int threshold_s = q->w / THRESHOLD_S_DEN; + quirc_pixel_t *row = q->pixels; + + /* + * Ensure a sane, non-zero value for threshold_s. + * + * threshold_s can be zero if the image width is small. We need to avoid + * SIGFPE as it will be used as divisor. + */ + if (threshold_s < THRESHOLD_S_MIN) + threshold_s = THRESHOLD_S_MIN; + + for (y = 0; y < q->h; y++) + { + int row_average[q->w]; + + memset(row_average, 0, sizeof(row_average)); + + for (x = 0; x < q->w; x++) + { + int w, u; + + if (y & 1) + { + w = x; + u = q->w - 1 - x; + } + else + { + w = q->w - 1 - x; + u = x; + } + + avg_w = (avg_w * (threshold_s - 1)) / + threshold_s + + row[w]; + avg_u = (avg_u * (threshold_s - 1)) / + threshold_s + + row[u]; + + row_average[w] += avg_w; + row_average[u] += avg_u; + } + + for (x = 0; x < q->w; x++) + { + if (row[x] < row_average[x] * + (100 - THRESHOLD_T) / (200 * threshold_s)) + row[x] = QUIRC_PIXEL_BLACK; + else + row[x] = QUIRC_PIXEL_WHITE; + } + + row += q->w; + } +} + +static void area_count(void *user_data, int y, int left, int right) +{ + ((struct quirc_region *)user_data)->count += right - left + 1; +} + +static int region_code(struct quirc *q, int x, int y) +{ //region指的是QRcode的区域,成员为区域的坐标,像素面积,是否顶点 + int pixel; + struct quirc_region *box; + int region; + + if (x < 0 || y < 0 || x >= q->w || y >= q->h) + return -1; + + pixel = q->pixels[y * q->w + x]; + //预先判断非正常的像素情况,退出 + if (pixel >= QUIRC_PIXEL_REGION) + return pixel; + + if (pixel == QUIRC_PIXEL_WHITE) + return -1; + + if (q->num_regions >= QUIRC_MAX_REGIONS) + return -1; + //新建一个区域 + region = q->num_regions; + box = &q->regions[q->num_regions++]; + + memset(box, 0, sizeof(*box)); + + box->seed.x = x; + box->seed.y = y; + box->capstone = -1; + //计算该区域的面积 + flood_fill_seed(q, x, y, pixel, region, area_count, box, 0); + + return region; +} + +struct polygon_score_data +{ + struct quirc_point ref; + + int scores[4]; + struct quirc_point *corners; +} __attribute__((aligned(8))); + +static void find_one_corner(void *user_data, int y, int left, int right) +{ + struct polygon_score_data *psd = + (struct polygon_score_data *)user_data; + int xs[2] = {left, right}; + int dy = y - psd->ref.y; + int i; + + for (i = 0; i < 2; i++) + { + int dx = xs[i] - psd->ref.x; + int d = dx * dx + dy * dy; + + if (d > psd->scores[0]) + { + psd->scores[0] = d; + psd->corners[0].x = xs[i]; + psd->corners[0].y = y; + } + } +} + +static void find_other_corners(void *user_data, int y, int left, int right) +{ + struct polygon_score_data *psd = + (struct polygon_score_data *)user_data; + int xs[2] = {left, right}; + int i; + + for (i = 0; i < 2; i++) + { + int up = xs[i] * psd->ref.x + y * psd->ref.y; + int right = xs[i] * -psd->ref.y + y * psd->ref.x; + int scores[4] = {up, right, -up, -right}; + int j; + + for (j = 0; j < 4; j++) + { + if (scores[j] > psd->scores[j]) + { + psd->scores[j] = scores[j]; + psd->corners[j].x = xs[i]; + psd->corners[j].y = y; + } + } + } +} + +static void find_region_corners(struct quirc *q, + int rcode, const struct quirc_point *ref, + struct quirc_point *corners) +{ + struct quirc_region *region = &q->regions[rcode]; + struct polygon_score_data psd; + int i; + + memset(&psd, 0, sizeof(psd)); + psd.corners = corners; + + memcpy(&psd.ref, ref, sizeof(psd.ref)); + psd.scores[0] = -1; + flood_fill_seed(q, region->seed.x, region->seed.y, + rcode, QUIRC_PIXEL_BLACK, + find_one_corner, &psd, 0); + + psd.ref.x = psd.corners[0].x - psd.ref.x; + psd.ref.y = psd.corners[0].y - psd.ref.y; + + for (i = 0; i < 4; i++) + memcpy(&psd.corners[i], ®ion->seed, + sizeof(psd.corners[i])); + + i = region->seed.x * psd.ref.x + region->seed.y * psd.ref.y; + psd.scores[0] = i; + psd.scores[2] = -i; + i = region->seed.x * -psd.ref.y + region->seed.y * psd.ref.x; + psd.scores[1] = i; + psd.scores[3] = -i; + + flood_fill_seed(q, region->seed.x, region->seed.y, + QUIRC_PIXEL_BLACK, rcode, + find_other_corners, &psd, 0); +} + +static void record_capstone(struct quirc *q, int ring, int stone) +{ + struct quirc_region *stone_reg = &q->regions[stone]; + struct quirc_region *ring_reg = &q->regions[ring]; + struct quirc_capstone *capstone; + int cs_index; + + if (q->num_capstones >= QUIRC_MAX_CAPSTONES) + return; + + cs_index = q->num_capstones; + capstone = &q->capstones[q->num_capstones++]; + + memset(capstone, 0, sizeof(*capstone)); + + capstone->qr_grid = -1; + capstone->ring = ring; + capstone->stone = stone; + stone_reg->capstone = cs_index; + ring_reg->capstone = cs_index; + + /* Find the corners of the ring */ + find_region_corners(q, ring, &stone_reg->seed, capstone->corners); + + /* Set up the perspective transform and find the center */ + perspective_setup(capstone->c, capstone->corners, 7.0, 7.0); + perspective_map(capstone->c, 3.5, 3.5, &capstone->center); +} + +static void test_capstone(struct quirc *q, int x, int y, int *pb) +{ + int ring_right = region_code(q, x - pb[4], y); //x-pb[4]是标记环右边的左侧 + int stone = region_code(q, x - pb[4] - pb[3] - pb[2], y); //实心点左侧 + int ring_left = region_code(q, x - pb[4] - pb[3] - pb[2] - pb[1] - pb[0], y); //环左侧 + struct quirc_region *stone_reg; + struct quirc_region *ring_reg; + int ratio; + //以下检测顶点标记是否符合规范,环称为ring,中间称为stone + if (ring_left < 0 || ring_right < 0 || stone < 0) + return; + + /* Left and ring of ring should be connected */ + if (ring_left != ring_right) + return; + + /* Ring should be disconnected from stone */ + if (ring_left == stone) + return; + + stone_reg = &q->regions[stone]; + ring_reg = &q->regions[ring_left]; + + /* Already detected */ + if (stone_reg->capstone >= 0 || ring_reg->capstone >= 0) + return; + + /* Ratio should ideally be 37.5 中间实心点占面积比例应该在37.5%左右*/ + ratio = stone_reg->count * 100 / ring_reg->count; + if (ratio < 10 || ratio > 70) + return; + + record_capstone(q, ring_left, stone); +} + +static void finder_scan(struct quirc *q, int y) +{ + quirc_pixel_t *row = q->pixels + y * q->w; + int x; + int last_color = 0; + int run_length = 0; + int run_count = 0; + int pb[5]; //means QRcode's pixel width + + memset(pb, 0, sizeof(pb)); + for (x = 0; x < q->w; x++) + { + int color = row[x] ? 1 : 0; + + if (x && color != last_color) + { // color is different + memmove(pb, pb + 1, sizeof(pb[0]) * 4); //left move in one data + pb[4] = run_length; //run how many pix to get different color + run_length = 0; + run_count++; //get more than 5 time color jump + + if (!color && run_count >= 5) + { // find the marker of QRcode(three corner's marker) + static int check[5] = {1, 1, 3, 1, 1}; + int avg, err; + int i; + int ok = 1; + + avg = (pb[0] + pb[1] + pb[3] + pb[4]) / 4; + err = avg * 3 / 4; + + for (i = 0; i < 5; i++) + if (pb[i] < check[i] * avg - err || + pb[i] > check[i] * avg + err) + ok = 0; + + if (ok) + test_capstone(q, x, y, pb); + } + } + + run_length++; + last_color = color; + } +} + +static void find_alignment_pattern(struct quirc *q, int index) +{ + struct quirc_grid *qr = &q->grids[index]; + struct quirc_capstone *c0 = &q->capstones[qr->caps[0]]; + struct quirc_capstone *c2 = &q->capstones[qr->caps[2]]; + struct quirc_point a; + struct quirc_point b; + struct quirc_point c; + int size_estimate; + int step_size = 1; + int dir = 0; + float u, v; + + /* Grab our previous estimate of the alignment pattern corner */ + memcpy(&b, &qr->align, sizeof(b)); + + /* Guess another two corners of the alignment pattern so that we + * can estimate its size. + */ + perspective_unmap(c0->c, &b, &u, &v); + perspective_map(c0->c, u, v + 1.0, &a); + perspective_unmap(c2->c, &b, &u, &v); + perspective_map(c2->c, u + 1.0, v, &c); + + size_estimate = abs((a.x - b.x) * -(c.y - b.y) + + (a.y - b.y) * (c.x - b.x)); + + /* Spiral outwards from the estimate point until we find something + * roughly the right size. Don't look too far from the estimate + * point. + */ + while (step_size * step_size < size_estimate * 100) + { + static const int dx_map[] = {1, 0, -1, 0}; + static const int dy_map[] = {0, -1, 0, 1}; + int i; + + for (i = 0; i < step_size; i++) + { + int code = region_code(q, b.x, b.y); + + if (code >= 0) + { + struct quirc_region *reg = &q->regions[code]; + + if (reg->count >= size_estimate / 2 && + reg->count <= size_estimate * 2) + { + qr->align_region = code; + return; + } + } + + b.x += dx_map[dir]; + b.y += dy_map[dir]; + } + + dir = (dir + 1) % 4; + if (!(dir & 1)) + step_size++; + } +} + +static void find_leftmost_to_line(void *user_data, int y, int left, int right) +{ + struct polygon_score_data *psd = + (struct polygon_score_data *)user_data; + int xs[2] = {left, right}; + int i; + + for (i = 0; i < 2; i++) + { + int d = -psd->ref.y * xs[i] + psd->ref.x * y; + + if (d < psd->scores[0]) + { + psd->scores[0] = d; + psd->corners[0].x = xs[i]; + psd->corners[0].y = y; + } + } +} + +/* Do a Bresenham scan from one point to another and count the number + * of black/white transitions. + */ +static int timing_scan(const struct quirc *q, + const struct quirc_point *p0, + const struct quirc_point *p1) +{ + int n = p1->x - p0->x; + int d = p1->y - p0->y; + int x = p0->x; + int y = p0->y; + int *dom, *nondom; + int dom_step; + int nondom_step; + int a = 0; + int i; + int run_length = 0; + int count = 0; + + if (p0->x < 0 || p0->y < 0 || p0->x >= q->w || p0->y >= q->h) + return -1; + if (p1->x < 0 || p1->y < 0 || p1->x >= q->w || p1->y >= q->h) + return -1; + + if (abs(n) > abs(d)) + { + int swap = n; + + n = d; + d = swap; + + dom = &x; + nondom = &y; + } + else + { + dom = &y; + nondom = &x; + } + + if (n < 0) + { + n = -n; + nondom_step = -1; + } + else + { + nondom_step = 1; + } + + if (d < 0) + { + d = -d; + dom_step = -1; + } + else + { + dom_step = 1; + } + + x = p0->x; + y = p0->y; + for (i = 0; i <= d; i++) + { + int pixel; + + if (y < 0 || y >= q->h || x < 0 || x >= q->w) + break; + + pixel = q->pixels[y * q->w + x]; + + if (pixel) + { + if (run_length >= 2) + count++; + run_length = 0; + } + else + { + run_length++; + } + + a += n; + *dom += dom_step; + if (a >= d) + { + *nondom += nondom_step; + a -= d; + } + } + + return count; +} + +/* Try the measure the timing pattern for a given QR code. This does + * not require the global perspective to have been set up, but it + * does require that the capstone corners have been set to their + * canonical rotation. + * + * For each capstone, we find a point in the middle of the ring band + * which is nearest the centre of the code. Using these points, we do + * a horizontal and a vertical timing scan. + */ +static int measure_timing_pattern(struct quirc *q, int index) +{ + struct quirc_grid *qr = &q->grids[index]; + int i; + int scan; + int ver; + int size; + + for (i = 0; i < 3; i++) + { + static const float us[] = {6.5, 6.5, 0.5}; + static const float vs[] = {0.5, 6.5, 6.5}; + struct quirc_capstone *cap = &q->capstones[qr->caps[i]]; + + perspective_map(cap->c, us[i], vs[i], &qr->tpep[i]); + } + + qr->hscan = timing_scan(q, &qr->tpep[1], &qr->tpep[2]); + qr->vscan = timing_scan(q, &qr->tpep[1], &qr->tpep[0]); + + scan = qr->hscan; + if (qr->vscan > scan) + scan = qr->vscan; + + /* If neither scan worked, we can't go any further. */ + if (scan < 0) + return -1; + + /* Choose the nearest allowable grid size */ + size = scan * 2 + 13; + ver = (size - 15) / 4; + qr->grid_size = ver * 4 + 17; + + return 0; +} + +/* Read a cell from a grid using the currently set perspective + * transform. Returns +/- 1 for black/white, 0 for cells which are + * out of image bounds. + */ +static int read_cell(const struct quirc *q, int index, int x, int y) +{ + const struct quirc_grid *qr = &q->grids[index]; + struct quirc_point p; + + perspective_map(qr->c, x + 0.5, y + 0.5, &p); + if (p.y < 0 || p.y >= q->h || p.x < 0 || p.x >= q->w) + return 0; + + return q->pixels[p.y * q->w + p.x] ? 1 : -1; +} + +static int fitness_cell(const struct quirc *q, int index, int x, int y) +{ + const struct quirc_grid *qr = &q->grids[index]; + int score = 0; + int u, v; + + for (v = 0; v < 3; v++) + for (u = 0; u < 3; u++) + { + static const float offsets[] = {0.3, 0.5, 0.7}; + struct quirc_point p; + + perspective_map(qr->c, x + offsets[u], + y + offsets[v], &p); + if (p.y < 0 || p.y >= q->h || p.x < 0 || p.x >= q->w) + continue; + + if (q->pixels[p.y * q->w + p.x]) + score++; + else + score--; + } + + return score; +} + +static int fitness_ring(const struct quirc *q, int index, int cx, int cy, + int radius) +{ + int i; + int score = 0; + + for (i = 0; i < radius * 2; i++) + { + score += fitness_cell(q, index, cx - radius + i, cy - radius); + score += fitness_cell(q, index, cx - radius, cy + radius - i); + score += fitness_cell(q, index, cx + radius, cy - radius + i); + score += fitness_cell(q, index, cx + radius - i, cy + radius); + } + + return score; +} + +static int fitness_apat(const struct quirc *q, int index, int cx, int cy) +{ + return fitness_cell(q, index, cx, cy) - + fitness_ring(q, index, cx, cy, 1) + + fitness_ring(q, index, cx, cy, 2); +} + +static int fitness_capstone(const struct quirc *q, int index, int x, int y) +{ + x += 3; + y += 3; + + return fitness_cell(q, index, x, y) + + fitness_ring(q, index, x, y, 1) - + fitness_ring(q, index, x, y, 2) + + fitness_ring(q, index, x, y, 3); +} + +/* Compute a fitness score for the currently configured perspective + * transform, using the features we expect to find by scanning the + * grid. + */ +static int fitness_all(const struct quirc *q, int index) +{ + const struct quirc_grid *qr = &q->grids[index]; + int version = (qr->grid_size - 17) / 4; + const struct quirc_version_info *info = &quirc_version_db[version]; + int score = 0; + int i, j; + int ap_count; + + /* Check the timing pattern */ + for (i = 0; i < qr->grid_size - 14; i++) + { + int expect = (i & 1) ? 1 : -1; + + score += fitness_cell(q, index, i + 7, 6) * expect; + score += fitness_cell(q, index, 6, i + 7) * expect; + } + + /* Check capstones */ + score += fitness_capstone(q, index, 0, 0); + score += fitness_capstone(q, index, qr->grid_size - 7, 0); + score += fitness_capstone(q, index, 0, qr->grid_size - 7); + + if (version < 0 || version > QUIRC_MAX_VERSION) + return score; + + /* Check alignment patterns */ + ap_count = 0; + while ((ap_count < QUIRC_MAX_ALIGNMENT) && info->apat[ap_count]) + ap_count++; + + for (i = 1; i + 1 < ap_count; i++) + { + score += fitness_apat(q, index, 6, info->apat[i]); + score += fitness_apat(q, index, info->apat[i], 6); + } + + for (i = 1; i < ap_count; i++) + for (j = 1; j < ap_count; j++) + score += fitness_apat(q, index, + info->apat[i], info->apat[j]); + //mp_printf(&mp_plat_print, "##score=%d\n",score); + return score; +} + +static void jiggle_perspective(struct quirc *q, int index) +{ + struct quirc_grid *qr = &q->grids[index]; + int best = fitness_all(q, index); + int pass; + float adjustments[8]; + int i; + + for (i = 0; i < 8; i++) + adjustments[i] = qr->c[i] * 0.02; + + for (pass = 0; pass < 5; pass++) + { + for (i = 0; i < 16; i++) + { + int j = i >> 1; + int test; + float old = qr->c[j]; + float step = adjustments[j]; + float new; + + if (i & 1) + new = old + step; + else + new = old - step; + + qr->c[j] = new; + test = fitness_all(q, index); + + if (test > best) + best = test; + else + qr->c[j] = old; + } + + for (i = 0; i < 8; i++) + adjustments[i] *= 0.5; + } +} + +/* Once the capstones are in place and an alignment point has been + * chosen, we call this function to set up a grid-reading perspective + * transform. + */ +static void setup_qr_perspective(struct quirc *q, int index) +{ + struct quirc_grid *qr = &q->grids[index]; + struct quirc_point rect[4]; + + /* Set up the perspective map for reading the grid */ + memcpy(&rect[0], &q->capstones[qr->caps[1]].corners[0], + sizeof(rect[0])); + memcpy(&rect[1], &q->capstones[qr->caps[2]].corners[0], + sizeof(rect[0])); + memcpy(&rect[2], &qr->align, sizeof(rect[0])); + memcpy(&rect[3], &q->capstones[qr->caps[0]].corners[0], + sizeof(rect[0])); + perspective_setup(qr->c, rect, qr->grid_size - 7, qr->grid_size - 7); + + jiggle_perspective(q, index); +} + +/* Rotate the capstone with so that corner 0 is the leftmost with respect + * to the given reference line. + */ +static void rotate_capstone(struct quirc_capstone *cap, + const struct quirc_point *h0, + const struct quirc_point *hd) +{ + struct quirc_point copy[4]; + int j; + int best = 0; + int best_score = 0; + + for (j = 0; j < 4; j++) + { + struct quirc_point *p = &cap->corners[j]; + int score = (p->x - h0->x) * -hd->y + + (p->y - h0->y) * hd->x; + + if (!j || score < best_score) + { + best = j; + best_score = score; + } + } + + /* Rotate the capstone */ + for (j = 0; j < 4; j++) + memcpy(©[j], &cap->corners[(j + best) % 4], + sizeof(copy[j])); + memcpy(cap->corners, copy, sizeof(cap->corners)); + perspective_setup(cap->c, cap->corners, 7.0, 7.0); +} + +static void record_qr_grid(struct quirc *q, int a, int b, int c) +{ + struct quirc_point h0, hd; + int i; + int qr_index; + struct quirc_grid *qr; + + if (q->num_grids >= QUIRC_MAX_GRIDS) + return; + + /* Construct the hypotenuse line from A to C. B should be to + * the left of this line. + */ + memcpy(&h0, &q->capstones[a].center, sizeof(h0)); + hd.x = q->capstones[c].center.x - q->capstones[a].center.x; + hd.y = q->capstones[c].center.y - q->capstones[a].center.y; + + /* Make sure A-B-C is clockwise */ + if ((q->capstones[b].center.x - h0.x) * -hd.y + + (q->capstones[b].center.y - h0.y) * hd.x > + 0) + { + int swap = a; + + a = c; + c = swap; + hd.x = -hd.x; + hd.y = -hd.y; + } + + /* Record the grid and its components */ + qr_index = q->num_grids; + qr = &q->grids[q->num_grids++]; + + memset(qr, 0, sizeof(*qr)); + qr->caps[0] = a; + qr->caps[1] = b; + qr->caps[2] = c; + qr->align_region = -1; + + /* Rotate each capstone so that corner 0 is top-left with respect + * to the grid. + */ + for (i = 0; i < 3; i++) + { + struct quirc_capstone *cap = &q->capstones[qr->caps[i]]; + + rotate_capstone(cap, &h0, &hd); + cap->qr_grid = qr_index; + } + + /* Check the timing pattern. This doesn't require a perspective + * transform. + */ + if (measure_timing_pattern(q, qr_index) < 0) + goto fail; + + /* Make an estimate based for the alignment pattern based on extending + * lines from capstones A and C. + */ + if (!line_intersect(&q->capstones[a].corners[0], + &q->capstones[a].corners[1], + &q->capstones[c].corners[0], + &q->capstones[c].corners[3], + &qr->align)) + goto fail; + + /* On V2+ grids, we should use the alignment pattern. */ + if (qr->grid_size > 21) + { + /* Try to find the actual location of the alignment pattern. */ + find_alignment_pattern(q, qr_index); + + /* Find the point of the alignment pattern closest to the + * top-left of the QR grid. + */ + if (qr->align_region >= 0) + { + struct polygon_score_data psd; + struct quirc_region *reg = + &q->regions[qr->align_region]; + + /* Start from some point inside the alignment pattern */ + memcpy(&qr->align, ®->seed, sizeof(qr->align)); + + memcpy(&psd.ref, &hd, sizeof(psd.ref)); + psd.corners = &qr->align; + psd.scores[0] = -hd.y * qr->align.x + + hd.x * qr->align.y; + + flood_fill_seed(q, reg->seed.x, reg->seed.y, + qr->align_region, QUIRC_PIXEL_BLACK, + NULL, NULL, 0); + flood_fill_seed(q, reg->seed.x, reg->seed.y, + QUIRC_PIXEL_BLACK, qr->align_region, + find_leftmost_to_line, &psd, 0); + } + } + + setup_qr_perspective(q, qr_index); + return; + +fail: + /* We've been unable to complete setup for this grid. Undo what we've + * recorded and pretend it never happened. + */ + for (i = 0; i < 3; i++) + q->capstones[qr->caps[i]].qr_grid = -1; + q->num_grids--; +} + +struct neighbour +{ + int index; + float distance; +} __attribute__((aligned(8))); + +struct neighbour_list +{ + struct neighbour n[QUIRC_MAX_CAPSTONES]; + int count; +} __attribute__((aligned(8))); + +static void test_neighbours(struct quirc *q, int i, + const struct neighbour_list *hlist, + const struct neighbour_list *vlist) +{ + int j, k; + float best_score = 0.0; + int best_h = -1, best_v = -1; + + /* Test each possible grouping */ + for (j = 0; j < hlist->count; j++) + for (k = 0; k < vlist->count; k++) + { + const struct neighbour *hn = &hlist->n[j]; + const struct neighbour *vn = &vlist->n[k]; + float score = fast_fabsf(1.0 - hn->distance / vn->distance); + + if (score > 2.5) + continue; + + if (best_h < 0 || score < best_score) + { + best_h = hn->index; + best_v = vn->index; + best_score = score; + } + } + + if (best_h < 0 || best_v < 0) + return; + + record_qr_grid(q, best_h, i, best_v); +} + +static void test_grouping(struct quirc *q, int i) +{ + struct quirc_capstone *c1 = &q->capstones[i]; + int j; + struct neighbour_list hlist; + struct neighbour_list vlist; + + if (c1->qr_grid >= 0) + return; + + hlist.count = 0; + vlist.count = 0; + + /* Look for potential neighbours by examining the relative gradients + * from this capstone to others. + */ + for (j = 0; j < q->num_capstones; j++) + { + struct quirc_capstone *c2 = &q->capstones[j]; + float u, v; + + if (i == j || c2->qr_grid >= 0) + continue; + + perspective_unmap(c1->c, &c2->center, &u, &v); + + u = fast_fabsf(u - 3.5); + v = fast_fabsf(v - 3.5); + + if (u < 0.2 * v) + { + struct neighbour *n = &hlist.n[hlist.count++]; + + n->index = j; + n->distance = v; + } + + if (v < 0.2 * u) + { + struct neighbour *n = &vlist.n[vlist.count++]; + + n->index = j; + n->distance = u; + } + } + + if (!(hlist.count && vlist.count)) + return; + + test_neighbours(q, i, &hlist, &vlist); +} + +static void pixels_setup(struct quirc *q) +{ + if (sizeof(*q->image) == sizeof(*q->pixels)) + { + q->pixels = (quirc_pixel_t *)q->image; + } + else + { + int x, y; + for (y = 0; y < q->h; y++) + { + for (x = 0; x < q->w; x++) + { + q->pixels[y * q->w + x] = q->image[y * q->w + x]; + } + } + } +} + +uint8_t *quirc_begin(struct quirc *q, int *w, int *h) +{ + q->num_regions = QUIRC_PIXEL_REGION; + q->num_capstones = 0; + q->num_grids = 0; + + if (w) + *w = q->w; + if (h) + *h = q->h; + + return q->image; +} + +void quirc_end(struct quirc *q) +{ + int i; + pixels_setup(q); + threshold(q); + + for (i = 0; i < q->h; i++) + { + finder_scan(q, i); + } + + for (i = 0; i < q->num_capstones; i++) + { + test_grouping(q, i); + } +} + +void quirc_extract(const struct quirc *q, int index, + struct quirc_code *code) +{ + const struct quirc_grid *qr = &q->grids[index]; + int y; + int i = 0; + + if (index < 0 || index > q->num_grids) + return; + + memset(code, 0, sizeof(*code)); + + perspective_map(qr->c, 0.0, 0.0, &code->corners[0]); + perspective_map(qr->c, qr->grid_size, 0.0, &code->corners[1]); + perspective_map(qr->c, qr->grid_size, qr->grid_size, + &code->corners[2]); + perspective_map(qr->c, 0.0, qr->grid_size, &code->corners[3]); + + code->size = qr->grid_size; + + for (y = 0; y < qr->grid_size; y++) + { + int x; + + for (x = 0; x < qr->grid_size; x++) + { + if (read_cell(q, index, x, y) > 0) + code->cell_bitmap[i >> 3] |= (1 << (i & 7)); + + i++; + } + } +} diff --git a/ESP32QRReaderDBWriterVideoStreamer/quirc.c b/ESP32QRReaderDBWriterVideoStreamer/quirc.c new file mode 100644 index 0000000..e5a30fb --- /dev/null +++ b/ESP32QRReaderDBWriterVideoStreamer/quirc.c @@ -0,0 +1,104 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include "quirc_internal.h" +#include + +const char *quirc_version(void) +{ + return "1.0"; +} + +//static struct quirc _q; +struct quirc *quirc_new(void) +{ + struct quirc *q = ps_malloc(sizeof(*q)); + + if (!q) + return NULL; + + memset(q, 0, sizeof(*q)); + return q; +} + +void quirc_destroy(struct quirc *q) +{ + if (q->image) + if (q->image) + free(q->image); + if (sizeof(*q->image) != sizeof(*q->pixels)) + if (q->pixels) + free(q->pixels); + + if (q) + free(q); +} + +//static quirc_pixel_t img_buf[320*240]; +int quirc_resize(struct quirc *q, int w, int h) +{ + if (q->image) + { + free(q->image); + } + uint8_t *new_image = ps_malloc(w * h); + + if (!new_image) + return -1; + + if (sizeof(*q->image) != sizeof(*q->pixels)) + { //should gray, 1==1 + size_t new_size = w * h * sizeof(quirc_pixel_t); + if (q->pixels) + free(q->pixels); + quirc_pixel_t *new_pixels = ps_malloc(new_size); + if (!new_pixels) + { + free(new_image); + return -1; + } + q->pixels = new_pixels; + } + q->image = new_image; + q->w = w; + q->h = h; + return 0; +} + +int quirc_count(const struct quirc *q) +{ + return q->num_grids; +} + +static const char *const error_table[] = { + [QUIRC_SUCCESS] = "Success", + [QUIRC_ERROR_INVALID_GRID_SIZE] = "Invalid grid size", + [QUIRC_ERROR_INVALID_VERSION] = "Invalid version", + [QUIRC_ERROR_FORMAT_ECC] = "Format data ECC failure", + [QUIRC_ERROR_DATA_ECC] = "ECC failure", + [QUIRC_ERROR_UNKNOWN_DATA_TYPE] = "Unknown data type", + [QUIRC_ERROR_DATA_OVERFLOW] = "Data overflow", + [QUIRC_ERROR_DATA_UNDERFLOW] = "Data underflow"}; + +const char *quirc_strerror(quirc_decode_error_t err) +{ + if (err >= 0 && err < sizeof(error_table) / sizeof(error_table[0])) + return error_table[err]; + + return "Unknown error"; +} diff --git a/ESP32QRReaderDBWriterVideoStreamer/quirc.h b/ESP32QRReaderDBWriterVideoStreamer/quirc.h new file mode 100644 index 0000000..ecdc172 --- /dev/null +++ b/ESP32QRReaderDBWriterVideoStreamer/quirc.h @@ -0,0 +1,178 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef QUIRC_H_ +#define QUIRC_H_ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + struct quirc; + + /* Obtain the library version string. */ + const char *quirc_version(void); + + /* Construct a new QR-code recognizer. This function will return NULL + * if sufficient memory could not be allocated. + */ + struct quirc *quirc_new(void); + + /* Destroy a QR-code recognizer. */ + void quirc_destroy(struct quirc *q); + + /* Resize the QR-code recognizer. The size of an image must be + * specified before codes can be analyzed. + * + * This function returns 0 on success, or -1 if sufficient memory could + * not be allocated. + */ + int quirc_resize(struct quirc *q, int w, int h); + + /* These functions are used to process images for QR-code recognition. + * quirc_begin() must first be called to obtain access to a buffer into + * which the input image should be placed. Optionally, the current + * width and height may be returned. + * + * After filling the buffer, quirc_end() should be called to process + * the image for QR-code recognition. The locations and content of each + * code may be obtained using accessor functions described below. + */ + uint8_t *quirc_begin(struct quirc *q, int *w, int *h); + void quirc_end(struct quirc *q); + + /* This structure describes a location in the input image buffer. */ + struct quirc_point + { + int x; + int y; + } __attribute__((aligned(8))); + + /* This enum describes the various decoder errors which may occur. */ + typedef enum + { + QUIRC_SUCCESS = 0, + QUIRC_ERROR_INVALID_GRID_SIZE, + QUIRC_ERROR_INVALID_VERSION, + QUIRC_ERROR_FORMAT_ECC, + QUIRC_ERROR_DATA_ECC, + QUIRC_ERROR_UNKNOWN_DATA_TYPE, + QUIRC_ERROR_DATA_OVERFLOW, + QUIRC_ERROR_DATA_UNDERFLOW + } quirc_decode_error_t; + + /* Return a string error message for an error code. */ + const char *quirc_strerror(quirc_decode_error_t err); + +/* Limits on the maximum size of QR-codes and their content. */ +#define QUIRC_MAX_BITMAP 3917 +#define QUIRC_MAX_PAYLOAD 8896 + +/* QR-code ECC types. */ +#define QUIRC_ECC_LEVEL_M 0 +#define QUIRC_ECC_LEVEL_L 1 +#define QUIRC_ECC_LEVEL_H 2 +#define QUIRC_ECC_LEVEL_Q 3 + +/* QR-code data types. */ +#define QUIRC_DATA_TYPE_NUMERIC 1 +#define QUIRC_DATA_TYPE_ALPHA 2 +#define QUIRC_DATA_TYPE_BYTE 4 +#define QUIRC_DATA_TYPE_KANJI 8 + +/* Common character encodings */ +#define QUIRC_ECI_ISO_8859_1 1 +#define QUIRC_ECI_IBM437 2 +#define QUIRC_ECI_ISO_8859_2 4 +#define QUIRC_ECI_ISO_8859_3 5 +#define QUIRC_ECI_ISO_8859_4 6 +#define QUIRC_ECI_ISO_8859_5 7 +#define QUIRC_ECI_ISO_8859_6 8 +#define QUIRC_ECI_ISO_8859_7 9 +#define QUIRC_ECI_ISO_8859_8 10 +#define QUIRC_ECI_ISO_8859_9 11 +#define QUIRC_ECI_WINDOWS_874 13 +#define QUIRC_ECI_ISO_8859_13 15 +#define QUIRC_ECI_ISO_8859_15 17 +#define QUIRC_ECI_SHIFT_JIS 20 +#define QUIRC_ECI_UTF_8 26 + + /* This structure is used to return information about detected QR codes + * in the input image. + */ + struct quirc_code + { + /* The four corners of the QR-code, from top left, clockwise */ + struct quirc_point corners[4]; + + /* The number of cells across in the QR-code. The cell bitmap + * is a bitmask giving the actual values of cells. If the cell + * at (x, y) is black, then the following bit is set: + * + * cell_bitmap[i >> 3] & (1 << (i & 7)) + * + * where i = (y * size) + x. + */ + int size; + uint8_t cell_bitmap[QUIRC_MAX_BITMAP]; + } __attribute__((aligned(8))); + + /* This structure holds the decoded QR-code data */ + struct quirc_data + { + /* Various parameters of the QR-code. These can mostly be + * ignored if you only care about the data. + */ + int version; + int ecc_level; + int mask; + + /* This field is the highest-valued data type found in the QR + * code. + */ + int data_type; + + /* Data payload. For the Kanji datatype, payload is encoded as + * Shift-JIS. For all other datatypes, payload is ASCII text. + */ + uint8_t payload[QUIRC_MAX_PAYLOAD]; + int payload_len; + + /* ECI assignment number */ + uint32_t eci; + } __attribute__((aligned(8))); + + /* Return the number of QR-codes identified in the last processed + * image. + */ + int quirc_count(const struct quirc *q); + + /* Extract the QR-code specified by the given index. */ + void quirc_extract(const struct quirc *q, int index, + struct quirc_code *code); + + /* Decode a QR-code, returning the payload data. */ + quirc_decode_error_t quirc_decode(const struct quirc_code *code, + struct quirc_data *data); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/ESP32QRReaderDBWriterVideoStreamer/quirc_internal.h b/ESP32QRReaderDBWriterVideoStreamer/quirc_internal.h new file mode 100644 index 0000000..3fa075c --- /dev/null +++ b/ESP32QRReaderDBWriterVideoStreamer/quirc_internal.h @@ -0,0 +1,121 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef QUIRC_INTERNAL_H_ +#define QUIRC_INTERNAL_H_ + +#include "quirc.h" + +#define QUIRC_PIXEL_WHITE 0 +#define QUIRC_PIXEL_BLACK 1 +#define QUIRC_PIXEL_REGION 2 + +#ifndef QUIRC_MAX_REGIONS +#define QUIRC_MAX_REGIONS 254 +#endif + +#define QUIRC_MAX_CAPSTONES 32 +#define QUIRC_MAX_GRIDS 8 + +#define QUIRC_PERSPECTIVE_PARAMS 8 + +#if QUIRC_MAX_REGIONS < UINT8_MAX +typedef uint8_t quirc_pixel_t; +#elif QUIRC_MAX_REGIONS < UINT16_MAX +typedef uint16_t quirc_pixel_t; +#else +#error "QUIRC_MAX_REGIONS > 65534 is not supported" +#endif + +struct quirc_region +{ + struct quirc_point seed; + int count; + int capstone; +} __attribute__((aligned(8))); + +struct quirc_capstone +{ + int ring; + int stone; + + struct quirc_point corners[4]; + struct quirc_point center; + float c[QUIRC_PERSPECTIVE_PARAMS]; + + int qr_grid; +} __attribute__((aligned(8))); + +struct quirc_grid +{ + /* Capstone indices */ + int caps[3]; + + /* Alignment pattern region and corner */ + int align_region; + struct quirc_point align; + + /* Timing pattern endpoints */ + struct quirc_point tpep[3]; + int hscan; + int vscan; + + /* Grid size and perspective transform */ + int grid_size; + float c[QUIRC_PERSPECTIVE_PARAMS]; +} __attribute__((aligned(8))); + +struct quirc +{ + uint8_t *image; + quirc_pixel_t *pixels; + int w; + int h; + + int num_regions; + struct quirc_region regions[QUIRC_MAX_REGIONS]; + + int num_capstones; + struct quirc_capstone capstones[QUIRC_MAX_CAPSTONES]; + + int num_grids; + struct quirc_grid grids[QUIRC_MAX_GRIDS]; +} __attribute__((aligned(8))); + +/************************************************************************ + * QR-code version information database + */ + +#define QUIRC_MAX_VERSION 40 +#define QUIRC_MAX_ALIGNMENT 7 + +struct quirc_rs_params +{ + uint8_t bs; /* Small block size */ + uint8_t dw; /* Small data words */ + uint8_t ns; /* Number of small blocks */ +} __attribute__((aligned(8))); + +struct quirc_version_info +{ + uint16_t data_bytes; + uint8_t apat[QUIRC_MAX_ALIGNMENT]; + struct quirc_rs_params ecc[4]; +} __attribute__((aligned(8))); + +extern const struct quirc_version_info quirc_version_db[QUIRC_MAX_VERSION + 1]; + +#endif \ No newline at end of file diff --git a/ESP32QRReaderDBWriterVideoStreamer/version_db.c b/ESP32QRReaderDBWriterVideoStreamer/version_db.c new file mode 100644 index 0000000..0da2d07 --- /dev/null +++ b/ESP32QRReaderDBWriterVideoStreamer/version_db.c @@ -0,0 +1,184 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "quirc_internal.h" + +const struct quirc_version_info quirc_version_db[QUIRC_MAX_VERSION + 1] = { + {0}, + {/* Version 1 */ + .data_bytes = 26, + .apat = {0}, + .ecc = { + {.bs = 26, .dw = 16, .ns = 1}, + {.bs = 26, .dw = 19, .ns = 1}, + {.bs = 26, .dw = 9, .ns = 1}, + {.bs = 26, .dw = 13, .ns = 1}}}, + {/* Version 2 */ + .data_bytes = 44, + .apat = {6, 18, 0}, + .ecc = {{.bs = 44, .dw = 28, .ns = 1}, {.bs = 44, .dw = 34, .ns = 1}, {.bs = 44, .dw = 16, .ns = 1}, {.bs = 44, .dw = 22, .ns = 1}}}, + {/* Version 3 */ + .data_bytes = 70, + .apat = {6, 22, 0}, + .ecc = {{.bs = 70, .dw = 44, .ns = 1}, {.bs = 70, .dw = 55, .ns = 1}, {.bs = 35, .dw = 13, .ns = 2}, {.bs = 35, .dw = 17, .ns = 2}}}, + {/* Version 4 */ + .data_bytes = 100, + .apat = {6, 26, 0}, + .ecc = {{.bs = 50, .dw = 32, .ns = 2}, {.bs = 100, .dw = 80, .ns = 1}, {.bs = 25, .dw = 9, .ns = 4}, {.bs = 50, .dw = 24, .ns = 2}}}, + {/* Version 5 */ + .data_bytes = 134, + .apat = {6, 30, 0}, + .ecc = {{.bs = 67, .dw = 43, .ns = 2}, {.bs = 134, .dw = 108, .ns = 1}, {.bs = 33, .dw = 11, .ns = 2}, {.bs = 33, .dw = 15, .ns = 2}}}, + {/* Version 6 */ + .data_bytes = 172, + .apat = {6, 34, 0}, + .ecc = {{.bs = 43, .dw = 27, .ns = 4}, {.bs = 86, .dw = 68, .ns = 2}, {.bs = 43, .dw = 15, .ns = 4}, {.bs = 43, .dw = 19, .ns = 4}}}, + {/* Version 7 */ + .data_bytes = 196, + .apat = {6, 22, 38, 0}, + .ecc = {{.bs = 49, .dw = 31, .ns = 4}, {.bs = 98, .dw = 78, .ns = 2}, {.bs = 39, .dw = 13, .ns = 4}, {.bs = 32, .dw = 14, .ns = 2}}}, + {/* Version 8 */ + .data_bytes = 242, + .apat = {6, 24, 42, 0}, + .ecc = {{.bs = 60, .dw = 38, .ns = 2}, {.bs = 121, .dw = 97, .ns = 2}, {.bs = 40, .dw = 14, .ns = 4}, {.bs = 40, .dw = 18, .ns = 4}}}, + {/* Version 9 */ + .data_bytes = 292, + .apat = {6, 26, 46, 0}, + .ecc = {{.bs = 58, .dw = 36, .ns = 3}, {.bs = 146, .dw = 116, .ns = 2}, {.bs = 36, .dw = 12, .ns = 4}, {.bs = 36, .dw = 16, .ns = 4}}}, + {/* Version 10 */ + .data_bytes = 346, + .apat = {6, 28, 50, 0}, + .ecc = {{.bs = 69, .dw = 43, .ns = 4}, {.bs = 86, .dw = 68, .ns = 2}, {.bs = 43, .dw = 15, .ns = 6}, {.bs = 43, .dw = 19, .ns = 6}}}, + {/* Version 11 */ + .data_bytes = 404, + .apat = {6, 30, 54, 0}, + .ecc = {{.bs = 80, .dw = 50, .ns = 1}, {.bs = 101, .dw = 81, .ns = 4}, {.bs = 36, .dw = 12, .ns = 3}, {.bs = 50, .dw = 22, .ns = 4}}}, + {/* Version 12 */ + .data_bytes = 466, + .apat = {6, 32, 58, 0}, + .ecc = {{.bs = 58, .dw = 36, .ns = 6}, {.bs = 116, .dw = 92, .ns = 2}, {.bs = 42, .dw = 14, .ns = 7}, {.bs = 46, .dw = 20, .ns = 4}}}, + {/* Version 13 */ + .data_bytes = 532, + .apat = {6, 34, 62, 0}, + .ecc = {{.bs = 59, .dw = 37, .ns = 8}, {.bs = 133, .dw = 107, .ns = 4}, {.bs = 33, .dw = 11, .ns = 12}, {.bs = 44, .dw = 20, .ns = 8}}}, + {/* Version 14 */ + .data_bytes = 581, + .apat = {6, 26, 46, 66, 0}, + .ecc = {{.bs = 64, .dw = 40, .ns = 4}, {.bs = 145, .dw = 115, .ns = 3}, {.bs = 36, .dw = 12, .ns = 11}, {.bs = 36, .dw = 16, .ns = 11}}}, + {/* Version 15 */ + .data_bytes = 655, + .apat = {6, 26, 48, 70, 0}, + .ecc = {{.bs = 65, .dw = 41, .ns = 5}, {.bs = 109, .dw = 87, .ns = 5}, {.bs = 36, .dw = 12, .ns = 11}, {.bs = 54, .dw = 24, .ns = 5}}}, + {/* Version 16 */ + .data_bytes = 733, + .apat = {6, 26, 50, 74, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 7}, {.bs = 122, .dw = 98, .ns = 5}, {.bs = 45, .dw = 15, .ns = 3}, {.bs = 43, .dw = 19, .ns = 15}}}, + {/* Version 17 */ + .data_bytes = 815, + .apat = {6, 30, 54, 78, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 10}, {.bs = 135, .dw = 107, .ns = 1}, {.bs = 42, .dw = 14, .ns = 2}, {.bs = 50, .dw = 22, .ns = 1}}}, + {/* Version 18 */ + .data_bytes = 901, + .apat = {6, 30, 56, 82, 0}, + .ecc = {{.bs = 69, .dw = 43, .ns = 9}, {.bs = 150, .dw = 120, .ns = 5}, {.bs = 42, .dw = 14, .ns = 2}, {.bs = 50, .dw = 22, .ns = 17}}}, + {/* Version 19 */ + .data_bytes = 991, + .apat = {6, 30, 58, 86, 0}, + .ecc = {{.bs = 70, .dw = 44, .ns = 3}, {.bs = 141, .dw = 113, .ns = 3}, {.bs = 39, .dw = 13, .ns = 9}, {.bs = 47, .dw = 21, .ns = 17}}}, + {/* Version 20 */ + .data_bytes = 1085, + .apat = {6, 34, 62, 90, 0}, + .ecc = {{.bs = 67, .dw = 41, .ns = 3}, {.bs = 135, .dw = 107, .ns = 3}, {.bs = 43, .dw = 15, .ns = 15}, {.bs = 54, .dw = 24, .ns = 15}}}, + {/* Version 21 */ + .data_bytes = 1156, + .apat = {6, 28, 50, 72, 92, 0}, + .ecc = {{.bs = 68, .dw = 42, .ns = 17}, {.bs = 144, .dw = 116, .ns = 4}, {.bs = 46, .dw = 16, .ns = 19}, {.bs = 50, .dw = 22, .ns = 17}}}, + {/* Version 22 */ + .data_bytes = 1258, + .apat = {6, 26, 50, 74, 98, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 17}, {.bs = 139, .dw = 111, .ns = 2}, {.bs = 37, .dw = 13, .ns = 34}, {.bs = 54, .dw = 24, .ns = 7}}}, + {/* Version 23 */ + .data_bytes = 1364, + .apat = {6, 30, 54, 78, 102, 0}, + .ecc = {{.bs = 75, .dw = 47, .ns = 4}, {.bs = 151, .dw = 121, .ns = 4}, {.bs = 45, .dw = 15, .ns = 16}, {.bs = 54, .dw = 24, .ns = 11}}}, + {/* Version 24 */ + .data_bytes = 1474, + .apat = {6, 28, 54, 80, 106, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 6}, {.bs = 147, .dw = 117, .ns = 6}, {.bs = 46, .dw = 16, .ns = 30}, {.bs = 54, .dw = 24, .ns = 11}}}, + {/* Version 25 */ + .data_bytes = 1588, + .apat = {6, 32, 58, 84, 110, 0}, + .ecc = {{.bs = 75, .dw = 47, .ns = 8}, {.bs = 132, .dw = 106, .ns = 8}, {.bs = 45, .dw = 15, .ns = 22}, {.bs = 54, .dw = 24, .ns = 7}}}, + {/* Version 26 */ + .data_bytes = 1706, + .apat = {6, 30, 58, 86, 114, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 19}, {.bs = 142, .dw = 114, .ns = 10}, {.bs = 46, .dw = 16, .ns = 33}, {.bs = 50, .dw = 22, .ns = 28}}}, + {/* Version 27 */ + .data_bytes = 1828, + .apat = {6, 34, 62, 90, 118, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 22}, {.bs = 152, .dw = 122, .ns = 8}, {.bs = 45, .dw = 15, .ns = 12}, {.bs = 53, .dw = 23, .ns = 8}}}, + {/* Version 28 */ + .data_bytes = 1921, + .apat = {6, 26, 50, 74, 98, 122, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 3}, {.bs = 147, .dw = 117, .ns = 3}, {.bs = 45, .dw = 15, .ns = 11}, {.bs = 54, .dw = 24, .ns = 4}}}, + {/* Version 29 */ + .data_bytes = 2051, + .apat = {6, 30, 54, 78, 102, 126, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 21}, {.bs = 146, .dw = 116, .ns = 7}, {.bs = 45, .dw = 15, .ns = 19}, {.bs = 53, .dw = 23, .ns = 1}}}, + {/* Version 30 */ + .data_bytes = 2185, + .apat = {6, 26, 52, 78, 104, 130, 0}, + .ecc = {{.bs = 75, .dw = 47, .ns = 19}, {.bs = 145, .dw = 115, .ns = 5}, {.bs = 45, .dw = 15, .ns = 23}, {.bs = 54, .dw = 24, .ns = 15}}}, + {/* Version 31 */ + .data_bytes = 2323, + .apat = {6, 30, 56, 82, 108, 134, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 2}, {.bs = 145, .dw = 115, .ns = 13}, {.bs = 45, .dw = 15, .ns = 23}, {.bs = 54, .dw = 24, .ns = 42}}}, + {/* Version 32 */ + .data_bytes = 2465, + .apat = {6, 34, 60, 86, 112, 138, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 10}, {.bs = 145, .dw = 115, .ns = 17}, {.bs = 45, .dw = 15, .ns = 19}, {.bs = 54, .dw = 24, .ns = 10}}}, + {/* Version 33 */ + .data_bytes = 2611, + .apat = {6, 30, 58, 86, 114, 142, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 14}, {.bs = 145, .dw = 115, .ns = 17}, {.bs = 45, .dw = 15, .ns = 11}, {.bs = 54, .dw = 24, .ns = 29}}}, + {/* Version 34 */ + .data_bytes = 2761, + .apat = {6, 34, 62, 90, 118, 146, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 14}, {.bs = 145, .dw = 115, .ns = 13}, {.bs = 46, .dw = 16, .ns = 59}, {.bs = 54, .dw = 24, .ns = 44}}}, + {/* Version 35 */ + .data_bytes = 2876, + .apat = {6, 30, 54, 78, 102, 126, 150}, + .ecc = {{.bs = 75, .dw = 47, .ns = 12}, {.bs = 151, .dw = 121, .ns = 12}, {.bs = 45, .dw = 15, .ns = 22}, {.bs = 54, .dw = 24, .ns = 39}}}, + {/* Version 36 */ + .data_bytes = 3034, + .apat = {6, 24, 50, 76, 102, 128, 154}, + .ecc = {{.bs = 75, .dw = 47, .ns = 6}, {.bs = 151, .dw = 121, .ns = 6}, {.bs = 45, .dw = 15, .ns = 2}, {.bs = 54, .dw = 24, .ns = 46}}}, + {/* Version 37 */ + .data_bytes = 3196, + .apat = {6, 28, 54, 80, 106, 132, 158}, + .ecc = {{.bs = 74, .dw = 46, .ns = 29}, {.bs = 152, .dw = 122, .ns = 17}, {.bs = 45, .dw = 15, .ns = 24}, {.bs = 54, .dw = 24, .ns = 49}}}, + {/* Version 38 */ + .data_bytes = 3362, + .apat = {6, 32, 58, 84, 110, 136, 162}, + .ecc = {{.bs = 74, .dw = 46, .ns = 13}, {.bs = 152, .dw = 122, .ns = 4}, {.bs = 45, .dw = 15, .ns = 42}, {.bs = 54, .dw = 24, .ns = 48}}}, + {/* Version 39 */ + .data_bytes = 3532, + .apat = {6, 26, 54, 82, 110, 138, 166}, + .ecc = {{.bs = 75, .dw = 47, .ns = 40}, {.bs = 147, .dw = 117, .ns = 20}, {.bs = 45, .dw = 15, .ns = 10}, {.bs = 54, .dw = 24, .ns = 43}}}, + {/* Version 40 */ + .data_bytes = 3706, + .apat = {6, 30, 58, 86, 114, 142, 170}, + .ecc = {{.bs = 75, .dw = 47, .ns = 18}, {.bs = 148, .dw = 118, .ns = 19}, {.bs = 45, .dw = 15, .ns = 20}, {.bs = 54, .dw = 24, .ns = 34}}}}; diff --git a/ESP32_VideoStreamer/ESP32_VideoStreamer.ino b/ESP32_VideoStreamer/ESP32_VideoStreamer.ino new file mode 100644 index 0000000..a054d84 --- /dev/null +++ b/ESP32_VideoStreamer/ESP32_VideoStreamer.ino @@ -0,0 +1,266 @@ +/********* + Rui Santos + Complete project details at https://RandomNerdTutorials.com/esp32-cam-video-streaming-web-server-camera-home-assistant/ + + IMPORTANT!!! + - Select Board "AI Thinker ESP32-CAM" + - GPIO 0 must be connected to GND to upload a sketch + - After connecting GPIO 0 to GND, press the ESP32-CAM on-board RESET button to put your board in flashing mode + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files. + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. +*********/ + +#include "esp_camera.h" +#include +#include "esp_timer.h" +#include "img_converters.h" +#include "Arduino.h" +#include "fb_gfx.h" +#include "soc/soc.h" //disable brownout problems +#include "soc/rtc_cntl_reg.h" //disable brownout problems +#include "esp_http_server.h" + +//Replace with your network credentials +const char* ssid = "cpsNUCwifi"; +const char* password = "ips999CPS"; + +#define PART_BOUNDARY "123456789000000000000987654321" + +// This project was tested with the AI Thinker Model, M5STACK PSRAM Model and M5STACK WITHOUT PSRAM +#define CAMERA_MODEL_AI_THINKER +//#define CAMERA_MODEL_M5STACK_PSRAM +//#define CAMERA_MODEL_M5STACK_WITHOUT_PSRAM + +// Not tested with this model +//#define CAMERA_MODEL_WROVER_KIT + +#if defined(CAMERA_MODEL_WROVER_KIT) + #define PWDN_GPIO_NUM -1 + #define RESET_GPIO_NUM -1 + #define XCLK_GPIO_NUM 21 + #define SIOD_GPIO_NUM 26 + #define SIOC_GPIO_NUM 27 + + #define Y9_GPIO_NUM 35 + #define Y8_GPIO_NUM 34 + #define Y7_GPIO_NUM 39 + #define Y6_GPIO_NUM 36 + #define Y5_GPIO_NUM 19 + #define Y4_GPIO_NUM 18 + #define Y3_GPIO_NUM 5 + #define Y2_GPIO_NUM 4 + #define VSYNC_GPIO_NUM 25 + #define HREF_GPIO_NUM 23 + #define PCLK_GPIO_NUM 22 + +#elif defined(CAMERA_MODEL_M5STACK_PSRAM) + #define PWDN_GPIO_NUM -1 + #define RESET_GPIO_NUM 15 + #define XCLK_GPIO_NUM 27 + #define SIOD_GPIO_NUM 25 + #define SIOC_GPIO_NUM 23 + + #define Y9_GPIO_NUM 19 + #define Y8_GPIO_NUM 36 + #define Y7_GPIO_NUM 18 + #define Y6_GPIO_NUM 39 + #define Y5_GPIO_NUM 5 + #define Y4_GPIO_NUM 34 + #define Y3_GPIO_NUM 35 + #define Y2_GPIO_NUM 32 + #define VSYNC_GPIO_NUM 22 + #define HREF_GPIO_NUM 26 + #define PCLK_GPIO_NUM 21 + +#elif defined(CAMERA_MODEL_M5STACK_WITHOUT_PSRAM) + #define PWDN_GPIO_NUM -1 + #define RESET_GPIO_NUM 15 + #define XCLK_GPIO_NUM 27 + #define SIOD_GPIO_NUM 25 + #define SIOC_GPIO_NUM 23 + + #define Y9_GPIO_NUM 19 + #define Y8_GPIO_NUM 36 + #define Y7_GPIO_NUM 18 + #define Y6_GPIO_NUM 39 + #define Y5_GPIO_NUM 5 + #define Y4_GPIO_NUM 34 + #define Y3_GPIO_NUM 35 + #define Y2_GPIO_NUM 17 + #define VSYNC_GPIO_NUM 22 + #define HREF_GPIO_NUM 26 + #define PCLK_GPIO_NUM 21 + +#elif defined(CAMERA_MODEL_AI_THINKER) + #define PWDN_GPIO_NUM 32 + #define RESET_GPIO_NUM -1 + #define XCLK_GPIO_NUM 0 + #define SIOD_GPIO_NUM 26 + #define SIOC_GPIO_NUM 27 + + #define Y9_GPIO_NUM 35 + #define Y8_GPIO_NUM 34 + #define Y7_GPIO_NUM 39 + #define Y6_GPIO_NUM 36 + #define Y5_GPIO_NUM 21 + #define Y4_GPIO_NUM 19 + #define Y3_GPIO_NUM 18 + #define Y2_GPIO_NUM 5 + #define VSYNC_GPIO_NUM 25 + #define HREF_GPIO_NUM 23 + #define PCLK_GPIO_NUM 22 +#else + #error "Camera model not selected" +#endif + +static const char* _STREAM_CONTENT_TYPE = "multipart/x-mixed-replace;boundary=" PART_BOUNDARY; +static const char* _STREAM_BOUNDARY = "\r\n--" PART_BOUNDARY "\r\n"; +static const char* _STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %u\r\n\r\n"; + +httpd_handle_t stream_httpd = NULL; + +static esp_err_t stream_handler(httpd_req_t *req){ //wenn via Browser (ip-Adresseingabe) auf den Stream zugegriffen wird, dann wird die Methode aufgerufen + camera_fb_t * fb = NULL; + esp_err_t res = ESP_OK; + size_t _jpg_buf_len = 0; + uint8_t * _jpg_buf = NULL; + char * part_buf[64]; + + res = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE); + if(res != ESP_OK){ + return res; + } + + while(true){ + fb = esp_camera_fb_get(); + if (!fb) { + Serial.println("Camera capture failed"); + res = ESP_FAIL; + } else { + if(fb->width > 400){ + if(fb->format != PIXFORMAT_JPEG){ + bool jpeg_converted = frame2jpg(fb, 80, &_jpg_buf, &_jpg_buf_len); + esp_camera_fb_return(fb); + fb = NULL; + if(!jpeg_converted){ + Serial.println("JPEG compression failed"); + res = ESP_FAIL; + } + } else { + _jpg_buf_len = fb->len; + _jpg_buf = fb->buf; + } + } + } + if(res == ESP_OK){ + size_t hlen = snprintf((char *)part_buf, 64, _STREAM_PART, _jpg_buf_len); + res = httpd_resp_send_chunk(req, (const char *)part_buf, hlen); + } + if(res == ESP_OK){ + res = httpd_resp_send_chunk(req, (const char *)_jpg_buf, _jpg_buf_len); + } + if(res == ESP_OK){ + res = httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY)); + } + if(fb){ + esp_camera_fb_return(fb); + fb = NULL; + _jpg_buf = NULL; + } else if(_jpg_buf){ + free(_jpg_buf); + _jpg_buf = NULL; + } + if(res != ESP_OK){ + break; + } + //Serial.printf("MJPG: %uB\n",(uint32_t)(_jpg_buf_len)); + } + return res; +} + +void startCameraServer(){ + httpd_config_t config = HTTPD_DEFAULT_CONFIG(); + config.server_port = 80; + + httpd_uri_t index_uri = { + .uri = "/", + .method = HTTP_GET, + .handler = stream_handler, + .user_ctx = NULL + }; + + //Serial.printf("Starting web server on port: '%d'\n", config.server_port); + if (httpd_start(&stream_httpd, &config) == ESP_OK) { + httpd_register_uri_handler(stream_httpd, &index_uri); + } +} + +void setup() { + WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector + + Serial.begin(115200); + Serial.setDebugOutput(false); + + camera_config_t config; + config.ledc_channel = LEDC_CHANNEL_0; + config.ledc_timer = LEDC_TIMER_0; + config.pin_d0 = Y2_GPIO_NUM; + config.pin_d1 = Y3_GPIO_NUM; + config.pin_d2 = Y4_GPIO_NUM; + config.pin_d3 = Y5_GPIO_NUM; + config.pin_d4 = Y6_GPIO_NUM; + config.pin_d5 = Y7_GPIO_NUM; + config.pin_d6 = Y8_GPIO_NUM; + config.pin_d7 = Y9_GPIO_NUM; + config.pin_xclk = XCLK_GPIO_NUM; + config.pin_pclk = PCLK_GPIO_NUM; + config.pin_vsync = VSYNC_GPIO_NUM; + config.pin_href = HREF_GPIO_NUM; + config.pin_sscb_sda = SIOD_GPIO_NUM; + config.pin_sscb_scl = SIOC_GPIO_NUM; + config.pin_pwdn = PWDN_GPIO_NUM; + config.pin_reset = RESET_GPIO_NUM; + config.xclk_freq_hz = 20000000; + config.pixel_format = PIXFORMAT_JPEG; + + if(psramFound()){ + config.frame_size = FRAMESIZE_UXGA; + config.jpeg_quality = 10; + config.fb_count = 2; + } else { + config.frame_size = FRAMESIZE_SVGA; + config.jpeg_quality = 12; + config.fb_count = 1; + } + + // Camera init + esp_err_t err = esp_camera_init(&config); + if (err != ESP_OK) { + Serial.printf("Camera init failed with error 0x%x", err); + return; + } + // Wi-Fi connection + //WiFi.begin(ssid, password); + WiFi.begin(ssid); + + while (WiFi.status() != WL_CONNECTED) { + delay(500); + Serial.print("."); + } + Serial.println(""); + Serial.println("WiFi connected"); + + Serial.print("Camera Stream Ready! Go to: http://"); + Serial.print(WiFi.localIP()); + + // Start streaming web server + startCameraServer(); +} + +void loop() { + delay(1); +} diff --git a/libraries/ESP32QRCodeReader_Page_original/ESP32QRCodeReader_Page.ino b/libraries/ESP32QRCodeReader_Page_original/ESP32QRCodeReader_Page.ino new file mode 100644 index 0000000..a7b889a --- /dev/null +++ b/libraries/ESP32QRCodeReader_Page_original/ESP32QRCodeReader_Page.ino @@ -0,0 +1,583 @@ +/* +ESP32-CAM QR code Reader +Author : ChungYi Fu (Kaohsiung, Taiwan) 2021-8-13 20:00 +https://www.facebook.com/francefu + +Refer to the code +https://github.com/alvarowolfx/ESP32QRCodeReader + +自訂指令格式 http://192.168.xxx.xxx/control?cmd=P1;P2;P3;P4;P5;P6;P7;P8;P9 + +http://192.168.xxx.xxx/?ip //取得APIP, STAIP +http://192.168.xxx.xxx/?mac //取得MAC位址 +http://192.168.xxx.xxx/?digitalwrite=pin;value //數位輸出 +http://192.168.xxx.xxx/?analogwrite=pin;value //類比輸出 +http://192.168.xxx.xxx/?digitalread=pin //數位讀取 +http://192.168.xxx.xxx/?analogread=pin //類比讀取 +http://192.168.xxx.xxx/?touchread=pin //觸碰讀取 +http://192.168.xxx.xxx/?restart //重啟電源 +http://192.168.xxx.xxx/?flash=value //閃光燈 value= 0~255 +http://192.168.xxx.xxx/?servo=pin;value //伺服馬達 value= 0~180 +http://192.168.xxx.xxx/?relay=pin;value //繼電器 value = 0, 1 +http://192.168.xxx.xxx/?uart=value //序列埠 +*/ + +//輸入WIFI連線帳號密碼 +const char* ssid = "*****"; +const char* password = "*****"; + +//輸入AP端連線帳號密碼 http://192.168.4.1 +const char* apssid = "esp32-cam"; +const char* appassword = "12345678"; //AP密碼至少要8個字元以上 + +String Feedback=""; //回傳客戶端訊息 +//指令參數值 +String Command="",cmd="",P1="",P2="",P3="",P4="",P5="",P6="",P7="",P8="",P9=""; +//指令拆解狀態值 +byte ReceiveState=0,cmdState=1,strState=1,questionstate=0,equalstate=0,semicolonstate=0; + +#include +#include "esp_camera.h" //視訊函式 +#include "soc/soc.h" //用於電源不穩不重開機 +#include "soc/rtc_cntl_reg.h" //用於電源不穩不重開機 +#include "quirc.h" + +TaskHandle_t Task; + +//ESP32-CAM 安信可模組腳位設定 +#define PWDN_GPIO_NUM 32 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 0 +#define SIOD_GPIO_NUM 26 +#define SIOC_GPIO_NUM 27 +#define Y9_GPIO_NUM 35 +#define Y8_GPIO_NUM 34 +#define Y7_GPIO_NUM 39 +#define Y6_GPIO_NUM 36 +#define Y5_GPIO_NUM 21 +#define Y4_GPIO_NUM 19 +#define Y3_GPIO_NUM 18 +#define Y2_GPIO_NUM 5 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 23 +#define PCLK_GPIO_NUM 22 + +struct QRCodeData +{ + bool valid; + int dataType; + uint8_t payload[1024]; + int payloadLen; +}; + +struct quirc *q = NULL; +uint8_t *image = NULL; +camera_fb_t * fb = NULL; +struct quirc_code code; +struct quirc_data data; +quirc_decode_error_t err; +struct QRCodeData qrCodeData; +String QRCodeResult = ""; + +WiFiServer server(80); +WiFiClient client; + +camera_config_t config; + +void setup() { + WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //關閉電源不穩就重開機的設定 + + Serial.begin(115200); + Serial.setDebugOutput(true); //開啟診斷輸出 + Serial.println(); + +//視訊組態設定 https://github.com/espressif/esp32-camera/blob/master/driver/include/esp_camera.h + config.ledc_channel = LEDC_CHANNEL_0; + config.ledc_timer = LEDC_TIMER_0; + config.pin_d0 = Y2_GPIO_NUM; + config.pin_d1 = Y3_GPIO_NUM; + config.pin_d2 = Y4_GPIO_NUM; + config.pin_d3 = Y5_GPIO_NUM; + config.pin_d4 = Y6_GPIO_NUM; + config.pin_d5 = Y7_GPIO_NUM; + config.pin_d6 = Y8_GPIO_NUM; + config.pin_d7 = Y9_GPIO_NUM; + config.pin_xclk = XCLK_GPIO_NUM; + config.pin_pclk = PCLK_GPIO_NUM; + config.pin_vsync = VSYNC_GPIO_NUM; + config.pin_href = HREF_GPIO_NUM; + config.pin_sscb_sda = SIOD_GPIO_NUM; + config.pin_sscb_scl = SIOC_GPIO_NUM; + config.pin_pwdn = PWDN_GPIO_NUM; + config.pin_reset = RESET_GPIO_NUM; + config.xclk_freq_hz = 10000000; + config.pixel_format = PIXFORMAT_GRAYSCALE; + config.frame_size = FRAMESIZE_QVGA; + config.jpeg_quality = 15; + config.fb_count = 1; + + //視訊初始化 + esp_err_t err = esp_camera_init(&config); + if (err != ESP_OK) { + Serial.printf("Camera init failed with error 0x%x", err); + ESP.restart(); + } + + sensor_t * s = esp_camera_sensor_get(); + s->set_framesize(s, FRAMESIZE_QVGA); + + //s->set_vflip(s, 1); //垂直翻轉 + //s->set_hmirror(s, 1); //水平鏡像 + + //閃光燈(GPIO4) + ledcAttachPin(4, 4); + ledcSetup(4, 5000, 8); + + WiFi.mode(WIFI_AP_STA); //其他模式 WiFi.mode(WIFI_AP); WiFi.mode(WIFI_STA); + + //指定Client端靜態IP + //WiFi.config(IPAddress(192, 168, 201, 100), IPAddress(192, 168, 201, 2), IPAddress(255, 255, 255, 0)); + + for (int i=0;i<2;i++) { + WiFi.begin(ssid, password); //執行網路連線 + + delay(1000); + Serial.println(""); + Serial.print("Connecting to "); + Serial.println(ssid); + + long int StartTime=millis(); + while (WiFi.status() != WL_CONNECTED) { + delay(500); + if ((StartTime+5000) < millis()) break; //等待10秒連線 + } + + if (WiFi.status() == WL_CONNECTED) { //若連線成功 + WiFi.softAP((WiFi.localIP().toString()+"_"+(String)apssid).c_str(), appassword); //設定SSID顯示客戶端IP + Serial.println(""); + Serial.println("STAIP address: "); + Serial.println(WiFi.localIP()); + Serial.println(""); + + for (int i=0;i<5;i++) { //若連上WIFI設定閃光燈快速閃爍 + ledcWrite(4,10); + delay(200); + ledcWrite(4,0); + delay(200); + } + break; + } + } + + if (WiFi.status() != WL_CONNECTED) { //若連線失敗 + WiFi.softAP((WiFi.softAPIP().toString()+"_"+(String)apssid).c_str(), appassword); + + for (int i=0;i<2;i++) { //若連不上WIFI設定閃光燈慢速閃爍 + ledcWrite(4,10); + delay(1000); + ledcWrite(4,0); + delay(1000); + } + } + + //指定AP端IP + //WiFi.softAPConfig(IPAddress(192, 168, 4, 1), IPAddress(192, 168, 4, 1), IPAddress(255, 255, 255, 0)); + Serial.println(""); + Serial.println("APIP address: "); + Serial.println(WiFi.softAPIP()); + Serial.println(""); + + //設定閃光燈為低電位 + pinMode(4, OUTPUT); + digitalWrite(4, LOW); + + server.begin(); + + xTaskCreatePinnedToCore( + QRCodeReader, /* Task function. */ + "Task", /* name of task. */ + 10000, /* Stack size of task */ + NULL, /* parameter of the task */ + 1, /* priority of the task */ + &Task, /* Task handle to keep track of created task */ + 0); /* pin task to core 0 */ + + Serial.print("listenConnection running on core "); + Serial.println(xPortGetCoreID()); +} + +void loop() { + listenConnection(); +} + +void QRCodeReader( void * pvParameters ){ + Serial.print("QRCodeReader running on core "); + Serial.println(xPortGetCoreID()); + + while(1){ + q = quirc_new(); + if (q == NULL){ + Serial.print("can't create quirc object\r\n"); + continue; + } + + fb = esp_camera_fb_get(); + if (!fb) + { + Serial.println("Camera capture failed"); + continue; + } + + //Serial.printf("quirc_begin\r\n"); + quirc_resize(q, fb->width, fb->height); + image = quirc_begin(q, NULL, NULL); + //Serial.printf("Frame w h len: %d, %d, %d \r\n", fb->width, fb->height, fb->len); + memcpy(image, fb->buf, fb->len); + quirc_end(q); + //Serial.printf("quirc_end\r\n"); + + int count = quirc_count(q); + if (count > 0) { + Serial.println(count); + quirc_extract(q, 0, &code); + err = quirc_decode(&code, &data); + + if (err){ + Serial.println("Decoding FAILED"); + QRCodeResult = "Decoding FAILED"; + } else { + Serial.printf("Decoding successful:\n"); + dumpData(&data); + /* + qrCodeData.dataType = data.data_type; + for (int j = 0; j < data.payload_len; j++) + { + qrCodeData.payload[j] = data.payload[j]; + } + qrCodeData.valid = true; + qrCodeData.payload[data.payload_len] = '\0'; + qrCodeData.payloadLen = data.payload_len; + */ + //vTaskDelay(3000/portTICK_RATE_MS); + } + Serial.println(); + } + + esp_camera_fb_return(fb); + fb = NULL; + image = NULL; + quirc_destroy(q); + } +} + +void dumpData(const struct quirc_data *data) +{ + Serial.printf("Version: %d\n", data->version); + Serial.printf("ECC level: %c\n", "MLHQ"[data->ecc_level]); + Serial.printf("Mask: %d\n", data->mask); + Serial.printf("Length: %d\n", data->payload_len); + Serial.printf("Payload: %s\n", data->payload); + + QRCodeResult = (const char *)data->payload; +} + +//執行自訂指令 +void ExecuteCommand() { + //Serial.println(""); + //Serial.println("Command: "+Command); + if (cmd!="getstill") { + Serial.println("cmd= "+cmd+" ,P1= "+P1+" ,P2= "+P2+" ,P3= "+P3+" ,P4= "+P4+" ,P5= "+P5+" ,P6= "+P6+" ,P7= "+P7+" ,P8= "+P8+" ,P9= "+P9); + Serial.println(""); + } + + //自訂指令區塊 http://192.168.xxx.xxx?cmd=P1;P2;P3;P4;P5;P6;P7;P8;P9 + if (cmd=="your cmd") { + // You can do anything + // Feedback="Hello World"; //可為一般文字或HTML語法 + } + else if (cmd=="ip") { //查詢APIP, STAIP + Feedback="AP IP: "+WiFi.softAPIP().toString(); + Feedback+="
"; + Feedback+="STA IP: "+WiFi.localIP().toString(); + } + else if (cmd=="mac") { //查詢MAC位址 + Feedback="STA MAC: "+WiFi.macAddress(); + } + else if (cmd=="restart") { //重設WIFI連線 + ESP.restart(); + } + else if (cmd=="digitalwrite") { //數位輸出 + ledcDetachPin(P1.toInt()); + pinMode(P1.toInt(), OUTPUT); + digitalWrite(P1.toInt(), P2.toInt()); + } + else if (cmd=="digitalread") { //數位輸入 + Feedback=String(digitalRead(P1.toInt())); + } + else if (cmd=="analogwrite") { //類比輸出 + if (P1=="4") { + ledcAttachPin(4, 4); + ledcSetup(4, 5000, 8); + ledcWrite(4,P2.toInt()); + } + else { + ledcAttachPin(P1.toInt(), 9); + ledcSetup(9, 5000, 8); + ledcWrite(9,P2.toInt()); + } + } + else if (cmd=="analogread") { //類比讀取 + Feedback=String(analogRead(P1.toInt())); + } + else if (cmd=="touchread") { //觸碰讀取 + Feedback=String(touchRead(P1.toInt())); + } + else if (cmd=="framesize") { //解析度 + sensor_t * s = esp_camera_sensor_get(); + int val = P1.toInt(); + s->set_framesize(s, (framesize_t)val); + } + else if (cmd=="quality") { //畫質 + sensor_t * s = esp_camera_sensor_get(); + int val = P1.toInt(); + s->set_quality(s, val); + } + else if (cmd=="contrast") { //對比 + sensor_t * s = esp_camera_sensor_get(); + int val = P1.toInt(); + s->set_contrast(s, val); + } + else if (cmd=="brightness") { //亮度 + sensor_t * s = esp_camera_sensor_get(); + int val = P1.toInt(); + s->set_brightness(s, val); + } + else if (cmd=="hmirror") { //水平鏡像 + sensor_t * s = esp_camera_sensor_get(); + int val = P1.toInt(); + s->set_hmirror(s, val); + } + else if (cmd=="vflip") { //垂直翻轉 + sensor_t * s = esp_camera_sensor_get(); + int val = P1.toInt(); + s->set_vflip(s, val); + } + else if (cmd=="serial") { //序列埠 + Serial.print(P1); + } + else if (cmd=="restart") { //重啟電源 + ESP.restart(); + } + else if (cmd=="flash") { //閃光燈 + ledcAttachPin(4, 4); + ledcSetup(4, 5000, 8); + int val = P1.toInt(); + ledcWrite(4,val); + } + else if(cmd=="servo") { //伺服馬達 (0-180) + ledcAttachPin(P1.toInt(), 3); + ledcSetup(3, 50, 16); + + int val = 7864-P2.toInt()*34.59; + if (val > 7864) + val = 7864; + else if (val < 1638) + val = 1638; + ledcWrite(3, val); + } + else if (cmd=="relay") { //繼電器 + pinMode(P1.toInt(), OUTPUT); + digitalWrite(13, P2.toInt()); + } + else { + Feedback="Command is not defined."; + } + + if (Feedback=="") Feedback=Command; +} + + +//自訂網頁首頁管理介面 +static const char PROGMEM INDEX_HTML[] = R"rawliteral( + + + + + + + +
+Flash +
+
+ + + + +)rawliteral"; + +void listenConnection() { + Feedback="";Command="";cmd="";P1="";P2="";P3="";P4="";P5="";P6="";P7="";P8="";P9=""; + ReceiveState=0,cmdState=1,strState=1,questionstate=0,equalstate=0,semicolonstate=0; + + client = server.available(); + + if (client) { + String currentLine = ""; + + while (client.connected()) { + if (client.available()) { + char c = client.read(); + getCommand(c); //將緩衝區取得的字元拆解出指令參數 + if (c == '\n') { + if (currentLine.length() == 0) { + if (cmd=="getstill") { + getStill(); + } else { + mainPage(); + } + Feedback=""; + break; + } else { + currentLine = ""; + } + } else if (c != '\r') { + currentLine += c; + } + + if ((currentLine.indexOf("?")!=-1)&&(currentLine.indexOf(" HTTP")!=-1)) { + if (Command.indexOf("stop")!=-1) { //若指令中含關鍵字stop立即斷線 -> http://192.168.xxx.xxx?cmd=aaa;bbb;ccc;stop + client.println(); + client.println(); + client.stop(); + } + currentLine=""; + Feedback=""; + ExecuteCommand(); + } + } + } + delay(1); + client.stop(); + } +} + +void mainPage() { + //回傳HTML首頁或Feedback + client.println("HTTP/1.1 200 OK"); + client.println("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); + client.println("Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS"); + client.println("Content-Type: text/html; charset=utf-8"); + client.println("Access-Control-Allow-Origin: *"); + client.println("Connection: close"); + client.println(); + + String Data=""; + if (cmd!="") + Data = Feedback; + else { + Data = String((const char *)INDEX_HTML); + } + int Index; + for (Index = 0; Index < Data.length(); Index = Index+1024) { + client.print(Data.substring(Index, Index+1024)); + } +} + +void getStill() { + camera_fb_t * fb = NULL; + fb = esp_camera_fb_get(); + if(!fb) { + Serial.println("Camera capture failed"); + return; + } + uint8_t *fbBuf = fb->buf; + size_t fbLen = fb->len; + + client.println("HTTP/1.1 200 OK"); + client.println("Access-Control-Allow-Origin: *"); + client.println("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); + client.println("Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS"); + client.println("Content-Type: application/octet-stream"); + client.println(); + + for (size_t n=0;n0) { + size_t remainder = fbLen%1024; + client.write(fbBuf, remainder); + } + } + esp_camera_fb_return(fb); + + pinMode(4, OUTPUT); + digitalWrite(4, LOW); +} + +//拆解命令字串置入變數 +void getCommand(char c) { + if (c=='?') ReceiveState=1; + if ((c==' ')||(c=='\r')||(c=='\n')) ReceiveState=0; + + if (ReceiveState==1) + { + Command=Command+String(c); + + if (c=='=') cmdState=0; + if (c==';') strState++; + + if ((cmdState==1)&&((c!='?')||(questionstate==1))) cmd=cmd+String(c); + if ((cmdState==0)&&(strState==1)&&((c!='=')||(equalstate==1))) P1=P1+String(c); + if ((cmdState==0)&&(strState==2)&&(c!=';')) P2=P2+String(c); + if ((cmdState==0)&&(strState==3)&&(c!=';')) P3=P3+String(c); + if ((cmdState==0)&&(strState==4)&&(c!=';')) P4=P4+String(c); + if ((cmdState==0)&&(strState==5)&&(c!=';')) P5=P5+String(c); + if ((cmdState==0)&&(strState==6)&&(c!=';')) P6=P6+String(c); + if ((cmdState==0)&&(strState==7)&&(c!=';')) P7=P7+String(c); + if ((cmdState==0)&&(strState==8)&&(c!=';')) P8=P8+String(c); + if ((cmdState==0)&&(strState>=9)&&((c!=';')||(semicolonstate==1))) P9=P9+String(c); + + if (c=='?') questionstate=1; + if (c=='=') equalstate=1; + if ((strState>=9)&&(c==';')) semicolonstate=1; + } +} diff --git a/libraries/ESP32QRCodeReader_Page_original/LICENSE b/libraries/ESP32QRCodeReader_Page_original/LICENSE new file mode 100644 index 0000000..d47c026 --- /dev/null +++ b/libraries/ESP32QRCodeReader_Page_original/LICENSE @@ -0,0 +1,16 @@ +quirc -- QR-code recognition library +Copyright (C) 2010-2012 Daniel Beer + +Permission to use, copy, modify, and/or distribute this software for +any purpose with or without fee is hereby granted, provided that the +above copyright notice and this permission notice appear in all +copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR +PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/libraries/ESP32QRCodeReader_Page_original/README.md b/libraries/ESP32QRCodeReader_Page_original/README.md new file mode 100644 index 0000000..d70c5c3 --- /dev/null +++ b/libraries/ESP32QRCodeReader_Page_original/README.md @@ -0,0 +1,193 @@ +Quirc +===== + +QR codes are a type of high-density matrix barcodes, and quirc is a library for +extracting and decoding them from images. It has several features which make it +a good choice for this purpose: + +* It is fast enough to be used with realtime video: extracting and decoding + from VGA frame takes about 50 ms on a modern x86 core. + +* It has a robust and tolerant recognition algorithm. It can correctly + recognise and decode QR codes which are rotated and/or oblique to the camera. + It can also distinguish and decode multiple codes within the same image. + +* It is easy to use, with a simple API described in a single commented header + file (see below for an overview). + +* It is small and easily embeddable, with no dependencies other than standard C + functions. + +* It has a very small memory footprint: one byte per image pixel, plus a few kB + per decoder object. + +* It uses no global mutable state, and is safe to use in a multithreaded + application. + +* BSD-licensed, with almost no restrictions regarding use and/or modification. + +The distribution comes with, in addition to the library, several test programs. +While the core library is very portable, these programs have some additional +dependencies. All of them require libjpeg, and two (`quirc-demo` and `inspect`) +require SDL. The camera demos use Linux-specific APIs: + +### quirc-demo + +This is an real-time demo which requires a camera and a graphical display. The +video stream is displayed on screen as it's received, and any QR codes +recognised are highlighted in the image, with the decoded information both +displayed on the image and printed on stdout. + +### quirc-scanner + +This program turns your camera into a barcode scanner. It's almost the same as +the `demo` application, but it doesn't display the video stream, and thus +doesn't require a graphical display. + +### qrtest + +This test is used to evaluate the performance of library. Given a directory +tree containing a bunch of JPEG images, it will attempt to locate and decode QR +codes in each image. Speed and success statistics are collected and printed on +stdout. + +### inspect + +This test is used for debugging. Given a single JPEG image, it will display a +diagram showing the internal state of the decoder as well as printing +additional information on stdout. + +Installation +------------ +To build the library and associated demos/tests, type `make`. If you need to +decode "large" image files build with `CFLAGS="-DQUIRC_MAX_REGIONS=65534" make` +instead. Note that this will increase the memory usage, it is discouraged for +low resource devices (i.e. embedded). + +Type `make install` to install the library, header file and camera demos. + +You can specify one or several of the following targets if you don't want, or +are unable to build everything: + +* libquirc.a +* libquirc.so +* qrtest +* inspect +* quirc-scanner +* quirc-demo + +Library use +----------- +All of the library's functionality is exposed through a single header file, +which you should include: + +```C +#include +``` + +To decode images, you'll need to instantiate a `struct quirc` object, which is +done with the `quirc_new` function. Later, when you no longer need to decode +anything, you should release the allocated memory with `quirc_destroy`: + +```C +struct quirc *qr; + +qr = quirc_new(); +if (!qr) { + perror("Failed to allocate memory"); + abort(); +} + +/* ... */ + +quirc_destroy(qr); +``` + +Having obtained a decoder object, you need to set the image size that you'll be +working with, which is done using `quirc_resize`: + +```C +if (quirc_resize(qr, 640, 480) < 0) { + perror("Failed to allocate video memory"); + abort(); +} +``` + +`quirc_resize` and `quirc_new` are the only library functions which allocate +memory. If you plan to process a series of frames (or a video stream), you +probably want to allocate and size a single decoder and hold onto it to process +each frame. + +Processing frames is done in two stages. The first stage is an +image-recognition stage called identification, which takes a grayscale image +and searches for QR codes. Using `quirc_begin` and `quirc_end`, you can feed a +grayscale image directly into the buffer that `quirc` uses for image +processing: + +```C +uint8_t *image; +int w, h; + +image = quirc_begin(qr, &w, &h); + +/* Fill out the image buffer here. + * image is a pointer to a w*h bytes. + * One byte per pixel, w pixels per line, h lines in the buffer. + */ + +quirc_end(qr); +``` + +Note that `quirc_begin` simply returns a pointer to a previously allocated +buffer. The buffer will contain uninitialized data. After the call to +`quirc_end`, the decoder holds a list of detected QR codes which can be queried +via `quirc_count` and `quirc_extract`. + +At this point, the second stage of processing occurs -- decoding. This is done +via the call to `quirc_decode`, which is not associated with a decoder object. + +```C +int num_codes; +int i; + +/* We've previously fed an image to the decoder via +* quirc_begin/quirc_end. +*/ + +num_codes = quirc_count(qr); +for (i = 0; i < num_codes; i++) { + struct quirc_code code; + struct quirc_data data; + quirc_decode_error_t err; + + quirc_extract(qr, i, &code); + + /* Decoding stage */ + err = quirc_decode(&code, &data); + if (err) + printf("DECODE FAILED: %s\n", quirc_strerror(err)); + else + printf("Data: %s\n", data.payload); +} +``` + +`quirc_code` and `quirc_data` are flat structures which don't need to be +initialized or freed after use. + +Copyright +--------- +Copyright (C) 2010-2012 Daniel Beer <> + +Permission to use, copy, modify, and/or distribute this software for +any purpose with or without fee is hereby granted, provided that the +above copyright notice and this permission notice appear in all +copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR +PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/libraries/ESP32QRCodeReader_Page_original/collections.c b/libraries/ESP32QRCodeReader_Page_original/collections.c new file mode 100644 index 0000000..ea0073d --- /dev/null +++ b/libraries/ESP32QRCodeReader_Page_original/collections.c @@ -0,0 +1,85 @@ +/* This file is part of the OpenMV project. + * Copyright (c) 2013-2017 Ibrahim Abdelkader & Kwabena W. Agyeman + * This work is licensed under the MIT license, see the file LICENSE for details. + */ + +#include "collections.h" +#define CHAR_BITS (sizeof(char) * 8) +#define CHAR_MASK (CHAR_BITS - 1) +#define CHAR_SHIFT IM_LOG2(CHAR_MASK) + +////////// +// lifo // +////////// + +void lifo_alloc(lifo_t *ptr, size_t size, size_t data_len) +{ + ptr->len = 0; + ptr->size = size; + ptr->data_len = data_len; + ptr->data = (char *)ps_malloc(size * data_len); +} + +void lifo_alloc_all(lifo_t *ptr, size_t *size, size_t data_len) +{ + ptr->data = (char *)ps_malloc(255); + ptr->data_len = data_len; + ptr->size = 255 / data_len; + ptr->len = 0; + *size = ptr->size; +} + +void lifo_free(lifo_t *ptr) +{ + if (ptr->data) + { + free(ptr->data); + } +} + +void lifo_clear(lifo_t *ptr) +{ + ptr->len = 0; +} + +size_t lifo_size(lifo_t *ptr) +{ + return ptr->len; +} + +bool lifo_is_not_empty(lifo_t *ptr) +{ + return ptr->len; +} + +bool lifo_is_not_full(lifo_t *ptr) +{ + return ptr->len != ptr->size; +} + +void lifo_enqueue(lifo_t *ptr, void *data) +{ + memcpy(ptr->data + (ptr->len * ptr->data_len), data, ptr->data_len); + + ptr->len += 1; +} + +void lifo_dequeue(lifo_t *ptr, void *data) +{ + if (data) + { + memcpy(data, ptr->data + ((ptr->len - 1) * ptr->data_len), ptr->data_len); + } + + ptr->len -= 1; +} + +void lifo_poke(lifo_t *ptr, void *data) +{ + memcpy(ptr->data + (ptr->len * ptr->data_len), data, ptr->data_len); +} + +void lifo_peek(lifo_t *ptr, void *data) +{ + memcpy(data, ptr->data + ((ptr->len - 1) * ptr->data_len), ptr->data_len); +} diff --git a/libraries/ESP32QRCodeReader_Page_original/collections.h b/libraries/ESP32QRCodeReader_Page_original/collections.h new file mode 100644 index 0000000..711cafa --- /dev/null +++ b/libraries/ESP32QRCodeReader_Page_original/collections.h @@ -0,0 +1,33 @@ +/* This file is part of the OpenMV project. + * Copyright (c) 2013-2017 Ibrahim Abdelkader & Kwabena W. Agyeman + * This work is licensed under the MIT license, see the file LICENSE for details. + */ + +#ifndef __COLLECTIONS_H__ +#define __COLLECTIONS_H__ +#include +#include +////////// +// lifo // +////////// + +typedef struct lifo +{ + size_t len, size, data_len; + char *data; +} +__attribute__((aligned(8))) lifo_t; + +void lifo_alloc(lifo_t *ptr, size_t size, size_t data_len); +void lifo_alloc_all(lifo_t *ptr, size_t *size, size_t data_len); +void lifo_free(lifo_t *ptr); +void lifo_clear(lifo_t *ptr); +size_t lifo_size(lifo_t *ptr); +bool lifo_is_not_empty(lifo_t *ptr); +bool lifo_is_not_full(lifo_t *ptr); +void lifo_enqueue(lifo_t *ptr, void *data); +void lifo_dequeue(lifo_t *ptr, void *data); +void lifo_poke(lifo_t *ptr, void *data); +void lifo_peek(lifo_t *ptr, void *data); + +#endif /* __COLLECTIONS_H__ */ \ No newline at end of file diff --git a/libraries/ESP32QRCodeReader_Page_original/decode.c b/libraries/ESP32QRCodeReader_Page_original/decode.c new file mode 100644 index 0000000..67c8ed5 --- /dev/null +++ b/libraries/ESP32QRCodeReader_Page_original/decode.c @@ -0,0 +1,983 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "quirc_internal.h" + +#include +#include + +#define MAX_POLY 64 + +/************************************************************************ + * Galois fields + */ + +struct galois_field +{ + int p; + const uint8_t *log; + const uint8_t *exp; +} __attribute__((aligned(8))); + +static const uint8_t gf16_exp[16] = { + 0x01, 0x02, 0x04, 0x08, 0x03, 0x06, 0x0c, 0x0b, + 0x05, 0x0a, 0x07, 0x0e, 0x0f, 0x0d, 0x09, 0x01}; + +static const uint8_t gf16_log[16] = { + 0x00, 0x0f, 0x01, 0x04, 0x02, 0x08, 0x05, 0x0a, + 0x03, 0x0e, 0x09, 0x07, 0x06, 0x0d, 0x0b, 0x0c}; + +static const struct galois_field gf16 = { + .p = 15, + .log = gf16_log, + .exp = gf16_exp}; + +static const uint8_t gf256_exp[256] = { + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, + 0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26, + 0x4c, 0x98, 0x2d, 0x5a, 0xb4, 0x75, 0xea, 0xc9, + 0x8f, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, + 0x9d, 0x27, 0x4e, 0x9c, 0x25, 0x4a, 0x94, 0x35, + 0x6a, 0xd4, 0xb5, 0x77, 0xee, 0xc1, 0x9f, 0x23, + 0x46, 0x8c, 0x05, 0x0a, 0x14, 0x28, 0x50, 0xa0, + 0x5d, 0xba, 0x69, 0xd2, 0xb9, 0x6f, 0xde, 0xa1, + 0x5f, 0xbe, 0x61, 0xc2, 0x99, 0x2f, 0x5e, 0xbc, + 0x65, 0xca, 0x89, 0x0f, 0x1e, 0x3c, 0x78, 0xf0, + 0xfd, 0xe7, 0xd3, 0xbb, 0x6b, 0xd6, 0xb1, 0x7f, + 0xfe, 0xe1, 0xdf, 0xa3, 0x5b, 0xb6, 0x71, 0xe2, + 0xd9, 0xaf, 0x43, 0x86, 0x11, 0x22, 0x44, 0x88, + 0x0d, 0x1a, 0x34, 0x68, 0xd0, 0xbd, 0x67, 0xce, + 0x81, 0x1f, 0x3e, 0x7c, 0xf8, 0xed, 0xc7, 0x93, + 0x3b, 0x76, 0xec, 0xc5, 0x97, 0x33, 0x66, 0xcc, + 0x85, 0x17, 0x2e, 0x5c, 0xb8, 0x6d, 0xda, 0xa9, + 0x4f, 0x9e, 0x21, 0x42, 0x84, 0x15, 0x2a, 0x54, + 0xa8, 0x4d, 0x9a, 0x29, 0x52, 0xa4, 0x55, 0xaa, + 0x49, 0x92, 0x39, 0x72, 0xe4, 0xd5, 0xb7, 0x73, + 0xe6, 0xd1, 0xbf, 0x63, 0xc6, 0x91, 0x3f, 0x7e, + 0xfc, 0xe5, 0xd7, 0xb3, 0x7b, 0xf6, 0xf1, 0xff, + 0xe3, 0xdb, 0xab, 0x4b, 0x96, 0x31, 0x62, 0xc4, + 0x95, 0x37, 0x6e, 0xdc, 0xa5, 0x57, 0xae, 0x41, + 0x82, 0x19, 0x32, 0x64, 0xc8, 0x8d, 0x07, 0x0e, + 0x1c, 0x38, 0x70, 0xe0, 0xdd, 0xa7, 0x53, 0xa6, + 0x51, 0xa2, 0x59, 0xb2, 0x79, 0xf2, 0xf9, 0xef, + 0xc3, 0x9b, 0x2b, 0x56, 0xac, 0x45, 0x8a, 0x09, + 0x12, 0x24, 0x48, 0x90, 0x3d, 0x7a, 0xf4, 0xf5, + 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16, + 0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, + 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x01}; + +static const uint8_t gf256_log[256] = { + 0x00, 0xff, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, + 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b, + 0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, + 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, 0x4c, 0x71, + 0x05, 0x8a, 0x65, 0x2f, 0xe1, 0x24, 0x0f, 0x21, + 0x35, 0x93, 0x8e, 0xda, 0xf0, 0x12, 0x82, 0x45, + 0x1d, 0xb5, 0xc2, 0x7d, 0x6a, 0x27, 0xf9, 0xb9, + 0xc9, 0x9a, 0x09, 0x78, 0x4d, 0xe4, 0x72, 0xa6, + 0x06, 0xbf, 0x8b, 0x62, 0x66, 0xdd, 0x30, 0xfd, + 0xe2, 0x98, 0x25, 0xb3, 0x10, 0x91, 0x22, 0x88, + 0x36, 0xd0, 0x94, 0xce, 0x8f, 0x96, 0xdb, 0xbd, + 0xf1, 0xd2, 0x13, 0x5c, 0x83, 0x38, 0x46, 0x40, + 0x1e, 0x42, 0xb6, 0xa3, 0xc3, 0x48, 0x7e, 0x6e, + 0x6b, 0x3a, 0x28, 0x54, 0xfa, 0x85, 0xba, 0x3d, + 0xca, 0x5e, 0x9b, 0x9f, 0x0a, 0x15, 0x79, 0x2b, + 0x4e, 0xd4, 0xe5, 0xac, 0x73, 0xf3, 0xa7, 0x57, + 0x07, 0x70, 0xc0, 0xf7, 0x8c, 0x80, 0x63, 0x0d, + 0x67, 0x4a, 0xde, 0xed, 0x31, 0xc5, 0xfe, 0x18, + 0xe3, 0xa5, 0x99, 0x77, 0x26, 0xb8, 0xb4, 0x7c, + 0x11, 0x44, 0x92, 0xd9, 0x23, 0x20, 0x89, 0x2e, + 0x37, 0x3f, 0xd1, 0x5b, 0x95, 0xbc, 0xcf, 0xcd, + 0x90, 0x87, 0x97, 0xb2, 0xdc, 0xfc, 0xbe, 0x61, + 0xf2, 0x56, 0xd3, 0xab, 0x14, 0x2a, 0x5d, 0x9e, + 0x84, 0x3c, 0x39, 0x53, 0x47, 0x6d, 0x41, 0xa2, + 0x1f, 0x2d, 0x43, 0xd8, 0xb7, 0x7b, 0xa4, 0x76, + 0xc4, 0x17, 0x49, 0xec, 0x7f, 0x0c, 0x6f, 0xf6, + 0x6c, 0xa1, 0x3b, 0x52, 0x29, 0x9d, 0x55, 0xaa, + 0xfb, 0x60, 0x86, 0xb1, 0xbb, 0xcc, 0x3e, 0x5a, + 0xcb, 0x59, 0x5f, 0xb0, 0x9c, 0xa9, 0xa0, 0x51, + 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7, + 0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, + 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf}; + +const static struct galois_field gf256 = { + .p = 255, + .log = gf256_log, + .exp = gf256_exp}; + +/************************************************************************ + * Polynomial operations + */ + +static void poly_add(uint8_t *dst, const uint8_t *src, uint8_t c, + int shift, const struct galois_field *gf) +{ + int i; + int log_c = gf->log[c]; + + if (!c) + return; + + for (i = 0; i < MAX_POLY; i++) + { + int p = i + shift; + uint8_t v = src[i]; + + if (p < 0 || p >= MAX_POLY) + continue; + if (!v) + continue; + + dst[p] ^= gf->exp[(gf->log[v] + log_c) % gf->p]; + } +} + +static uint8_t poly_eval(const uint8_t *s, uint8_t x, + const struct galois_field *gf) +{ + int i; + uint8_t sum = 0; + uint8_t log_x = gf->log[x]; + + if (!x) + return s[0]; + + for (i = 0; i < MAX_POLY; i++) + { + uint8_t c = s[i]; + + if (!c) + continue; + + sum ^= gf->exp[(gf->log[c] + log_x * i) % gf->p]; + } + + return sum; +} + +/************************************************************************ + * Berlekamp-Massey algorithm for finding error locator polynomials. + */ + +static void berlekamp_massey(const uint8_t *s, int N, + const struct galois_field *gf, + uint8_t *sigma) +{ + uint8_t C[MAX_POLY]; + uint8_t B[MAX_POLY]; + int L = 0; + int m = 1; + uint8_t b = 1; + int n; + + memset(B, 0, sizeof(B)); + memset(C, 0, sizeof(C)); + B[0] = 1; + C[0] = 1; + + for (n = 0; n < N; n++) + { + uint8_t d = s[n]; + uint8_t mult; + int i; + + for (i = 1; i <= L; i++) + { + if (!(C[i] && s[n - i])) + continue; + + d ^= gf->exp[(gf->log[C[i]] + + gf->log[s[n - i]]) % + gf->p]; + } + + mult = gf->exp[(gf->p - gf->log[b] + gf->log[d]) % gf->p]; + + if (!d) + { + m++; + } + else if (L * 2 <= n) + { + uint8_t T[MAX_POLY]; + + memcpy(T, C, sizeof(T)); + poly_add(C, B, mult, m, gf); + memcpy(B, T, sizeof(B)); + L = n + 1 - L; + b = d; + m = 1; + } + else + { + poly_add(C, B, mult, m, gf); + m++; + } + } + + memcpy(sigma, C, MAX_POLY); +} + +/************************************************************************ + * Code stream error correction + * + * Generator polynomial for GF(2^8) is x^8 + x^4 + x^3 + x^2 + 1 + */ + +static int block_syndromes(const uint8_t *data, int bs, int npar, uint8_t *s) +{ + int nonzero = 0; + int i; + + memset(s, 0, MAX_POLY); + + for (i = 0; i < npar; i++) + { + int j; + + for (j = 0; j < bs; j++) + { + uint8_t c = data[bs - j - 1]; + + if (!c) + continue; + + s[i] ^= gf256_exp[((int)gf256_log[c] + + i * j) % + 255]; + } + + if (s[i]) + nonzero = 1; + } + + return nonzero; +} + +static void eloc_poly(uint8_t *omega, + const uint8_t *s, const uint8_t *sigma, + int npar) +{ + int i; + + memset(omega, 0, MAX_POLY); + + for (i = 0; i < npar; i++) + { + const uint8_t a = sigma[i]; + const uint8_t log_a = gf256_log[a]; + int j; + + if (!a) + continue; + + for (j = 0; j + 1 < MAX_POLY; j++) + { + const uint8_t b = s[j + 1]; + + if (i + j >= npar) + break; + + if (!b) + continue; + + omega[i + j] ^= + gf256_exp[(log_a + gf256_log[b]) % 255]; + } + } +} + +static quirc_decode_error_t correct_block(uint8_t *data, + const struct quirc_rs_params *ecc) +{ + int npar = ecc->bs - ecc->dw; + uint8_t s[MAX_POLY]; + uint8_t sigma[MAX_POLY]; + uint8_t sigma_deriv[MAX_POLY]; + uint8_t omega[MAX_POLY]; + int i; + + /* Compute syndrome vector */ + if (!block_syndromes(data, ecc->bs, npar, s)) + return QUIRC_SUCCESS; + + berlekamp_massey(s, npar, &gf256, sigma); + + /* Compute derivative of sigma */ + memset(sigma_deriv, 0, MAX_POLY); + for (i = 0; i + 1 < MAX_POLY; i += 2) + sigma_deriv[i] = sigma[i + 1]; + + /* Compute error evaluator polynomial */ + eloc_poly(omega, s, sigma, npar - 1); + + /* Find error locations and magnitudes */ + for (i = 0; i < ecc->bs; i++) + { + uint8_t xinv = gf256_exp[255 - i]; + + if (!poly_eval(sigma, xinv, &gf256)) + { + uint8_t sd_x = poly_eval(sigma_deriv, xinv, &gf256); + uint8_t omega_x = poly_eval(omega, xinv, &gf256); + uint8_t error = gf256_exp[(255 - gf256_log[sd_x] + + gf256_log[omega_x]) % + 255]; + + data[ecc->bs - i - 1] ^= error; + } + } + + if (block_syndromes(data, ecc->bs, npar, s)) + return QUIRC_ERROR_DATA_ECC; + + return QUIRC_SUCCESS; +} + +/************************************************************************ + * Format value error correction + * + * Generator polynomial for GF(2^4) is x^4 + x + 1 + */ + +#define FORMAT_MAX_ERROR 3 +#define FORMAT_SYNDROMES (FORMAT_MAX_ERROR * 2) +#define FORMAT_BITS 15 + +static int format_syndromes(uint16_t u, uint8_t *s) +{ + int i; + int nonzero = 0; + + memset(s, 0, MAX_POLY); + + for (i = 0; i < FORMAT_SYNDROMES; i++) + { + int j; + + s[i] = 0; + for (j = 0; j < FORMAT_BITS; j++) + if (u & (1 << j)) + s[i] ^= gf16_exp[((i + 1) * j) % 15]; + + if (s[i]) + nonzero = 1; + } + + return nonzero; +} + +static quirc_decode_error_t correct_format(uint16_t *f_ret) +{ + uint16_t u = *f_ret; + int i; + uint8_t s[MAX_POLY]; + uint8_t sigma[MAX_POLY]; + + /* Evaluate U (received codeword) at each of alpha_1 .. alpha_6 + * to get S_1 .. S_6 (but we index them from 0). + */ + if (!format_syndromes(u, s)) + return QUIRC_SUCCESS; + + berlekamp_massey(s, FORMAT_SYNDROMES, &gf16, sigma); + + /* Now, find the roots of the polynomial */ + for (i = 0; i < 15; i++) + if (!poly_eval(sigma, gf16_exp[15 - i], &gf16)) + u ^= (1 << i); + + if (format_syndromes(u, s)) + return QUIRC_ERROR_FORMAT_ECC; + + *f_ret = u; + return QUIRC_SUCCESS; +} + +/************************************************************************ + * Decoder algorithm + */ + +struct datastream +{ + uint8_t raw[QUIRC_MAX_PAYLOAD]; + int data_bits; + int ptr; + + uint8_t data[QUIRC_MAX_PAYLOAD]; +} __attribute__((aligned(8))); + +static inline int grid_bit(const struct quirc_code *code, int x, int y) +{ + int p = y * code->size + x; + + return (code->cell_bitmap[p >> 3] >> (p & 7)) & 1; +} + +static quirc_decode_error_t read_format(const struct quirc_code *code, + struct quirc_data *data, int which) +{ + int i; + uint16_t format = 0; + uint16_t fdata; + quirc_decode_error_t err; + + if (which) + { + for (i = 0; i < 7; i++) + format = (format << 1) | + grid_bit(code, 8, code->size - 1 - i); + for (i = 0; i < 8; i++) + format = (format << 1) | + grid_bit(code, code->size - 8 + i, 8); + } + else + { + static const int xs[15] = { + 8, 8, 8, 8, 8, 8, 8, 8, 7, 5, 4, 3, 2, 1, 0}; + static const int ys[15] = { + 0, 1, 2, 3, 4, 5, 7, 8, 8, 8, 8, 8, 8, 8, 8}; + + for (i = 14; i >= 0; i--) + format = (format << 1) | grid_bit(code, xs[i], ys[i]); + } + + format ^= 0x5412; + + err = correct_format(&format); + if (err) + return err; + + fdata = format >> 10; + data->ecc_level = fdata >> 3; + data->mask = fdata & 7; + + return QUIRC_SUCCESS; +} + +static int mask_bit(int mask, int i, int j) +{ + switch (mask) + { + case 0: + return !((i + j) % 2); + case 1: + return !(i % 2); + case 2: + return !(j % 3); + case 3: + return !((i + j) % 3); + case 4: + return !(((i / 2) + (j / 3)) % 2); + case 5: + return !((i * j) % 2 + (i * j) % 3); + case 6: + return !(((i * j) % 2 + (i * j) % 3) % 2); + case 7: + return !(((i * j) % 3 + (i + j) % 2) % 2); + } + + return 0; +} + +static int reserved_cell(int version, int i, int j) +{ + const struct quirc_version_info *ver = &quirc_version_db[version]; + int size = version * 4 + 17; + int ai = -1, aj = -1, a; + + /* Finder + format: top left */ + if (i < 9 && j < 9) + return 1; + + /* Finder + format: bottom left */ + if (i + 8 >= size && j < 9) + return 1; + + /* Finder + format: top right */ + if (i < 9 && j + 8 >= size) + return 1; + + /* Exclude timing patterns */ + if (i == 6 || j == 6) + return 1; + + /* Exclude version info, if it exists. Version info sits adjacent to + * the top-right and bottom-left finders in three rows, bounded by + * the timing pattern. + */ + if (version >= 7) + { + if (i < 6 && j + 11 >= size) + return 1; + if (i + 11 >= size && j < 6) + return 1; + } + + /* Exclude alignment patterns */ + for (a = 0; a < QUIRC_MAX_ALIGNMENT && ver->apat[a]; a++) + { + int p = ver->apat[a]; + + if (abs(p - i) < 3) + ai = a; + if (abs(p - j) < 3) + aj = a; + } + + if (ai >= 0 && aj >= 0) + { + a--; + if (ai > 0 && ai < a) + return 1; + if (aj > 0 && aj < a) + return 1; + if (aj == a && ai == a) + return 1; + } + + return 0; +} + +static void read_bit(const struct quirc_code *code, + struct quirc_data *data, + struct datastream *ds, int i, int j) +{ + int bitpos = ds->data_bits & 7; + int bytepos = ds->data_bits >> 3; + int v = grid_bit(code, j, i); + + if (mask_bit(data->mask, i, j)) + v ^= 1; + + if (v) + ds->raw[bytepos] |= (0x80 >> bitpos); + + ds->data_bits++; +} + +static void read_data(const struct quirc_code *code, + struct quirc_data *data, + struct datastream *ds) +{ + int y = code->size - 1; + int x = code->size - 1; + int dir = -1; + + while (x > 0) + { + if (x == 6) + x--; + + if (!reserved_cell(data->version, y, x)) + read_bit(code, data, ds, y, x); + + if (!reserved_cell(data->version, y, x - 1)) + read_bit(code, data, ds, y, x - 1); + + y += dir; + if (y < 0 || y >= code->size) + { + dir = -dir; + x -= 2; + y += dir; + } + } +} + +static quirc_decode_error_t codestream_ecc(struct quirc_data *data, + struct datastream *ds) +{ + const struct quirc_version_info *ver = + &quirc_version_db[data->version]; + const struct quirc_rs_params *sb_ecc = &ver->ecc[data->ecc_level]; + struct quirc_rs_params lb_ecc; + const int lb_count = + (ver->data_bytes - sb_ecc->bs * sb_ecc->ns) / (sb_ecc->bs + 1); + const int bc = lb_count + sb_ecc->ns; + const int ecc_offset = sb_ecc->dw * bc + lb_count; + int dst_offset = 0; + int i; + + memcpy(&lb_ecc, sb_ecc, sizeof(lb_ecc)); + lb_ecc.dw++; + lb_ecc.bs++; + + for (i = 0; i < bc; i++) + { + uint8_t *dst = ds->data + dst_offset; + const struct quirc_rs_params *ecc = + (i < sb_ecc->ns) ? sb_ecc : &lb_ecc; + const int num_ec = ecc->bs - ecc->dw; + quirc_decode_error_t err; + int j; + + for (j = 0; j < ecc->dw; j++) + dst[j] = ds->raw[j * bc + i]; + for (j = 0; j < num_ec; j++) + dst[ecc->dw + j] = ds->raw[ecc_offset + j * bc + i]; + + err = correct_block(dst, ecc); + if (err) + return err; + + dst_offset += ecc->dw; + } + + ds->data_bits = dst_offset * 8; + + return QUIRC_SUCCESS; +} + +static inline int bits_remaining(const struct datastream *ds) +{ + return ds->data_bits - ds->ptr; +} + +static int take_bits(struct datastream *ds, int len) +{ + int ret = 0; + + while (len && (ds->ptr < ds->data_bits)) + { + uint8_t b = ds->data[ds->ptr >> 3]; + int bitpos = ds->ptr & 7; + + ret <<= 1; + if ((b << bitpos) & 0x80) + ret |= 1; + + ds->ptr++; + len--; + } + + return ret; +} + +static int numeric_tuple(struct quirc_data *data, + struct datastream *ds, + int bits, int digits) +{ + int tuple; + int i; + + if (bits_remaining(ds) < bits) + return -1; + + tuple = take_bits(ds, bits); + + for (i = digits - 1; i >= 0; i--) + { + data->payload[data->payload_len + i] = tuple % 10 + '0'; + tuple /= 10; + } + + data->payload_len += digits; + return 0; +} + +static quirc_decode_error_t decode_numeric(struct quirc_data *data, + struct datastream *ds) +{ + int bits = 14; + int count; + + if (data->version < 10) + bits = 10; + else if (data->version < 27) + bits = 12; + + count = take_bits(ds, bits); + if (data->payload_len + count + 1 > QUIRC_MAX_PAYLOAD) + return QUIRC_ERROR_DATA_OVERFLOW; + + while (count >= 3) + { + if (numeric_tuple(data, ds, 10, 3) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count -= 3; + } + + if (count >= 2) + { + if (numeric_tuple(data, ds, 7, 2) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count -= 2; + } + + if (count) + { + if (numeric_tuple(data, ds, 4, 1) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count--; + } + + return QUIRC_SUCCESS; +} + +static int alpha_tuple(struct quirc_data *data, + struct datastream *ds, + int bits, int digits) +{ + int tuple; + int i; + + if (bits_remaining(ds) < bits) + return -1; + + tuple = take_bits(ds, bits); + + for (i = 0; i < digits; i++) + { + static const char *alpha_map = + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"; + + data->payload[data->payload_len + digits - i - 1] = + alpha_map[tuple % 45]; + tuple /= 45; + } + + data->payload_len += digits; + return 0; +} + +static quirc_decode_error_t decode_alpha(struct quirc_data *data, + struct datastream *ds) +{ + int bits = 13; + int count; + + if (data->version < 10) + bits = 9; + else if (data->version < 27) + bits = 11; + + count = take_bits(ds, bits); + if (data->payload_len + count + 1 > QUIRC_MAX_PAYLOAD) + return QUIRC_ERROR_DATA_OVERFLOW; + + while (count >= 2) + { + if (alpha_tuple(data, ds, 11, 2) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count -= 2; + } + + if (count) + { + if (alpha_tuple(data, ds, 6, 1) < 0) + return QUIRC_ERROR_DATA_UNDERFLOW; + count--; + } + + return QUIRC_SUCCESS; +} + +static quirc_decode_error_t decode_byte(struct quirc_data *data, + struct datastream *ds) +{ + int bits = 16; + int count; + int i; + + if (data->version < 10) + bits = 8; + + count = take_bits(ds, bits); + if (data->payload_len + count + 1 > QUIRC_MAX_PAYLOAD) + return QUIRC_ERROR_DATA_OVERFLOW; + if (bits_remaining(ds) < count * 8) + return QUIRC_ERROR_DATA_UNDERFLOW; + + for (i = 0; i < count; i++) + data->payload[data->payload_len++] = take_bits(ds, 8); + + return QUIRC_SUCCESS; +} + +static quirc_decode_error_t decode_kanji(struct quirc_data *data, + struct datastream *ds) +{ + int bits = 12; + int count; + int i; + + if (data->version < 10) + bits = 8; + else if (data->version < 27) + bits = 10; + + count = take_bits(ds, bits); + if (data->payload_len + count * 2 + 1 > QUIRC_MAX_PAYLOAD) + return QUIRC_ERROR_DATA_OVERFLOW; + if (bits_remaining(ds) < count * 13) + return QUIRC_ERROR_DATA_UNDERFLOW; + + for (i = 0; i < count; i++) + { + int d = take_bits(ds, 13); + int msB = d / 0xc0; + int lsB = d % 0xc0; + int intermediate = (msB << 8) | lsB; + uint16_t sjw; + + if (intermediate + 0x8140 <= 0x9ffc) + { + /* bytes are in the range 0x8140 to 0x9FFC */ + sjw = intermediate + 0x8140; + } + else + { + /* bytes are in the range 0xE040 to 0xEBBF */ + sjw = intermediate + 0xc140; + } + + data->payload[data->payload_len++] = sjw >> 8; + data->payload[data->payload_len++] = sjw & 0xff; + } + + return QUIRC_SUCCESS; +} + +static quirc_decode_error_t decode_eci(struct quirc_data *data, + struct datastream *ds) +{ + if (bits_remaining(ds) < 8) + return QUIRC_ERROR_DATA_UNDERFLOW; + + data->eci = take_bits(ds, 8); + + if ((data->eci & 0xc0) == 0x80) + { + if (bits_remaining(ds) < 8) + return QUIRC_ERROR_DATA_UNDERFLOW; + + data->eci = (data->eci << 8) | take_bits(ds, 8); + } + else if ((data->eci & 0xe0) == 0xc0) + { + if (bits_remaining(ds) < 16) + return QUIRC_ERROR_DATA_UNDERFLOW; + + data->eci = (data->eci << 16) | take_bits(ds, 16); + } + + return QUIRC_SUCCESS; +} + +static quirc_decode_error_t decode_payload(struct quirc_data *data, + struct datastream *ds) +{ + while (bits_remaining(ds) >= 4) + { + quirc_decode_error_t err = QUIRC_SUCCESS; + int type = take_bits(ds, 4); + + switch (type) + { + case QUIRC_DATA_TYPE_NUMERIC: + err = decode_numeric(data, ds); + break; + + case QUIRC_DATA_TYPE_ALPHA: + err = decode_alpha(data, ds); + break; + + case QUIRC_DATA_TYPE_BYTE: + err = decode_byte(data, ds); + break; + + case QUIRC_DATA_TYPE_KANJI: + err = decode_kanji(data, ds); + break; + + case 7: + err = decode_eci(data, ds); + break; + + default: + goto done; + } + + if (err) + return err; + + if (!(type & (type - 1)) && (type > data->data_type)) + data->data_type = type; + } + +done: + + /* Add nul terminator to all payloads */ + if (data->payload_len >= sizeof(data->payload)) + data->payload_len--; + data->payload[data->payload_len] = 0; + + return QUIRC_SUCCESS; +} + +quirc_decode_error_t quirc_decode(const struct quirc_code *code, + struct quirc_data *data) +{ + quirc_decode_error_t err; + struct datastream *ds = ps_malloc(sizeof(struct datastream)); + + if ((code->size - 17) % 4) + { + free(ds); + return QUIRC_ERROR_INVALID_GRID_SIZE; + } + + memset(data, 0, sizeof(*data)); + memset(ds, 0, sizeof(*ds)); + + data->version = (code->size - 17) / 4; + + if (data->version < 1 || + data->version > QUIRC_MAX_VERSION) + { + free(ds); + return QUIRC_ERROR_INVALID_VERSION; + } + + /* Read format information -- try both locations */ + err = read_format(code, data, 0); + if (err) + err = read_format(code, data, 1); + if (err) + { + free(ds); + return err; + } + + read_data(code, data, ds); + err = codestream_ecc(data, ds); + if (err) + { + free(ds); + return err; + } + + err = decode_payload(data, ds); + if (err) + { + free(ds); + return err; + } + + free(ds); + return QUIRC_SUCCESS; +} \ No newline at end of file diff --git a/libraries/ESP32QRCodeReader_Page_original/fmath.h b/libraries/ESP32QRCodeReader_Page_original/fmath.h new file mode 100644 index 0000000..76c3b93 --- /dev/null +++ b/libraries/ESP32QRCodeReader_Page_original/fmath.h @@ -0,0 +1,70 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * Fast approximate math functions. + * + */ +#ifndef __FMATH_H +#define __FMATH_H +#include +#include + +static inline float fast_sqrtf(float x) +{ + //return sqrtf(x); + asm("fsqrt.s %0, %1" + : "=f"(x) + : "f"(x)); + return x; +} +static inline int fast_floorf(float x) +{ + return (int)(x); +} + +static inline int fast_ceilf(float x) +{ + return (int)(x + 0.9999f); +} + +static inline int fast_roundf(float x) +{ + return (int)(x); +} + +static inline float fast_fabsf(float d) +{ + return fabsf(d); +} + +extern int fast_floorf(float x); +extern int fast_ceilf(float x); +extern int fast_roundf(float x); +extern float fast_atanf(float x); +extern float fast_atan2f(float y, float x); +extern float fast_expf(float x); +extern float fast_cbrtf(float d); +extern float fast_fabsf(float d); +extern float fast_log(float x); +extern float fast_log2(float x); +extern float fast_powf(float a, float b); + +/*#define fast_sqrtf(x) (sqrtf(x)) +#define fast_floorf(x) ((int)floorf(x)) +#define fast_ceilf(x) ((int)ceilf(x)) +#define fast_roundf(x) ((int)roundf(x)) +#define fast_atanf(x) (atanf(x)) +#define fast_atan2f(x,y) (atan2f((x),(y))) +#define fast_expf(x) (expf(x)) +#define fast_cbrtf(x) (cbrtf(x)) +#define fast_fabsf(x) (fabsf(x)) +#define fast_log(x) (log(x)) +#define fast_log2(x) (log2(x)) +#define fast_powf(x,y) (powf((x),(y))) +*/ + +extern const float cos_table[360]; +extern const float sin_table[360]; +#endif // __FMATH_H \ No newline at end of file diff --git a/libraries/ESP32QRCodeReader_Page_original/identify.c b/libraries/ESP32QRCodeReader_Page_original/identify.c new file mode 100644 index 0000000..d0d0316 --- /dev/null +++ b/libraries/ESP32QRCodeReader_Page_original/identify.c @@ -0,0 +1,1286 @@ +/* quirc - QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + +#include "fmath.h" +#include "collections.h" +#include "quirc_internal.h" + +/************************************************************************ + * Linear algebra routines + */ + +static int line_intersect(const struct quirc_point *p0, + const struct quirc_point *p1, + const struct quirc_point *q0, + const struct quirc_point *q1, + struct quirc_point *r) +{ + /* (a, b) is perpendicular to line p */ + int a = -(p1->y - p0->y); + int b = p1->x - p0->x; + + /* (c, d) is perpendicular to line q */ + int c = -(q1->y - q0->y); + int d = q1->x - q0->x; + + /* e and f are dot products of the respective vectors with p and q */ + int e = a * p1->x + b * p1->y; + int f = c * q1->x + d * q1->y; + + /* Now we need to solve: + * [a b] [rx] [e] + * [c d] [ry] = [f] + * + * We do this by inverting the matrix and applying it to (e, f): + * [ d -b] [e] [rx] + * 1/det [-c a] [f] = [ry] + */ + int det = (a * d) - (b * c); + + if (!det) + return 0; + + r->x = (d * e - b * f) / det; + r->y = (-c * e + a * f) / det; + + return 1; +} + +static void perspective_setup(float *c, + const struct quirc_point *rect, + float w, float h) +{ + float x0 = rect[0].x; + float y0 = rect[0].y; + float x1 = rect[1].x; + float y1 = rect[1].y; + float x2 = rect[2].x; + float y2 = rect[2].y; + float x3 = rect[3].x; + float y3 = rect[3].y; + + float wden = w * (x2 * y3 - x3 * y2 + (x3 - x2) * y1 + x1 * (y2 - y3)); + float hden = h * (x2 * y3 + x1 * (y2 - y3) - x3 * y2 + (x3 - x2) * y1); + + c[0] = (x1 * (x2 * y3 - x3 * y2) + x0 * (-x2 * y3 + x3 * y2 + (x2 - x3) * y1) + + x1 * (x3 - x2) * y0) / + wden; + c[1] = -(x0 * (x2 * y3 + x1 * (y2 - y3) - x2 * y1) - x1 * x3 * y2 + x2 * x3 * y1 + (x1 * x3 - x2 * x3) * y0) / hden; + c[2] = x0; + c[3] = (y0 * (x1 * (y3 - y2) - x2 * y3 + x3 * y2) + y1 * (x2 * y3 - x3 * y2) + + x0 * y1 * (y2 - y3)) / + wden; + c[4] = (x0 * (y1 * y3 - y2 * y3) + x1 * y2 * y3 - x2 * y1 * y3 + + y0 * (x3 * y2 - x1 * y2 + (x2 - x3) * y1)) / + hden; + c[5] = y0; + c[6] = (x1 * (y3 - y2) + x0 * (y2 - y3) + (x2 - x3) * y1 + (x3 - x2) * y0) / wden; + c[7] = (-x2 * y3 + x1 * y3 + x3 * y2 + x0 * (y1 - y2) - x3 * y1 + (x2 - x1) * y0) / + hden; +} + +static void perspective_map(const float *c, + float u, float v, struct quirc_point *ret) +{ + float den = c[6] * u + c[7] * v + 1.0; + float x = (c[0] * u + c[1] * v + c[2]) / den; + float y = (c[3] * u + c[4] * v + c[5]) / den; + + ret->x = fast_roundf(x); + ret->y = fast_roundf(y); +} + +static void perspective_unmap(const float *c, + const struct quirc_point *in, + float *u, float *v) +{ + float x = in->x; + float y = in->y; + float den = -c[0] * c[7] * y + c[1] * c[6] * y + (c[3] * c[7] - c[4] * c[6]) * x + + c[0] * c[4] - c[1] * c[3]; + + *u = -(c[1] * (y - c[5]) - c[2] * c[7] * y + (c[5] * c[7] - c[4]) * x + c[2] * c[4]) / + den; + *v = (c[0] * (y - c[5]) - c[2] * c[6] * y + (c[5] * c[6] - c[3]) * x + c[2] * c[3]) / + den; +} + +/************************************************************************ + * Span-based floodfill routine + */ + +typedef void (*span_func_t)(void *user_data, int y, int left, int right); + +typedef struct xylf +{ + int16_t x, y, l, r; +} __attribute__((aligned(8))) +xylf_t; + +//计算该区域的面积,from是像素颜色,to是区块标号,user_data是申请的区块结构体,func是计算面积的函数 +static void flood_fill_seed(struct quirc *q, int x, int y, int from, int to, + span_func_t func, void *user_data, + int depth) +{ + (void)depth; // unused + + lifo_t lifo; + size_t lifo_len; + lifo_alloc_all(&lifo, &lifo_len, sizeof(xylf_t)); + //late in first out. 申请xylf_t的lifo,一次申请完,长度存储在lifo_len中 + + for (;;) + { + int left = x; + int right = x; + int i; + quirc_pixel_t *row = q->pixels + y * q->w; //行起始地址 + //查找左右边界 + while (left > 0 && row[left - 1] == from) + left--; + + while (right < q->w - 1 && row[right + 1] == from) + right++; + + /* Fill the extent 对应像素标记为区块号*/ + for (i = left; i <= right; i++) + row[i] = to; + //累加区域内的像素点数作为面积 + if (func) + func(user_data, y, left, right); + + for (;;) + { + if (lifo_size(&lifo) < lifo_len) + { //栈中的数量 + /* Seed new flood-fills */ + if (y > 0) + { //查找上一行有没有在同一区域的点 + row = q->pixels + (y - 1) * q->w; + + bool recurse = false; + for (i = left; i <= right; i++) + if (row[i] == from) + { //相同区域,则入栈原来的区块 + xylf_t context; + context.x = x; + context.y = y; + context.l = left; + context.r = right; + lifo_enqueue(&lifo, &context); + //mp_printf(&mp_plat_print, "#x=%x,y=%d;x1=%d,y1=%d\n",x,y,i,y-1); + x = i; + y = y - 1; + recurse = true; + break; + } + if (recurse) + break; + } + //查找下一行有没有在同一区域的点 + if (y < q->h - 1) + { + row = q->pixels + (y + 1) * q->w; + + bool recurse = false; + for (i = left; i <= right; i++) + if (row[i] == from) + { + xylf_t context; + context.x = x; + context.y = y; + context.l = left; + context.r = right; + lifo_enqueue(&lifo, &context); + //mp_printf(&mp_plat_print, "#x=%x,y=%d;x1=%d,y1=%d\n",x,y,i,y+1); + x = i; + y = y + 1; + recurse = true; + break; + } + if (recurse) + break; + } + } + + if (!lifo_size(&lifo)) + { + lifo_free(&lifo); //如果最起始为止就没找到,那么返回 + return; + } + //本次迭代,往上,往下找边界(相同颜色像素点),直到找不到为止 + //找到边界后,出栈上层像素点,回退回去 + xylf_t context; + lifo_dequeue(&lifo, &context); //这里存疑,如果都没有的话,dequeue就会反向溢出吧。。 + x = context.x; + y = context.y; + left = context.l; + right = context.r; + //mp_printf(&mp_plat_print, "#deq: x=%x,y=%d\n",x,y); + } //找到相同from,break到这外面 + } +} + +/************************************************************************ + * Adaptive thresholding + */ + +#define THRESHOLD_S_MIN 1 +#define THRESHOLD_S_DEN 8 +#define THRESHOLD_T 5 + +static void threshold(struct quirc *q) +{ + int x, y; + int avg_w = 0; + int avg_u = 0; + int threshold_s = q->w / THRESHOLD_S_DEN; + quirc_pixel_t *row = q->pixels; + + /* + * Ensure a sane, non-zero value for threshold_s. + * + * threshold_s can be zero if the image width is small. We need to avoid + * SIGFPE as it will be used as divisor. + */ + if (threshold_s < THRESHOLD_S_MIN) + threshold_s = THRESHOLD_S_MIN; + + for (y = 0; y < q->h; y++) + { + int row_average[q->w]; + + memset(row_average, 0, sizeof(row_average)); + + for (x = 0; x < q->w; x++) + { + int w, u; + + if (y & 1) + { + w = x; + u = q->w - 1 - x; + } + else + { + w = q->w - 1 - x; + u = x; + } + + avg_w = (avg_w * (threshold_s - 1)) / + threshold_s + + row[w]; + avg_u = (avg_u * (threshold_s - 1)) / + threshold_s + + row[u]; + + row_average[w] += avg_w; + row_average[u] += avg_u; + } + + for (x = 0; x < q->w; x++) + { + if (row[x] < row_average[x] * + (100 - THRESHOLD_T) / (200 * threshold_s)) + row[x] = QUIRC_PIXEL_BLACK; + else + row[x] = QUIRC_PIXEL_WHITE; + } + + row += q->w; + } +} + +static void area_count(void *user_data, int y, int left, int right) +{ + ((struct quirc_region *)user_data)->count += right - left + 1; +} + +static int region_code(struct quirc *q, int x, int y) +{ //region指的是QRcode的区域,成员为区域的坐标,像素面积,是否顶点 + int pixel; + struct quirc_region *box; + int region; + + if (x < 0 || y < 0 || x >= q->w || y >= q->h) + return -1; + + pixel = q->pixels[y * q->w + x]; + //预先判断非正常的像素情况,退出 + if (pixel >= QUIRC_PIXEL_REGION) + return pixel; + + if (pixel == QUIRC_PIXEL_WHITE) + return -1; + + if (q->num_regions >= QUIRC_MAX_REGIONS) + return -1; + //新建一个区域 + region = q->num_regions; + box = &q->regions[q->num_regions++]; + + memset(box, 0, sizeof(*box)); + + box->seed.x = x; + box->seed.y = y; + box->capstone = -1; + //计算该区域的面积 + flood_fill_seed(q, x, y, pixel, region, area_count, box, 0); + + return region; +} + +struct polygon_score_data +{ + struct quirc_point ref; + + int scores[4]; + struct quirc_point *corners; +} __attribute__((aligned(8))); + +static void find_one_corner(void *user_data, int y, int left, int right) +{ + struct polygon_score_data *psd = + (struct polygon_score_data *)user_data; + int xs[2] = {left, right}; + int dy = y - psd->ref.y; + int i; + + for (i = 0; i < 2; i++) + { + int dx = xs[i] - psd->ref.x; + int d = dx * dx + dy * dy; + + if (d > psd->scores[0]) + { + psd->scores[0] = d; + psd->corners[0].x = xs[i]; + psd->corners[0].y = y; + } + } +} + +static void find_other_corners(void *user_data, int y, int left, int right) +{ + struct polygon_score_data *psd = + (struct polygon_score_data *)user_data; + int xs[2] = {left, right}; + int i; + + for (i = 0; i < 2; i++) + { + int up = xs[i] * psd->ref.x + y * psd->ref.y; + int right = xs[i] * -psd->ref.y + y * psd->ref.x; + int scores[4] = {up, right, -up, -right}; + int j; + + for (j = 0; j < 4; j++) + { + if (scores[j] > psd->scores[j]) + { + psd->scores[j] = scores[j]; + psd->corners[j].x = xs[i]; + psd->corners[j].y = y; + } + } + } +} + +static void find_region_corners(struct quirc *q, + int rcode, const struct quirc_point *ref, + struct quirc_point *corners) +{ + struct quirc_region *region = &q->regions[rcode]; + struct polygon_score_data psd; + int i; + + memset(&psd, 0, sizeof(psd)); + psd.corners = corners; + + memcpy(&psd.ref, ref, sizeof(psd.ref)); + psd.scores[0] = -1; + flood_fill_seed(q, region->seed.x, region->seed.y, + rcode, QUIRC_PIXEL_BLACK, + find_one_corner, &psd, 0); + + psd.ref.x = psd.corners[0].x - psd.ref.x; + psd.ref.y = psd.corners[0].y - psd.ref.y; + + for (i = 0; i < 4; i++) + memcpy(&psd.corners[i], ®ion->seed, + sizeof(psd.corners[i])); + + i = region->seed.x * psd.ref.x + region->seed.y * psd.ref.y; + psd.scores[0] = i; + psd.scores[2] = -i; + i = region->seed.x * -psd.ref.y + region->seed.y * psd.ref.x; + psd.scores[1] = i; + psd.scores[3] = -i; + + flood_fill_seed(q, region->seed.x, region->seed.y, + QUIRC_PIXEL_BLACK, rcode, + find_other_corners, &psd, 0); +} + +static void record_capstone(struct quirc *q, int ring, int stone) +{ + struct quirc_region *stone_reg = &q->regions[stone]; + struct quirc_region *ring_reg = &q->regions[ring]; + struct quirc_capstone *capstone; + int cs_index; + + if (q->num_capstones >= QUIRC_MAX_CAPSTONES) + return; + + cs_index = q->num_capstones; + capstone = &q->capstones[q->num_capstones++]; + + memset(capstone, 0, sizeof(*capstone)); + + capstone->qr_grid = -1; + capstone->ring = ring; + capstone->stone = stone; + stone_reg->capstone = cs_index; + ring_reg->capstone = cs_index; + + /* Find the corners of the ring */ + find_region_corners(q, ring, &stone_reg->seed, capstone->corners); + + /* Set up the perspective transform and find the center */ + perspective_setup(capstone->c, capstone->corners, 7.0, 7.0); + perspective_map(capstone->c, 3.5, 3.5, &capstone->center); +} + +static void test_capstone(struct quirc *q, int x, int y, int *pb) +{ + int ring_right = region_code(q, x - pb[4], y); //x-pb[4]是标记环右边的左侧 + int stone = region_code(q, x - pb[4] - pb[3] - pb[2], y); //实心点左侧 + int ring_left = region_code(q, x - pb[4] - pb[3] - pb[2] - pb[1] - pb[0], y); //环左侧 + struct quirc_region *stone_reg; + struct quirc_region *ring_reg; + int ratio; + //以下检测顶点标记是否符合规范,环称为ring,中间称为stone + if (ring_left < 0 || ring_right < 0 || stone < 0) + return; + + /* Left and ring of ring should be connected */ + if (ring_left != ring_right) + return; + + /* Ring should be disconnected from stone */ + if (ring_left == stone) + return; + + stone_reg = &q->regions[stone]; + ring_reg = &q->regions[ring_left]; + + /* Already detected */ + if (stone_reg->capstone >= 0 || ring_reg->capstone >= 0) + return; + + /* Ratio should ideally be 37.5 中间实心点占面积比例应该在37.5%左右*/ + ratio = stone_reg->count * 100 / ring_reg->count; + if (ratio < 10 || ratio > 70) + return; + + record_capstone(q, ring_left, stone); +} + +static void finder_scan(struct quirc *q, int y) +{ + quirc_pixel_t *row = q->pixels + y * q->w; + int x; + int last_color = 0; + int run_length = 0; + int run_count = 0; + int pb[5]; //means QRcode's pixel width + + memset(pb, 0, sizeof(pb)); + for (x = 0; x < q->w; x++) + { + int color = row[x] ? 1 : 0; + + if (x && color != last_color) + { // color is different + memmove(pb, pb + 1, sizeof(pb[0]) * 4); //left move in one data + pb[4] = run_length; //run how many pix to get different color + run_length = 0; + run_count++; //get more than 5 time color jump + + if (!color && run_count >= 5) + { // find the marker of QRcode(three corner's marker) + static int check[5] = {1, 1, 3, 1, 1}; + int avg, err; + int i; + int ok = 1; + + avg = (pb[0] + pb[1] + pb[3] + pb[4]) / 4; + err = avg * 3 / 4; + + for (i = 0; i < 5; i++) + if (pb[i] < check[i] * avg - err || + pb[i] > check[i] * avg + err) + ok = 0; + + if (ok) + test_capstone(q, x, y, pb); + } + } + + run_length++; + last_color = color; + } +} + +static void find_alignment_pattern(struct quirc *q, int index) +{ + struct quirc_grid *qr = &q->grids[index]; + struct quirc_capstone *c0 = &q->capstones[qr->caps[0]]; + struct quirc_capstone *c2 = &q->capstones[qr->caps[2]]; + struct quirc_point a; + struct quirc_point b; + struct quirc_point c; + int size_estimate; + int step_size = 1; + int dir = 0; + float u, v; + + /* Grab our previous estimate of the alignment pattern corner */ + memcpy(&b, &qr->align, sizeof(b)); + + /* Guess another two corners of the alignment pattern so that we + * can estimate its size. + */ + perspective_unmap(c0->c, &b, &u, &v); + perspective_map(c0->c, u, v + 1.0, &a); + perspective_unmap(c2->c, &b, &u, &v); + perspective_map(c2->c, u + 1.0, v, &c); + + size_estimate = abs((a.x - b.x) * -(c.y - b.y) + + (a.y - b.y) * (c.x - b.x)); + + /* Spiral outwards from the estimate point until we find something + * roughly the right size. Don't look too far from the estimate + * point. + */ + while (step_size * step_size < size_estimate * 100) + { + static const int dx_map[] = {1, 0, -1, 0}; + static const int dy_map[] = {0, -1, 0, 1}; + int i; + + for (i = 0; i < step_size; i++) + { + int code = region_code(q, b.x, b.y); + + if (code >= 0) + { + struct quirc_region *reg = &q->regions[code]; + + if (reg->count >= size_estimate / 2 && + reg->count <= size_estimate * 2) + { + qr->align_region = code; + return; + } + } + + b.x += dx_map[dir]; + b.y += dy_map[dir]; + } + + dir = (dir + 1) % 4; + if (!(dir & 1)) + step_size++; + } +} + +static void find_leftmost_to_line(void *user_data, int y, int left, int right) +{ + struct polygon_score_data *psd = + (struct polygon_score_data *)user_data; + int xs[2] = {left, right}; + int i; + + for (i = 0; i < 2; i++) + { + int d = -psd->ref.y * xs[i] + psd->ref.x * y; + + if (d < psd->scores[0]) + { + psd->scores[0] = d; + psd->corners[0].x = xs[i]; + psd->corners[0].y = y; + } + } +} + +/* Do a Bresenham scan from one point to another and count the number + * of black/white transitions. + */ +static int timing_scan(const struct quirc *q, + const struct quirc_point *p0, + const struct quirc_point *p1) +{ + int n = p1->x - p0->x; + int d = p1->y - p0->y; + int x = p0->x; + int y = p0->y; + int *dom, *nondom; + int dom_step; + int nondom_step; + int a = 0; + int i; + int run_length = 0; + int count = 0; + + if (p0->x < 0 || p0->y < 0 || p0->x >= q->w || p0->y >= q->h) + return -1; + if (p1->x < 0 || p1->y < 0 || p1->x >= q->w || p1->y >= q->h) + return -1; + + if (abs(n) > abs(d)) + { + int swap = n; + + n = d; + d = swap; + + dom = &x; + nondom = &y; + } + else + { + dom = &y; + nondom = &x; + } + + if (n < 0) + { + n = -n; + nondom_step = -1; + } + else + { + nondom_step = 1; + } + + if (d < 0) + { + d = -d; + dom_step = -1; + } + else + { + dom_step = 1; + } + + x = p0->x; + y = p0->y; + for (i = 0; i <= d; i++) + { + int pixel; + + if (y < 0 || y >= q->h || x < 0 || x >= q->w) + break; + + pixel = q->pixels[y * q->w + x]; + + if (pixel) + { + if (run_length >= 2) + count++; + run_length = 0; + } + else + { + run_length++; + } + + a += n; + *dom += dom_step; + if (a >= d) + { + *nondom += nondom_step; + a -= d; + } + } + + return count; +} + +/* Try the measure the timing pattern for a given QR code. This does + * not require the global perspective to have been set up, but it + * does require that the capstone corners have been set to their + * canonical rotation. + * + * For each capstone, we find a point in the middle of the ring band + * which is nearest the centre of the code. Using these points, we do + * a horizontal and a vertical timing scan. + */ +static int measure_timing_pattern(struct quirc *q, int index) +{ + struct quirc_grid *qr = &q->grids[index]; + int i; + int scan; + int ver; + int size; + + for (i = 0; i < 3; i++) + { + static const float us[] = {6.5, 6.5, 0.5}; + static const float vs[] = {0.5, 6.5, 6.5}; + struct quirc_capstone *cap = &q->capstones[qr->caps[i]]; + + perspective_map(cap->c, us[i], vs[i], &qr->tpep[i]); + } + + qr->hscan = timing_scan(q, &qr->tpep[1], &qr->tpep[2]); + qr->vscan = timing_scan(q, &qr->tpep[1], &qr->tpep[0]); + + scan = qr->hscan; + if (qr->vscan > scan) + scan = qr->vscan; + + /* If neither scan worked, we can't go any further. */ + if (scan < 0) + return -1; + + /* Choose the nearest allowable grid size */ + size = scan * 2 + 13; + ver = (size - 15) / 4; + qr->grid_size = ver * 4 + 17; + + return 0; +} + +/* Read a cell from a grid using the currently set perspective + * transform. Returns +/- 1 for black/white, 0 for cells which are + * out of image bounds. + */ +static int read_cell(const struct quirc *q, int index, int x, int y) +{ + const struct quirc_grid *qr = &q->grids[index]; + struct quirc_point p; + + perspective_map(qr->c, x + 0.5, y + 0.5, &p); + if (p.y < 0 || p.y >= q->h || p.x < 0 || p.x >= q->w) + return 0; + + return q->pixels[p.y * q->w + p.x] ? 1 : -1; +} + +static int fitness_cell(const struct quirc *q, int index, int x, int y) +{ + const struct quirc_grid *qr = &q->grids[index]; + int score = 0; + int u, v; + + for (v = 0; v < 3; v++) + for (u = 0; u < 3; u++) + { + static const float offsets[] = {0.3, 0.5, 0.7}; + struct quirc_point p; + + perspective_map(qr->c, x + offsets[u], + y + offsets[v], &p); + if (p.y < 0 || p.y >= q->h || p.x < 0 || p.x >= q->w) + continue; + + if (q->pixels[p.y * q->w + p.x]) + score++; + else + score--; + } + + return score; +} + +static int fitness_ring(const struct quirc *q, int index, int cx, int cy, + int radius) +{ + int i; + int score = 0; + + for (i = 0; i < radius * 2; i++) + { + score += fitness_cell(q, index, cx - radius + i, cy - radius); + score += fitness_cell(q, index, cx - radius, cy + radius - i); + score += fitness_cell(q, index, cx + radius, cy - radius + i); + score += fitness_cell(q, index, cx + radius - i, cy + radius); + } + + return score; +} + +static int fitness_apat(const struct quirc *q, int index, int cx, int cy) +{ + return fitness_cell(q, index, cx, cy) - + fitness_ring(q, index, cx, cy, 1) + + fitness_ring(q, index, cx, cy, 2); +} + +static int fitness_capstone(const struct quirc *q, int index, int x, int y) +{ + x += 3; + y += 3; + + return fitness_cell(q, index, x, y) + + fitness_ring(q, index, x, y, 1) - + fitness_ring(q, index, x, y, 2) + + fitness_ring(q, index, x, y, 3); +} + +/* Compute a fitness score for the currently configured perspective + * transform, using the features we expect to find by scanning the + * grid. + */ +static int fitness_all(const struct quirc *q, int index) +{ + const struct quirc_grid *qr = &q->grids[index]; + int version = (qr->grid_size - 17) / 4; + const struct quirc_version_info *info = &quirc_version_db[version]; + int score = 0; + int i, j; + int ap_count; + + /* Check the timing pattern */ + for (i = 0; i < qr->grid_size - 14; i++) + { + int expect = (i & 1) ? 1 : -1; + + score += fitness_cell(q, index, i + 7, 6) * expect; + score += fitness_cell(q, index, 6, i + 7) * expect; + } + + /* Check capstones */ + score += fitness_capstone(q, index, 0, 0); + score += fitness_capstone(q, index, qr->grid_size - 7, 0); + score += fitness_capstone(q, index, 0, qr->grid_size - 7); + + if (version < 0 || version > QUIRC_MAX_VERSION) + return score; + + /* Check alignment patterns */ + ap_count = 0; + while ((ap_count < QUIRC_MAX_ALIGNMENT) && info->apat[ap_count]) + ap_count++; + + for (i = 1; i + 1 < ap_count; i++) + { + score += fitness_apat(q, index, 6, info->apat[i]); + score += fitness_apat(q, index, info->apat[i], 6); + } + + for (i = 1; i < ap_count; i++) + for (j = 1; j < ap_count; j++) + score += fitness_apat(q, index, + info->apat[i], info->apat[j]); + //mp_printf(&mp_plat_print, "##score=%d\n",score); + return score; +} + +static void jiggle_perspective(struct quirc *q, int index) +{ + struct quirc_grid *qr = &q->grids[index]; + int best = fitness_all(q, index); + int pass; + float adjustments[8]; + int i; + + for (i = 0; i < 8; i++) + adjustments[i] = qr->c[i] * 0.02; + + for (pass = 0; pass < 5; pass++) + { + for (i = 0; i < 16; i++) + { + int j = i >> 1; + int test; + float old = qr->c[j]; + float step = adjustments[j]; + float new; + + if (i & 1) + new = old + step; + else + new = old - step; + + qr->c[j] = new; + test = fitness_all(q, index); + + if (test > best) + best = test; + else + qr->c[j] = old; + } + + for (i = 0; i < 8; i++) + adjustments[i] *= 0.5; + } +} + +/* Once the capstones are in place and an alignment point has been + * chosen, we call this function to set up a grid-reading perspective + * transform. + */ +static void setup_qr_perspective(struct quirc *q, int index) +{ + struct quirc_grid *qr = &q->grids[index]; + struct quirc_point rect[4]; + + /* Set up the perspective map for reading the grid */ + memcpy(&rect[0], &q->capstones[qr->caps[1]].corners[0], + sizeof(rect[0])); + memcpy(&rect[1], &q->capstones[qr->caps[2]].corners[0], + sizeof(rect[0])); + memcpy(&rect[2], &qr->align, sizeof(rect[0])); + memcpy(&rect[3], &q->capstones[qr->caps[0]].corners[0], + sizeof(rect[0])); + perspective_setup(qr->c, rect, qr->grid_size - 7, qr->grid_size - 7); + + jiggle_perspective(q, index); +} + +/* Rotate the capstone with so that corner 0 is the leftmost with respect + * to the given reference line. + */ +static void rotate_capstone(struct quirc_capstone *cap, + const struct quirc_point *h0, + const struct quirc_point *hd) +{ + struct quirc_point copy[4]; + int j; + int best = 0; + int best_score = 0; + + for (j = 0; j < 4; j++) + { + struct quirc_point *p = &cap->corners[j]; + int score = (p->x - h0->x) * -hd->y + + (p->y - h0->y) * hd->x; + + if (!j || score < best_score) + { + best = j; + best_score = score; + } + } + + /* Rotate the capstone */ + for (j = 0; j < 4; j++) + memcpy(©[j], &cap->corners[(j + best) % 4], + sizeof(copy[j])); + memcpy(cap->corners, copy, sizeof(cap->corners)); + perspective_setup(cap->c, cap->corners, 7.0, 7.0); +} + +static void record_qr_grid(struct quirc *q, int a, int b, int c) +{ + struct quirc_point h0, hd; + int i; + int qr_index; + struct quirc_grid *qr; + + if (q->num_grids >= QUIRC_MAX_GRIDS) + return; + + /* Construct the hypotenuse line from A to C. B should be to + * the left of this line. + */ + memcpy(&h0, &q->capstones[a].center, sizeof(h0)); + hd.x = q->capstones[c].center.x - q->capstones[a].center.x; + hd.y = q->capstones[c].center.y - q->capstones[a].center.y; + + /* Make sure A-B-C is clockwise */ + if ((q->capstones[b].center.x - h0.x) * -hd.y + + (q->capstones[b].center.y - h0.y) * hd.x > + 0) + { + int swap = a; + + a = c; + c = swap; + hd.x = -hd.x; + hd.y = -hd.y; + } + + /* Record the grid and its components */ + qr_index = q->num_grids; + qr = &q->grids[q->num_grids++]; + + memset(qr, 0, sizeof(*qr)); + qr->caps[0] = a; + qr->caps[1] = b; + qr->caps[2] = c; + qr->align_region = -1; + + /* Rotate each capstone so that corner 0 is top-left with respect + * to the grid. + */ + for (i = 0; i < 3; i++) + { + struct quirc_capstone *cap = &q->capstones[qr->caps[i]]; + + rotate_capstone(cap, &h0, &hd); + cap->qr_grid = qr_index; + } + + /* Check the timing pattern. This doesn't require a perspective + * transform. + */ + if (measure_timing_pattern(q, qr_index) < 0) + goto fail; + + /* Make an estimate based for the alignment pattern based on extending + * lines from capstones A and C. + */ + if (!line_intersect(&q->capstones[a].corners[0], + &q->capstones[a].corners[1], + &q->capstones[c].corners[0], + &q->capstones[c].corners[3], + &qr->align)) + goto fail; + + /* On V2+ grids, we should use the alignment pattern. */ + if (qr->grid_size > 21) + { + /* Try to find the actual location of the alignment pattern. */ + find_alignment_pattern(q, qr_index); + + /* Find the point of the alignment pattern closest to the + * top-left of the QR grid. + */ + if (qr->align_region >= 0) + { + struct polygon_score_data psd; + struct quirc_region *reg = + &q->regions[qr->align_region]; + + /* Start from some point inside the alignment pattern */ + memcpy(&qr->align, ®->seed, sizeof(qr->align)); + + memcpy(&psd.ref, &hd, sizeof(psd.ref)); + psd.corners = &qr->align; + psd.scores[0] = -hd.y * qr->align.x + + hd.x * qr->align.y; + + flood_fill_seed(q, reg->seed.x, reg->seed.y, + qr->align_region, QUIRC_PIXEL_BLACK, + NULL, NULL, 0); + flood_fill_seed(q, reg->seed.x, reg->seed.y, + QUIRC_PIXEL_BLACK, qr->align_region, + find_leftmost_to_line, &psd, 0); + } + } + + setup_qr_perspective(q, qr_index); + return; + +fail: + /* We've been unable to complete setup for this grid. Undo what we've + * recorded and pretend it never happened. + */ + for (i = 0; i < 3; i++) + q->capstones[qr->caps[i]].qr_grid = -1; + q->num_grids--; +} + +struct neighbour +{ + int index; + float distance; +} __attribute__((aligned(8))); + +struct neighbour_list +{ + struct neighbour n[QUIRC_MAX_CAPSTONES]; + int count; +} __attribute__((aligned(8))); + +static void test_neighbours(struct quirc *q, int i, + const struct neighbour_list *hlist, + const struct neighbour_list *vlist) +{ + int j, k; + float best_score = 0.0; + int best_h = -1, best_v = -1; + + /* Test each possible grouping */ + for (j = 0; j < hlist->count; j++) + for (k = 0; k < vlist->count; k++) + { + const struct neighbour *hn = &hlist->n[j]; + const struct neighbour *vn = &vlist->n[k]; + float score = fast_fabsf(1.0 - hn->distance / vn->distance); + + if (score > 2.5) + continue; + + if (best_h < 0 || score < best_score) + { + best_h = hn->index; + best_v = vn->index; + best_score = score; + } + } + + if (best_h < 0 || best_v < 0) + return; + + record_qr_grid(q, best_h, i, best_v); +} + +static void test_grouping(struct quirc *q, int i) +{ + struct quirc_capstone *c1 = &q->capstones[i]; + int j; + struct neighbour_list hlist; + struct neighbour_list vlist; + + if (c1->qr_grid >= 0) + return; + + hlist.count = 0; + vlist.count = 0; + + /* Look for potential neighbours by examining the relative gradients + * from this capstone to others. + */ + for (j = 0; j < q->num_capstones; j++) + { + struct quirc_capstone *c2 = &q->capstones[j]; + float u, v; + + if (i == j || c2->qr_grid >= 0) + continue; + + perspective_unmap(c1->c, &c2->center, &u, &v); + + u = fast_fabsf(u - 3.5); + v = fast_fabsf(v - 3.5); + + if (u < 0.2 * v) + { + struct neighbour *n = &hlist.n[hlist.count++]; + + n->index = j; + n->distance = v; + } + + if (v < 0.2 * u) + { + struct neighbour *n = &vlist.n[vlist.count++]; + + n->index = j; + n->distance = u; + } + } + + if (!(hlist.count && vlist.count)) + return; + + test_neighbours(q, i, &hlist, &vlist); +} + +static void pixels_setup(struct quirc *q) +{ + if (sizeof(*q->image) == sizeof(*q->pixels)) + { + q->pixels = (quirc_pixel_t *)q->image; + } + else + { + int x, y; + for (y = 0; y < q->h; y++) + { + for (x = 0; x < q->w; x++) + { + q->pixels[y * q->w + x] = q->image[y * q->w + x]; + } + } + } +} + +uint8_t *quirc_begin(struct quirc *q, int *w, int *h) +{ + q->num_regions = QUIRC_PIXEL_REGION; + q->num_capstones = 0; + q->num_grids = 0; + + if (w) + *w = q->w; + if (h) + *h = q->h; + + return q->image; +} + +void quirc_end(struct quirc *q) +{ + int i; + pixels_setup(q); + threshold(q); + + for (i = 0; i < q->h; i++) + { + finder_scan(q, i); + } + + for (i = 0; i < q->num_capstones; i++) + { + test_grouping(q, i); + } +} + +void quirc_extract(const struct quirc *q, int index, + struct quirc_code *code) +{ + const struct quirc_grid *qr = &q->grids[index]; + int y; + int i = 0; + + if (index < 0 || index > q->num_grids) + return; + + memset(code, 0, sizeof(*code)); + + perspective_map(qr->c, 0.0, 0.0, &code->corners[0]); + perspective_map(qr->c, qr->grid_size, 0.0, &code->corners[1]); + perspective_map(qr->c, qr->grid_size, qr->grid_size, + &code->corners[2]); + perspective_map(qr->c, 0.0, qr->grid_size, &code->corners[3]); + + code->size = qr->grid_size; + + for (y = 0; y < qr->grid_size; y++) + { + int x; + + for (x = 0; x < qr->grid_size; x++) + { + if (read_cell(q, index, x, y) > 0) + code->cell_bitmap[i >> 3] |= (1 << (i & 7)); + + i++; + } + } +} diff --git a/libraries/ESP32QRCodeReader_Page_original/quirc.c b/libraries/ESP32QRCodeReader_Page_original/quirc.c new file mode 100644 index 0000000..e5a30fb --- /dev/null +++ b/libraries/ESP32QRCodeReader_Page_original/quirc.c @@ -0,0 +1,104 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include "quirc_internal.h" +#include + +const char *quirc_version(void) +{ + return "1.0"; +} + +//static struct quirc _q; +struct quirc *quirc_new(void) +{ + struct quirc *q = ps_malloc(sizeof(*q)); + + if (!q) + return NULL; + + memset(q, 0, sizeof(*q)); + return q; +} + +void quirc_destroy(struct quirc *q) +{ + if (q->image) + if (q->image) + free(q->image); + if (sizeof(*q->image) != sizeof(*q->pixels)) + if (q->pixels) + free(q->pixels); + + if (q) + free(q); +} + +//static quirc_pixel_t img_buf[320*240]; +int quirc_resize(struct quirc *q, int w, int h) +{ + if (q->image) + { + free(q->image); + } + uint8_t *new_image = ps_malloc(w * h); + + if (!new_image) + return -1; + + if (sizeof(*q->image) != sizeof(*q->pixels)) + { //should gray, 1==1 + size_t new_size = w * h * sizeof(quirc_pixel_t); + if (q->pixels) + free(q->pixels); + quirc_pixel_t *new_pixels = ps_malloc(new_size); + if (!new_pixels) + { + free(new_image); + return -1; + } + q->pixels = new_pixels; + } + q->image = new_image; + q->w = w; + q->h = h; + return 0; +} + +int quirc_count(const struct quirc *q) +{ + return q->num_grids; +} + +static const char *const error_table[] = { + [QUIRC_SUCCESS] = "Success", + [QUIRC_ERROR_INVALID_GRID_SIZE] = "Invalid grid size", + [QUIRC_ERROR_INVALID_VERSION] = "Invalid version", + [QUIRC_ERROR_FORMAT_ECC] = "Format data ECC failure", + [QUIRC_ERROR_DATA_ECC] = "ECC failure", + [QUIRC_ERROR_UNKNOWN_DATA_TYPE] = "Unknown data type", + [QUIRC_ERROR_DATA_OVERFLOW] = "Data overflow", + [QUIRC_ERROR_DATA_UNDERFLOW] = "Data underflow"}; + +const char *quirc_strerror(quirc_decode_error_t err) +{ + if (err >= 0 && err < sizeof(error_table) / sizeof(error_table[0])) + return error_table[err]; + + return "Unknown error"; +} diff --git a/libraries/ESP32QRCodeReader_Page_original/quirc.h b/libraries/ESP32QRCodeReader_Page_original/quirc.h new file mode 100644 index 0000000..ecdc172 --- /dev/null +++ b/libraries/ESP32QRCodeReader_Page_original/quirc.h @@ -0,0 +1,178 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef QUIRC_H_ +#define QUIRC_H_ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + struct quirc; + + /* Obtain the library version string. */ + const char *quirc_version(void); + + /* Construct a new QR-code recognizer. This function will return NULL + * if sufficient memory could not be allocated. + */ + struct quirc *quirc_new(void); + + /* Destroy a QR-code recognizer. */ + void quirc_destroy(struct quirc *q); + + /* Resize the QR-code recognizer. The size of an image must be + * specified before codes can be analyzed. + * + * This function returns 0 on success, or -1 if sufficient memory could + * not be allocated. + */ + int quirc_resize(struct quirc *q, int w, int h); + + /* These functions are used to process images for QR-code recognition. + * quirc_begin() must first be called to obtain access to a buffer into + * which the input image should be placed. Optionally, the current + * width and height may be returned. + * + * After filling the buffer, quirc_end() should be called to process + * the image for QR-code recognition. The locations and content of each + * code may be obtained using accessor functions described below. + */ + uint8_t *quirc_begin(struct quirc *q, int *w, int *h); + void quirc_end(struct quirc *q); + + /* This structure describes a location in the input image buffer. */ + struct quirc_point + { + int x; + int y; + } __attribute__((aligned(8))); + + /* This enum describes the various decoder errors which may occur. */ + typedef enum + { + QUIRC_SUCCESS = 0, + QUIRC_ERROR_INVALID_GRID_SIZE, + QUIRC_ERROR_INVALID_VERSION, + QUIRC_ERROR_FORMAT_ECC, + QUIRC_ERROR_DATA_ECC, + QUIRC_ERROR_UNKNOWN_DATA_TYPE, + QUIRC_ERROR_DATA_OVERFLOW, + QUIRC_ERROR_DATA_UNDERFLOW + } quirc_decode_error_t; + + /* Return a string error message for an error code. */ + const char *quirc_strerror(quirc_decode_error_t err); + +/* Limits on the maximum size of QR-codes and their content. */ +#define QUIRC_MAX_BITMAP 3917 +#define QUIRC_MAX_PAYLOAD 8896 + +/* QR-code ECC types. */ +#define QUIRC_ECC_LEVEL_M 0 +#define QUIRC_ECC_LEVEL_L 1 +#define QUIRC_ECC_LEVEL_H 2 +#define QUIRC_ECC_LEVEL_Q 3 + +/* QR-code data types. */ +#define QUIRC_DATA_TYPE_NUMERIC 1 +#define QUIRC_DATA_TYPE_ALPHA 2 +#define QUIRC_DATA_TYPE_BYTE 4 +#define QUIRC_DATA_TYPE_KANJI 8 + +/* Common character encodings */ +#define QUIRC_ECI_ISO_8859_1 1 +#define QUIRC_ECI_IBM437 2 +#define QUIRC_ECI_ISO_8859_2 4 +#define QUIRC_ECI_ISO_8859_3 5 +#define QUIRC_ECI_ISO_8859_4 6 +#define QUIRC_ECI_ISO_8859_5 7 +#define QUIRC_ECI_ISO_8859_6 8 +#define QUIRC_ECI_ISO_8859_7 9 +#define QUIRC_ECI_ISO_8859_8 10 +#define QUIRC_ECI_ISO_8859_9 11 +#define QUIRC_ECI_WINDOWS_874 13 +#define QUIRC_ECI_ISO_8859_13 15 +#define QUIRC_ECI_ISO_8859_15 17 +#define QUIRC_ECI_SHIFT_JIS 20 +#define QUIRC_ECI_UTF_8 26 + + /* This structure is used to return information about detected QR codes + * in the input image. + */ + struct quirc_code + { + /* The four corners of the QR-code, from top left, clockwise */ + struct quirc_point corners[4]; + + /* The number of cells across in the QR-code. The cell bitmap + * is a bitmask giving the actual values of cells. If the cell + * at (x, y) is black, then the following bit is set: + * + * cell_bitmap[i >> 3] & (1 << (i & 7)) + * + * where i = (y * size) + x. + */ + int size; + uint8_t cell_bitmap[QUIRC_MAX_BITMAP]; + } __attribute__((aligned(8))); + + /* This structure holds the decoded QR-code data */ + struct quirc_data + { + /* Various parameters of the QR-code. These can mostly be + * ignored if you only care about the data. + */ + int version; + int ecc_level; + int mask; + + /* This field is the highest-valued data type found in the QR + * code. + */ + int data_type; + + /* Data payload. For the Kanji datatype, payload is encoded as + * Shift-JIS. For all other datatypes, payload is ASCII text. + */ + uint8_t payload[QUIRC_MAX_PAYLOAD]; + int payload_len; + + /* ECI assignment number */ + uint32_t eci; + } __attribute__((aligned(8))); + + /* Return the number of QR-codes identified in the last processed + * image. + */ + int quirc_count(const struct quirc *q); + + /* Extract the QR-code specified by the given index. */ + void quirc_extract(const struct quirc *q, int index, + struct quirc_code *code); + + /* Decode a QR-code, returning the payload data. */ + quirc_decode_error_t quirc_decode(const struct quirc_code *code, + struct quirc_data *data); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/libraries/ESP32QRCodeReader_Page_original/quirc_internal.h b/libraries/ESP32QRCodeReader_Page_original/quirc_internal.h new file mode 100644 index 0000000..3fa075c --- /dev/null +++ b/libraries/ESP32QRCodeReader_Page_original/quirc_internal.h @@ -0,0 +1,121 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef QUIRC_INTERNAL_H_ +#define QUIRC_INTERNAL_H_ + +#include "quirc.h" + +#define QUIRC_PIXEL_WHITE 0 +#define QUIRC_PIXEL_BLACK 1 +#define QUIRC_PIXEL_REGION 2 + +#ifndef QUIRC_MAX_REGIONS +#define QUIRC_MAX_REGIONS 254 +#endif + +#define QUIRC_MAX_CAPSTONES 32 +#define QUIRC_MAX_GRIDS 8 + +#define QUIRC_PERSPECTIVE_PARAMS 8 + +#if QUIRC_MAX_REGIONS < UINT8_MAX +typedef uint8_t quirc_pixel_t; +#elif QUIRC_MAX_REGIONS < UINT16_MAX +typedef uint16_t quirc_pixel_t; +#else +#error "QUIRC_MAX_REGIONS > 65534 is not supported" +#endif + +struct quirc_region +{ + struct quirc_point seed; + int count; + int capstone; +} __attribute__((aligned(8))); + +struct quirc_capstone +{ + int ring; + int stone; + + struct quirc_point corners[4]; + struct quirc_point center; + float c[QUIRC_PERSPECTIVE_PARAMS]; + + int qr_grid; +} __attribute__((aligned(8))); + +struct quirc_grid +{ + /* Capstone indices */ + int caps[3]; + + /* Alignment pattern region and corner */ + int align_region; + struct quirc_point align; + + /* Timing pattern endpoints */ + struct quirc_point tpep[3]; + int hscan; + int vscan; + + /* Grid size and perspective transform */ + int grid_size; + float c[QUIRC_PERSPECTIVE_PARAMS]; +} __attribute__((aligned(8))); + +struct quirc +{ + uint8_t *image; + quirc_pixel_t *pixels; + int w; + int h; + + int num_regions; + struct quirc_region regions[QUIRC_MAX_REGIONS]; + + int num_capstones; + struct quirc_capstone capstones[QUIRC_MAX_CAPSTONES]; + + int num_grids; + struct quirc_grid grids[QUIRC_MAX_GRIDS]; +} __attribute__((aligned(8))); + +/************************************************************************ + * QR-code version information database + */ + +#define QUIRC_MAX_VERSION 40 +#define QUIRC_MAX_ALIGNMENT 7 + +struct quirc_rs_params +{ + uint8_t bs; /* Small block size */ + uint8_t dw; /* Small data words */ + uint8_t ns; /* Number of small blocks */ +} __attribute__((aligned(8))); + +struct quirc_version_info +{ + uint16_t data_bytes; + uint8_t apat[QUIRC_MAX_ALIGNMENT]; + struct quirc_rs_params ecc[4]; +} __attribute__((aligned(8))); + +extern const struct quirc_version_info quirc_version_db[QUIRC_MAX_VERSION + 1]; + +#endif \ No newline at end of file diff --git a/libraries/ESP32QRCodeReader_Page_original/version_db.c b/libraries/ESP32QRCodeReader_Page_original/version_db.c new file mode 100644 index 0000000..0da2d07 --- /dev/null +++ b/libraries/ESP32QRCodeReader_Page_original/version_db.c @@ -0,0 +1,184 @@ +/* quirc -- QR-code recognition library + * Copyright (C) 2010-2012 Daniel Beer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "quirc_internal.h" + +const struct quirc_version_info quirc_version_db[QUIRC_MAX_VERSION + 1] = { + {0}, + {/* Version 1 */ + .data_bytes = 26, + .apat = {0}, + .ecc = { + {.bs = 26, .dw = 16, .ns = 1}, + {.bs = 26, .dw = 19, .ns = 1}, + {.bs = 26, .dw = 9, .ns = 1}, + {.bs = 26, .dw = 13, .ns = 1}}}, + {/* Version 2 */ + .data_bytes = 44, + .apat = {6, 18, 0}, + .ecc = {{.bs = 44, .dw = 28, .ns = 1}, {.bs = 44, .dw = 34, .ns = 1}, {.bs = 44, .dw = 16, .ns = 1}, {.bs = 44, .dw = 22, .ns = 1}}}, + {/* Version 3 */ + .data_bytes = 70, + .apat = {6, 22, 0}, + .ecc = {{.bs = 70, .dw = 44, .ns = 1}, {.bs = 70, .dw = 55, .ns = 1}, {.bs = 35, .dw = 13, .ns = 2}, {.bs = 35, .dw = 17, .ns = 2}}}, + {/* Version 4 */ + .data_bytes = 100, + .apat = {6, 26, 0}, + .ecc = {{.bs = 50, .dw = 32, .ns = 2}, {.bs = 100, .dw = 80, .ns = 1}, {.bs = 25, .dw = 9, .ns = 4}, {.bs = 50, .dw = 24, .ns = 2}}}, + {/* Version 5 */ + .data_bytes = 134, + .apat = {6, 30, 0}, + .ecc = {{.bs = 67, .dw = 43, .ns = 2}, {.bs = 134, .dw = 108, .ns = 1}, {.bs = 33, .dw = 11, .ns = 2}, {.bs = 33, .dw = 15, .ns = 2}}}, + {/* Version 6 */ + .data_bytes = 172, + .apat = {6, 34, 0}, + .ecc = {{.bs = 43, .dw = 27, .ns = 4}, {.bs = 86, .dw = 68, .ns = 2}, {.bs = 43, .dw = 15, .ns = 4}, {.bs = 43, .dw = 19, .ns = 4}}}, + {/* Version 7 */ + .data_bytes = 196, + .apat = {6, 22, 38, 0}, + .ecc = {{.bs = 49, .dw = 31, .ns = 4}, {.bs = 98, .dw = 78, .ns = 2}, {.bs = 39, .dw = 13, .ns = 4}, {.bs = 32, .dw = 14, .ns = 2}}}, + {/* Version 8 */ + .data_bytes = 242, + .apat = {6, 24, 42, 0}, + .ecc = {{.bs = 60, .dw = 38, .ns = 2}, {.bs = 121, .dw = 97, .ns = 2}, {.bs = 40, .dw = 14, .ns = 4}, {.bs = 40, .dw = 18, .ns = 4}}}, + {/* Version 9 */ + .data_bytes = 292, + .apat = {6, 26, 46, 0}, + .ecc = {{.bs = 58, .dw = 36, .ns = 3}, {.bs = 146, .dw = 116, .ns = 2}, {.bs = 36, .dw = 12, .ns = 4}, {.bs = 36, .dw = 16, .ns = 4}}}, + {/* Version 10 */ + .data_bytes = 346, + .apat = {6, 28, 50, 0}, + .ecc = {{.bs = 69, .dw = 43, .ns = 4}, {.bs = 86, .dw = 68, .ns = 2}, {.bs = 43, .dw = 15, .ns = 6}, {.bs = 43, .dw = 19, .ns = 6}}}, + {/* Version 11 */ + .data_bytes = 404, + .apat = {6, 30, 54, 0}, + .ecc = {{.bs = 80, .dw = 50, .ns = 1}, {.bs = 101, .dw = 81, .ns = 4}, {.bs = 36, .dw = 12, .ns = 3}, {.bs = 50, .dw = 22, .ns = 4}}}, + {/* Version 12 */ + .data_bytes = 466, + .apat = {6, 32, 58, 0}, + .ecc = {{.bs = 58, .dw = 36, .ns = 6}, {.bs = 116, .dw = 92, .ns = 2}, {.bs = 42, .dw = 14, .ns = 7}, {.bs = 46, .dw = 20, .ns = 4}}}, + {/* Version 13 */ + .data_bytes = 532, + .apat = {6, 34, 62, 0}, + .ecc = {{.bs = 59, .dw = 37, .ns = 8}, {.bs = 133, .dw = 107, .ns = 4}, {.bs = 33, .dw = 11, .ns = 12}, {.bs = 44, .dw = 20, .ns = 8}}}, + {/* Version 14 */ + .data_bytes = 581, + .apat = {6, 26, 46, 66, 0}, + .ecc = {{.bs = 64, .dw = 40, .ns = 4}, {.bs = 145, .dw = 115, .ns = 3}, {.bs = 36, .dw = 12, .ns = 11}, {.bs = 36, .dw = 16, .ns = 11}}}, + {/* Version 15 */ + .data_bytes = 655, + .apat = {6, 26, 48, 70, 0}, + .ecc = {{.bs = 65, .dw = 41, .ns = 5}, {.bs = 109, .dw = 87, .ns = 5}, {.bs = 36, .dw = 12, .ns = 11}, {.bs = 54, .dw = 24, .ns = 5}}}, + {/* Version 16 */ + .data_bytes = 733, + .apat = {6, 26, 50, 74, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 7}, {.bs = 122, .dw = 98, .ns = 5}, {.bs = 45, .dw = 15, .ns = 3}, {.bs = 43, .dw = 19, .ns = 15}}}, + {/* Version 17 */ + .data_bytes = 815, + .apat = {6, 30, 54, 78, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 10}, {.bs = 135, .dw = 107, .ns = 1}, {.bs = 42, .dw = 14, .ns = 2}, {.bs = 50, .dw = 22, .ns = 1}}}, + {/* Version 18 */ + .data_bytes = 901, + .apat = {6, 30, 56, 82, 0}, + .ecc = {{.bs = 69, .dw = 43, .ns = 9}, {.bs = 150, .dw = 120, .ns = 5}, {.bs = 42, .dw = 14, .ns = 2}, {.bs = 50, .dw = 22, .ns = 17}}}, + {/* Version 19 */ + .data_bytes = 991, + .apat = {6, 30, 58, 86, 0}, + .ecc = {{.bs = 70, .dw = 44, .ns = 3}, {.bs = 141, .dw = 113, .ns = 3}, {.bs = 39, .dw = 13, .ns = 9}, {.bs = 47, .dw = 21, .ns = 17}}}, + {/* Version 20 */ + .data_bytes = 1085, + .apat = {6, 34, 62, 90, 0}, + .ecc = {{.bs = 67, .dw = 41, .ns = 3}, {.bs = 135, .dw = 107, .ns = 3}, {.bs = 43, .dw = 15, .ns = 15}, {.bs = 54, .dw = 24, .ns = 15}}}, + {/* Version 21 */ + .data_bytes = 1156, + .apat = {6, 28, 50, 72, 92, 0}, + .ecc = {{.bs = 68, .dw = 42, .ns = 17}, {.bs = 144, .dw = 116, .ns = 4}, {.bs = 46, .dw = 16, .ns = 19}, {.bs = 50, .dw = 22, .ns = 17}}}, + {/* Version 22 */ + .data_bytes = 1258, + .apat = {6, 26, 50, 74, 98, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 17}, {.bs = 139, .dw = 111, .ns = 2}, {.bs = 37, .dw = 13, .ns = 34}, {.bs = 54, .dw = 24, .ns = 7}}}, + {/* Version 23 */ + .data_bytes = 1364, + .apat = {6, 30, 54, 78, 102, 0}, + .ecc = {{.bs = 75, .dw = 47, .ns = 4}, {.bs = 151, .dw = 121, .ns = 4}, {.bs = 45, .dw = 15, .ns = 16}, {.bs = 54, .dw = 24, .ns = 11}}}, + {/* Version 24 */ + .data_bytes = 1474, + .apat = {6, 28, 54, 80, 106, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 6}, {.bs = 147, .dw = 117, .ns = 6}, {.bs = 46, .dw = 16, .ns = 30}, {.bs = 54, .dw = 24, .ns = 11}}}, + {/* Version 25 */ + .data_bytes = 1588, + .apat = {6, 32, 58, 84, 110, 0}, + .ecc = {{.bs = 75, .dw = 47, .ns = 8}, {.bs = 132, .dw = 106, .ns = 8}, {.bs = 45, .dw = 15, .ns = 22}, {.bs = 54, .dw = 24, .ns = 7}}}, + {/* Version 26 */ + .data_bytes = 1706, + .apat = {6, 30, 58, 86, 114, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 19}, {.bs = 142, .dw = 114, .ns = 10}, {.bs = 46, .dw = 16, .ns = 33}, {.bs = 50, .dw = 22, .ns = 28}}}, + {/* Version 27 */ + .data_bytes = 1828, + .apat = {6, 34, 62, 90, 118, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 22}, {.bs = 152, .dw = 122, .ns = 8}, {.bs = 45, .dw = 15, .ns = 12}, {.bs = 53, .dw = 23, .ns = 8}}}, + {/* Version 28 */ + .data_bytes = 1921, + .apat = {6, 26, 50, 74, 98, 122, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 3}, {.bs = 147, .dw = 117, .ns = 3}, {.bs = 45, .dw = 15, .ns = 11}, {.bs = 54, .dw = 24, .ns = 4}}}, + {/* Version 29 */ + .data_bytes = 2051, + .apat = {6, 30, 54, 78, 102, 126, 0}, + .ecc = {{.bs = 73, .dw = 45, .ns = 21}, {.bs = 146, .dw = 116, .ns = 7}, {.bs = 45, .dw = 15, .ns = 19}, {.bs = 53, .dw = 23, .ns = 1}}}, + {/* Version 30 */ + .data_bytes = 2185, + .apat = {6, 26, 52, 78, 104, 130, 0}, + .ecc = {{.bs = 75, .dw = 47, .ns = 19}, {.bs = 145, .dw = 115, .ns = 5}, {.bs = 45, .dw = 15, .ns = 23}, {.bs = 54, .dw = 24, .ns = 15}}}, + {/* Version 31 */ + .data_bytes = 2323, + .apat = {6, 30, 56, 82, 108, 134, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 2}, {.bs = 145, .dw = 115, .ns = 13}, {.bs = 45, .dw = 15, .ns = 23}, {.bs = 54, .dw = 24, .ns = 42}}}, + {/* Version 32 */ + .data_bytes = 2465, + .apat = {6, 34, 60, 86, 112, 138, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 10}, {.bs = 145, .dw = 115, .ns = 17}, {.bs = 45, .dw = 15, .ns = 19}, {.bs = 54, .dw = 24, .ns = 10}}}, + {/* Version 33 */ + .data_bytes = 2611, + .apat = {6, 30, 58, 86, 114, 142, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 14}, {.bs = 145, .dw = 115, .ns = 17}, {.bs = 45, .dw = 15, .ns = 11}, {.bs = 54, .dw = 24, .ns = 29}}}, + {/* Version 34 */ + .data_bytes = 2761, + .apat = {6, 34, 62, 90, 118, 146, 0}, + .ecc = {{.bs = 74, .dw = 46, .ns = 14}, {.bs = 145, .dw = 115, .ns = 13}, {.bs = 46, .dw = 16, .ns = 59}, {.bs = 54, .dw = 24, .ns = 44}}}, + {/* Version 35 */ + .data_bytes = 2876, + .apat = {6, 30, 54, 78, 102, 126, 150}, + .ecc = {{.bs = 75, .dw = 47, .ns = 12}, {.bs = 151, .dw = 121, .ns = 12}, {.bs = 45, .dw = 15, .ns = 22}, {.bs = 54, .dw = 24, .ns = 39}}}, + {/* Version 36 */ + .data_bytes = 3034, + .apat = {6, 24, 50, 76, 102, 128, 154}, + .ecc = {{.bs = 75, .dw = 47, .ns = 6}, {.bs = 151, .dw = 121, .ns = 6}, {.bs = 45, .dw = 15, .ns = 2}, {.bs = 54, .dw = 24, .ns = 46}}}, + {/* Version 37 */ + .data_bytes = 3196, + .apat = {6, 28, 54, 80, 106, 132, 158}, + .ecc = {{.bs = 74, .dw = 46, .ns = 29}, {.bs = 152, .dw = 122, .ns = 17}, {.bs = 45, .dw = 15, .ns = 24}, {.bs = 54, .dw = 24, .ns = 49}}}, + {/* Version 38 */ + .data_bytes = 3362, + .apat = {6, 32, 58, 84, 110, 136, 162}, + .ecc = {{.bs = 74, .dw = 46, .ns = 13}, {.bs = 152, .dw = 122, .ns = 4}, {.bs = 45, .dw = 15, .ns = 42}, {.bs = 54, .dw = 24, .ns = 48}}}, + {/* Version 39 */ + .data_bytes = 3532, + .apat = {6, 26, 54, 82, 110, 138, 166}, + .ecc = {{.bs = 75, .dw = 47, .ns = 40}, {.bs = 147, .dw = 117, .ns = 20}, {.bs = 45, .dw = 15, .ns = 10}, {.bs = 54, .dw = 24, .ns = 43}}}, + {/* Version 40 */ + .data_bytes = 3706, + .apat = {6, 30, 58, 86, 114, 142, 170}, + .ecc = {{.bs = 75, .dw = 47, .ns = 18}, {.bs = 148, .dw = 118, .ns = 19}, {.bs = 45, .dw = 15, .ns = 20}, {.bs = 54, .dw = 24, .ns = 34}}}}; diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/CONTRIBUTING.md b/libraries/MySQL_MariaDB_Generic-1.7.2/CONTRIBUTING.md new file mode 100644 index 0000000..81addcf --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/CONTRIBUTING.md @@ -0,0 +1,54 @@ +## Contributing to MySQL_MariaDB_Generic + +### Reporting Bugs + +Please report bugs in MySQL_MariaDB_Generic if you find them. + +However, before reporting a bug please check through the following: + +* [Existing Open Issues](https://github.com/khoih-prog/MySQL_MariaDB_Generic/issues) - someone might have already encountered this. + +If you don't find anything, please [open a new issue](https://github.com/khoih-prog/MySQL_MariaDB_Generic/issues/new). + +### How to submit a bug report + +Please ensure to specify the following: + +* Arduino IDE version (e.g. 1.8.19) or Platform.io version +* Board Core Version (e.g. Arduino SAMDUE core v1.6.12, ESP32 core v2.0.2, ESP8266 core v3.0.2, ArduinoCore-mbed v3.0.1, etc.) +* Contextual information (e.g. what you were trying to achieve) +* Simplest possible steps to reproduce +* Anything that might be relevant in your opinion, such as: + * Operating system (Windows, Ubuntu, etc.) and the output of `uname -a` + * Network configuration + + +### Example + +``` +Arduino IDE version: 1.8.19 +MBED RASPBERRY_PI_PICO board +ArduinoCore-mbed v3.0.1 +OS: Ubuntu 20.04 LTS +Linux xy-Inspiron-3593 5.13.0-39-generic #44~20.04.1-Ubuntu SMP Thu Mar 24 16:43:35 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux + +Context: +I encountered a crash while trying to use the Timer Interrupt. + +Steps to reproduce: +1. ... +2. ... +3. ... +4. ... +``` + +### Sending Feature Requests + +Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful. + +There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/MySQL_MariaDB_Generic/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them. + +### Sending Pull Requests + +Pull Requests with changes and fixes are also welcome! + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LICENSE b/libraries/MySQL_MariaDB_Generic-1.7.2/LICENSE new file mode 100644 index 0000000..cfe22f4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Khoi Hoang + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet/src/Ethernet.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet/src/Ethernet.cpp new file mode 100644 index 0000000..0f3db05 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet/src/Ethernet.cpp @@ -0,0 +1,320 @@ +/**************************************************************************************************************************** + Ethernet.cpp + + EthernetWebServer is a library for the Ethernet shields to run WebServer + + Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases + Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer + Licensed under MIT license + Version: 1.0.9 + + Copyright 2018 Paul Stoffregen + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/02/2020 Initial coding for Arduino Mega, Teensy, etc to support Ethernetx libraries + 1.0.1 K Hoang 20/02/2020 Add support to lambda functions + 1.0.2 K Hoang 20/02/2020 Add support to UIPEthernet library for ENC28J60 + 1.0.3 K Hoang 23/02/2020 Add support to SAM DUE / SAMD21 boards + 1.0.4 K Hoang 16/04/2020 Add support to SAMD51 boards + 1.0.5 K Hoang 24/04/2020 Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, + Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, etc. + More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge + 1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards + 1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards + 1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. + 1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future. + *****************************************************************************************************************************/ + +#include +#include "Ethernet.h" +#include "utility/w5100.h" +#include "Dhcp.h" + +#define ETHERNET_DEBUG 1 + + +IPAddress EthernetClass::_dnsServerAddress; +DhcpClass* EthernetClass::_dhcp = NULL; + +// KH +void EthernetClass::setRstPin(uint8_t pinRST) +{ + _pinRST = pinRST; + pinMode(_pinRST, OUTPUT); + digitalWrite(_pinRST, HIGH); +} +void EthernetClass::setCsPin(uint8_t pinCS) +{ + _pinCS = pinCS; + W5100.setSS(pinCS); + +#if ( ETHERNET_DEBUG > 0 ) + Serial.print("Input pinCS = "); + Serial.println(pinCS); + Serial.print("_pinCS = "); + Serial.println(_pinCS); +#endif +} + +void EthernetClass::initMaxSockNum(uint8_t maxSockNum) +{ + _maxSockNum = maxSockNum; +} + +uint8_t EthernetClass::softreset() +{ + return W5100.softReset(); +} + +void EthernetClass::hardreset() +{ + if(_pinRST != 0) + { + digitalWrite(_pinRST, LOW); + delay(1); + digitalWrite(_pinRST, HIGH); + delay(150); + } +} + +int EthernetClass::begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) +{ + DhcpClass s_dhcp; + _dhcp = &s_dhcp; + +#if ( ETHERNET_DEBUG > 0 ) + Serial.print("_pinCS = "); + Serial.print(_pinCS); +#endif + + // Initialise the basic info + if (W5100.init() == 0) + return 0; + + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.setMACAddress(mac); + W5100.setIPAddress(IPAddress(0,0,0,0).raw_address()); + SPI.endTransaction(); + + // Now try to get our config info from a DHCP server + int ret = _dhcp->beginWithDHCP(mac, timeout, responseTimeout); + if (ret == 1) + { + // We've successfully found a DHCP server and got our configuration + // info, so set things accordingly + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.setIPAddress(_dhcp->getLocalIp().raw_address()); + W5100.setGatewayIp(_dhcp->getGatewayIp().raw_address()); + W5100.setSubnetMask(_dhcp->getSubnetMask().raw_address()); + SPI.endTransaction(); + _dnsServerAddress = _dhcp->getDnsServerIp(); + socketPortRand(micros()); + } + return ret; +} + +void EthernetClass::begin(uint8_t *mac, IPAddress ip) +{ + // Assume the DNS server will be the machine on the same network as the local IP + // but with last octet being '1' + IPAddress dns = ip; + dns[3] = 1; + begin(mac, ip, dns); +} + +void EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns) +{ + // Assume the gateway will be the machine on the same network as the local IP + // but with last octet being '1' + IPAddress gateway = ip; + gateway[3] = 1; + begin(mac, ip, dns, gateway); +} + +void EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway) +{ + IPAddress subnet(255, 255, 255, 0); + begin(mac, ip, dns, gateway, subnet); +} + +void EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet) +{ + // Initialise the basic info + if (W5100.init() == 0) + return; + + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.setMACAddress(mac); + +#if ( defined(ESP8266) || defined(ESP32) ) + W5100.setIPAddress(ip.raw_address()); + W5100.setGatewayIp(gateway.raw_address()); + W5100.setSubnetMask(subnet.raw_address()); +#elif (ARDUINO > 106 || TEENSYDUINO > 121) + W5100.setIPAddress(ip._address.bytes); + W5100.setGatewayIp(gateway._address.bytes); + W5100.setSubnetMask(subnet._address.bytes); +#else + W5100.setIPAddress(ip._address); + W5100.setGatewayIp(gateway._address); + W5100.setSubnetMask(subnet._address); +#endif + + SPI.endTransaction(); + _dnsServerAddress = dns; +} + +void EthernetClass::init(uint8_t sspin) +{ + W5100.setSS(sspin); +} + +EthernetLinkStatus EthernetClass::linkStatus() +{ + switch (W5100.getLinkStatus()) { + case UNKNOWN: return Unknown; + case LINK_ON: return LinkON; + case LINK_OFF: return LinkOFF; + default: return Unknown; + } +} + +EthernetHardwareStatus EthernetClass::hardwareStatus() +{ + switch (W5100.getChip()) { + case 51: return EthernetW5100; + case 52: return EthernetW5200; + case 55: return EthernetW5500; + default: return EthernetNoHardware; + } +} + +int EthernetClass::maintain() +{ + int rc = DHCP_CHECK_NONE; + if (_dhcp != NULL) { + // we have a pointer to dhcp, use it + rc = _dhcp->checkLease(); + switch (rc) + { + case DHCP_CHECK_NONE: + //nothing done + break; + case DHCP_CHECK_RENEW_OK: + case DHCP_CHECK_REBIND_OK: + //we might have got a new IP. + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.setIPAddress(_dhcp->getLocalIp().raw_address()); + W5100.setGatewayIp(_dhcp->getGatewayIp().raw_address()); + W5100.setSubnetMask(_dhcp->getSubnetMask().raw_address()); + SPI.endTransaction(); + _dnsServerAddress = _dhcp->getDnsServerIp(); + break; + default: + //this is actually an error, it will retry though + break; + } + } + return rc; +} + + +void EthernetClass::MACAddress(uint8_t *mac_address) +{ + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.getMACAddress(mac_address); + SPI.endTransaction(); +} + +IPAddress EthernetClass::localIP() +{ + IPAddress ret; + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.getIPAddress(ret.raw_address()); + SPI.endTransaction(); + return ret; +} + +IPAddress EthernetClass::subnetMask() +{ + IPAddress ret; + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.getSubnetMask(ret.raw_address()); + SPI.endTransaction(); + return ret; +} + +IPAddress EthernetClass::gatewayIP() +{ + IPAddress ret; + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.getGatewayIp(ret.raw_address()); + SPI.endTransaction(); + return ret; +} + +void EthernetClass::setMACAddress(const uint8_t *mac_address) +{ + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.setMACAddress(mac_address); + SPI.endTransaction(); +} + +void EthernetClass::setLocalIP(const IPAddress local_ip) +{ + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + IPAddress ip = local_ip; + W5100.setIPAddress(ip.raw_address()); + SPI.endTransaction(); +} + +void EthernetClass::setSubnetMask(const IPAddress subnet) +{ + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + IPAddress ip = subnet; + W5100.setSubnetMask(ip.raw_address()); + SPI.endTransaction(); +} + +void EthernetClass::setGatewayIP(const IPAddress gateway) +{ + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + IPAddress ip = gateway; + W5100.setGatewayIp(ip.raw_address()); + SPI.endTransaction(); +} + +void EthernetClass::setRetransmissionTimeout(uint16_t milliseconds) +{ + if (milliseconds > 6553) milliseconds = 6553; + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.setRetransmissionTime(milliseconds * 10); + SPI.endTransaction(); +} + +void EthernetClass::setRetransmissionCount(uint8_t num) +{ + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.setRetransmissionCount(num); + SPI.endTransaction(); +} + +EthernetClass Ethernet; diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet/src/Ethernet.h b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet/src/Ethernet.h new file mode 100644 index 0000000..6fee77f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet/src/Ethernet.h @@ -0,0 +1,366 @@ +/**************************************************************************************************************************** + Ethernet.h + + EthernetWebServer is a library for the Ethernet shields to run WebServer + + Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases + Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer + Licensed under MIT license + Version: 1.0.9 + + Copyright 2018 Paul Stoffregen + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/02/2020 Initial coding for Arduino Mega, Teensy, etc to support Ethernetx libraries + 1.0.1 K Hoang 20/02/2020 Add support to lambda functions + 1.0.2 K Hoang 20/02/2020 Add support to UIPEthernet library for ENC28J60 + 1.0.3 K Hoang 23/02/2020 Add support to SAM DUE / SAMD21 boards + 1.0.4 K Hoang 16/04/2020 Add support to SAMD51 boards + 1.0.5 K Hoang 24/04/2020 Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, + Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, etc. + More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge + 1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards + 1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards + 1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. + 1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future. + *****************************************************************************************************************************/ + +#ifndef ethernet_h_ +#define ethernet_h_ + +// All symbols exposed to Arduino sketches are contained in this header file +// +// Older versions had much of this stuff in EthernetClient.h, EthernetServer.h, +// and socket.h. Including headers in different order could cause trouble, so +// these "friend" classes are now defined in the same header file. socket.h +// was removed to avoid possible conflict with the C library header files. + + +// Configure the maximum number of sockets to support. W5100 chips can have +// up to 4 sockets. W5200 & W5500 can have up to 8 sockets. Several bytes +// of RAM are used for each socket. Reducing the maximum can save RAM, but +// you are limited to fewer simultaneous connections. +#if defined(RAMEND) && defined(RAMSTART) && ((RAMEND - RAMSTART) <= 2048) +#define MAX_SOCK_NUM 2 //Reduce MAX_SOCK_NUM to 2 from 4, to increase buffer from 2k to 4K +#else +#define MAX_SOCK_NUM 4 //Reduce MAX_SOCK_NUM to 4 from 8, to increase buffer from 2k to 4K +#endif + +// By default, each socket uses 2K buffers inside the Wiznet chip. If +// MAX_SOCK_NUM is set to fewer than the chip's maximum, uncommenting +// this will use larger buffers within the Wiznet chip. Large buffers +// can really help with UDP protocols like Artnet. In theory larger +// buffers should allow faster TCP over high-latency links, but this +// does not always seem to work in practice (maybe Wiznet bugs?) +// +//KH, to increase buffer size for W5x00 to min 4K +#define ETHERNET_LARGE_BUFFERS + + +#include +#include "Client.h" +#include "Server.h" +#include "Udp.h" + +enum EthernetLinkStatus { + Unknown, + LinkON, + LinkOFF +}; + +enum EthernetHardwareStatus { + EthernetNoHardware, + EthernetW5100, + EthernetW5200, + EthernetW5500 +}; + +class EthernetUDP; +class EthernetClient; +class EthernetServer; +class DhcpClass; + +class EthernetClass { +private: + static IPAddress _dnsServerAddress; + static DhcpClass* _dhcp; +public: + // KH + uint8_t _maxSockNum; + uint8_t _pinCS; + uint8_t _pinRST; + + void setRstPin(uint8_t pinRST = 9); // for WIZ550io or USR-ES1, must set befor Ethernet.begin + void setCsPin(uint8_t pinCS = 10); // must set befor Ethernet.begin + + // Initialize with less sockets but more RX/TX Buffer + // maxSockNum = 1 Socket 0 -> RX/TX Buffer 16k + // maxSockNum = 2 Socket 0, 1 -> RX/TX Buffer 8k + // maxSockNum = 4 Socket 0...3 -> RX/TX Buffer 4k + // maxSockNum = 8 (Standard) all sockets -> RX/TX Buffer 2k + // be carefull of the MAX_SOCK_NUM, because in the moment it can't dynamicly changed + void initMaxSockNum(uint8_t maxSockNum = 8); + + uint8_t softreset(); // can set only after Ethernet.begin + void hardreset(); // You need to set the Rst pin + + // Initialise the Ethernet shield to use the provided MAC address and + // gain the rest of the configuration through DHCP. + // Returns 0 if the DHCP configuration failed, and 1 if it succeeded + int begin(uint8_t *mac, unsigned long timeout = 60000, unsigned long responseTimeout = 4000); + int maintain(); + EthernetLinkStatus linkStatus(); + EthernetHardwareStatus hardwareStatus(); + + // Manual configuration + void begin(uint8_t *mac, IPAddress ip); + void begin(uint8_t *mac, IPAddress ip, IPAddress dns); + void begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway); + void begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet); + void init(uint8_t sspin = 10); + + void MACAddress(uint8_t *mac_address); + IPAddress localIP(); + IPAddress subnetMask(); + IPAddress gatewayIP(); + IPAddress dnsServerIP() { return _dnsServerAddress; } + + void setMACAddress(const uint8_t *mac_address); + void setLocalIP(const IPAddress local_ip); + void setSubnetMask(const IPAddress subnet); + void setGatewayIP(const IPAddress gateway); + void setDnsServerIP(const IPAddress dns_server) { _dnsServerAddress = dns_server; } + void setRetransmissionTimeout(uint16_t milliseconds); + void setRetransmissionCount(uint8_t num); + + friend class EthernetClient; + friend class EthernetServer; + friend class EthernetUDP; +private: + // Opens a socket(TCP or UDP or IP_RAW mode) + uint8_t socketBegin(uint8_t protocol, uint16_t port); + uint8_t socketBeginMulticast(uint8_t protocol, IPAddress ip,uint16_t port); + uint8_t socketStatus(uint8_t s); + // Close socket + void socketClose(uint8_t s); + // Establish TCP connection (Active connection) + void socketConnect(uint8_t s, uint8_t * addr, uint16_t port); + // disconnect the connection + void socketDisconnect(uint8_t s); + // Establish TCP connection (Passive connection) + uint8_t socketListen(uint8_t s); + // Send data (TCP) + uint16_t socketSend(uint8_t s, const uint8_t * buf, uint16_t len); + uint16_t socketSendAvailable(uint8_t s); + // Receive data (TCP) + int socketRecv(uint8_t s, uint8_t * buf, int16_t len); + uint16_t socketRecvAvailable(uint8_t s); + uint8_t socketPeek(uint8_t s); + // sets up a UDP datagram, the data for which will be provided by one + // or more calls to bufferData and then finally sent with sendUDP. + // return true if the datagram was successfully set up, or false if there was an error + bool socketStartUDP(uint8_t s, uint8_t* addr, uint16_t port); + // copy up to len bytes of data from buf into a UDP datagram to be + // sent later by sendUDP. Allows datagrams to be built up from a series of bufferData calls. + // return Number of bytes successfully buffered + uint16_t socketBufferData(uint8_t s, uint16_t offset, const uint8_t* buf, uint16_t len); + // Send a UDP datagram built up from a sequence of startUDP followed by one or more + // calls to bufferData. + // return true if the datagram was successfully sent, or false if there was an error + bool socketSendUDP(uint8_t s); + // Initialize the "random" source port number + void socketPortRand(uint16_t n); +}; + +extern EthernetClass Ethernet; + + +#define UDP_TX_PACKET_MAX_SIZE 24 + +class EthernetUDP : public UDP { +private: + uint16_t _port; // local port to listen on + IPAddress _remoteIP; // remote IP address for the incoming packet whilst it's being processed + uint16_t _remotePort; // remote port for the incoming packet whilst it's being processed + uint16_t _offset; // offset into the packet being sent + +protected: + uint8_t sockindex; + uint16_t _remaining; // remaining bytes of incoming packet yet to be processed + +public: + EthernetUDP() : sockindex(MAX_SOCK_NUM) {} // Constructor + virtual uint8_t begin(uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual uint8_t beginMulticast(IPAddress, uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual void stop(); // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port); + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port); + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket(); + // Write a single byte into the packet + virtual size_t write(uint8_t); + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size); + + using Print::write; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket(); + // Number of bytes remaining in the current packet + virtual int available(); + // Read a single byte from the current packet + virtual int read(); + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len); + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) { return read((unsigned char*)buffer, len); }; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek(); + virtual void flush(); // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() { return _remoteIP; }; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() { return _remotePort; }; + virtual uint16_t localPort() { return _port; } +}; + + + + +class EthernetClient : public Client { +public: + + EthernetClient() : sockindex(MAX_SOCK_NUM), _timeout(5000) { } + EthernetClient(uint8_t s) : sockindex(s), _timeout(5000) { } + + uint8_t status(); + virtual int connect(IPAddress ip, uint16_t port); + virtual int connect(const char *host, uint16_t port); + virtual int availableForWrite(void); + virtual size_t write(uint8_t); + virtual size_t write(const uint8_t *buf, size_t size); + + virtual int available(); + virtual int read(); + virtual int read(uint8_t *buf, size_t size); + virtual int peek(); + virtual void flush(); + virtual void stop(); + virtual uint8_t connected(); + virtual operator bool() { return sockindex < MAX_SOCK_NUM; } + virtual bool operator==(const bool value) { return bool() == value; } + virtual bool operator!=(const bool value) { return bool() != value; } + virtual bool operator==(const EthernetClient&); + virtual bool operator!=(const EthernetClient& rhs) { return !this->operator==(rhs); } + uint8_t getSocketNumber() const { return sockindex; } + virtual uint16_t localPort(); + virtual IPAddress remoteIP(); + virtual uint16_t remotePort(); + virtual void setConnectionTimeout(uint16_t timeout) { _timeout = timeout; } + + friend class EthernetServer; + + using Print::write; + +private: + uint8_t sockindex; // MAX_SOCK_NUM means client not in use + uint16_t _timeout; +}; + + +class EthernetServer : public Server { +private: + uint16_t _port; +public: + EthernetServer(uint16_t port) : _port(port) { } + EthernetClient available(); + EthernetClient accept(); + virtual void begin(); + virtual size_t write(uint8_t); + virtual size_t write(const uint8_t *buf, size_t size); + virtual operator bool(); + using Print::write; + //void statusreport(); + + // TODO: make private when socket allocation moves to EthernetClass + static uint16_t server_port[MAX_SOCK_NUM]; +}; + + +class DhcpClass { +private: + uint32_t _dhcpInitialTransactionId; + uint32_t _dhcpTransactionId; + uint8_t _dhcpMacAddr[6]; +#ifdef __arm__ + uint8_t _dhcpLocalIp[4] __attribute__((aligned(4))); + uint8_t _dhcpSubnetMask[4] __attribute__((aligned(4))); + uint8_t _dhcpGatewayIp[4] __attribute__((aligned(4))); + uint8_t _dhcpDhcpServerIp[4] __attribute__((aligned(4))); + uint8_t _dhcpDnsServerIp[4] __attribute__((aligned(4))); +#else + uint8_t _dhcpLocalIp[4]; + uint8_t _dhcpSubnetMask[4]; + uint8_t _dhcpGatewayIp[4]; + uint8_t _dhcpDhcpServerIp[4]; + uint8_t _dhcpDnsServerIp[4]; +#endif + uint32_t _dhcpLeaseTime; + uint32_t _dhcpT1, _dhcpT2; + uint32_t _renewInSec; + uint32_t _rebindInSec; + unsigned long _timeout; + unsigned long _responseTimeout; + unsigned long _lastCheckLeaseMillis; + uint8_t _dhcp_state; + EthernetUDP _dhcpUdpSocket; + + int request_DHCP_lease(); + void reset_DHCP_lease(); + void presend_DHCP(); + void send_DHCP_MESSAGE(uint8_t, uint16_t); + void printByte(char *, uint8_t); + + uint8_t parseDHCPResponse(unsigned long responseTimeout, uint32_t& transactionId); +public: + IPAddress getLocalIp(); + IPAddress getSubnetMask(); + IPAddress getGatewayIp(); + IPAddress getDhcpServerIp(); + IPAddress getDnsServerIp(); + + int beginWithDHCP(uint8_t *, unsigned long timeout = 60000, unsigned long responseTimeout = 4000); + int checkLease(); +}; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet/src/EthernetServer.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet/src/EthernetServer.cpp new file mode 100644 index 0000000..2f6b8fb --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet/src/EthernetServer.cpp @@ -0,0 +1,244 @@ +/**************************************************************************************************************************** + EthernetServer.cpp + + EthernetWebServer is a library for the Ethernet shields to run WebServer + + Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases + Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer + Licensed under MIT license + Version: 1.0.9 + + Copyright 2018 Paul Stoffregen + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/02/2020 Initial coding for Arduino Mega, Teensy, etc to support Ethernetx libraries + 1.0.1 K Hoang 20/02/2020 Add support to lambda functions + 1.0.2 K Hoang 20/02/2020 Add support to UIPEthernet library for ENC28J60 + 1.0.3 K Hoang 23/02/2020 Add support to SAM DUE / SAMD21 boards + 1.0.4 K Hoang 16/04/2020 Add support to SAMD51 boards + 1.0.5 K Hoang 24/04/2020 Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, + Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, etc. + More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge + 1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards + 1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards + 1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. + 1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future. + *****************************************************************************************************************************/ + +#include +#include "Ethernet.h" +#include "utility/w5100.h" + +uint16_t EthernetServer::server_port[MAX_SOCK_NUM]; + + +void EthernetServer::begin() +{ + uint8_t sockindex = Ethernet.socketBegin(SnMR::TCP, _port); + if (sockindex < MAX_SOCK_NUM) + { + if (Ethernet.socketListen(sockindex)) + { + server_port[sockindex] = _port; + } + else + { + Ethernet.socketDisconnect(sockindex); + } + } +} + +EthernetClient EthernetServer::available() +{ + bool listening = false; + uint8_t sockindex = MAX_SOCK_NUM; + uint8_t chip, maxindex=MAX_SOCK_NUM; + + chip = W5100.getChip(); + + if (!chip) + return EthernetClient(MAX_SOCK_NUM); + + //KH, set W5100 to max 2 sockets to increase buffer size + if (chip == 51) + { +#ifdef ETHERNET_LARGE_BUFFERS + maxindex = 2; // W5100 chip never supports more than 4 sockets +#else + maxindex = 4; // W5100 chip never supports more than 4 sockets. Original +#endif + } + + for (uint8_t i=0; i < maxindex; i++) + { + if (server_port[i] == _port) + { + uint8_t stat = Ethernet.socketStatus(i); + if (stat == SnSR::ESTABLISHED || stat == SnSR::CLOSE_WAIT) + { + if (Ethernet.socketRecvAvailable(i) > 0) + { + sockindex = i; + } + else + { + // remote host closed connection, our end still open + if (stat == SnSR::CLOSE_WAIT) + { + Ethernet.socketDisconnect(i); + // status becomes LAST_ACK for short time + } + } + } + else if (stat == SnSR::LISTEN) + { + listening = true; + } + else if (stat == SnSR::CLOSED) + { + server_port[i] = 0; + } + } + } + + if (!listening) + { + begin(); + } + + return EthernetClient(sockindex); +} + +EthernetClient EthernetServer::accept() +{ + bool listening = false; + uint8_t sockindex = MAX_SOCK_NUM; + uint8_t chip, maxindex=MAX_SOCK_NUM; + + chip = W5100.getChip(); + + if (!chip) + return EthernetClient(MAX_SOCK_NUM); + + //KH, set W5100 to max 2 sockets to increase buffer size + if (chip == 51) + { +#ifdef ETHERNET_LARGE_BUFFERS + maxindex = 2; // W5100 chip never supports more than 4 sockets +#else + maxindex = 4; // W5100 chip never supports more than 4 sockets. Original +#endif + } + + for (uint8_t i=0; i < maxindex; i++) + { + if (server_port[i] == _port) + { + uint8_t stat = Ethernet.socketStatus(i); + + if (sockindex == MAX_SOCK_NUM && (stat == SnSR::ESTABLISHED || stat == SnSR::CLOSE_WAIT)) + { + // Return the connected client even if no data received. + // Some protocols like FTP expect the server to send the + // first data. + sockindex = i; + server_port[i] = 0; // only return the client once + } + else if (stat == SnSR::LISTEN) + { + listening = true; + } + else if (stat == SnSR::CLOSED) + { + server_port[i] = 0; + } + } + } + + if (!listening) + begin(); + + return EthernetClient(sockindex); +} + +EthernetServer::operator bool() +{ + uint8_t maxindex=MAX_SOCK_NUM; + + //KH, set W5100 to max 2 sockets to increase buffer size + if (W5100.getChip() == 51) + { +#ifdef ETHERNET_LARGE_BUFFERS + maxindex = 2; // W5100 chip never supports more than 4 sockets +#else + maxindex = 4; // W5100 chip never supports more than 4 sockets. Original +#endif + } + + for (uint8_t i=0; i < maxindex; i++) + { + if (server_port[i] == _port) + { + if (Ethernet.socketStatus(i) == SnSR::LISTEN) + { + return true; // server is listening for incoming clients + } + } + } + return false; +} + +size_t EthernetServer::write(uint8_t b) +{ + return write(&b, 1); +} + +size_t EthernetServer::write(const uint8_t *buffer, size_t size) +{ + uint8_t chip, maxindex=MAX_SOCK_NUM; + + chip = W5100.getChip(); + if (!chip) return 0; + + //KH, set W5100 to max 2 sockets to increase buffer size + if (chip == 51) + { +#ifdef ETHERNET_LARGE_BUFFERS + maxindex = 2; // W5100 chip never supports more than 4 sockets +#else + maxindex = 4; // W5100 chip never supports more than 4 sockets. Original +#endif + } + + available(); + + for (uint8_t i=0; i < maxindex; i++) + { + if (server_port[i] == _port) + { + if (Ethernet.socketStatus(i) == SnSR::ESTABLISHED) + { + Ethernet.socketSend(i, buffer, size); + } + } + } + return size; +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet/src/utility/w5100.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet/src/utility/w5100.cpp new file mode 100644 index 0000000..5cf9cf7 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet/src/utility/w5100.cpp @@ -0,0 +1,711 @@ +/**************************************************************************************************************************** + w5100.cpp - Driver for W5x00 + + EthernetWebServer is a library for the Ethernet shields to run WebServer + + Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases + Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer + Licensed under MIT license + Version: 1.0.9 + + Copyright 2018 Paul Stoffregen + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/02/2020 Initial coding for Arduino Mega, Teensy, etc to support Ethernetx libraries + 1.0.1 K Hoang 20/02/2020 Add support to lambda functions + 1.0.2 K Hoang 20/02/2020 Add support to UIPEthernet library for ENC28J60 + 1.0.3 K Hoang 23/02/2020 Add support to SAM DUE / SAMD21 boards + 1.0.4 K Hoang 16/04/2020 Add support to SAMD51 boards + 1.0.5 K Hoang 24/04/2020 Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, + Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, etc. + More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge + 1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards + 1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards + 1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. + 1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future. + *****************************************************************************************************************************/ + +#include +#include "Ethernet.h" +#include "w5100.h" + +#define W5100_DEBUG 1 + +/***************************************************/ +/** Default SS pin setting **/ +/***************************************************/ + +// If variant.h or other headers specifically define the +// default SS pin for ethernet, use it. +#if defined(PIN_SPI_SS_ETHERNET_LIB) + +#define SS_PIN_DEFAULT PIN_SPI_SS_ETHERNET_LIB +//KH +#warning w5100.cpp Use PIN_SPI_SS_ETHERNET_LIB defined, change SS_PIN_DEFAULT to PIN_SPI_SS_ETHERNET_LIB + +// MKR boards default to pin 5 for MKR ETH +// Pins 8-10 are MOSI/SCK/MISO on MRK, so don't use pin 10 +#elif defined(USE_ARDUINO_MKR_PIN_LAYOUT) || defined(ARDUINO_SAMD_MKRZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRWAN1300) + +#define SS_PIN_DEFAULT 5 +//KH +#warning w5100.cpp Use MKR, change SS_PIN_DEFAULT to 5 + +// For boards using AVR, assume shields with SS on pin 10 +// will be used. This allows for Arduino Mega (where +// SS is pin 53) and Arduino Leonardo (where SS is pin 17) +// to work by default with Arduino Ethernet Shield R2 & R3. +#elif defined(__AVR__) + +#define SS_PIN_DEFAULT 10 +//KH +#warning w5100.cpp Use __AVR__, change SS_PIN_DEFAULT to 10 + +// If variant.h or other headers define these names +// use them if none of the other cases match +#elif defined(PIN_SPI_SS) + +#if defined(__SAMD21G18A__) +//10 - 2 (6 conflict) all not OK for Nano 33 IoT !!! SPI corrupted??? +#warning w5100.cpp Use __SAMD21G18A__, change SS_PIN_DEFAULT to 10 +#define SS_PIN_DEFAULT 10 +#else +#define SS_PIN_DEFAULT PIN_SPI_SS + +//KH +#warning w5100.cpp Use PIN_SPI_SS defined, change SS_PIN_DEFAULT to PIN_SPI_SS +#endif + +#elif defined(CORE_SS0_PIN) +#define SS_PIN_DEFAULT CORE_SS0_PIN + +//KH +#warning w5100.cpp Use CORE_SS0_PIN defined, change SS_PIN_DEFAULT to CORE_SS0_PIN + +//KH for ESP32 +#elif defined(ESP32) +//pin SS already defined in ESP32 as pin 5, don't use this as conflict with SPIFFS, EEPROM, etc. +// Use in GPIO22 +#warning w5100.cpp Use ESP32, change SS_PIN_DEFAULT to GPIO22, MOSI(23), MISO(19), SCK(18) +#define SS_PIN_DEFAULT 22 //SS +/////// + +//KH for ESP8266 +#elif defined(ESP8266) +//pin SS already defined in ESP8266 as pin 15. Conflict => Move to pin GPIO4 (D2) +#warning w5100.cpp Use ESP8266, change SS_PIN_DEFAULT to SS(4), MOSI(13), MISO(12), SCK(14) +#define SS_PIN_DEFAULT D2 // GPIO4, SS + +/////// + +// As a final fallback, use pin 10 +#else +#define SS_PIN_DEFAULT 10 + +//KH +#warning w5100.cpp Use fallback, change SS_PIN_DEFAULT to 10 + +#endif + +// W5100 controller instance +uint8_t W5100Class::chip = 0; +uint8_t W5100Class::CH_BASE_MSB; +uint8_t W5100Class::ss_pin = SS_PIN_DEFAULT; +#ifdef ETHERNET_LARGE_BUFFERS +uint16_t W5100Class::SSIZE = 2048; +uint16_t W5100Class::SMASK = 0x07FF; +#endif +W5100Class W5100; + +// pointers and bitmasks for optimized SS pin +#if defined(__AVR__) + volatile uint8_t * W5100Class::ss_pin_reg; + uint8_t W5100Class::ss_pin_mask; +#elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK66FX1M0__) || defined(__MK64FX512__) + volatile uint8_t * W5100Class::ss_pin_reg; +#elif defined(__IMXRT1062__) + volatile uint32_t * W5100Class::ss_pin_reg; + uint32_t W5100Class::ss_pin_mask; +#elif defined(__MKL26Z64__) + volatile uint8_t * W5100Class::ss_pin_reg; + uint8_t W5100Class::ss_pin_mask; +#elif defined(__SAM3X8E__) || defined(__SAM3A8C__) || defined(__SAM3A4C__) + volatile uint32_t * W5100Class::ss_pin_reg; + uint32_t W5100Class::ss_pin_mask; +#elif defined(__PIC32MX__) + volatile uint32_t * W5100Class::ss_pin_reg; + uint32_t W5100Class::ss_pin_mask; +#elif defined(ARDUINO_ARCH_ESP8266) + volatile uint32_t * W5100Class::ss_pin_reg; + uint32_t W5100Class::ss_pin_mask; +#elif defined(__SAMD21G18A__) + volatile uint32_t * W5100Class::ss_pin_reg; + uint32_t W5100Class::ss_pin_mask; + #warning w5100.cpp Use __SAMD21G18A__ +#endif + +// KH +uint8_t W5100Class::init(uint8_t socketNumbers, uint8_t new_ss_pin) +{ + uint8_t i; + + if (initialized) return 1; + + // Many Ethernet shields have a CAT811 or similar reset chip + // connected to W5100 or W5200 chips. The W5200 will not work at + // all, and may even drive its MISO pin, until given an active low + // reset pulse! The CAT811 has a 240 ms typical pulse length, and + // a 400 ms worst case maximum pulse length. MAX811 has a worst + // case maximum 560 ms pulse length. This delay is meant to wait + // until the reset pulse is ended. If your hardware has a shorter + // reset time, this can be edited or removed. + delay(560); + + //W5100Class::ss_pin = new_ss_pin; + +#if ( W5100_DEBUG > 0 ) + //KH + Serial.print("\nW5100 init, using SS_PIN_DEFAULT = "); + Serial.print(SS_PIN_DEFAULT); + Serial.print(", new ss_pin = "); + Serial.print(new_ss_pin); + Serial.print(", W5100Class::ss_pin = "); + Serial.println(W5100Class::ss_pin); +#endif + + SPI.begin(); + + initSS(); + resetSS(); + + // From #define SPI_ETHERNET_SETTINGS SPISettings(14000000, MSBFIRST, SPI_MODE0) + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + + // Attempt W5200 detection first, because W5200 does not properly + // reset its SPI state when CS goes high (inactive). Communication + // from detecting the other chips can leave the W5200 in a state + // where it won't recover, unless given a reset pulse. + if (isW5200()) + { + CH_BASE_MSB = 0x40; +#ifdef ETHERNET_LARGE_BUFFERS +#if MAX_SOCK_NUM <= 1 + SSIZE = 16384; +#elif MAX_SOCK_NUM <= 2 + SSIZE = 8192; +#elif MAX_SOCK_NUM <= 4 + SSIZE = 4096; +#else + SSIZE = 2048; +#endif + SMASK = SSIZE - 1; +#endif + for (i=0; i> 10); + writeSnTX_SIZE(i, SSIZE >> 10); + } + for (; i<8; i++) + { + writeSnRX_SIZE(i, 0); + writeSnTX_SIZE(i, 0); + } + +#if ( W5100_DEBUG > 0 ) + Serial.print("W5100::init: W5200, SSIZE ="); + Serial.println(SSIZE); +#endif + + // Try W5500 next. Wiznet finally seems to have implemented + // SPI well with this chip. It appears to be very resilient, + // so try it after the fragile W5200 + } else if (isW5500()) + { + CH_BASE_MSB = 0x10; +#ifdef ETHERNET_LARGE_BUFFERS +#if MAX_SOCK_NUM <= 1 + SSIZE = 16384; +#elif MAX_SOCK_NUM <= 2 + SSIZE = 8192; +#elif MAX_SOCK_NUM <= 4 + SSIZE = 4096; +#else + SSIZE = 2048; +#endif + SMASK = SSIZE - 1; + for (i=0; i> 10); + writeSnTX_SIZE(i, SSIZE >> 10); + } + for (; i<8; i++) + { + writeSnRX_SIZE(i, 0); + writeSnTX_SIZE(i, 0); + } +#endif + +#if ( W5100_DEBUG > 0 ) + Serial.print("W5100::init: W5500, SSIZE ="); + Serial.println(SSIZE); +#endif + + // Try W5100 last. This simple chip uses fixed 4 byte frames + // for every 8 bit access. Terribly inefficient, but so simple + // it recovers from "hearing" unsuccessful W5100 or W5200 + // communication. W5100 is also the only chip without a VERSIONR + // register for identification, so we check this last. + } else if (isW5100()) + { + CH_BASE_MSB = 0x04; + +#ifdef ETHERNET_LARGE_BUFFERS + + #if MAX_SOCK_NUM <= 1 + SSIZE = 8192; + writeTMSR(0x03); + writeRMSR(0x03); + #else + SSIZE = 4096; + writeTMSR(0x0A); + writeRMSR(0x0A); + #endif + + SMASK = SSIZE - 1; +#else + + writeTMSR(0x55); + writeRMSR(0x55); +#endif + +#if ( W5100_DEBUG > 0 ) + Serial.print("W5100::init: W5100, SSIZE ="); + Serial.println(SSIZE); +#endif + + // No hardware seems to be present. Or it could be a W5200 + // that's heard other SPI communication if its chip select + // pin wasn't high when a SD card or other SPI chip was used. + } + else + { +#if ( W5100_DEBUG > 0 ) + Serial.println("no chip :-("); +#endif + + chip = 0; + SPI.endTransaction(); + return 0; // no known chip is responding :-( + } + + SPI.endTransaction(); + initialized = true; + return 1; // successful init +} + +// Soft reset the Wiznet chip, by writing to its MR register reset bit +uint8_t W5100Class::softReset(void) +{ + uint16_t count=0; + +#if ( W5100_DEBUG > 1 ) + Serial.println("Wiznet soft reset"); +#endif + + // write to reset bit + writeMR(0x80); + // then wait for soft reset to complete + do + { + uint8_t mr = readMR(); + +#if ( W5100_DEBUG > 2 ) + Serial.print("mr="); + Serial.println(mr, HEX); +#endif + + if (mr == 0) + return 1; + + delay(1); + } while (++count < 20); + return 0; +} + +uint8_t W5100Class::isW5100(void) +{ + chip = 51; + +#if ( W5100_DEBUG > 1 ) + Serial.println("W5100.cpp: detect W5100 chip"); +#endif + + if (!softReset()) + return 0; + + writeMR(0x10); + if (readMR() != 0x10) + return 0; + + writeMR(0x12); + if (readMR() != 0x12) + return 0; + + writeMR(0x00); + if (readMR() != 0x00) + return 0; + +#if ( W5100_DEBUG > 1 ) + Serial.println("chip is W5100"); +#endif + + return 1; +} + +uint8_t W5100Class::isW5200(void) +{ + chip = 52; + +#if ( W5100_DEBUG > 1 ) + Serial.println("W5100.cpp: detect W5200 chip"); +#endif + + if (!softReset()) + return 0; + + writeMR(0x08); + if (readMR() != 0x08) + return 0; + + writeMR(0x10); + if (readMR() != 0x10) + return 0; + + writeMR(0x00); + if (readMR() != 0x00) + return 0; + + int ver = readVERSIONR_W5200(); + +#if ( W5100_DEBUG > 1 ) + Serial.print("version="); + Serial.println(ver); +#endif + + if (ver != 3) + return 0; + +#if ( W5100_DEBUG > 1 ) + Serial.println("chip is W5200"); +#endif + + return 1; +} + +uint8_t W5100Class::isW5500(void) +{ + chip = 55; + +#if ( W5100_DEBUG > 1 ) + Serial.println("W5100.cpp: detect W5500 chip"); +#endif + + if (!softReset()) + return 0; + + writeMR(0x08); + if (readMR() != 0x08) + return 0; + + writeMR(0x10); + if (readMR() != 0x10) + return 0; + + writeMR(0x00); + if (readMR() != 0x00) + return 0; + + int ver = readVERSIONR_W5500(); + +#if ( W5100_DEBUG > 1 ) + Serial.print("version="); + Serial.println(ver); +#endif + + if (ver != 4) + return 0; + +#if ( W5100_DEBUG > 1 ) + Serial.println("chip is W5500"); +#endif + + return 1; +} + +W5100Linkstatus W5100Class::getLinkStatus() +{ + uint8_t phystatus; + + // KH + if (!initialized) return UNKNOWN; + + switch (chip) + { + case 52: + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + phystatus = readPSTATUS_W5200(); + SPI.endTransaction(); + if (phystatus & 0x20) + return LINK_ON; + + return LINK_OFF; + + case 55: + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + phystatus = readPHYCFGR_W5500(); + SPI.endTransaction(); + if (phystatus & 0x01) + return LINK_ON; + + return LINK_OFF; + + default: + return UNKNOWN; + } +} + +uint16_t W5100Class::write(uint16_t addr, const uint8_t *buf, uint16_t len) +{ + uint8_t cmd[8]; + + if (chip == 51) + { + for (uint16_t i=0; i> 8); + SPI.transfer(addr & 0xFF); + addr++; + SPI.transfer(buf[i]); + resetSS(); + } + } + else if (chip == 52) + { + setSS(); + cmd[0] = addr >> 8; + cmd[1] = addr & 0xFF; + cmd[2] = ((len >> 8) & 0x7F) | 0x80; + cmd[3] = len & 0xFF; + SPI.transfer(cmd, 4); + +#ifdef SPI_HAS_TRANSFER_BUF + SPI.transfer(buf, NULL, len); +#else + // TODO: copy 8 bytes at a time to cmd[] and block transfer + for (uint16_t i=0; i < len; i++) + { + SPI.transfer(buf[i]); + } +#endif + resetSS(); + } + else + { + // chip == 55 + setSS(); + if (addr < 0x100) + { + // common registers 00nn + cmd[0] = 0; + cmd[1] = addr & 0xFF; + cmd[2] = 0x04; + } + else if (addr < 0x8000) + { + // socket registers 10nn, 11nn, 12nn, 13nn, etc + cmd[0] = 0; + cmd[1] = addr & 0xFF; + cmd[2] = ((addr >> 3) & 0xE0) | 0x0C; + } + else if (addr < 0xC000) + { + // transmit buffers 8000-87FF, 8800-8FFF, 9000-97FF, etc + // 10## #nnn nnnn nnnn + cmd[0] = addr >> 8; + cmd[1] = addr & 0xFF; + #if defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 1 + cmd[2] = 0x14; // 16K buffers + #elif defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 2 + cmd[2] = ((addr >> 8) & 0x20) | 0x14; // 8K buffers + #elif defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 4 + cmd[2] = ((addr >> 7) & 0x60) | 0x14; // 4K buffers + #else + cmd[2] = ((addr >> 6) & 0xE0) | 0x14; // 2K buffers + #endif + } + else + { + // receive buffers + cmd[0] = addr >> 8; + cmd[1] = addr & 0xFF; + #if defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 1 + cmd[2] = 0x1C; // 16K buffers + #elif defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 2 + cmd[2] = ((addr >> 8) & 0x20) | 0x1C; // 8K buffers + #elif defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 4 + cmd[2] = ((addr >> 7) & 0x60) | 0x1C; // 4K buffers + #else + cmd[2] = ((addr >> 6) & 0xE0) | 0x1C; // 2K buffers + #endif + } + + if (len <= 5) + { + for (uint8_t i=0; i < len; i++) + { + cmd[i + 3] = buf[i]; + } + + SPI.transfer(cmd, len + 3); + } + else + { + SPI.transfer(cmd, 3); +#ifdef SPI_HAS_TRANSFER_BUF + SPI.transfer(buf, NULL, len); +#else + // TODO: copy 8 bytes at a time to cmd[] and block transfer + for (uint16_t i=0; i < len; i++) + { + SPI.transfer(buf[i]); + } +#endif + } + resetSS(); + } + return len; +} + +uint16_t W5100Class::read(uint16_t addr, uint8_t *buf, uint16_t len) +{ + uint8_t cmd[4]; + + if (chip == 51) + { + for (uint16_t i=0; i < len; i++) + { + setSS(); + #if 1 + SPI.transfer(0x0F); + SPI.transfer(addr >> 8); + SPI.transfer(addr & 0xFF); + addr++; + buf[i] = SPI.transfer(0); + #else + cmd[0] = 0x0F; + cmd[1] = addr >> 8; + cmd[2] = addr & 0xFF; + cmd[3] = 0; + SPI.transfer(cmd, 4); // TODO: why doesn't this work? + buf[i] = cmd[3]; + addr++; + #endif + resetSS(); + } + } + else if (chip == 52) + { + setSS(); + cmd[0] = addr >> 8; + cmd[1] = addr & 0xFF; + cmd[2] = (len >> 8) & 0x7F; + cmd[3] = len & 0xFF; + SPI.transfer(cmd, 4); + memset(buf, 0, len); + SPI.transfer(buf, len); + resetSS(); + } + else + { + // chip == 55 + setSS(); + + if (addr < 0x100) + { + // common registers 00nn + cmd[0] = 0; + cmd[1] = addr & 0xFF; + cmd[2] = 0x00; + } + else if (addr < 0x8000) + { + // socket registers 10nn, 11nn, 12nn, 13nn, etc + cmd[0] = 0; + cmd[1] = addr & 0xFF; + cmd[2] = ((addr >> 3) & 0xE0) | 0x08; + } + else if (addr < 0xC000) + { + // transmit buffers 8000-87FF, 8800-8FFF, 9000-97FF, etc + // 10## #nnn nnnn nnnn + cmd[0] = addr >> 8; + cmd[1] = addr & 0xFF; + #if defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 1 + cmd[2] = 0x10; // 16K buffers + #elif defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 2 + cmd[2] = ((addr >> 8) & 0x20) | 0x10; // 8K buffers + #elif defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 4 + cmd[2] = ((addr >> 7) & 0x60) | 0x10; // 4K buffers + #else + cmd[2] = ((addr >> 6) & 0xE0) | 0x10; // 2K buffers + #endif + } else + { + // receive buffers + cmd[0] = addr >> 8; + cmd[1] = addr & 0xFF; + #if defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 1 + cmd[2] = 0x18; // 16K buffers + #elif defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 2 + cmd[2] = ((addr >> 8) & 0x20) | 0x18; // 8K buffers + #elif defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 4 + cmd[2] = ((addr >> 7) & 0x60) | 0x18; // 4K buffers + #else + cmd[2] = ((addr >> 6) & 0xE0) | 0x18; // 2K buffers + #endif + } + SPI.transfer(cmd, 3); + memset(buf, 0, len); + SPI.transfer(buf, len); + resetSS(); + } + return len; +} + +void W5100Class::execCmdSn(SOCKET s, SockCMD _cmd) +{ + // Send command to socket + writeSnCR(s, _cmd); + // Wait for command to complete + while (readSnCR(s)) ; +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet/src/utility/w5100.h b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet/src/utility/w5100.h new file mode 100644 index 0000000..838a49f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet/src/utility/w5100.h @@ -0,0 +1,642 @@ +/**************************************************************************************************************************** + w5100.h - Driver for W5x00 + + EthernetWebServer is a library for the Ethernet shields to run WebServer + + Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases + Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer + Licensed under MIT license + Version: 1.0.9 + + Copyright 2018 Paul Stoffregen + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/02/2020 Initial coding for Arduino Mega, Teensy, etc to support Ethernetx libraries + 1.0.1 K Hoang 20/02/2020 Add support to lambda functions + 1.0.2 K Hoang 20/02/2020 Add support to UIPEthernet library for ENC28J60 + 1.0.3 K Hoang 23/02/2020 Add support to SAM DUE / SAMD21 boards + 1.0.4 K Hoang 16/04/2020 Add support to SAMD51 boards + 1.0.5 K Hoang 24/04/2020 Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, + Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, etc. + More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge + 1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards + 1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards + 1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. + 1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future. + *****************************************************************************************************************************/ + +// w5100.h contains private W5x00 hardware "driver" level definitions +// which are not meant to be exposed to other libraries or Arduino users + +#ifndef W5100_H_INCLUDED +#define W5100_H_INCLUDED + +#include +#include + +#ifndef USE_W5100 +#define USE_W5100 false +#else +#define USE_W5100 true +#endif + +#if !USE_W5100 + +// Safe for W5200 and W5500, but also tested OK on W5100 +// Use 14MHz if you know your W5100 can't run +// Higher SPI clock results in faster transfer to hosts on a LAN +// or with very low packet latency. With ordinary internet latency, +// the TCP window size & packet loss determine your overall speed. +#warning Use 25MHz clock for W5200/W5500. Not for W5100 +#define SPI_ETHERNET_SETTINGS SPISettings(25000000, MSBFIRST, SPI_MODE0) + +#else + +// Safe for all chips but too slow +#define SPI_ETHERNET_SETTINGS SPISettings(14000000, MSBFIRST, SPI_MODE0) +#warning Use 14MHz clock for W5100/W5200/W5500. Slow. + +#endif + +// Require Ethernet.h, because we need MAX_SOCK_NUM +#ifndef ethernet_h_ +#error "Ethernet.h must be included before w5100.h" +#endif + +// Arduino 101's SPI can not run faster than 8 MHz. +#if defined(ARDUINO_ARCH_ARC32) +#undef SPI_ETHERNET_SETTINGS +#define SPI_ETHERNET_SETTINGS SPISettings(8000000, MSBFIRST, SPI_MODE0) +#endif + +// Arduino Zero can't use W5100-based shields faster than 8 MHz +// https://github.com/arduino-libraries/Ethernet/issues/37#issuecomment-408036848 +// W5500 does seem to work at 12 MHz. Delete this if only using W5500 +#if defined(__SAMD21G18A__) +#undef SPI_ETHERNET_SETTINGS +//#warning Use SAMD21 architecture SPISettings(8000000, MSBFIRST, SPI_MODE3) => IP OK +#warning Use SAMD21 architecture SPISettings(30000000, MSBFIRST, SPI_MODE3) => IP OK +// Still not working !!! Original SPI_MODE0 not OK at all +//#define SPI_ETHERNET_SETTINGS SPISettings(8000000, MSBFIRST, SPI_MODE3) +#define SPI_ETHERNET_SETTINGS SPISettings(30000000, MSBFIRST, SPI_MODE3) +#endif + +typedef uint8_t SOCKET; + +class SnMR { +public: + static const uint8_t CLOSE = 0x00; + static const uint8_t TCP = 0x21; + static const uint8_t UDP = 0x02; + static const uint8_t IPRAW = 0x03; + static const uint8_t MACRAW = 0x04; + static const uint8_t PPPOE = 0x05; + static const uint8_t ND = 0x20; + static const uint8_t MULTI = 0x80; +}; + +enum SockCMD { + Sock_OPEN = 0x01, + Sock_LISTEN = 0x02, + Sock_CONNECT = 0x04, + Sock_DISCON = 0x08, + Sock_CLOSE = 0x10, + Sock_SEND = 0x20, + Sock_SEND_MAC = 0x21, + Sock_SEND_KEEP = 0x22, + Sock_RECV = 0x40 +}; + +class SnIR { +public: + static const uint8_t SEND_OK = 0x10; + static const uint8_t TIMEOUT = 0x08; + static const uint8_t RECV = 0x04; + static const uint8_t DISCON = 0x02; + static const uint8_t CON = 0x01; +}; + +class SnSR { +public: + static const uint8_t CLOSED = 0x00; + static const uint8_t INIT = 0x13; + static const uint8_t LISTEN = 0x14; + static const uint8_t SYNSENT = 0x15; + static const uint8_t SYNRECV = 0x16; + static const uint8_t ESTABLISHED = 0x17; + static const uint8_t FIN_WAIT = 0x18; + static const uint8_t CLOSING = 0x1A; + static const uint8_t TIME_WAIT = 0x1B; + static const uint8_t CLOSE_WAIT = 0x1C; + static const uint8_t LAST_ACK = 0x1D; + static const uint8_t UDP = 0x22; + static const uint8_t IPRAW = 0x32; + static const uint8_t MACRAW = 0x42; + static const uint8_t PPPOE = 0x5F; +}; + +class IPPROTO { +public: + static const uint8_t IP = 0; + static const uint8_t ICMP = 1; + static const uint8_t IGMP = 2; + static const uint8_t GGP = 3; + static const uint8_t TCP = 6; + static const uint8_t PUP = 12; + static const uint8_t UDP = 17; + static const uint8_t IDP = 22; + static const uint8_t ND = 77; + static const uint8_t RAW = 255; +}; + +enum W5100Linkstatus { + UNKNOWN, + LINK_ON, + LINK_OFF +}; + +class W5100Class { + +public: + // KH + uint8_t init(uint8_t socketNumbers = MAX_SOCK_NUM, uint8_t new_ss_pin = 10); + + inline void setGatewayIp(const uint8_t * addr) { writeGAR(addr); } + inline void getGatewayIp(uint8_t * addr) { readGAR(addr); } + + inline void setSubnetMask(const uint8_t * addr) { writeSUBR(addr); } + inline void getSubnetMask(uint8_t * addr) { readSUBR(addr); } + + inline void setMACAddress(const uint8_t * addr) { writeSHAR(addr); } + inline void getMACAddress(uint8_t * addr) { readSHAR(addr); } + + inline void setIPAddress(const uint8_t * addr) { writeSIPR(addr); } + inline void getIPAddress(uint8_t * addr) { readSIPR(addr); } + + inline void setRetransmissionTime(uint16_t timeout) { writeRTR(timeout); } + inline void setRetransmissionCount(uint8_t retry) { writeRCR(retry); } + + static void execCmdSn(SOCKET s, SockCMD _cmd); + + + // W5100 Registers + // --------------- +//private: +public: + static uint16_t write(uint16_t addr, const uint8_t *buf, uint16_t len); + + static uint8_t write(uint16_t addr, uint8_t data) + { + return write(addr, &data, 1); + } + + static uint16_t read(uint16_t addr, uint8_t *buf, uint16_t len); + + static uint8_t read(uint16_t addr) + { + uint8_t data; + read(addr, &data, 1); + return data; + } + +#define __GP_REGISTER8(name, address) \ + static inline void write##name(uint8_t _data) { \ + write(address, _data); \ + } \ + static inline uint8_t read##name() { \ + return read(address); \ + } +#define __GP_REGISTER16(name, address) \ + static void write##name(uint16_t _data) { \ + uint8_t buf[2]; \ + buf[0] = _data >> 8; \ + buf[1] = _data & 0xFF; \ + write(address, buf, 2); \ + } \ + static uint16_t read##name() { \ + uint8_t buf[2]; \ + read(address, buf, 2); \ + return (buf[0] << 8) | buf[1]; \ + } +#define __GP_REGISTER_N(name, address, size) \ + static uint16_t write##name(const uint8_t *_buff) { \ + return write(address, _buff, size); \ + } \ + static uint16_t read##name(uint8_t *_buff) { \ + return read(address, _buff, size); \ + } + + W5100Linkstatus getLinkStatus(); + +public: + __GP_REGISTER8 (MR, 0x0000); // Mode + __GP_REGISTER_N(GAR, 0x0001, 4); // Gateway IP address + __GP_REGISTER_N(SUBR, 0x0005, 4); // Subnet mask address + __GP_REGISTER_N(SHAR, 0x0009, 6); // Source MAC address + __GP_REGISTER_N(SIPR, 0x000F, 4); // Source IP address + __GP_REGISTER8 (IR, 0x0015); // Interrupt + __GP_REGISTER8 (IMR, 0x0016); // Interrupt Mask + __GP_REGISTER16(RTR, 0x0017); // Timeout address + __GP_REGISTER8 (RCR, 0x0019); // Retry count + __GP_REGISTER8 (RMSR, 0x001A); // Receive memory size (W5100 only) + __GP_REGISTER8 (TMSR, 0x001B); // Transmit memory size (W5100 only) + __GP_REGISTER8 (PATR, 0x001C); // Authentication type address in PPPoE mode + __GP_REGISTER8 (PTIMER, 0x0028); // PPP LCP Request Timer + __GP_REGISTER8 (PMAGIC, 0x0029); // PPP LCP Magic Number + __GP_REGISTER_N(UIPR, 0x002A, 4); // Unreachable IP address in UDP mode (W5100 only) + __GP_REGISTER16(UPORT, 0x002E); // Unreachable Port address in UDP mode (W5100 only) + __GP_REGISTER8 (VERSIONR_W5200,0x001F); // Chip Version Register (W5200 only) + __GP_REGISTER8 (VERSIONR_W5500,0x0039); // Chip Version Register (W5500 only) + __GP_REGISTER8 (PSTATUS_W5200, 0x0035); // PHY Status + __GP_REGISTER8 (PHYCFGR_W5500, 0x002E); // PHY Configuration register, default: 10111xxx + + +#undef __GP_REGISTER8 +#undef __GP_REGISTER16 +#undef __GP_REGISTER_N + + // W5100 Socket registers + // ---------------------- +private: + static uint16_t CH_BASE(void) { + //if (chip == 55) return 0x1000; + //if (chip == 52) return 0x4000; + //return 0x0400; + return CH_BASE_MSB << 8; + } + static uint8_t CH_BASE_MSB; // 1 redundant byte, saves ~80 bytes code on AVR + static const uint16_t CH_SIZE = 0x0100; + + static inline uint8_t readSn(SOCKET s, uint16_t addr) + { + return read(CH_BASE() + s * CH_SIZE + addr); + } + static inline uint8_t writeSn(SOCKET s, uint16_t addr, uint8_t data) + { + return write(CH_BASE() + s * CH_SIZE + addr, data); + } + static inline uint16_t readSn(SOCKET s, uint16_t addr, uint8_t *buf, uint16_t len) + { + return read(CH_BASE() + s * CH_SIZE + addr, buf, len); + } + static inline uint16_t writeSn(SOCKET s, uint16_t addr, uint8_t *buf, uint16_t len) + { + return write(CH_BASE() + s * CH_SIZE + addr, buf, len); + } + +#define __SOCKET_REGISTER8(name, address) \ + static inline void write##name(SOCKET _s, uint8_t _data) { \ + writeSn(_s, address, _data); \ + } \ + static inline uint8_t read##name(SOCKET _s) { \ + return readSn(_s, address); \ + } +#define __SOCKET_REGISTER16(name, address) \ + static void write##name(SOCKET _s, uint16_t _data) { \ + uint8_t buf[2]; \ + buf[0] = _data >> 8; \ + buf[1] = _data & 0xFF; \ + writeSn(_s, address, buf, 2); \ + } \ + static uint16_t read##name(SOCKET _s) { \ + uint8_t buf[2]; \ + readSn(_s, address, buf, 2); \ + return (buf[0] << 8) | buf[1]; \ + } +#define __SOCKET_REGISTER_N(name, address, size) \ + static uint16_t write##name(SOCKET _s, uint8_t *_buff) { \ + return writeSn(_s, address, _buff, size); \ + } \ + static uint16_t read##name(SOCKET _s, uint8_t *_buff) { \ + return readSn(_s, address, _buff, size); \ + } + +public: + __SOCKET_REGISTER8(SnMR, 0x0000) // Mode + __SOCKET_REGISTER8(SnCR, 0x0001) // Command + __SOCKET_REGISTER8(SnIR, 0x0002) // Interrupt + __SOCKET_REGISTER8(SnSR, 0x0003) // Status + __SOCKET_REGISTER16(SnPORT, 0x0004) // Source Port + __SOCKET_REGISTER_N(SnDHAR, 0x0006, 6) // Destination Hardw Addr + __SOCKET_REGISTER_N(SnDIPR, 0x000C, 4) // Destination IP Addr + __SOCKET_REGISTER16(SnDPORT, 0x0010) // Destination Port + __SOCKET_REGISTER16(SnMSSR, 0x0012) // Max Segment Size + __SOCKET_REGISTER8(SnPROTO, 0x0014) // Protocol in IP RAW Mode + __SOCKET_REGISTER8(SnTOS, 0x0015) // IP TOS + __SOCKET_REGISTER8(SnTTL, 0x0016) // IP TTL + __SOCKET_REGISTER8(SnRX_SIZE, 0x001E) // RX Memory Size (W5200 only) + __SOCKET_REGISTER8(SnTX_SIZE, 0x001F) // RX Memory Size (W5200 only) + __SOCKET_REGISTER16(SnTX_FSR, 0x0020) // TX Free Size + __SOCKET_REGISTER16(SnTX_RD, 0x0022) // TX Read Pointer + __SOCKET_REGISTER16(SnTX_WR, 0x0024) // TX Write Pointer + __SOCKET_REGISTER16(SnRX_RSR, 0x0026) // RX Free Size + __SOCKET_REGISTER16(SnRX_RD, 0x0028) // RX Read Pointer + __SOCKET_REGISTER16(SnRX_WR, 0x002A) // RX Write Pointer (supported?) + +#undef __SOCKET_REGISTER8 +#undef __SOCKET_REGISTER16 +#undef __SOCKET_REGISTER_N + + +private: + // KH + bool initialized = false; + static uint8_t chip; + static uint8_t ss_pin; + + static uint8_t isW5100(void); + static uint8_t isW5200(void); + static uint8_t isW5500(void); + +public: + // KH + static uint8_t softReset(void); + static uint8_t getChip(void) { return chip; } +#ifdef ETHERNET_LARGE_BUFFERS + static uint16_t SSIZE; + static uint16_t SMASK; +#else + static const uint16_t SSIZE = 2048; + static const uint16_t SMASK = 0x07FF; +#endif + static uint16_t SBASE(uint8_t socknum) + { + if (chip == 51) + { + return socknum * SSIZE + 0x4000; + } + else + { + return socknum * SSIZE + 0x8000; + } + } + + static uint16_t RBASE(uint8_t socknum) + { + if (chip == 51) { + return socknum * SSIZE + 0x6000; + } + else + { + return socknum * SSIZE + 0xC000; + } + } + + static bool hasOffsetAddressMapping(void) + { + if (chip == 55) + return true; + + return false; + } + + static void setSS(uint8_t pin) { ss_pin = pin; } + +private: +#if defined(__AVR__) + +#warning Use AVR architecture + + static volatile uint8_t *ss_pin_reg; + static uint8_t ss_pin_mask; + + inline static void initSS() + { + ss_pin_reg = portOutputRegister(digitalPinToPort(ss_pin)); + ss_pin_mask = digitalPinToBitMask(ss_pin); + pinMode(ss_pin, OUTPUT); + } + + inline static void setSS() + { + *(ss_pin_reg) &= ~ss_pin_mask; + } + + inline static void resetSS() + { + *(ss_pin_reg) |= ss_pin_mask; + } +#elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK66FX1M0__) || defined(__MK64FX512__) + +#warning Use MK architecture + + static volatile uint8_t *ss_pin_reg; + + inline static void initSS() + { + ss_pin_reg = portOutputRegister(ss_pin); + pinMode(ss_pin, OUTPUT); + } + + inline static void setSS() + { + *(ss_pin_reg+256) = 1; + } + + inline static void resetSS() + { + *(ss_pin_reg+128) = 1; + } +#elif defined(__IMXRT1062__) + +#warning Use Teensy architecture + + static volatile uint32_t *ss_pin_reg; + static uint32_t ss_pin_mask; + + inline static void initSS() + { + ss_pin_reg = portOutputRegister(digitalPinToPort(ss_pin)); + ss_pin_mask = digitalPinToBitMask(ss_pin); + pinMode(ss_pin, OUTPUT); + } + + inline static void setSS() + { + *(ss_pin_reg+34) = ss_pin_mask; + } + + inline static void resetSS() + { + *(ss_pin_reg+33) = ss_pin_mask; + + // Check https://forum.pjrc.com/threads/66758-Teensy-4-0-and-Ethernet-(WIZ5100-and-WIZ812) + if (chip == 51) + delayNanoseconds(10); // <-- fixes W5100 on Teensy 4 + } +#elif defined(__MKL26Z64__) + static volatile uint8_t *ss_pin_reg; + static uint8_t ss_pin_mask; + inline static void initSS() + { + ss_pin_reg = portOutputRegister(digitalPinToPort(ss_pin)); + ss_pin_mask = digitalPinToBitMask(ss_pin); + pinMode(ss_pin, OUTPUT); + } + + inline static void setSS() + { + *(ss_pin_reg+8) = ss_pin_mask; + } + + inline static void resetSS() + { + *(ss_pin_reg+4) = ss_pin_mask; + } +#elif defined(__SAM3X8E__) || defined(__SAM3A8C__) || defined(__SAM3A4C__) + +#warning Use SAM3 architecture + + static volatile uint32_t *ss_pin_reg; + static uint32_t ss_pin_mask; + + inline static void initSS() + { + ss_pin_reg = &(digitalPinToPort(ss_pin)->PIO_PER); + ss_pin_mask = digitalPinToBitMask(ss_pin); + pinMode(ss_pin, OUTPUT); + } + + inline static void setSS() + { + *(ss_pin_reg+13) = ss_pin_mask; + } + + inline static void resetSS() + { + *(ss_pin_reg+12) = ss_pin_mask; + } +#elif defined(__PIC32MX__) + static volatile uint32_t *ss_pin_reg; + static uint32_t ss_pin_mask; + + inline static void initSS() + { + ss_pin_reg = portModeRegister(digitalPinToPort(ss_pin)); + ss_pin_mask = digitalPinToBitMask(ss_pin); + pinMode(ss_pin, OUTPUT); + } + + inline static void setSS() + { + *(ss_pin_reg+8+1) = ss_pin_mask; + } + + inline static void resetSS() + { + *(ss_pin_reg+8+2) = ss_pin_mask; + } + +#elif defined(ARDUINO_ARCH_ESP8266) + +#warning Use ARDUINO_ARCH_ESP8266 architecture + + static volatile uint32_t *ss_pin_reg; + static uint32_t ss_pin_mask; + + inline static void initSS() + { + ss_pin_reg = (volatile uint32_t*)GPO; + ss_pin_mask = 1 << ss_pin; + pinMode(ss_pin, OUTPUT); + } + + inline static void setSS() + { + GPOC = ss_pin_mask; + } + + inline static void resetSS() + { + GPOS = ss_pin_mask; + } + +#elif defined(__SAMD21G18A__) + +#warning Use SAMD21 architecture + + static volatile uint32_t *ss_pin_reg; + static uint32_t ss_pin_mask; + + inline static void initSS() + { + ss_pin_reg = portModeRegister(digitalPinToPort(ss_pin)); + ss_pin_mask = digitalPinToBitMask(ss_pin); + pinMode(ss_pin, OUTPUT); + } + + inline static void setSS() + { + *(ss_pin_reg+5) = ss_pin_mask; + } + + inline static void resetSS() + { + *(ss_pin_reg+6) = ss_pin_mask; + } +#else + +#warning Use Default architecture + + inline static void initSS() + { + pinMode(ss_pin, OUTPUT); + } + + inline static void setSS() + { + digitalWrite(ss_pin, LOW); + } + + inline static void resetSS() + { + digitalWrite(ss_pin, HIGH); + } +#endif +}; + +extern W5100Class W5100; + +#endif + +#ifndef UTIL_H +#define UTIL_H + +#ifndef htons +#define htons(x) ( (((x)<<8)&0xFF00) | (((x)>>8)&0xFF) ) +#endif + +#ifndef ntohs +#define ntohs(x) htons(x) +#endif + +#ifndef htonl +#define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \ + ((x)<< 8 & 0x00FF0000UL) | \ + ((x)>> 8 & 0x0000FF00UL) | \ + ((x)>>24 & 0x000000FFUL) ) +#endif + +#ifndef ntohl +#define ntohl(x) htonl(x) +#endif + +#endif //W5100_H_INCLUDED diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet2/src/Ethernet2.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet2/src/Ethernet2.cpp new file mode 100644 index 0000000..f90be20 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet2/src/Ethernet2.cpp @@ -0,0 +1,262 @@ +/* + modified 12 Aug 2013 + by Soohwan Kim (suhwan@wiznet.co.kr) + +- 10 Apr. 2015 + Added support for Arduino Ethernet Shield 2 + by Arduino.org team + + */ + +#include "Ethernet2.h" +#include "Dhcp.h" + +// XXX: don't make assumptions about the value of MAX_SOCK_NUM. +uint8_t EthernetClass::_state[MAX_SOCK_NUM] = { 0, }; +uint16_t EthernetClass::_server_port[MAX_SOCK_NUM] = { 0, }; + + + +#if defined(WIZ550io_WITH_MACADDRESS) +int EthernetClass::begin(void) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var _mac_address + //byte mac_address[6] ={0,}; + ////// + + if (_dhcp != NULL) { + delete _dhcp; + } + _dhcp = new DhcpClass(); + + // Initialise the basic info + w5500.init(w5500_cspin); + w5500.setIPAddress(IPAddress(0,0,0,0).raw_address()); + + // KH mod + w5500.getMACAddress(_mac_address); + + // Now try to get our config info from a DHCP server + int ret = _dhcp->beginWithDHCP(_mac_address); + ////// + + if(ret == 1) + { + // We've successfully found a DHCP server and got our configuration info, so set things + // accordingly + w5500.setIPAddress(_dhcp->getLocalIp().raw_address()); + w5500.setGatewayIp(_dhcp->getGatewayIp().raw_address()); + w5500.setSubnetMask(_dhcp->getSubnetMask().raw_address()); + _dnsServerAddress = _dhcp->getDnsServerIp(); + _dnsDomainName = _dhcp->getDnsDomainName(); + _hostName = _dhcp->getHostName(); + } + + return ret; +} + +void EthernetClass::begin(IPAddress local_ip) +{ + // Assume the DNS server will be the machine on the same network as the local IP + // but with last octet being '1' + IPAddress dns_server = local_ip; + dns_server[3] = 1; + begin(local_ip, dns_server); +} + +void EthernetClass::begin(IPAddress local_ip, IPAddress dns_server) +{ + // Assume the gateway will be the machine on the same network as the local IP + // but with last octet being '1' + IPAddress gateway = local_ip; + gateway[3] = 1; + begin(local_ip, dns_server, gateway); +} + +void EthernetClass::begin(IPAddress local_ip, IPAddress dns_server, IPAddress gateway) +{ + IPAddress subnet(255, 255, 255, 0); + begin(local_ip, dns_server, gateway, subnet); +} + +void EthernetClass::begin(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet) +{ + w5500.init(w5500_cspin); + w5500.setIPAddress(local_ip.raw_address()); + w5500.setGatewayIp(gateway.raw_address()); + w5500.setSubnetMask(subnet.raw_address()); + _dnsServerAddress = dns_server; +} +#else +int EthernetClass::begin(uint8_t *mac_address) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac_address, sizeof(_mac_address)); + ////// + + if (_dhcp != NULL) { + delete _dhcp; + } + _dhcp = new DhcpClass(); + // Initialise the basic info + w5500.init(w5500_cspin); + w5500.setMACAddress(mac_address); + w5500.setIPAddress(IPAddress(0,0,0,0).raw_address()); + + // Now try to get our config info from a DHCP server + int ret = _dhcp->beginWithDHCP(mac_address); + if(ret == 1) + { + // We've successfully found a DHCP server and got our configuration info, so set things + // accordingly + w5500.setIPAddress(_dhcp->getLocalIp().raw_address()); + w5500.setGatewayIp(_dhcp->getGatewayIp().raw_address()); + w5500.setSubnetMask(_dhcp->getSubnetMask().raw_address()); + _dnsServerAddress = _dhcp->getDnsServerIp(); + _dnsDomainName = _dhcp->getDnsDomainName(); + _hostName = _dhcp->getHostName(); + } + + return ret; +} + +void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac_address, sizeof(_mac_address)); + ////// + + // Assume the DNS server will be the machine on the same network as the local IP + // but with last octet being '1' + IPAddress dns_server = local_ip; + dns_server[3] = 1; + begin(mac_address, local_ip, dns_server); +} + +void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac_address, sizeof(_mac_address)); + ////// + + // Assume the gateway will be the machine on the same network as the local IP + // but with last octet being '1' + IPAddress gateway = local_ip; + gateway[3] = 1; + begin(mac_address, local_ip, dns_server, gateway); +} + +void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac_address, sizeof(_mac_address)); + ////// + + IPAddress subnet(255, 255, 255, 0); + begin(mac_address, local_ip, dns_server, gateway, subnet); +} + +void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac_address, sizeof(_mac_address)); + ////// + + w5500.init(w5500_cspin); + w5500.setMACAddress(mac_address); + w5500.setIPAddress(local_ip.raw_address()); + w5500.setGatewayIp(gateway.raw_address()); + w5500.setSubnetMask(subnet.raw_address()); + _dnsServerAddress = dns_server; +} + +#endif + +int EthernetClass::maintain(){ + int rc = DHCP_CHECK_NONE; + if(_dhcp != NULL){ + //we have a pointer to dhcp, use it + rc = _dhcp->checkLease(); + switch ( rc ){ + case DHCP_CHECK_NONE: + //nothing done + break; + case DHCP_CHECK_RENEW_OK: + case DHCP_CHECK_REBIND_OK: + //we might have got a new IP. + w5500.setIPAddress(_dhcp->getLocalIp().raw_address()); + w5500.setGatewayIp(_dhcp->getGatewayIp().raw_address()); + w5500.setSubnetMask(_dhcp->getSubnetMask().raw_address()); + _dnsServerAddress = _dhcp->getDnsServerIp(); + _dnsDomainName = _dhcp->getDnsDomainName(); + _hostName = _dhcp->getHostName(); + break; + default: + //this is actually a error, it will retry though + break; + } + } + return rc; +} + +// KH add to report link status +uint8_t EthernetClass::link() +{ + return bitRead(w5500.getPHYCFGR(), 0); +} + +const char* EthernetClass::linkReport() +{ + if (bitRead(w5500.getPHYCFGR(), 0) == 1) + return "LINK"; + else + return "NO LINK"; +} +////// + +IPAddress EthernetClass::localIP() +{ + IPAddress ret; + w5500.getIPAddress(ret.raw_address()); + return ret; +} + +IPAddress EthernetClass::subnetMask() +{ + IPAddress ret; + w5500.getSubnetMask(ret.raw_address()); + return ret; +} + +IPAddress EthernetClass::gatewayIP() +{ + IPAddress ret; + w5500.getGatewayIp(ret.raw_address()); + return ret; +} + +IPAddress EthernetClass::dnsServerIP() +{ + return _dnsServerAddress; +} + +char* EthernetClass::dnsDomainName(){ + return _dnsDomainName; +} + +char* EthernetClass::hostName(){ + return _hostName; +} + +EthernetClass Ethernet; diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet2/src/Ethernet2.h b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet2/src/Ethernet2.h new file mode 100644 index 0000000..7a5a25f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet2/src/Ethernet2.h @@ -0,0 +1,92 @@ +/* + modified 12 Aug 2013 + by Soohwan Kim (suhwan@wiznet.co.kr) + + - 10 Apr. 2015 + Added support for Arduino Ethernet Shield 2 + by Arduino.org team + + */ +#ifndef ethernet_h +#define ethernet_h + +#include +#include "utility/w5500.h" +#include "IPAddress.h" +#include "EthernetClient.h" +#include "EthernetServer.h" +#include "Dhcp.h" + + + +class EthernetClass { +private: + IPAddress _dnsServerAddress; + char* _dnsDomainName; + char* _hostName; + DhcpClass* _dhcp; + + // KH add to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + uint8_t _mac_address[6] ={0,}; + ////// + +public: + uint8_t w5500_cspin; + + static uint8_t _state[MAX_SOCK_NUM]; + static uint16_t _server_port[MAX_SOCK_NUM]; + + EthernetClass() { _dhcp = NULL; w5500_cspin = 10; } + void init(uint8_t _cspin = 10) { w5500_cspin = _cspin; } + +#if defined(WIZ550io_WITH_MACADDRESS) + // Initialize function when use the ioShield serise (included WIZ550io) + // WIZ550io has a MAC address which is written after reset. + // Default IP, Gateway and subnet address are also writen. + // so, It needs some initial time. please refer WIZ550io Datasheet in details. + int begin(void); + void begin(IPAddress local_ip); + void begin(IPAddress local_ip, IPAddress dns_server); + void begin(IPAddress local_ip, IPAddress dns_server, IPAddress gateway); + void begin(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet); +#else + // Initialize the Ethernet shield to use the provided MAC address and gain the rest of the + // configuration through DHCP. + // Returns 0 if the DHCP configuration failed, and 1 if it succeeded + int begin(uint8_t *mac_address); + void begin(uint8_t *mac_address, IPAddress local_ip); + void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server); + void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway); + void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet); + +#endif + + int maintain(); + + // KH add to report link status + uint8_t link(); // returns the linkstate, 1 = linked, 0 = no link + const char* linkReport(); // returns the linkstate as a string + ////// + + // KH add to have similar function to Ethernet lib + // Certainly we can use void macAddress(uint8_t mac[]) to read from W5x00. + void MACAddress(uint8_t *mac_address) + { + memcpy(mac_address, _mac_address, sizeof(_mac_address)); + } + ////// + + IPAddress localIP(); + IPAddress subnetMask(); + IPAddress gatewayIP(); + IPAddress dnsServerIP(); + char* dnsDomainName(); + char* hostName(); + + friend class EthernetClient; + friend class EthernetServer; +}; + +extern EthernetClass Ethernet; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet2/src/EthernetUdp2.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet2/src/EthernetUdp2.cpp new file mode 100644 index 0000000..d8671cd --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet2/src/EthernetUdp2.cpp @@ -0,0 +1,290 @@ +/* + * Udp.cpp: Library to send/receive UDP packets with the Arduino ethernet shield. + * This version only offers minimal wrapping of socket.c/socket.h + * Drop Udp.h/.cpp into the Ethernet library directory at hardware/libraries/Ethernet/ + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + * + * - 10 Apr. 2015 + * Added support for Arduino Ethernet Shield 2 + * by Arduino.org team + */ + +#include "utility/w5500.h" +#include "utility/socket.h" +#include "Ethernet2.h" +#include "Udp.h" +#include "Dns.h" + +#define ETHERNET2_DEBUG 0 + +/* Constructor */ +EthernetUDP::EthernetUDP() : _sock(MAX_SOCK_NUM) {} + +/* Start EthernetUDP socket, listening at local port PORT */ +uint8_t EthernetUDP::begin(uint16_t port) { + if (_sock != MAX_SOCK_NUM) + return 0; + + for (int i = 0; i < MAX_SOCK_NUM; i++) { + uint8_t s = w5500.readSnSR(i); + if (s == SnSR::CLOSED || s == SnSR::FIN_WAIT) { + _sock = i; + break; + } + } + + if (_sock == MAX_SOCK_NUM) + return 0; + + _port = port; + _remaining = 0; + socket(_sock, SnMR::UDP, _port, 0); + + return 1; +} + +//KH, to add Multicast support +/* Start EthernetUDP socket, listening at local port PORT */ +uint8_t EthernetUDP::beginMulticast(IPAddress ip, uint16_t port) +{ + if (_sock != MAX_SOCK_NUM) + return 0; + + for (int i = 0; i < MAX_SOCK_NUM; i++) { + uint8_t s = w5500.readSnSR(i); + if (s == SnSR::CLOSED || s == SnSR::FIN_WAIT) { + _sock = i; + break; + } + } + + if (_sock == MAX_SOCK_NUM) + return 0; + + // Calculate MAC address from Multicast IP Address + byte mac[] = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0x00 }; + + mac[3] = ip[1] & 0x7F; + mac[4] = ip[2]; + mac[5] = ip[3]; + + w5500.writeSnDIPR(_sock, rawIPAddress(ip)); //239.255.0.1 + w5500.writeSnDPORT(_sock, port); + w5500.writeSnDHAR(_sock,mac); + + _remaining = 0; + socket(_sock, SnMR::UDP, port, SnMR::MULTI); + return 1; +} +////// + + + +/* return number of bytes available in the current packet, + will return zero if parsePacket hasn't been called yet */ +int EthernetUDP::available() { + return _remaining; +} + +/* Release any resources being used by this EthernetUDP instance */ +void EthernetUDP::stop() +{ + if (_sock == MAX_SOCK_NUM) + return; + + close(_sock); + + EthernetClass::_server_port[_sock] = 0; + _sock = MAX_SOCK_NUM; +} + +int EthernetUDP::beginPacket(const char *host, uint16_t port) +{ + // Look up the host first + int ret = 0; + DNSClient dns; + IPAddress remote_addr; + + dns.begin(Ethernet.dnsServerIP()); + ret = dns.getHostByName(host, remote_addr); + if (ret == 1) { + return beginPacket(remote_addr, port); + } else { + return ret; + } +} + +int EthernetUDP::beginPacket(IPAddress ip, uint16_t port) +{ + _offset = 0; + +// KH debug +#if (ETHERNET2_DEBUG > 1) + Serial.print("Ethernet2UDP::beginPacket: ip="); + Serial.print(ip); + Serial.print(", port="); + Serial.println(port); +#endif + + return startUDP(_sock, rawIPAddress(ip), port); +} + +int EthernetUDP::endPacket() +{ + return sendUDP(_sock); +} + +size_t EthernetUDP::write(uint8_t byte) +{ + return write(&byte, 1); +} + +size_t EthernetUDP::write(const uint8_t *buffer, size_t size) +{ + // KH debug +#if (ETHERNET2_DEBUG > 1) + Serial.print("Ethernet2UDP:write, size="); + Serial.println(size); +#endif + + uint16_t bytes_written = bufferData(_sock, _offset, buffer, size); + _offset += bytes_written; + + // KH debug +#if (ETHERNET2_DEBUG > 1) + Serial.print("Ethernet2UDP: bytes written="); + Serial.println(bytes_written); +#endif + + return bytes_written; +} + +int EthernetUDP::parsePacket() +{ + // discard any remaining bytes in the last packet + flush(); + + if (w5500.getRXReceivedSize(_sock) > 0) + { + //HACK - hand-parse the UDP packet using TCP recv method + uint8_t tmpBuf[8]; + int ret =0; + //read 8 header bytes and get IP and port from it + ret = recv(_sock,tmpBuf,8); + if (ret > 0) + { + _remoteIP = tmpBuf; + _remotePort = tmpBuf[4]; + _remotePort = (_remotePort << 8) + tmpBuf[5]; + _remaining = tmpBuf[6]; + _remaining = (_remaining << 8) + tmpBuf[7]; + + // When we get here, any remaining bytes are the data + ret = _remaining; + } + + // KH debug +#if (ETHERNET2_DEBUG > 1) + Serial.print("Ethernet2UDP:parsePacket OK, datasize="); + Serial.println(ret); +#endif + + return ret; + } + // There aren't any packets available + return 0; +} + +int EthernetUDP::read() +{ + uint8_t byte; + + if ((_remaining > 0) && (recv(_sock, &byte, 1) > 0)) + { + // We read things without any problems + _remaining--; + return byte; + } + + // If we get here, there's no data available + return -1; +} + +int EthernetUDP::read(unsigned char* buffer, size_t len) +{ + + if (_remaining > 0) + { + + int got; + + if (_remaining <= len) + { + // data should fit in the buffer + got = recv(_sock, buffer, _remaining); + } + else + { + // too much data for the buffer, + // grab as much as will fit + got = recv(_sock, buffer, len); + } + + if (got > 0) + { + _remaining -= got; + return got; + } + + } + + // If we get here, there's no data available or recv failed + return -1; + +} + +int EthernetUDP::peek() +{ + uint8_t b; + // Unlike recv, peek doesn't check to see if there's any data available, so we must. + // If the user hasn't called parsePacket yet then return nothing otherwise they + // may get the UDP header + if (!_remaining) + return -1; + ::peek(_sock, &b); + return b; +} + +void EthernetUDP::flush() +{ + // could this fail (loop endlessly) if _remaining > 0 and recv in read fails? + // should only occur if recv fails after telling us the data is there, lets + // hope the w5500 always behaves :) + + while (_remaining) + { + read(); + } +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet2/src/EthernetUdp2.h b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet2/src/EthernetUdp2.h new file mode 100644 index 0000000..fe8d110 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet2/src/EthernetUdp2.h @@ -0,0 +1,110 @@ +/* + * Udp.cpp: Library to send/receive UDP packets with the Arduino ethernet shield. + * This version only offers minimal wrapping of socket.c/socket.h + * Drop Udp.h/.cpp into the Ethernet library directory at hardware/libraries/Ethernet/ + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + * + * - 10 Apr. 2015 + * Added support for Arduino Ethernet Shield 2 + * by Arduino.org team + * + */ + + +#ifndef ethernetudp_h +#define ethernetudp_h + +#include + +#define UDP_TX_PACKET_MAX_SIZE 24 + +class EthernetUDP : public UDP { +private: + uint8_t _sock; // socket ID for Wiz5100 + uint16_t _port; // local port to listen on + IPAddress _remoteIP; // remote IP address for the incoming packet whilst it's being processed + uint16_t _remotePort; // remote port for the incoming packet whilst it's being processed + uint16_t _offset; // offset into the packet being sent + uint16_t _remaining; // remaining bytes of incoming packet yet to be processed + +public: + EthernetUDP(); // Constructor + virtual uint8_t begin(uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + + //KH, to add Multicast support + virtual uint8_t beginMulticast(IPAddress, uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + ////// + + virtual void stop(); // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port); + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port); + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket(); + // Write a single byte into the packet + virtual size_t write(uint8_t); + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size); + + using Print::write; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket(); + // Number of bytes remaining in the current packet + virtual int available(); + // Read a single byte from the current packet + virtual int read(); + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len); + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) { return read((unsigned char*)buffer, len); }; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek(); + virtual void flush(); // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() { return _remoteIP; }; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() { return _remotePort; }; +}; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet3/src/Ethernet3.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet3/src/Ethernet3.cpp new file mode 100644 index 0000000..ec28896 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet3/src/Ethernet3.cpp @@ -0,0 +1,431 @@ +/* + modified 12 Aug 2013 + by Soohwan Kim (suhwan@wiznet.co.kr) + +- 10 Apr. 2015 + Added support for Arduino Ethernet Shield 2 + by Arduino.org team + + */ + +#include "Ethernet3.h" +#include "Dhcp.h" + +// XXX: don't make assumptions about the value of MAX_SOCK_NUM. +uint8_t EthernetClass::_state[MAX_SOCK_NUM] = { 0, }; +uint16_t EthernetClass::_server_port[MAX_SOCK_NUM] = { 0, }; + +void EthernetClass::setRstPin(uint8_t pinRST) { + _pinRST = pinRST; + pinMode(_pinRST, OUTPUT); + digitalWrite(_pinRST, HIGH); + } +void EthernetClass::setCsPin(uint8_t pinCS) { + _pinCS = pinCS; + } + +void EthernetClass::init(uint8_t maxSockNum) { + _maxSockNum = maxSockNum; + } + +uint8_t EthernetClass::softreset() { + return w5500.softReset(); + } + +void EthernetClass::hardreset() { + if(_pinRST != 0) { + digitalWrite(_pinRST, LOW); + delay(1); + digitalWrite(_pinRST, HIGH); + delay(150); + } + } + +#if defined(WIZ550io_WITH_MACADDRESS) + +int EthernetClass::begin(void) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var _mac_address + //uint8_t mac_address[6] ={0,}; + ////// + + _dhcp = new DhcpClass(); + + // Initialise the basic info + w5500.init(_maxSockNum, _pinCS); + w5500.setIPAddress(IPAddress(0,0,0,0).raw_address()); + + // KH mod + w5500.getMACAddress(_mac_address); + ////// + + if (strlen(_customHostname) != 0) + { + _dhcp->setCustomHostname(_customHostname); + } + + // Now try to get our config info from a DHCP server + // KH mod + int ret = _dhcp->beginWithDHCP(_mac_address); + ////// + + if(ret == 1) + { + // We've successfully found a DHCP server and got our configuration info, so set things + // accordingly + w5500.setIPAddress(_dhcp->getLocalIp().raw_address()); + w5500.setGatewayIp(_dhcp->getGatewayIp().raw_address()); + w5500.setSubnetMask(_dhcp->getSubnetMask().raw_address()); + _dnsServerAddress = _dhcp->getDnsServerIp(); + } + return ret; +} + +void EthernetClass::begin(IPAddress local_ip) +{ + IPAddress subnet(255, 255, 255, 0); + begin(local_ip, subnet); +} + +void EthernetClass::begin(IPAddress local_ip, IPAddress subnet) +{ + // Assume the gateway will be the machine on the same network as the local IP + // but with last octet being '1' + IPAddress gateway = local_ip; + gateway[3] = 1; + begin(local_ip, subnet, gateway); +} + +void EthernetClass::begin(IPAddress local_ip, IPAddress subnet, IPAddress gateway) +{ + // Assume the DNS server will be the machine on the same network as the local IP + // but with last octet being '1' + IPAddress dns_server = local_ip; + dns_server[3] = 1; + begin(local_ip, subnet, gateway, dns_server); +} + +void EthernetClass::begin(IPAddress local_ip, IPAddress subnet, IPAddress gateway, IPAddress dns_server) +{ + w5500.init(_maxSockNum, _pinCS); + w5500.setIPAddress(local_ip.raw_address()); + w5500.setGatewayIp(gateway.raw_address()); + w5500.setSubnetMask(subnet.raw_address()); + _dnsServerAddress = dns_server; +} + +#else +int EthernetClass::begin(uint8_t *mac_address) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac_address, sizeof(_mac_address)); + ////// + + _dhcp = new DhcpClass(); + // Initialise the basic info + w5500.init(_maxSockNum, _pinCS); + w5500.setMACAddress(mac_address); + w5500.setIPAddress(IPAddress(0,0,0,0).raw_address()); + + if (strlen(_customHostname) != 0) + { + _dhcp->setCustomHostname(_customHostname); + } + + // Now try to get our config info from a DHCP server + int ret = _dhcp->beginWithDHCP(mac_address); + if(ret == 1) + { + // We've successfully found a DHCP server and got our configuration info, so set things + // accordingly + w5500.setIPAddress(_dhcp->getLocalIp().raw_address()); + w5500.setGatewayIp(_dhcp->getGatewayIp().raw_address()); + w5500.setSubnetMask(_dhcp->getSubnetMask().raw_address()); + _dnsServerAddress = _dhcp->getDnsServerIp(); + } + + return ret; +} + +void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac_address, sizeof(_mac_address)); + ////// + + IPAddress subnet(255, 255, 255, 0); + begin(mac_address, local_ip, subnet); +} + +void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress subnet) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac_address, sizeof(_mac_address)); + ////// + + // Assume the gateway will be the machine on the same network as the local IP + // but with last octet being '1' + IPAddress gateway = local_ip; + gateway[3] = 1; + begin(mac_address, local_ip, subnet, gateway); +} + +void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress subnet, IPAddress gateway) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac_address, sizeof(_mac_address)); + ////// + + // Assume the DNS server will be the machine on the same network as the local IP + // but with last octet being '1' + IPAddress dns_server = local_ip; + dns_server[3] = 1; + begin(mac_address, local_ip, subnet, gateway, dns_server); +} + +void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress subnet, IPAddress gateway, IPAddress dns_server) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac_address, sizeof(_mac_address)); + ////// + + w5500.init(_maxSockNum, _pinCS); + w5500.setMACAddress(mac_address); + w5500.setIPAddress(local_ip.raw_address()); + w5500.setGatewayIp(gateway.raw_address()); + w5500.setSubnetMask(subnet.raw_address()); + _dnsServerAddress = dns_server; +} + +#endif + +int EthernetClass::maintain(){ + int rc = DHCP_CHECK_NONE; + if(_dhcp != NULL){ + //we have a pointer to dhcp, use it + rc = _dhcp->checkLease(); + switch ( rc ){ + case DHCP_CHECK_NONE: + //nothing done + break; + case DHCP_CHECK_RENEW_OK: + case DHCP_CHECK_REBIND_OK: + //we might have got a new IP. + w5500.setIPAddress(_dhcp->getLocalIp().raw_address()); + w5500.setGatewayIp(_dhcp->getGatewayIp().raw_address()); + w5500.setSubnetMask(_dhcp->getSubnetMask().raw_address()); + _dnsServerAddress = _dhcp->getDnsServerIp(); + break; + default: + //this is actually a error, it will retry though + break; + } + } + return rc; +} + +void EthernetClass::WoL(bool wol) { + uint8_t val = w5500.readMR(); + bitWrite(val, 5, wol); + w5500.writeMR(val); + } + +bool EthernetClass::WoL() { + uint8_t val = w5500.readMR(); + return bitRead(val, 5); + } + +void EthernetClass::phyMode(phyMode_t mode) { + uint8_t val = w5500.getPHYCFGR(); + bitWrite(val, 6, 1); + if (mode == HALF_DUPLEX_10) { + bitWrite(val, 3, 0); + bitWrite(val, 4, 0); + bitWrite(val, 5, 0); + w5500.setPHYCFGR(val); + } + else if (mode == FULL_DUPLEX_10) { + bitWrite(val, 3, 1); + bitWrite(val, 4, 0); + bitWrite(val, 5, 0); + w5500.setPHYCFGR(val); + } + else if (mode == HALF_DUPLEX_100) { + bitWrite(val, 3, 0); + bitWrite(val, 4, 1); + bitWrite(val, 5, 0); + w5500.setPHYCFGR(val); + } + else if (mode == FULL_DUPLEX_100) { + bitWrite(val, 3, 1); + bitWrite(val, 4, 1); + bitWrite(val, 5, 0); + w5500.setPHYCFGR(val); + } + else if (mode == FULL_DUPLEX_100_AUTONEG) { + bitWrite(val, 3, 0); + bitWrite(val, 4, 0); + bitWrite(val, 5, 1); + w5500.setPHYCFGR(val); + } + else if (mode == POWER_DOWN) { + bitWrite(val, 3, 0); + bitWrite(val, 4, 1); + bitWrite(val, 5, 1); + w5500.setPHYCFGR(val); + } + else if (mode == ALL_AUTONEG) { + bitWrite(val, 3, 1); + bitWrite(val, 4, 1); + bitWrite(val, 5, 1); + w5500.setPHYCFGR(val); + } + bitWrite(val, 7, 0); + w5500.setPHYCFGR(val); + bitWrite(val, 7, 1); + w5500.setPHYCFGR(val); + } + +void EthernetClass::setHostname(const char* hostname) { + memset(_customHostname, 0, 32); + memcpy((void*)_customHostname, (void*)hostname, strlen(hostname) >= 31 ? 31 : strlen(hostname)); + } + +uint8_t EthernetClass::phyState() { + return w5500.getPHYCFGR(); + } + +uint8_t EthernetClass::link() { + return bitRead(w5500.getPHYCFGR(), 0); + } + +const char* EthernetClass::linkReport() +{ + if (bitRead(w5500.getPHYCFGR(), 0) == 1) + return "LINK"; + else + return "NO LINK"; + } + +uint8_t EthernetClass::speed() +{ + if (bitRead(w5500.getPHYCFGR(), 0) == 1) + { + if (bitRead(w5500.getPHYCFGR(), 1) == 1) + return 100; + + if (bitRead(w5500.getPHYCFGR(), 1) == 0) + return 10; + } + + return 0; +} + +const char* EthernetClass::speedReport() +{ + if (bitRead(w5500.getPHYCFGR(), 0) == 1) + { + if (bitRead(w5500.getPHYCFGR(), 1) == 1) + return "100 MB"; + + if (bitRead(w5500.getPHYCFGR(), 1) == 0) + return "10 MB"; + } + + return "NO LINK"; +} + +uint8_t EthernetClass::duplex() +{ + if(bitRead(w5500.getPHYCFGR(), 0) == 1) + { + if (bitRead(w5500.getPHYCFGR(), 2) == 1) + return 2; + + if (bitRead(w5500.getPHYCFGR(), 2) == 0) + return 1; + } + + return 0; +} + +const char* EthernetClass::duplexReport() +{ + if (bitRead(w5500.getPHYCFGR(), 0) == 1) + { + if(bitRead(w5500.getPHYCFGR(), 2) == 1) + return "FULL DUPLEX"; + + if (bitRead(w5500.getPHYCFGR(), 2) == 0) + return "HALF DUPLEX"; + } + + return "NO LINK"; +} + +void EthernetClass::setRtTimeOut(uint16_t timeout) { + w5500.setRetransmissionTime(timeout); + } + +uint16_t EthernetClass::getRtTimeOut() { + return w5500.getRetransmissionTime(); + } + +void EthernetClass::setRtCount(uint8_t count) { + w5500.setRetransmissionCount(count); + } + +uint8_t EthernetClass::getRtCount() { + return w5500.getRetransmissionCount(); + } + +void EthernetClass::macAddress(uint8_t mac[]) { + w5500.getMACAddress(mac); + } + +const char* EthernetClass::macAddressReport() { + uint8_t mac[6]; + static char str[18]; + w5500.getMACAddress(mac); + sprintf(str, "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + return str; + } + +IPAddress EthernetClass::localIP() +{ + IPAddress ret; + w5500.getIPAddress(ret.raw_address()); + return ret; +} + +IPAddress EthernetClass::subnetMask() +{ + IPAddress ret; + w5500.getSubnetMask(ret.raw_address()); + return ret; +} + +IPAddress EthernetClass::gatewayIP() +{ + IPAddress ret; + w5500.getGatewayIp(ret.raw_address()); + return ret; +} + +IPAddress EthernetClass::dnsServerIP() +{ + return _dnsServerAddress; +} + +EthernetClass Ethernet; diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet3/src/Ethernet3.h b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet3/src/Ethernet3.h new file mode 100644 index 0000000..dab54f4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/Ethernet3/src/Ethernet3.h @@ -0,0 +1,127 @@ +/* + modified 12 Aug 2013 + by Soohwan Kim (suhwan@wiznet.co.kr) + + - 10 Apr. 2015 + Added support for Arduino Ethernet Shield 2 + by Arduino.org team + + */ +#ifndef ethernet3_h +#define ethernet3_h + +#include +#include "utility/w5500.h" +#include "IPAddress.h" +#include "EthernetClient.h" +#include "EthernetServer.h" +#include "Dhcp.h" + +enum phyMode_t { + HALF_DUPLEX_10, + FULL_DUPLEX_10, + HALF_DUPLEX_100, + FULL_DUPLEX_100, + FULL_DUPLEX_100_AUTONEG, + POWER_DOWN, + ALL_AUTONEG + }; + +class EthernetClass { +private: + IPAddress _dnsServerAddress; + DhcpClass* _dhcp; + char _customHostname[32]; + + // KH add to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + uint8_t _mac_address[6] ={0,}; + ////// + +public: + uint8_t _maxSockNum; + uint8_t _pinCS; + uint8_t _pinRST; + + static uint8_t _state[MAX_SOCK_NUM]; + static uint16_t _server_port[MAX_SOCK_NUM]; + + EthernetClass() { _dhcp = NULL; _pinCS = 10; _maxSockNum = 8; } + + void setRstPin(uint8_t pinRST = 9); // for WIZ550io or USR-ES1, must set befor Ethernet.begin + void setCsPin(uint8_t pinCS = 10); // must set befor Ethernet.begin + + // Initialize with less sockets but more RX/TX Buffer + // maxSockNum = 1 Socket 0 -> RX/TX Buffer 16k + // maxSockNum = 2 Socket 0, 1 -> RX/TX Buffer 8k + // maxSockNum = 4 Socket 0...3 -> RX/TX Buffer 4k + // maxSockNum = 8 (Standard) all sockets -> RX/TX Buffer 2k + // be carefull of the MAX_SOCK_NUM, because in the moment it can't dynamicly changed + void init(uint8_t maxSockNum = 8); + + uint8_t softreset(); // can set only after Ethernet.begin + void hardreset(); // You need to set the Rst pin + +#if defined(WIZ550io_WITH_MACADDRESS) + + // Initialize function when use the ioShield serise (included WIZ550io) + // WIZ550io has a MAC address which is written after reset. + // Default IP, Gateway and subnet address are also writen. + // so, It needs some initial time. please refer WIZ550io Datasheet in details. + int begin(void); + void begin(IPAddress local_ip); + void begin(IPAddress local_ip, IPAddress subnet); + void begin(IPAddress local_ip, IPAddress subnet, IPAddress gateway); + void begin(IPAddress local_ip, IPAddress subnet, IPAddress gateway, IPAddress dns_server); +#else + // Initialize the Ethernet shield to use the provided MAC address and gain the rest of the + // configuration through DHCP. + // Returns 0 if the DHCP configuration failed, and 1 if it succeeded + int begin(uint8_t *mac_address); + void begin(uint8_t *mac_address, IPAddress local_ip); + void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress subnet); + void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress subnet, IPAddress gateway); + void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress subnet, IPAddress gateway, IPAddress dns_server); +#endif + + int maintain(); + void WoL(bool wol); // set Wake on LAN + bool WoL(); // get the WoL state + void phyMode(phyMode_t mode); // set PHYCFGR + uint8_t phyState(); // returns the PHYCFGR + uint8_t link(); // returns the linkstate, 1 = linked, 0 = no link + const char* linkReport(); // returns the linkstate as a string + uint8_t speed(); // returns speed in MB/s + const char* speedReport(); // returns speed as a string + uint8_t duplex(); // returns duplex mode 0 = no link, 1 = Half Duplex, 2 = Full Duplex + const char* duplexReport(); // returns duplex mode as a string + + void setRtTimeOut(uint16_t timeout = 2000); // set the retransmission timout *100us + uint16_t getRtTimeOut(); // get the retransmission timout + void setRtCount(uint8_t count = 8); // set the retransmission count + uint8_t getRtCount(); // get the retransmission count + + void macAddress(uint8_t mac[]); // get the MAC Address + const char* macAddressReport(); // returns the the MAC Address as a string + + void setHostname(const char* hostname); + + // KH add to have similar function to Ethernet lib + // Certainly we can use void macAddress(uint8_t mac[]) to read from W5x00. + void MACAddress(uint8_t *mac_address) + { + memcpy(mac_address, _mac_address, sizeof(_mac_address)); + } + ////// + + IPAddress localIP(); + IPAddress subnetMask(); + IPAddress gatewayIP(); + IPAddress dnsServerIP(); + + friend class EthernetClient; + friend class EthernetServer; +}; + +extern EthernetClass Ethernet; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/EthernetLarge/src/EthernetLarge.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/EthernetLarge/src/EthernetLarge.cpp new file mode 100644 index 0000000..4357b3c --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/EthernetLarge/src/EthernetLarge.cpp @@ -0,0 +1,318 @@ +/**************************************************************************************************************************** + EthernetLarge.cpp + + EthernetWebServer is a library for the Ethernet shields to run WebServer + + Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases + Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer + Licensed under MIT license + Version: 1.0.9 + + Copyright 2018 Paul Stoffregen + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/02/2020 Initial coding for Arduino Mega, Teensy, etc to support Ethernetx libraries + 1.0.1 K Hoang 20/02/2020 Add support to lambda functions + 1.0.2 K Hoang 20/02/2020 Add support to UIPEthernet library for ENC28J60 + 1.0.3 K Hoang 23/02/2020 Add support to SAM DUE / SAMD21 boards + 1.0.4 K Hoang 16/04/2020 Add support to SAMD51 boards + 1.0.5 K Hoang 24/04/2020 Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, + Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, etc. + More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge + 1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards + 1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards + 1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. + 1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future. + *****************************************************************************************************************************/ + +#include +#include "EthernetLarge.h" +#include "utility/w5100.h" +#include "Dhcp.h" + +#define ETHERNET_DEBUG 1 + +IPAddress EthernetClass::_dnsServerAddress; +DhcpClass* EthernetClass::_dhcp = NULL; + +// KH +void EthernetClass::setRstPin(uint8_t pinRST) +{ + _pinRST = pinRST; + pinMode(_pinRST, OUTPUT); + digitalWrite(_pinRST, HIGH); +} +void EthernetClass::setCsPin(uint8_t pinCS) +{ + _pinCS = pinCS; + W5100.setSS(pinCS); + +#if ( ETHERNET_DEBUG > 0 ) + Serial.print("Input pinCS = "); + Serial.println(pinCS); + Serial.print("_pinCS = "); + Serial.println(_pinCS); +#endif +} + +void EthernetClass::initMaxSockNum(uint8_t maxSockNum) +{ + _maxSockNum = maxSockNum; +} + +uint8_t EthernetClass::softreset() +{ + return W5100.softReset(); +} + +void EthernetClass::hardreset() +{ + if(_pinRST != 0) + { + digitalWrite(_pinRST, LOW); + delay(1); + digitalWrite(_pinRST, HIGH); + delay(150); + } +} + +int EthernetClass::begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) +{ + static DhcpClass s_dhcp; + _dhcp = &s_dhcp; + +#if ( ETHERNET_DEBUG > 0 ) + Serial.print("_pinCS = "); + Serial.print(_pinCS); +#endif + + // Initialise the basic info + if (W5100.init() == 0) + return 0; + + + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.setMACAddress(mac); + W5100.setIPAddress(IPAddress(0,0,0,0).raw_address()); + SPI.endTransaction(); + + // Now try to get our config info from a DHCP server + int ret = _dhcp->beginWithDHCP(mac, timeout, responseTimeout); + if (ret == 1) { + // We've successfully found a DHCP server and got our configuration + // info, so set things accordingly + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.setIPAddress(_dhcp->getLocalIp().raw_address()); + W5100.setGatewayIp(_dhcp->getGatewayIp().raw_address()); + W5100.setSubnetMask(_dhcp->getSubnetMask().raw_address()); + SPI.endTransaction(); + _dnsServerAddress = _dhcp->getDnsServerIp(); + socketPortRand(micros()); + } + return ret; +} + +void EthernetClass::begin(uint8_t *mac, IPAddress ip) +{ + // Assume the DNS server will be the machine on the same network as the local IP + // but with last octet being '1' + IPAddress dns = ip; + dns[3] = 1; + begin(mac, ip, dns); +} + +void EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns) +{ + // Assume the gateway will be the machine on the same network as the local IP + // but with last octet being '1' + IPAddress gateway = ip; + gateway[3] = 1; + begin(mac, ip, dns, gateway); +} + +void EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway) +{ + IPAddress subnet(255, 255, 255, 0); + begin(mac, ip, dns, gateway, subnet); +} + +void EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet) +{ + // Initialise the basic info + if (W5100.init() == 0) + return; + + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.setMACAddress(mac); +#if ( defined(ESP8266) || defined(ESP32) ) + W5100.setIPAddress(&ip[0]); + W5100.setGatewayIp(&gateway[0]); + W5100.setSubnetMask(&subnet[0]); +#elif ARDUINO > 106 || TEENSYDUINO > 121 + W5100.setIPAddress(ip._address.bytes); + W5100.setGatewayIp(gateway._address.bytes); + W5100.setSubnetMask(subnet._address.bytes); +#else + W5100.setIPAddress(ip._address); + W5100.setGatewayIp(gateway._address); + W5100.setSubnetMask(subnet._address); +#endif + SPI.endTransaction(); + _dnsServerAddress = dns; +} + +void EthernetClass::init(uint8_t sspin) +{ + W5100.setSS(sspin); +} + +EthernetLinkStatus EthernetClass::linkStatus() +{ + switch (W5100.getLinkStatus()) { + case UNKNOWN: return Unknown; + case LINK_ON: return LinkON; + case LINK_OFF: return LinkOFF; + default: return Unknown; + } +} + +EthernetHardwareStatus EthernetClass::hardwareStatus() +{ + switch (W5100.getChip()) { + case 51: return EthernetW5100; + case 52: return EthernetW5200; + case 55: return EthernetW5500; + default: return EthernetNoHardware; + } +} + +int EthernetClass::maintain() +{ + int rc = DHCP_CHECK_NONE; + if (_dhcp != NULL) { + // we have a pointer to dhcp, use it + rc = _dhcp->checkLease(); + switch (rc) + { + case DHCP_CHECK_NONE: + //nothing done + break; + case DHCP_CHECK_RENEW_OK: + case DHCP_CHECK_REBIND_OK: + //we might have got a new IP. + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.setIPAddress(_dhcp->getLocalIp().raw_address()); + W5100.setGatewayIp(_dhcp->getGatewayIp().raw_address()); + W5100.setSubnetMask(_dhcp->getSubnetMask().raw_address()); + SPI.endTransaction(); + _dnsServerAddress = _dhcp->getDnsServerIp(); + break; + default: + //this is actually an error, it will retry though + break; + } + } + return rc; +} + + +void EthernetClass::MACAddress(uint8_t *mac_address) +{ + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.getMACAddress(mac_address); + SPI.endTransaction(); +} + +IPAddress EthernetClass::localIP() +{ + IPAddress ret; + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.getIPAddress(ret.raw_address()); + SPI.endTransaction(); + return ret; +} + +IPAddress EthernetClass::subnetMask() +{ + IPAddress ret; + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.getSubnetMask(ret.raw_address()); + SPI.endTransaction(); + return ret; +} + +IPAddress EthernetClass::gatewayIP() +{ + IPAddress ret; + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.getGatewayIp(ret.raw_address()); + SPI.endTransaction(); + return ret; +} + +void EthernetClass::setMACAddress(const uint8_t *mac_address) +{ + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.setMACAddress(mac_address); + SPI.endTransaction(); +} + +void EthernetClass::setLocalIP(const IPAddress local_ip) +{ + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + IPAddress ip = local_ip; + W5100.setIPAddress(ip.raw_address()); + SPI.endTransaction(); +} + +void EthernetClass::setSubnetMask(const IPAddress subnet) +{ + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + IPAddress ip = subnet; + W5100.setSubnetMask(ip.raw_address()); + SPI.endTransaction(); +} + +void EthernetClass::setGatewayIP(const IPAddress gateway) +{ + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + IPAddress ip = gateway; + W5100.setGatewayIp(ip.raw_address()); + SPI.endTransaction(); +} + +void EthernetClass::setRetransmissionTimeout(uint16_t milliseconds) +{ + if (milliseconds > 6553) milliseconds = 6553; + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.setRetransmissionTime(milliseconds * 10); + SPI.endTransaction(); +} + +void EthernetClass::setRetransmissionCount(uint8_t num) +{ + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + W5100.setRetransmissionCount(num); + SPI.endTransaction(); +} + + +EthernetClass Ethernet; diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/EthernetLarge/src/EthernetLarge.h b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/EthernetLarge/src/EthernetLarge.h new file mode 100644 index 0000000..4a18a2d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/EthernetLarge/src/EthernetLarge.h @@ -0,0 +1,362 @@ +/**************************************************************************************************************************** + EthernetLarge.h + + EthernetWebServer is a library for the Ethernet shields to run WebServer + + Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases + Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer + Licensed under MIT license + Version: 1.0.9 + + Copyright 2018 Paul Stoffregen + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/02/2020 Initial coding for Arduino Mega, Teensy, etc to support Ethernetx libraries + 1.0.1 K Hoang 20/02/2020 Add support to lambda functions + 1.0.2 K Hoang 20/02/2020 Add support to UIPEthernet library for ENC28J60 + 1.0.3 K Hoang 23/02/2020 Add support to SAM DUE / SAMD21 boards + 1.0.4 K Hoang 16/04/2020 Add support to SAMD51 boards + 1.0.5 K Hoang 24/04/2020 Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, + Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, etc. + More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge + 1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards + 1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards + 1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. + 1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future. + *****************************************************************************************************************************/ + +#ifndef ethernet_h_ +#define ethernet_h_ + +// All symbols exposed to Arduino sketches are contained in this header file +// +// Older versions had much of this stuff in EthernetClient.h, EthernetServer.h, +// and socket.h. Including headers in different order could cause trouble, so +// these "friend" classes are now defined in the same header file. socket.h +// was removed to avoid possible conflict with the C library header files. + + +// Configure the maximum number of sockets to support. W5100 chips can have +// up to 4 sockets. W5200 & W5500 can have up to 8 sockets. Several bytes +// of RAM are used for each socket. Reducing the maximum can save RAM, but +// you are limited to fewer simultaneous connections. +#define MAX_SOCK_NUM 2 + +// By default, each socket uses 2K buffers inside the Wiznet chip. If +// MAX_SOCK_NUM is set to fewer than the chip's maximum, uncommenting +// this will use larger buffers within the Wiznet chip. Large buffers +// can really help with UDP protocols like Artnet. In theory larger +// buffers should allow faster TCP over high-latency links, but this +// does not always seem to work in practice (maybe Wiznet bugs?) +#define ETHERNET_LARGE_BUFFERS + + +#include +#include "Client.h" +#include "Server.h" +#include "Udp.h" + +enum EthernetLinkStatus { + Unknown, + LinkON, + LinkOFF +}; + +enum EthernetHardwareStatus { + EthernetNoHardware, + EthernetW5100, + EthernetW5200, + EthernetW5500 +}; + +class EthernetUDP; +class EthernetClient; +class EthernetServer; +class DhcpClass; + +class EthernetClass { +private: + static IPAddress _dnsServerAddress; + static DhcpClass* _dhcp; +public: + // KH + uint8_t _maxSockNum; + uint8_t _pinCS; + uint8_t _pinRST; + + void setRstPin(uint8_t pinRST = 9); // for WIZ550io or USR-ES1, must set befor Ethernet.begin + void setCsPin(uint8_t pinCS = 10); // must set befor Ethernet.begin + + // Initialize with less sockets but more RX/TX Buffer + // maxSockNum = 1 Socket 0 -> RX/TX Buffer 16k + // maxSockNum = 2 Socket 0, 1 -> RX/TX Buffer 8k + // maxSockNum = 4 Socket 0...3 -> RX/TX Buffer 4k + // maxSockNum = 8 (Standard) all sockets -> RX/TX Buffer 2k + // be carefull of the MAX_SOCK_NUM, because in the moment it can't dynamicly changed + void initMaxSockNum(uint8_t maxSockNum = 8); + + uint8_t softreset(); // can set only after Ethernet.begin + void hardreset(); // You need to set the Rst pin + + // Initialise the Ethernet shield to use the provided MAC address and + // gain the rest of the configuration through DHCP. + // Returns 0 if the DHCP configuration failed, and 1 if it succeeded + int begin(uint8_t *mac, unsigned long timeout = 60000, unsigned long responseTimeout = 4000); + int maintain(); + EthernetLinkStatus linkStatus(); + EthernetHardwareStatus hardwareStatus(); + + // Manual configuration + void begin(uint8_t *mac, IPAddress ip); + void begin(uint8_t *mac, IPAddress ip, IPAddress dns); + void begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway); + void begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet); + void init(uint8_t sspin = 10); + + void MACAddress(uint8_t *mac_address); + IPAddress localIP(); + IPAddress subnetMask(); + IPAddress gatewayIP(); + IPAddress dnsServerIP() { return _dnsServerAddress; } + + void setMACAddress(const uint8_t *mac_address); + void setLocalIP(const IPAddress local_ip); + void setSubnetMask(const IPAddress subnet); + void setGatewayIP(const IPAddress gateway); + void setDnsServerIP(const IPAddress dns_server) { _dnsServerAddress = dns_server; } + void setRetransmissionTimeout(uint16_t milliseconds); + void setRetransmissionCount(uint8_t num); + + friend class EthernetClient; + friend class EthernetServer; + friend class EthernetUDP; +private: + // Opens a socket(TCP or UDP or IP_RAW mode) + uint8_t socketBegin(uint8_t protocol, uint16_t port); + uint8_t socketBeginMulticast(uint8_t protocol, IPAddress ip,uint16_t port); + uint8_t socketStatus(uint8_t s); + // Close socket + void socketClose(uint8_t s); + // Establish TCP connection (Active connection) + void socketConnect(uint8_t s, uint8_t * addr, uint16_t port); + // disconnect the connection + void socketDisconnect(uint8_t s); + // Establish TCP connection (Passive connection) + uint8_t socketListen(uint8_t s); + // Send data (TCP) + uint16_t socketSend(uint8_t s, const uint8_t * buf, uint16_t len); + uint16_t socketSendAvailable(uint8_t s); + // Receive data (TCP) + int socketRecv(uint8_t s, uint8_t * buf, int16_t len); + uint16_t socketRecvAvailable(uint8_t s); + uint8_t socketPeek(uint8_t s); + // sets up a UDP datagram, the data for which will be provided by one + // or more calls to bufferData and then finally sent with sendUDP. + // return true if the datagram was successfully set up, or false if there was an error + bool socketStartUDP(uint8_t s, uint8_t* addr, uint16_t port); + // copy up to len bytes of data from buf into a UDP datagram to be + // sent later by sendUDP. Allows datagrams to be built up from a series of bufferData calls. + // return Number of bytes successfully buffered + uint16_t socketBufferData(uint8_t s, uint16_t offset, const uint8_t* buf, uint16_t len); + // Send a UDP datagram built up from a sequence of startUDP followed by one or more + // calls to bufferData. + // return true if the datagram was successfully sent, or false if there was an error + bool socketSendUDP(uint8_t s); + // Initialize the "random" source port number + void socketPortRand(uint16_t n); +}; + +extern EthernetClass Ethernet; + + +#define UDP_TX_PACKET_MAX_SIZE 24 + +class EthernetUDP : public UDP { +private: + uint16_t _port; // local port to listen on + IPAddress _remoteIP; // remote IP address for the incoming packet whilst it's being processed + uint16_t _remotePort; // remote port for the incoming packet whilst it's being processed + uint16_t _offset; // offset into the packet being sent + +protected: + uint8_t sockindex; + uint16_t _remaining; // remaining bytes of incoming packet yet to be processed + +public: + EthernetUDP() : sockindex(MAX_SOCK_NUM) {} // Constructor + virtual uint8_t begin(uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual uint8_t beginMulticast(IPAddress, uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual void stop(); // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port); + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port); + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket(); + // Write a single byte into the packet + virtual size_t write(uint8_t); + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size); + + using Print::write; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket(); + // Number of bytes remaining in the current packet + virtual int available(); + // Read a single byte from the current packet + virtual int read(); + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len); + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) { return read((unsigned char*)buffer, len); }; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek(); + virtual void flush(); // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() { return _remoteIP; }; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() { return _remotePort; }; + virtual uint16_t localPort() { return _port; } +}; + + + + +class EthernetClient : public Client { +public: + EthernetClient() : sockindex(MAX_SOCK_NUM), _timeout(1000) { } + EthernetClient(uint8_t s) : sockindex(s), _timeout(1000) { } + + uint8_t status(); + virtual int connect(IPAddress ip, uint16_t port); + virtual int connect(const char *host, uint16_t port); + virtual int availableForWrite(void); + virtual size_t write(uint8_t); + virtual size_t write(const uint8_t *buf, size_t size); + virtual int available(); + virtual int read(); + virtual int read(uint8_t *buf, size_t size); + virtual int peek(); + virtual void flush(); + virtual void stop(); + virtual uint8_t connected(); + virtual operator bool() { return sockindex < MAX_SOCK_NUM; } + virtual bool operator==(const bool value) { return bool() == value; } + virtual bool operator!=(const bool value) { return bool() != value; } + virtual bool operator==(const EthernetClient&); + virtual bool operator!=(const EthernetClient& rhs) { return !this->operator==(rhs); } + uint8_t getSocketNumber() const { return sockindex; } + virtual uint16_t localPort(); + virtual IPAddress remoteIP(); + virtual uint16_t remotePort(); + virtual void setConnectionTimeout(uint16_t timeout) { _timeout = timeout; } + + friend class EthernetServer; + + using Print::write; + +private: + uint8_t sockindex; // MAX_SOCK_NUM means client not in use + uint16_t _timeout; +}; + + +class EthernetServer : public Server { +private: + uint16_t _port; +public: + EthernetServer(uint16_t port) : _port(port) { } + EthernetClient available(); + EthernetClient accept(); + virtual void begin(); + virtual size_t write(uint8_t); + virtual size_t write(const uint8_t *buf, size_t size); + virtual operator bool(); + using Print::write; + //void statusreport(); + + // TODO: make private when socket allocation moves to EthernetClass + static uint16_t server_port[MAX_SOCK_NUM]; +}; + + +class DhcpClass { +private: + uint32_t _dhcpInitialTransactionId; + uint32_t _dhcpTransactionId; + uint8_t _dhcpMacAddr[6]; +#ifdef __arm__ + uint8_t _dhcpLocalIp[4] __attribute__((aligned(4))); + uint8_t _dhcpSubnetMask[4] __attribute__((aligned(4))); + uint8_t _dhcpGatewayIp[4] __attribute__((aligned(4))); + uint8_t _dhcpDhcpServerIp[4] __attribute__((aligned(4))); + uint8_t _dhcpDnsServerIp[4] __attribute__((aligned(4))); +#else + uint8_t _dhcpLocalIp[4]; + uint8_t _dhcpSubnetMask[4]; + uint8_t _dhcpGatewayIp[4]; + uint8_t _dhcpDhcpServerIp[4]; + uint8_t _dhcpDnsServerIp[4]; +#endif + uint32_t _dhcpLeaseTime; + uint32_t _dhcpT1, _dhcpT2; + uint32_t _renewInSec; + uint32_t _rebindInSec; + unsigned long _timeout; + unsigned long _responseTimeout; + unsigned long _lastCheckLeaseMillis; + uint8_t _dhcp_state; + EthernetUDP _dhcpUdpSocket; + + int request_DHCP_lease(); + void reset_DHCP_lease(); + void presend_DHCP(); + void send_DHCP_MESSAGE(uint8_t, uint16_t); + void printByte(char *, uint8_t); + + uint8_t parseDHCPResponse(unsigned long responseTimeout, uint32_t& transactionId); +public: + IPAddress getLocalIp(); + IPAddress getSubnetMask(); + IPAddress getGatewayIp(); + IPAddress getDhcpServerIp(); + IPAddress getDnsServerIp(); + + int beginWithDHCP(uint8_t *, unsigned long timeout = 60000, unsigned long responseTimeout = 4000); + int checkLease(); +}; + + + + + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/EthernetLarge/src/EthernetServer.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/EthernetLarge/src/EthernetServer.cpp new file mode 100644 index 0000000..a77b569 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/EthernetLarge/src/EthernetServer.cpp @@ -0,0 +1,240 @@ +/**************************************************************************************************************************** + EthernetServer.cpp + + EthernetWebServer is a library for the Ethernet shields to run WebServer + + Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases + Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer + Licensed under MIT license + Version: 1.0.9 + + Copyright 2018 Paul Stoffregen + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/02/2020 Initial coding for Arduino Mega, Teensy, etc to support Ethernetx libraries + 1.0.1 K Hoang 20/02/2020 Add support to lambda functions + 1.0.2 K Hoang 20/02/2020 Add support to UIPEthernet library for ENC28J60 + 1.0.3 K Hoang 23/02/2020 Add support to SAM DUE / SAMD21 boards + 1.0.4 K Hoang 16/04/2020 Add support to SAMD51 boards + 1.0.5 K Hoang 24/04/2020 Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, + Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, etc. + More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge + 1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards + 1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards + 1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. + 1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future. + *****************************************************************************************************************************/ + +#include +#include "EthernetLarge.h" +#include "utility/w5100.h" + +uint16_t EthernetServer::server_port[MAX_SOCK_NUM]; + + +void EthernetServer::begin() +{ + uint8_t sockindex = Ethernet.socketBegin(SnMR::TCP, _port); + if (sockindex < MAX_SOCK_NUM) { + if (Ethernet.socketListen(sockindex)) { + server_port[sockindex] = _port; + } else { + Ethernet.socketDisconnect(sockindex); + } + } +} + +EthernetClient EthernetServer::available() +{ + bool listening = false; + uint8_t sockindex = MAX_SOCK_NUM; + uint8_t chip, maxindex=MAX_SOCK_NUM; + + chip = W5100.getChip(); + if (!chip) return EthernetClient(MAX_SOCK_NUM); +#if MAX_SOCK_NUM > 4 + if (chip == 51) maxindex = 4; // W5100 chip never supports more than 4 sockets +#endif + + for (uint8_t i=0; i < maxindex; i++) + { + if (server_port[i] == _port) + { + uint8_t stat = Ethernet.socketStatus(i); + if (stat == SnSR::ESTABLISHED || stat == SnSR::CLOSE_WAIT) + { + if (Ethernet.socketRecvAvailable(i) > 0) + { + sockindex = i; + } + else + { + // remote host closed connection, our end still open + if (stat == SnSR::CLOSE_WAIT) + { + Ethernet.socketDisconnect(i); + // status becomes LAST_ACK for short time + } + } + } + else if (stat == SnSR::LISTEN) + { + listening = true; + } + else if (stat == SnSR::CLOSED) + { + server_port[i] = 0; + } + } + } + + if (!listening) + { + begin(); + } + + return EthernetClient(sockindex); +} + +EthernetClient EthernetServer::accept() +{ + bool listening = false; + uint8_t sockindex = MAX_SOCK_NUM; + uint8_t chip, maxindex=MAX_SOCK_NUM; + + chip = W5100.getChip(); + if (!chip) return EthernetClient(MAX_SOCK_NUM); +#if MAX_SOCK_NUM > 4 + if (chip == 51) maxindex = 4; // W5100 chip never supports more than 4 sockets +#endif + + for (uint8_t i=0; i < maxindex; i++) + { + if (server_port[i] == _port) + { + uint8_t stat = Ethernet.socketStatus(i); + + if (sockindex == MAX_SOCK_NUM && (stat == SnSR::ESTABLISHED || stat == SnSR::CLOSE_WAIT)) + { + // Return the connected client even if no data received. + // Some protocols like FTP expect the server to send the + // first data. + sockindex = i; + server_port[i] = 0; // only return the client once + } + else if (stat == SnSR::LISTEN) + { + listening = true; + } + else if (stat == SnSR::CLOSED) + { + server_port[i] = 0; + } + } + } + + if (!listening) + begin(); + + return EthernetClient(sockindex); +} + +EthernetServer::operator bool() +{ + uint8_t maxindex=MAX_SOCK_NUM; +#if MAX_SOCK_NUM > 4 + if (W5100.getChip() == 51) maxindex = 4; // W5100 chip never supports more than 4 sockets +#endif + + for (uint8_t i=0; i < maxindex; i++) + { + if (server_port[i] == _port) + { + if (Ethernet.socketStatus(i) == SnSR::LISTEN) + { + return true; // server is listening for incoming clients + } + } + } + return false; +} + +#if 0 +void EthernetServer::statusreport() +{ + Serial.printf("EthernetServer, port=%d\n", _port); + for (uint8_t i=0; i < MAX_SOCK_NUM; i++) { + uint16_t port = server_port[i]; + uint8_t stat = Ethernet.socketStatus(i); + const char *name; + switch (stat) { + case 0x00: name = "CLOSED"; break; + case 0x13: name = "INIT"; break; + case 0x14: name = "LISTEN"; break; + case 0x15: name = "SYNSENT"; break; + case 0x16: name = "SYNRECV"; break; + case 0x17: name = "ESTABLISHED"; break; + case 0x18: name = "FIN_WAIT"; break; + case 0x1A: name = "CLOSING"; break; + case 0x1B: name = "TIME_WAIT"; break; + case 0x1C: name = "CLOSE_WAIT"; break; + case 0x1D: name = "LAST_ACK"; break; + case 0x22: name = "UDP"; break; + case 0x32: name = "IPRAW"; break; + case 0x42: name = "MACRAW"; break; + case 0x5F: name = "PPPOE"; break; + default: name = "???"; + } + int avail = Ethernet.socketRecvAvailable(i); + Serial.printf(" %d: port=%d, status=%s (0x%02X), avail=%d\n", + i, port, name, stat, avail); + } +} +#endif + +size_t EthernetServer::write(uint8_t b) +{ + return write(&b, 1); +} + +size_t EthernetServer::write(const uint8_t *buffer, size_t size) +{ + uint8_t chip, maxindex=MAX_SOCK_NUM; + + chip = W5100.getChip(); + if (!chip) return 0; +#if MAX_SOCK_NUM > 4 + if (chip == 51) maxindex = 4; // W5100 chip never supports more than 4 sockets +#endif + available(); + + for (uint8_t i=0; i < maxindex; i++) + { + if (server_port[i] == _port) + { + if (Ethernet.socketStatus(i) == SnSR::ESTABLISHED) + { + Ethernet.socketSend(i, buffer, size); + } + } + } + return size; +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/EthernetLarge/src/utility/w5100.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/EthernetLarge/src/utility/w5100.cpp new file mode 100644 index 0000000..2e2e5a6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/EthernetLarge/src/utility/w5100.cpp @@ -0,0 +1,703 @@ +/**************************************************************************************************************************** + w5100.cpp - Driver for W5x00 + + EthernetWebServer is a library for the Ethernet shields to run WebServer + + Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases + Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer + Licensed under MIT license + Version: 1.0.9 + + Copyright 2018 Paul Stoffregen + Copyright (c) 2010 by Cristian Maglie + + This file is free software; you can redistribute it and/or modify + it under the terms of either the GNU General Public License version 2 + or the GNU Lesser General Public License version 2.1, both as + published by the Free Software Foundation. + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/02/2020 Initial coding for Arduino Mega, Teensy, etc to support Ethernetx libraries + 1.0.1 K Hoang 20/02/2020 Add support to lambda functions + 1.0.2 K Hoang 20/02/2020 Add support to UIPEthernet library for ENC28J60 + 1.0.3 K Hoang 23/02/2020 Add support to SAM DUE / SAMD21 boards + 1.0.4 K Hoang 16/04/2020 Add support to SAMD51 boards + 1.0.5 K Hoang 24/04/2020 Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, + Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, etc. + More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge + 1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards + 1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards + 1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. + 1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future. + *****************************************************************************************************************************/ + +#include +#include "EthernetLarge.h" +#include "w5100.h" + +#define W5100_DEBUG 1 + +/***************************************************/ +/** Default SS pin setting **/ +/***************************************************/ + +// If variant.h or other headers specifically define the +// default SS pin for ethernet, use it. +#if defined(PIN_SPI_SS_ETHERNET_LIB) + +#define SS_PIN_DEFAULT PIN_SPI_SS_ETHERNET_LIB +//KH +#warning w5100.cpp Use PIN_SPI_SS_ETHERNET_LIB defined, change SS_PIN_DEFAULT to PIN_SPI_SS_ETHERNET_LIB + +// MKR boards default to pin 5 for MKR ETH +// Pins 8-10 are MOSI/SCK/MISO on MRK, so don't use pin 10 +#elif defined(USE_ARDUINO_MKR_PIN_LAYOUT) || defined(ARDUINO_SAMD_MKRZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRWAN1300) + +#define SS_PIN_DEFAULT 5 +//KH +#warning w5100.cpp Use MKR, change SS_PIN_DEFAULT to 5 + +// For boards using AVR, assume shields with SS on pin 10 +// will be used. This allows for Arduino Mega (where +// SS is pin 53) and Arduino Leonardo (where SS is pin 17) +// to work by default with Arduino Ethernet Shield R2 & R3. +#elif defined(__AVR__) + +#define SS_PIN_DEFAULT 10 +//KH +#warning w5100.cpp Use __AVR__, change SS_PIN_DEFAULT to 10 + +// If variant.h or other headers define these names +// use them if none of the other cases match +#elif defined(PIN_SPI_SS) + +#if defined(__SAMD21G18A__) +//10 - 2 (6 conflict) all not OK for Nano 33 IoT !!! SPI corrupted??? +#warning w5100.cpp Use __SAMD21G18A__, change SS_PIN_DEFAULT to 10 +#define SS_PIN_DEFAULT 10 +#else +#define SS_PIN_DEFAULT PIN_SPI_SS + +//KH +#warning w5100.cpp Use PIN_SPI_SS defined, change SS_PIN_DEFAULT to PIN_SPI_SS +#endif + +#elif defined(CORE_SS0_PIN) +#define SS_PIN_DEFAULT CORE_SS0_PIN + +//KH +#warning w5100.cpp Use CORE_SS0_PIN defined, change SS_PIN_DEFAULT to CORE_SS0_PIN + +//KH for ESP32 +#elif defined(ESP32) +//pin SS already defined in ESP32 as pin 5, don't use this as conflict with SPIFFS, EEPROM, etc. +// Use in GPIO22 +#warning w5100.cpp Use ESP32, change SS_PIN_DEFAULT to GPIO22, MOSI(23), MISO(19), SCK(18) +#define SS_PIN_DEFAULT 22 //SS +/////// + +//KH for ESP8266 +#elif defined(ESP8266) +//pin SS already defined in ESP8266 as pin 15. Conflict => Move to pin GPIO4 (D2) +#warning w5100.cpp Use ESP8266, change SS_PIN_DEFAULT to SS(4), MOSI(13), MISO(12), SCK(14) +#define SS_PIN_DEFAULT D2 // GPIO4, SS + +/////// + +// As a final fallback, use pin 10 +#else +#define SS_PIN_DEFAULT 10 + +//KH +#warning w5100.cpp Use fallback, change SS_PIN_DEFAULT to 10 + +#endif + +// W5100 controller instance +uint8_t W5100Class::chip = 0; +uint8_t W5100Class::CH_BASE_MSB; +uint8_t W5100Class::ss_pin = SS_PIN_DEFAULT; +#ifdef ETHERNET_LARGE_BUFFERS +uint16_t W5100Class::SSIZE = 2048; +uint16_t W5100Class::SMASK = 0x07FF; +#endif +W5100Class W5100; + +// pointers and bitmasks for optimized SS pin +#if defined(__AVR__) + volatile uint8_t * W5100Class::ss_pin_reg; + uint8_t W5100Class::ss_pin_mask; +#elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK66FX1M0__) || defined(__MK64FX512__) + volatile uint8_t * W5100Class::ss_pin_reg; +#elif defined(__IMXRT1062__) + volatile uint32_t * W5100Class::ss_pin_reg; + uint32_t W5100Class::ss_pin_mask; +#elif defined(__MKL26Z64__) + volatile uint8_t * W5100Class::ss_pin_reg; + uint8_t W5100Class::ss_pin_mask; +#elif defined(__SAM3X8E__) || defined(__SAM3A8C__) || defined(__SAM3A4C__) + volatile uint32_t * W5100Class::ss_pin_reg; + uint32_t W5100Class::ss_pin_mask; +#elif defined(__PIC32MX__) + volatile uint32_t * W5100Class::ss_pin_reg; + uint32_t W5100Class::ss_pin_mask; +#elif defined(ARDUINO_ARCH_ESP8266) + volatile uint32_t * W5100Class::ss_pin_reg; + uint32_t W5100Class::ss_pin_mask; +#elif defined(__SAMD21G18A__) + volatile uint32_t * W5100Class::ss_pin_reg; + uint32_t W5100Class::ss_pin_mask; + #warning w5100.cpp Use __SAMD21G18A__ +#endif + +// KH +uint8_t W5100Class::init(uint8_t socketNumbers, uint8_t new_ss_pin) +{ + // KH + uint8_t i; + + if (initialized) return 1; + + // Many Ethernet shields have a CAT811 or similar reset chip + // connected to W5100 or W5200 chips. The W5200 will not work at + // all, and may even drive its MISO pin, until given an active low + // reset pulse! The CAT811 has a 240 ms typical pulse length, and + // a 400 ms worst case maximum pulse length. MAX811 has a worst + // case maximum 560 ms pulse length. This delay is meant to wait + // until the reset pulse is ended. If your hardware has a shorter + // reset time, this can be edited or removed. + delay(560); + + //W5100Class::ss_pin = new_ss_pin; + +#if ( W5100_DEBUG > 0 ) + //KH + Serial.print("\nW5100 init, using SS_PIN_DEFAULT = "); + Serial.print(SS_PIN_DEFAULT); + Serial.print(", new ss_pin = "); + Serial.print(new_ss_pin); + Serial.print(", W5100Class::ss_pin = "); + Serial.println(W5100Class::ss_pin); +#endif + + SPI.begin(); + + initSS(); + resetSS(); + + // From #define SPI_ETHERNET_SETTINGS SPISettings(14000000, MSBFIRST, SPI_MODE0) + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + + // Attempt W5200 detection first, because W5200 does not properly + // reset its SPI state when CS goes high (inactive). Communication + // from detecting the other chips can leave the W5200 in a state + // where it won't recover, unless given a reset pulse. + if (isW5200()) + { + CH_BASE_MSB = 0x40; +#ifdef ETHERNET_LARGE_BUFFERS +#if MAX_SOCK_NUM <= 1 + SSIZE = 16384; +#elif MAX_SOCK_NUM <= 2 + SSIZE = 8192; +#elif MAX_SOCK_NUM <= 4 + SSIZE = 4096; +#else + SSIZE = 2048; +#endif + SMASK = SSIZE - 1; +#endif + for (i=0; i> 10); + writeSnTX_SIZE(i, SSIZE >> 10); + } + for (; i<8; i++) + { + writeSnRX_SIZE(i, 0); + writeSnTX_SIZE(i, 0); + } + +#if ( W5100_DEBUG > 0 ) + Serial.print("W5100::init: W5200, SSIZE ="); + Serial.println(SSIZE); +#endif + + // Try W5500 next. Wiznet finally seems to have implemented + // SPI well with this chip. It appears to be very resilient, + // so try it after the fragile W5200 + } + else if (isW5500()) + { + CH_BASE_MSB = 0x10; +#ifdef ETHERNET_LARGE_BUFFERS +#if MAX_SOCK_NUM <= 1 + SSIZE = 16384; +#elif MAX_SOCK_NUM <= 2 + SSIZE = 8192; +#elif MAX_SOCK_NUM <= 4 + SSIZE = 4096; +#else + SSIZE = 2048; +#endif + SMASK = SSIZE - 1; + for (i=0; i> 10); + writeSnTX_SIZE(i, SSIZE >> 10); + } + for (; i<8; i++) + { + writeSnRX_SIZE(i, 0); + writeSnTX_SIZE(i, 0); + } +#endif + +#if ( W5100_DEBUG > 0 ) + Serial.print("W5100::init: W5500, SSIZE ="); + Serial.println(SSIZE); +#endif + + + // Try W5100 last. This simple chip uses fixed 4 byte frames + // for every 8 bit access. Terribly inefficient, but so simple + // it recovers from "hearing" unsuccessful W5100 or W5200 + // communication. W5100 is also the only chip without a VERSIONR + // register for identification, so we check this last. + } else if (isW5100()) + { + CH_BASE_MSB = 0x04; +#ifdef ETHERNET_LARGE_BUFFERS +#if MAX_SOCK_NUM <= 1 + SSIZE = 8192; + writeTMSR(0x03); + writeRMSR(0x03); +#elif MAX_SOCK_NUM <= 2 + SSIZE = 4096; + writeTMSR(0x0A); + writeRMSR(0x0A); +#else + SSIZE = 2048; + writeTMSR(0x55); + writeRMSR(0x55); +#endif + SMASK = SSIZE - 1; +#else + writeTMSR(0x55); + writeRMSR(0x55); +#endif + +#if ( W5100_DEBUG > 0 ) + Serial.print("W5100::init: W5100, SSIZE ="); + Serial.println(SSIZE); +#endif + + // No hardware seems to be present. Or it could be a W5200 + // that's heard other SPI communication if its chip select + // pin wasn't high when a SD card or other SPI chip was used. + } + else + { +#if ( W5100_DEBUG > 0 ) + Serial.println("no chip :-("); +#endif + + chip = 0; + SPI.endTransaction(); + return 0; // no known chip is responding :-( + } + SPI.endTransaction(); + initialized = true; + return 1; // successful init +} + +// Soft reset the Wiznet chip, by writing to its MR register reset bit +uint8_t W5100Class::softReset(void) +{ + uint16_t count=0; + +#if ( W5100_DEBUG > 1 ) + Serial.println("EthernetLarge:Wiznet soft reset"); +#endif + + // write to reset bit + writeMR(0x80); + // then wait for soft reset to complete + do + { + uint8_t mr = readMR(); + +#if ( W5100_DEBUG > 2 ) + Serial.print("mr="); + Serial.println(mr, HEX); +#endif + + if (mr == 0) + return 1; + + delay(1); + } while (++count < 20); + return 0; +} + + +uint8_t W5100Class::isW5100(void) +{ + chip = 51; + +#if ( W5100_DEBUG > 1 ) + Serial.println("W5100.cpp: detect W5100 chip"); +#endif + + if (!softReset()) + return 0; + + writeMR(0x10); + if (readMR() != 0x10) + return 0; + + writeMR(0x12); + if (readMR() != 0x12) + return 0; + + writeMR(0x00); + if (readMR() != 0x00) + return 0; + +#if ( W5100_DEBUG > 1 ) + Serial.println("chip is W5100"); +#endif + + return 1; +} + +uint8_t W5100Class::isW5200(void) +{ + chip = 52; + +#if ( W5100_DEBUG > 1 ) + Serial.println("W5100.cpp: detect W5200 chip"); +#endif + + if (!softReset()) + return 0; + + writeMR(0x08); + if (readMR() != 0x08) + return 0; + + writeMR(0x10); + if (readMR() != 0x10) + return 0; + + writeMR(0x00); + if (readMR() != 0x00) + return 0; + + int ver = readVERSIONR_W5200(); + +#if ( W5100_DEBUG > 1 ) + Serial.print("version="); + Serial.println(ver); +#endif + + if (ver != 3) + return 0; + +#if ( W5100_DEBUG > 1 ) + Serial.println("chip is W5200"); +#endif + + return 1; +} + +uint8_t W5100Class::isW5500(void) +{ + chip = 55; + +#if ( W5100_DEBUG > 1 ) + Serial.println("W5100.cpp: detect W5500 chip"); +#endif + + if (!softReset()) + return 0; + + writeMR(0x08); + if (readMR() != 0x08) + return 0; + + writeMR(0x10); + if (readMR() != 0x10) + return 0; + + writeMR(0x00); + if (readMR() != 0x00) + return 0; + + int ver = readVERSIONR_W5500(); + +#if ( W5100_DEBUG > 1 ) + Serial.print("version="); + Serial.println(ver); +#endif + + if (ver != 4) + return 0; + +#if ( W5100_DEBUG > 1 ) + Serial.println("chip is W5500"); +#endif + + return 1; +} + +W5100Linkstatus W5100Class::getLinkStatus() +{ + uint8_t phystatus; + + // KH + if (!initialized) return UNKNOWN; + + switch (chip) + { + case 52: + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + phystatus = readPSTATUS_W5200(); + SPI.endTransaction(); + if (phystatus & 0x20) + return LINK_ON; + + return LINK_OFF; + + case 55: + SPI.beginTransaction(SPI_ETHERNET_SETTINGS); + phystatus = readPHYCFGR_W5500(); + SPI.endTransaction(); + if (phystatus & 0x01) + return LINK_ON; + + return LINK_OFF; + + default: + return UNKNOWN; + } +} + +uint16_t W5100Class::write(uint16_t addr, const uint8_t *buf, uint16_t len) +{ + uint8_t cmd[8]; + + if (chip == 51) + { + for (uint16_t i=0; i> 8); + SPI.transfer(addr & 0xFF); + addr++; + SPI.transfer(buf[i]); + resetSS(); + } + } + else if (chip == 52) + { + setSS(); + cmd[0] = addr >> 8; + cmd[1] = addr & 0xFF; + cmd[2] = ((len >> 8) & 0x7F) | 0x80; + cmd[3] = len & 0xFF; + SPI.transfer(cmd, 4); + +#ifdef SPI_HAS_TRANSFER_BUF + SPI.transfer(buf, NULL, len); +#else + // TODO: copy 8 bytes at a time to cmd[] and block transfer + for (uint16_t i=0; i < len; i++) + { + SPI.transfer(buf[i]); + } +#endif + resetSS(); + } + else + { + // chip == 55 + setSS(); + if (addr < 0x100) + { + // common registers 00nn + cmd[0] = 0; + cmd[1] = addr & 0xFF; + cmd[2] = 0x04; + } + else if (addr < 0x8000) + { + // socket registers 10nn, 11nn, 12nn, 13nn, etc + cmd[0] = 0; + cmd[1] = addr & 0xFF; + cmd[2] = ((addr >> 3) & 0xE0) | 0x0C; + } + else if (addr < 0xC000) + { + // transmit buffers 8000-87FF, 8800-8FFF, 9000-97FF, etc + // 10## #nnn nnnn nnnn + cmd[0] = addr >> 8; + cmd[1] = addr & 0xFF; + #if defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 1 + cmd[2] = 0x14; // 16K buffers + #elif defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 2 + cmd[2] = ((addr >> 8) & 0x20) | 0x14; // 8K buffers + #elif defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 4 + cmd[2] = ((addr >> 7) & 0x60) | 0x14; // 4K buffers + #else + cmd[2] = ((addr >> 6) & 0xE0) | 0x14; // 2K buffers + #endif + } + else + { + // receive buffers + cmd[0] = addr >> 8; + cmd[1] = addr & 0xFF; + #if defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 1 + cmd[2] = 0x1C; // 16K buffers + #elif defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 2 + cmd[2] = ((addr >> 8) & 0x20) | 0x1C; // 8K buffers + #elif defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 4 + cmd[2] = ((addr >> 7) & 0x60) | 0x1C; // 4K buffers + #else + cmd[2] = ((addr >> 6) & 0xE0) | 0x1C; // 2K buffers + #endif + } + + if (len <= 5) + { + for (uint8_t i=0; i < len; i++) + { + cmd[i + 3] = buf[i]; + } + + SPI.transfer(cmd, len + 3); + } + else + { + SPI.transfer(cmd, 3); +#ifdef SPI_HAS_TRANSFER_BUF + SPI.transfer(buf, NULL, len); +#else + // TODO: copy 8 bytes at a time to cmd[] and block transfer + for (uint16_t i=0; i < len; i++) + { + SPI.transfer(buf[i]); + } +#endif + } + resetSS(); + } + return len; +} + +uint16_t W5100Class::read(uint16_t addr, uint8_t *buf, uint16_t len) +{ + uint8_t cmd[4]; + + if (chip == 51) + { + for (uint16_t i=0; i < len; i++) + { + setSS(); + #if 1 + SPI.transfer(0x0F); + SPI.transfer(addr >> 8); + SPI.transfer(addr & 0xFF); + addr++; + buf[i] = SPI.transfer(0); + #else + cmd[0] = 0x0F; + cmd[1] = addr >> 8; + cmd[2] = addr & 0xFF; + cmd[3] = 0; + SPI.transfer(cmd, 4); // TODO: why doesn't this work? + buf[i] = cmd[3]; + addr++; + #endif + resetSS(); + } + } + else if (chip == 52) + { + setSS(); + cmd[0] = addr >> 8; + cmd[1] = addr & 0xFF; + cmd[2] = (len >> 8) & 0x7F; + cmd[3] = len & 0xFF; + SPI.transfer(cmd, 4); + memset(buf, 0, len); + SPI.transfer(buf, len); + resetSS(); + } + else + { + // chip == 55 + setSS(); + + if (addr < 0x100) + { + // common registers 00nn + cmd[0] = 0; + cmd[1] = addr & 0xFF; + cmd[2] = 0x00; + } + else if (addr < 0x8000) + { + // socket registers 10nn, 11nn, 12nn, 13nn, etc + cmd[0] = 0; + cmd[1] = addr & 0xFF; + cmd[2] = ((addr >> 3) & 0xE0) | 0x08; + } + else if (addr < 0xC000) + { + // transmit buffers 8000-87FF, 8800-8FFF, 9000-97FF, etc + // 10## #nnn nnnn nnnn + cmd[0] = addr >> 8; + cmd[1] = addr & 0xFF; + #if defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 1 + cmd[2] = 0x10; // 16K buffers + #elif defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 2 + cmd[2] = ((addr >> 8) & 0x20) | 0x10; // 8K buffers + #elif defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 4 + cmd[2] = ((addr >> 7) & 0x60) | 0x10; // 4K buffers + #else + cmd[2] = ((addr >> 6) & 0xE0) | 0x10; // 2K buffers + #endif + } else + { + // receive buffers + cmd[0] = addr >> 8; + cmd[1] = addr & 0xFF; + #if defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 1 + cmd[2] = 0x18; // 16K buffers + #elif defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 2 + cmd[2] = ((addr >> 8) & 0x20) | 0x18; // 8K buffers + #elif defined(ETHERNET_LARGE_BUFFERS) && MAX_SOCK_NUM <= 4 + cmd[2] = ((addr >> 7) & 0x60) | 0x18; // 4K buffers + #else + cmd[2] = ((addr >> 6) & 0xE0) | 0x18; // 2K buffers + #endif + } + SPI.transfer(cmd, 3); + memset(buf, 0, len); + SPI.transfer(buf, len); + resetSS(); + } + return len; +} + +void W5100Class::execCmdSn(SOCKET s, SockCMD _cmd) +{ + // Send command to socket + writeSnCR(s, _cmd); + // Wait for command to complete + while (readSnCR(s)) ; +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/EthernetLarge/src/utility/w5100.h b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/EthernetLarge/src/utility/w5100.h new file mode 100644 index 0000000..e5a71c0 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/EthernetLarge/src/utility/w5100.h @@ -0,0 +1,632 @@ +/**************************************************************************************************************************** + w5100.cpp - Driver for W5x00 + + EthernetWebServer is a library for the Ethernet shields to run WebServer + + Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases + Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer + Licensed under MIT license + Version: 1.0.9 + + Copyright 2018 Paul Stoffregen + Copyright (c) 2010 by Cristian Maglie + + This file is free software; you can redistribute it and/or modify + it under the terms of either the GNU General Public License version 2 + or the GNU Lesser General Public License version 2.1, both as + published by the Free Software Foundation. + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/02/2020 Initial coding for Arduino Mega, Teensy, etc to support Ethernetx libraries + 1.0.1 K Hoang 20/02/2020 Add support to lambda functions + 1.0.2 K Hoang 20/02/2020 Add support to UIPEthernet library for ENC28J60 + 1.0.3 K Hoang 23/02/2020 Add support to SAM DUE / SAMD21 boards + 1.0.4 K Hoang 16/04/2020 Add support to SAMD51 boards + 1.0.5 K Hoang 24/04/2020 Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, + Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, etc. + More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge + 1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards + 1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards + 1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. + 1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future. + *****************************************************************************************************************************/ + +// w5100.h contains private W5x00 hardware "driver" level definitions +// which are not meant to be exposed to other libraries or Arduino users + +#ifndef W5100_H_INCLUDED +#define W5100_H_INCLUDED + +#include +#include + +#ifndef USE_W5100 +#define USE_W5100 false +#else +#define USE_W5100 true +#endif + +#if !USE_W5100 + +// Safe for W5200 and W5500, but also tested OK on W5100 +// Use 14MHz if you know your W5100 can't run +// Higher SPI clock results in faster transfer to hosts on a LAN +// or with very low packet latency. With ordinary internet latency, +// the TCP window size & packet loss determine your overall speed. +#warning Use 25MHz clock for W5200/W5500. Not for W5100 +#define SPI_ETHERNET_SETTINGS SPISettings(25000000, MSBFIRST, SPI_MODE0) + +#else + +// Safe for all chips but too slow +#define SPI_ETHERNET_SETTINGS SPISettings(14000000, MSBFIRST, SPI_MODE0) +#warning Use 14MHz clock for W5100/W5200/W5500. Slow. + +#endif + + +// Require Ethernet.h, because we need MAX_SOCK_NUM +#ifndef ethernet_h_ +#error "EthernetLarge.h must be included before w5100.h" +#endif + + +// Arduino 101's SPI can not run faster than 8 MHz. +#if defined(ARDUINO_ARCH_ARC32) +#undef SPI_ETHERNET_SETTINGS +#define SPI_ETHERNET_SETTINGS SPISettings(8000000, MSBFIRST, SPI_MODE0) +#endif + +// Arduino Zero can't use W5100-based shields faster than 8 MHz +// https://github.com/arduino-libraries/Ethernet/issues/37#issuecomment-408036848 +// W5500 does seem to work at 12 MHz. Delete this if only using W5500 +#if defined(__SAMD21G18A__) +#undef SPI_ETHERNET_SETTINGS +//#warning Use SAMD21 architecture SPISettings(8000000, MSBFIRST, SPI_MODE3) => IP OK +#warning Use SAMD21 architecture SPISettings(30000000, MSBFIRST, SPI_MODE3) => IP OK +// Still not working !!! Original SPI_MODE0 not OK at all +//#define SPI_ETHERNET_SETTINGS SPISettings(8000000, MSBFIRST, SPI_MODE3) +#define SPI_ETHERNET_SETTINGS SPISettings(30000000, MSBFIRST, SPI_MODE3) +#endif + + +typedef uint8_t SOCKET; + +class SnMR { +public: + static const uint8_t CLOSE = 0x00; + static const uint8_t TCP = 0x21; + static const uint8_t UDP = 0x02; + static const uint8_t IPRAW = 0x03; + static const uint8_t MACRAW = 0x04; + static const uint8_t PPPOE = 0x05; + static const uint8_t ND = 0x20; + static const uint8_t MULTI = 0x80; +}; + +enum SockCMD { + Sock_OPEN = 0x01, + Sock_LISTEN = 0x02, + Sock_CONNECT = 0x04, + Sock_DISCON = 0x08, + Sock_CLOSE = 0x10, + Sock_SEND = 0x20, + Sock_SEND_MAC = 0x21, + Sock_SEND_KEEP = 0x22, + Sock_RECV = 0x40 +}; + +class SnIR { +public: + static const uint8_t SEND_OK = 0x10; + static const uint8_t TIMEOUT = 0x08; + static const uint8_t RECV = 0x04; + static const uint8_t DISCON = 0x02; + static const uint8_t CON = 0x01; +}; + +class SnSR { +public: + static const uint8_t CLOSED = 0x00; + static const uint8_t INIT = 0x13; + static const uint8_t LISTEN = 0x14; + static const uint8_t SYNSENT = 0x15; + static const uint8_t SYNRECV = 0x16; + static const uint8_t ESTABLISHED = 0x17; + static const uint8_t FIN_WAIT = 0x18; + static const uint8_t CLOSING = 0x1A; + static const uint8_t TIME_WAIT = 0x1B; + static const uint8_t CLOSE_WAIT = 0x1C; + static const uint8_t LAST_ACK = 0x1D; + static const uint8_t UDP = 0x22; + static const uint8_t IPRAW = 0x32; + static const uint8_t MACRAW = 0x42; + static const uint8_t PPPOE = 0x5F; +}; + +class IPPROTO { +public: + static const uint8_t IP = 0; + static const uint8_t ICMP = 1; + static const uint8_t IGMP = 2; + static const uint8_t GGP = 3; + static const uint8_t TCP = 6; + static const uint8_t PUP = 12; + static const uint8_t UDP = 17; + static const uint8_t IDP = 22; + static const uint8_t ND = 77; + static const uint8_t RAW = 255; +}; + +enum W5100Linkstatus { + UNKNOWN, + LINK_ON, + LINK_OFF +}; + +class W5100Class { + +public: + // KH + uint8_t init(uint8_t socketNumbers = MAX_SOCK_NUM, uint8_t new_ss_pin = 10); + + inline void setGatewayIp(const uint8_t * addr) { writeGAR(addr); } + inline void getGatewayIp(uint8_t * addr) { readGAR(addr); } + + inline void setSubnetMask(const uint8_t * addr) { writeSUBR(addr); } + inline void getSubnetMask(uint8_t * addr) { readSUBR(addr); } + + inline void setMACAddress(const uint8_t * addr) { writeSHAR(addr); } + inline void getMACAddress(uint8_t * addr) { readSHAR(addr); } + + inline void setIPAddress(const uint8_t * addr) { writeSIPR(addr); } + inline void getIPAddress(uint8_t * addr) { readSIPR(addr); } + + inline void setRetransmissionTime(uint16_t timeout) { writeRTR(timeout); } + inline void setRetransmissionCount(uint8_t retry) { writeRCR(retry); } + + static void execCmdSn(SOCKET s, SockCMD _cmd); + + + // W5100 Registers + // --------------- +//private: +public: + static uint16_t write(uint16_t addr, const uint8_t *buf, uint16_t len); + + static uint8_t write(uint16_t addr, uint8_t data) + { + return write(addr, &data, 1); + } + + static uint16_t read(uint16_t addr, uint8_t *buf, uint16_t len); + + static uint8_t read(uint16_t addr) + { + uint8_t data; + read(addr, &data, 1); + return data; + } + +#define __GP_REGISTER8(name, address) \ + static inline void write##name(uint8_t _data) { \ + write(address, _data); \ + } \ + static inline uint8_t read##name() { \ + return read(address); \ + } +#define __GP_REGISTER16(name, address) \ + static void write##name(uint16_t _data) { \ + uint8_t buf[2]; \ + buf[0] = _data >> 8; \ + buf[1] = _data & 0xFF; \ + write(address, buf, 2); \ + } \ + static uint16_t read##name() { \ + uint8_t buf[2]; \ + read(address, buf, 2); \ + return (buf[0] << 8) | buf[1]; \ + } +#define __GP_REGISTER_N(name, address, size) \ + static uint16_t write##name(const uint8_t *_buff) { \ + return write(address, _buff, size); \ + } \ + static uint16_t read##name(uint8_t *_buff) { \ + return read(address, _buff, size); \ + } + + // KH + W5100Linkstatus getLinkStatus(); + + +public: + __GP_REGISTER8 (MR, 0x0000); // Mode + __GP_REGISTER_N(GAR, 0x0001, 4); // Gateway IP address + __GP_REGISTER_N(SUBR, 0x0005, 4); // Subnet mask address + __GP_REGISTER_N(SHAR, 0x0009, 6); // Source MAC address + __GP_REGISTER_N(SIPR, 0x000F, 4); // Source IP address + __GP_REGISTER8 (IR, 0x0015); // Interrupt + __GP_REGISTER8 (IMR, 0x0016); // Interrupt Mask + __GP_REGISTER16(RTR, 0x0017); // Timeout address + __GP_REGISTER8 (RCR, 0x0019); // Retry count + __GP_REGISTER8 (RMSR, 0x001A); // Receive memory size (W5100 only) + __GP_REGISTER8 (TMSR, 0x001B); // Transmit memory size (W5100 only) + __GP_REGISTER8 (PATR, 0x001C); // Authentication type address in PPPoE mode + __GP_REGISTER8 (PTIMER, 0x0028); // PPP LCP Request Timer + __GP_REGISTER8 (PMAGIC, 0x0029); // PPP LCP Magic Number + __GP_REGISTER_N(UIPR, 0x002A, 4); // Unreachable IP address in UDP mode (W5100 only) + __GP_REGISTER16(UPORT, 0x002E); // Unreachable Port address in UDP mode (W5100 only) + __GP_REGISTER8 (VERSIONR_W5200,0x001F); // Chip Version Register (W5200 only) + __GP_REGISTER8 (VERSIONR_W5500,0x0039); // Chip Version Register (W5500 only) + __GP_REGISTER8 (PSTATUS_W5200, 0x0035); // PHY Status + __GP_REGISTER8 (PHYCFGR_W5500, 0x002E); // PHY Configuration register, default: 10111xxx + + +#undef __GP_REGISTER8 +#undef __GP_REGISTER16 +#undef __GP_REGISTER_N + + // W5100 Socket registers + // ---------------------- +private: + static uint16_t CH_BASE(void) { + //if (chip == 55) return 0x1000; + //if (chip == 52) return 0x4000; + //return 0x0400; + return CH_BASE_MSB << 8; + } + static uint8_t CH_BASE_MSB; // 1 redundant byte, saves ~80 bytes code on AVR + static const uint16_t CH_SIZE = 0x0100; + + static inline uint8_t readSn(SOCKET s, uint16_t addr) + { + return read(CH_BASE() + s * CH_SIZE + addr); + } + static inline uint8_t writeSn(SOCKET s, uint16_t addr, uint8_t data) + { + return write(CH_BASE() + s * CH_SIZE + addr, data); + } + static inline uint16_t readSn(SOCKET s, uint16_t addr, uint8_t *buf, uint16_t len) + { + return read(CH_BASE() + s * CH_SIZE + addr, buf, len); + } + static inline uint16_t writeSn(SOCKET s, uint16_t addr, uint8_t *buf, uint16_t len) + { + return write(CH_BASE() + s * CH_SIZE + addr, buf, len); + } + +#define __SOCKET_REGISTER8(name, address) \ + static inline void write##name(SOCKET _s, uint8_t _data) { \ + writeSn(_s, address, _data); \ + } \ + static inline uint8_t read##name(SOCKET _s) { \ + return readSn(_s, address); \ + } +#define __SOCKET_REGISTER16(name, address) \ + static void write##name(SOCKET _s, uint16_t _data) { \ + uint8_t buf[2]; \ + buf[0] = _data >> 8; \ + buf[1] = _data & 0xFF; \ + writeSn(_s, address, buf, 2); \ + } \ + static uint16_t read##name(SOCKET _s) { \ + uint8_t buf[2]; \ + readSn(_s, address, buf, 2); \ + return (buf[0] << 8) | buf[1]; \ + } +#define __SOCKET_REGISTER_N(name, address, size) \ + static uint16_t write##name(SOCKET _s, uint8_t *_buff) { \ + return writeSn(_s, address, _buff, size); \ + } \ + static uint16_t read##name(SOCKET _s, uint8_t *_buff) { \ + return readSn(_s, address, _buff, size); \ + } + +public: + __SOCKET_REGISTER8(SnMR, 0x0000) // Mode + __SOCKET_REGISTER8(SnCR, 0x0001) // Command + __SOCKET_REGISTER8(SnIR, 0x0002) // Interrupt + __SOCKET_REGISTER8(SnSR, 0x0003) // Status + __SOCKET_REGISTER16(SnPORT, 0x0004) // Source Port + __SOCKET_REGISTER_N(SnDHAR, 0x0006, 6) // Destination Hardw Addr + __SOCKET_REGISTER_N(SnDIPR, 0x000C, 4) // Destination IP Addr + __SOCKET_REGISTER16(SnDPORT, 0x0010) // Destination Port + __SOCKET_REGISTER16(SnMSSR, 0x0012) // Max Segment Size + __SOCKET_REGISTER8(SnPROTO, 0x0014) // Protocol in IP RAW Mode + __SOCKET_REGISTER8(SnTOS, 0x0015) // IP TOS + __SOCKET_REGISTER8(SnTTL, 0x0016) // IP TTL + __SOCKET_REGISTER8(SnRX_SIZE, 0x001E) // RX Memory Size (W5200 only) + __SOCKET_REGISTER8(SnTX_SIZE, 0x001F) // RX Memory Size (W5200 only) + __SOCKET_REGISTER16(SnTX_FSR, 0x0020) // TX Free Size + __SOCKET_REGISTER16(SnTX_RD, 0x0022) // TX Read Pointer + __SOCKET_REGISTER16(SnTX_WR, 0x0024) // TX Write Pointer + __SOCKET_REGISTER16(SnRX_RSR, 0x0026) // RX Free Size + __SOCKET_REGISTER16(SnRX_RD, 0x0028) // RX Read Pointer + __SOCKET_REGISTER16(SnRX_WR, 0x002A) // RX Write Pointer (supported?) + +#undef __SOCKET_REGISTER8 +#undef __SOCKET_REGISTER16 +#undef __SOCKET_REGISTER_N + + +private: + // KH + bool initialized = false; + static uint8_t chip; + static uint8_t ss_pin; + + static uint8_t isW5100(void); + static uint8_t isW5200(void); + static uint8_t isW5500(void); + +public: + // KH + static uint8_t softReset(void); + static uint8_t getChip(void) { return chip; } +#ifdef ETHERNET_LARGE_BUFFERS + static uint16_t SSIZE; + static uint16_t SMASK; +#else + static const uint16_t SSIZE = 2048; + static const uint16_t SMASK = 0x07FF; +#endif + static uint16_t SBASE(uint8_t socknum) + { + if (chip == 51) + { + return socknum * SSIZE + 0x4000; + } + else + { + return socknum * SSIZE + 0x8000; + } + } + + static uint16_t RBASE(uint8_t socknum) + { + if (chip == 51) { + return socknum * SSIZE + 0x6000; + } + else + { + return socknum * SSIZE + 0xC000; + } + } + + static bool hasOffsetAddressMapping(void) + { + if (chip == 55) + return true; + + return false; + } + + static void setSS(uint8_t pin) { ss_pin = pin; } + +private: +#if defined(__AVR__) + +#warning Use AVR architecture + + static volatile uint8_t *ss_pin_reg; + static uint8_t ss_pin_mask; + + inline static void initSS() + { + ss_pin_reg = portOutputRegister(digitalPinToPort(ss_pin)); + ss_pin_mask = digitalPinToBitMask(ss_pin); + pinMode(ss_pin, OUTPUT); + } + + inline static void setSS() + { + *(ss_pin_reg) &= ~ss_pin_mask; + } + + inline static void resetSS() + { + *(ss_pin_reg) |= ss_pin_mask; + } +#elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK66FX1M0__) || defined(__MK64FX512__) + +#warning Use MK architecture + + static volatile uint8_t *ss_pin_reg; + + inline static void initSS() + { + ss_pin_reg = portOutputRegister(ss_pin); + pinMode(ss_pin, OUTPUT); + } + + inline static void setSS() + { + *(ss_pin_reg+256) = 1; + } + + inline static void resetSS() + { + *(ss_pin_reg+128) = 1; + } +#elif defined(__IMXRT1062__) + +#warning Use Teensy architecture + + static volatile uint32_t *ss_pin_reg; + static uint32_t ss_pin_mask; + + inline static void initSS() + { + ss_pin_reg = portOutputRegister(digitalPinToPort(ss_pin)); + ss_pin_mask = digitalPinToBitMask(ss_pin); + pinMode(ss_pin, OUTPUT); + } + + inline static void setSS() + { + *(ss_pin_reg+34) = ss_pin_mask; + } + + inline static void resetSS() + { + *(ss_pin_reg+33) = ss_pin_mask; + } +#elif defined(__MKL26Z64__) + static volatile uint8_t *ss_pin_reg; + static uint8_t ss_pin_mask; + inline static void initSS() + { + ss_pin_reg = portOutputRegister(digitalPinToPort(ss_pin)); + ss_pin_mask = digitalPinToBitMask(ss_pin); + pinMode(ss_pin, OUTPUT); + } + + inline static void setSS() + { + *(ss_pin_reg+8) = ss_pin_mask; + } + + inline static void resetSS() + { + *(ss_pin_reg+4) = ss_pin_mask; + } +#elif defined(__SAM3X8E__) || defined(__SAM3A8C__) || defined(__SAM3A4C__) + +#warning Use SAM3 architecture + + static volatile uint32_t *ss_pin_reg; + static uint32_t ss_pin_mask; + + inline static void initSS() + { + ss_pin_reg = &(digitalPinToPort(ss_pin)->PIO_PER); + ss_pin_mask = digitalPinToBitMask(ss_pin); + pinMode(ss_pin, OUTPUT); + } + + inline static void setSS() + { + *(ss_pin_reg+13) = ss_pin_mask; + } + + inline static void resetSS() + { + *(ss_pin_reg+12) = ss_pin_mask; + } +#elif defined(__PIC32MX__) + static volatile uint32_t *ss_pin_reg; + static uint32_t ss_pin_mask; + + inline static void initSS() + { + ss_pin_reg = portModeRegister(digitalPinToPort(ss_pin)); + ss_pin_mask = digitalPinToBitMask(ss_pin); + pinMode(ss_pin, OUTPUT); + } + + inline static void setSS() + { + *(ss_pin_reg+8+1) = ss_pin_mask; + } + + inline static void resetSS() + { + *(ss_pin_reg+8+2) = ss_pin_mask; + } + +#elif defined(ARDUINO_ARCH_ESP8266) + +#warning Use ARDUINO_ARCH_ESP8266 architecture + + static volatile uint32_t *ss_pin_reg; + static uint32_t ss_pin_mask; + + inline static void initSS() + { + ss_pin_reg = (volatile uint32_t*)GPO; + ss_pin_mask = 1 << ss_pin; + pinMode(ss_pin, OUTPUT); + } + + inline static void setSS() + { + GPOC = ss_pin_mask; + } + + inline static void resetSS() + { + GPOS = ss_pin_mask; + } + +#elif defined(__SAMD21G18A__) + +#warning Use SAMD21 architecture + + static volatile uint32_t *ss_pin_reg; + static uint32_t ss_pin_mask; + + inline static void initSS() + { + ss_pin_reg = portModeRegister(digitalPinToPort(ss_pin)); + ss_pin_mask = digitalPinToBitMask(ss_pin); + pinMode(ss_pin, OUTPUT); + } + + inline static void setSS() + { + *(ss_pin_reg+5) = ss_pin_mask; + } + + inline static void resetSS() + { + *(ss_pin_reg+6) = ss_pin_mask; + } +#else + +#warning Use Default architecture + + inline static void initSS() + { + pinMode(ss_pin, OUTPUT); + } + + inline static void setSS() + { + digitalWrite(ss_pin, LOW); + } + + inline static void resetSS() + { + digitalWrite(ss_pin, HIGH); + } +#endif +}; + +extern W5100Class W5100; + +#endif + +#ifndef UTIL_H +#define UTIL_H + +#ifndef htons +#define htons(x) ( (((x)<<8)&0xFF00) | (((x)>>8)&0xFF) ) +#endif + +#ifndef ntohs +#define ntohs(x) htons(x) +#endif + +#ifndef htonl +#define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \ + ((x)<< 8 & 0x00FF0000UL) | \ + ((x)>> 8 & 0x0000FF00UL) | \ + ((x)>>24 & 0x000000FFUL) ) +#endif + +#ifndef ntohl +#define ntohl(x) htonl(x) +#endif + +#endif //W5100_H_INCLUDED diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet-2.0.9/UIPEthernet.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet-2.0.9/UIPEthernet.cpp new file mode 100644 index 0000000..2af3cfb --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet-2.0.9/UIPEthernet.cpp @@ -0,0 +1,625 @@ +/* + UIPEthernet.cpp - Arduino implementation of a uIP wrapper class. + Copyright (c) 2013 Norbert Truchsess + All rights reserved. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#if defined(ARDUINO) + #include +#endif +#if defined(__MBED__) + #include + #include "mbed/millis.h" +#endif +#include "UIPEthernet.h" +#include "utility/logging.h" +#include "utility/Enc28J60Network.h" + +#include "UIPUdp.h" + +extern "C" +{ +#include "utility/uipopt.h" +#include "utility/uip.h" +#include "utility/uip_arp.h" +} + +#define ETH_HDR ((struct uip_eth_hdr *)&uip_buf[0]) + +memhandle UIPEthernetClass::in_packet(NOBLOCK); +memhandle UIPEthernetClass::uip_packet(NOBLOCK); +uint8_t UIPEthernetClass::uip_hdrlen(0); +uint8_t UIPEthernetClass::packetstate(0); + +unsigned long UIPEthernetClass::periodic_timer; + +IPAddress UIPEthernetClass::_dnsServerAddress; +#if UIP_UDP + DhcpClass* UIPEthernetClass::_dhcp(NULL); + static DhcpClass s_dhcp; // Placing this instance here is saving 40K to final *.bin (see bug below) +#endif + +// Because uIP isn't encapsulated within a class we have to use global +// variables, so we can only have one TCP/IP stack per program. + +UIPEthernetClass::UIPEthernetClass() +{ +} + +void UIPEthernetClass::init(const uint8_t pin) +{ + ENC28J60ControlCS = pin; +} + +#if UIP_UDP +int +UIPEthernetClass::begin(const uint8_t* mac) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var _mac_address + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac, sizeof(_mac_address)); + ////// + + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::begin(const uint8_t* mac) DEBUG_V3:Function started")); + #endif + //static DhcpClass s_dhcp; // <-- this is a bug ! + // I leave it there commented for history. It is bring all GCC "new" memory allocation code, making the *.bin almost 40K bigger. I've move it globally. + _dhcp = &s_dhcp; + // Initialise the basic info + netInit(mac); + + // Now try to get our config info from a DHCP server + int ret = _dhcp->beginWithDHCP((uint8_t*)mac); + if(ret == 1) + { + // We've successfully found a DHCP server and got our configuration info, so set things + // accordingly + configure(_dhcp->getLocalIp(),_dhcp->getDnsServerIp(),_dhcp->getGatewayIp(),_dhcp->getSubnetMask()); + } + return ret; +} +#endif + +void +UIPEthernetClass::begin(const uint8_t* mac, IPAddress ip) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var _mac_address + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac, sizeof(_mac_address)); + ////// + + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::begin(const uint8_t* mac, IPAddress ip) DEBUG_V3:Function started")); + #endif + IPAddress dns = ip; + dns[3] = 1; + begin(mac, ip, dns); +} + +void +UIPEthernetClass::begin(const uint8_t* mac, IPAddress ip, IPAddress dns) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var _mac_address + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac, sizeof(_mac_address)); + ////// + + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::begin(const uint8_t* mac, IPAddress ip, IPAddress dns) DEBUG_V3:Function started")); + #endif + IPAddress gateway = ip; + gateway[3] = 1; + begin(mac, ip, dns, gateway); +} + +void +UIPEthernetClass::begin(const uint8_t* mac, IPAddress ip, IPAddress dns, IPAddress gateway) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var _mac_address + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac, sizeof(_mac_address)); + ////// + + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::begin(const uint8_t* mac, IPAddress ip, IPAddress dns, IPAddress gateway) DEBUG_V3:Function started")); + #endif + IPAddress subnet(255, 255, 255, 0); + begin(mac, ip, dns, gateway, subnet); +} + +void +UIPEthernetClass::begin(const uint8_t* mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var _mac_address + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac, sizeof(_mac_address)); + ////// + + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::begin(const uint8_t* mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet) DEBUG_V3:Function started")); + #endif + netInit(mac); + configure(ip,dns,gateway,subnet); +} + +int UIPEthernetClass::maintain(){ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::maintain() DEBUG_V3:Function started")); + #endif + tick(); + int rc = DHCP_CHECK_NONE; +#if UIP_UDP + if(_dhcp != NULL){ + //we have a pointer to dhcp, use it + rc = _dhcp->checkLease(); + switch ( rc ){ + case DHCP_CHECK_NONE: + //nothing done + break; + case DHCP_CHECK_RENEW_OK: + case DHCP_CHECK_REBIND_OK: + //we might have got a new IP. + configure(_dhcp->getLocalIp(),_dhcp->getDnsServerIp(),_dhcp->getGatewayIp(),_dhcp->getSubnetMask()); + break; + default: + //this is actually a error, it will retry though + break; + } + } + return rc; +#endif +} + +EthernetLinkStatus UIPEthernetClass::linkStatus() +{ + if (!Enc28J60Network::geterevid()) + return Unknown; + return Enc28J60Network::linkStatus() ? LinkON : LinkOFF; +} + +EthernetHardwareStatus UIPEthernetClass::hardwareStatus() { + if (!Enc28J60Network::geterevid()) + return EthernetNoHardware; + return EthernetENC28J60; +} + +IPAddress UIPEthernetClass::localIP() +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::localIP() DEBUG_V3:Function started")); + #endif + IPAddress ret; + uip_ipaddr_t a; + uip_gethostaddr(a); + return ip_addr_uip(a); +} + +IPAddress UIPEthernetClass::subnetMask() +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::subnetMask() DEBUG_V3:Function started")); + #endif + IPAddress ret; + uip_ipaddr_t a; + uip_getnetmask(a); + return ip_addr_uip(a); +} + +IPAddress UIPEthernetClass::gatewayIP() +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::gatewayIP() DEBUG_V3:Function started")); + #endif + IPAddress ret; + uip_ipaddr_t a; + uip_getdraddr(a); + return ip_addr_uip(a); +} + +IPAddress UIPEthernetClass::dnsServerIP() +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::dnsServerIP() DEBUG_V3:Function started")); + #endif + return _dnsServerAddress; +} + +void +UIPEthernetClass::tick() +{ +#if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::tick() DEBUG_V3:Function started")); +#endif +if (Enc28J60Network::geterevid()==0) + { + #if ACTLOGLEVEL>=LOG_ERR + LogObject.uart_send_strln(F("UIPEthernetClass::tick() ERROR:EREVID=0 -> Not found ENC28j60 device !! Function ended !!")); + #endif + return; + } +#if defined(ESP8266) + wdt_reset(); +#endif + if (in_packet == NOBLOCK) + { + in_packet = Enc28J60Network::receivePacket(); + #if ACTLOGLEVEL>=LOG_DEBUG + if (in_packet != NOBLOCK) + { + LogObject.uart_send_str(F("UIPEthernetClass::tick() DEBUG:receivePacket: ")); + LogObject.uart_send_decln(in_packet); + } + #endif + } + if (in_packet != NOBLOCK) + { + packetstate = UIPETHERNET_FREEPACKET; + uip_len = Enc28J60Network::blockSize(in_packet); + if (uip_len > 0) + { + Enc28J60Network::readPacket(in_packet,0,(uint8_t*)uip_buf,UIP_BUFSIZE); + if (ETH_HDR ->type == HTONS(UIP_ETHTYPE_IP)) + { + uip_packet = in_packet; //required for upper_layer_checksum of in_packet! + #if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_str(F("UIPEthernetClass::tick() DEBUG:readPacket type IP, uip_len: ")); + LogObject.uart_send_decln(uip_len); + #endif + uip_arp_ipin(); + uip_input(); + if (uip_len > 0) + { + uip_arp_out(); + network_send(); + } + } + else if (ETH_HDR ->type == HTONS(UIP_ETHTYPE_ARP)) + { + #if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_str(F("UIPEthernetClass::tick() DEBUG:readPacket type ARP, uip_len: ")); + LogObject.uart_send_decln(uip_len); + #endif + uip_arp_arpin(); + if (uip_len > 0) + { + network_send(); + } + } + } + if (in_packet != NOBLOCK && (packetstate & UIPETHERNET_FREEPACKET)) + { + #if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_str(F("UIPEthernetClass::tick() DEBUG:freeing packet: ")); + LogObject.uart_send_decln(in_packet); + #endif + Enc28J60Network::freePacket(); + in_packet = NOBLOCK; + } + } + + unsigned long now = millis(); + +#if UIP_CLIENT_TIMER >= 0 + bool periodic = (long)( now - periodic_timer ) >= 0; + for (int i = 0; i < UIP_CONNS; i++) + { +#else + if ((long)( now - periodic_timer ) >= 0) + { + periodic_timer = now + UIP_PERIODIC_TIMER; + + for (int i = 0; i < UIP_CONNS; i++) + { +#endif + + uip_conn = &uip_conns[i]; + +#if UIP_CLIENT_TIMER >= 0 + if (periodic) + { +#endif + + uip_process(UIP_TIMER); + +#if UIP_CLIENT_TIMER >= 0 + } + else + { + if (((uip_userdata_t*)uip_conn->appstate)!=NULL) + { + if ((long)( now - ((uip_userdata_t*)uip_conn->appstate)->timer) >= 0) + { + uip_process(UIP_POLL_REQUEST); + ((uip_userdata_t*)uip_conn->appstate)->timer = millis() + UIP_CLIENT_TIMER; + } + else + { + continue; + } + } + else + continue; + } +#endif + // If the above function invocation resulted in data that + // should be sent out on the Enc28J60Network, the global variable + // uip_len is set to a value > 0. + if (uip_len > 0) + { + uip_arp_out(); + network_send(); + } + } +#if UIP_CLIENT_TIMER >= 0 + if (periodic) + { + periodic_timer = now + UIP_PERIODIC_TIMER; +#endif +#if UIP_UDP + for (int i = 0; i < UIP_UDP_CONNS; i++) + { + uip_udp_periodic(i); + // If the above function invocation resulted in data that + // should be sent out on the Enc28J60Network, the global variable + // uip_len is set to a value > 0. */ + if (uip_len > 0) + { + UIPUDP::_send((uip_udp_userdata_t *)(uip_udp_conns[i].appstate)); + } + } +#endif /* UIP_UDP */ + } +} + +bool UIPEthernetClass::network_send() +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::network_send() DEBUG_V3:Function started")); + #endif + if (packetstate & UIPETHERNET_SENDPACKET) + { +#if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_str(F("UIPEthernetClass::network_send() DEBUG:uip_packet: ")); + LogObject.uart_send_dec(uip_packet); + LogObject.uart_send_str(F(", hdrlen: ")); + LogObject.uart_send_decln(uip_hdrlen); +#endif + Enc28J60Network::writePacket(uip_packet, UIP_SENDBUFFER_OFFSET,uip_buf,uip_hdrlen); + packetstate &= ~ UIPETHERNET_SENDPACKET; + goto sendandfree; + } + uip_packet = Enc28J60Network::allocBlock(uip_len + UIP_SENDBUFFER_OFFSET + UIP_SENDBUFFER_PADDING); + if (uip_packet != NOBLOCK) + { +#if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_str(F("UIPEthernetClass::network_send() DEBUG:uip_buf (uip_len): ")); + LogObject.uart_send_dec(uip_len); + LogObject.uart_send_str(F(", packet: ")); + LogObject.uart_send_decln(uip_packet); +#endif + Enc28J60Network::writePacket(uip_packet, UIP_SENDBUFFER_OFFSET,uip_buf,uip_len); + goto sendandfree; + } + return false; +sendandfree: + bool success = Enc28J60Network::sendPacket(uip_packet); + Enc28J60Network::freeBlock(uip_packet); + uip_packet = NOBLOCK; + return success; +} + +void UIPEthernetClass::netInit(const uint8_t* mac) { + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::netInit(const uint8_t* mac) DEBUG_V3:Function started")); + #endif + periodic_timer = millis() + UIP_PERIODIC_TIMER; + + Enc28J60Network::init((uint8_t*)mac); + uip_seteth_addr(mac); + + uip_init(); + uip_arp_init(); +} + +void UIPEthernetClass::configure(IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet) { + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::configure(IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet) DEBUG_V3:Function started")); + #endif + uip_ipaddr_t ipaddr; + + uip_ip_addr(ipaddr, ip); + uip_sethostaddr(ipaddr); + + uip_ip_addr(ipaddr, gateway); + uip_setdraddr(ipaddr); + + uip_ip_addr(ipaddr, subnet); + uip_setnetmask(ipaddr); + + _dnsServerAddress = dns; +} + +UIPEthernetClass UIPEthernet; + +/*---------------------------------------------------------------------------*/ +uint16_t +UIPEthernetClass::chksum(uint16_t sum, const uint8_t *data, uint16_t len) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::chksum(uint16_t sum, const uint8_t *data, uint16_t len) DEBUG_V3:Function started")); + #endif + uint16_t t; + const uint8_t *dataptr; + const uint8_t *last_byte; + + dataptr = data; + last_byte = data + len - 1; + + while(dataptr < last_byte) { /* At least two more bytes */ + t = (dataptr[0] << 8) + dataptr[1]; + sum += t; + if(sum < t) { + sum++; /* carry */ + } + dataptr += 2; + } + + if(dataptr == last_byte) { + t = (dataptr[0] << 8) + 0; + sum += t; + if(sum < t) { + sum++; /* carry */ + } + } + + /* Return sum in host byte order. */ + return sum; +} + +/*---------------------------------------------------------------------------*/ + +uint16_t +UIPEthernetClass::ipchksum(void) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::ipchksum(void) DEBUG_V3:Function started")); + #endif + uint16_t sum; + + sum = chksum(0, &uip_buf[UIP_LLH_LEN], UIP_IPH_LEN); + return (sum == 0) ? 0xffff : htons(sum); +} + +/*---------------------------------------------------------------------------*/ +uint16_t +#if UIP_UDP +UIPEthernetClass::upper_layer_chksum(uint8_t proto) +#else +uip_tcpchksum(void) +#endif +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + #if UIP_UDP + LogObject.uart_send_strln(F("UIPEthernetClass::upper_layer_chksum(uint8_t proto) DEBUG_V3:Function started")); + #else + LogObject.uart_send_strln(F("uip_tcpchksum(void) INFO:Function started")); + #endif + #endif + uint16_t upper_layer_len; + uint16_t sum; + +#if UIP_CONF_IPV6 + upper_layer_len = (((u16_t)(BUF->len[0]) << 8) + BUF->len[1]); +#else /* UIP_CONF_IPV6 */ + upper_layer_len = (((u16_t)(BUF->len[0]) << 8) + BUF->len[1]) - UIP_IPH_LEN; +#endif /* UIP_CONF_IPV6 */ + + /* First sum pseudoheader. */ + + /* IP protocol and length fields. This addition cannot carry. */ +#if UIP_UDP + sum = upper_layer_len + proto; +#else + sum = upper_layer_len + UIP_PROTO_TCP; +#endif + /* Sum IP source and destination addresses. */ + sum = UIPEthernetClass::chksum(sum, (u8_t *)&BUF->srcipaddr[0], 2 * sizeof(uip_ipaddr_t)); + + uint8_t upper_layer_memlen; +#if UIP_UDP + switch(proto) + { +// case UIP_PROTO_ICMP: +// case UIP_PROTO_ICMP6: +// upper_layer_memlen = upper_layer_len; +// break; + case UIP_PROTO_UDP: + upper_layer_memlen = UIP_UDPH_LEN; + break; + default: +// case UIP_PROTO_TCP: +#endif + upper_layer_memlen = (BUF->tcpoffset >> 4) << 2; +#if UIP_UDP + break; + } +#endif + sum = UIPEthernetClass::chksum(sum, &uip_buf[UIP_IPH_LEN + UIP_LLH_LEN], upper_layer_memlen); +#if ACTLOGLEVEL>=LOG_DEBUG + #if UIP_UDP + LogObject.uart_send_str(F("UIPEthernetClass::upper_layer_chksum(uint8_t proto) DEBUG:uip_buf[")); + #else + LogObject.uart_send_str(F("uip_tcpchksum(void) DEBUG:uip_buf[")); + #endif + LogObject.uart_send_dec(UIP_IPH_LEN + UIP_LLH_LEN); + LogObject.uart_send_str(F("-")); + LogObject.uart_send_dec(UIP_IPH_LEN + UIP_LLH_LEN + upper_layer_memlen); + LogObject.uart_send_str(F("]: ")); + LogObject.uart_send_hexln(htons(sum)); +#endif + if (upper_layer_memlen < upper_layer_len) + { + sum = Enc28J60Network::chksum( + sum, + UIPEthernetClass::uip_packet, + (UIPEthernetClass::packetstate & UIPETHERNET_SENDPACKET ? UIP_IPH_LEN + UIP_LLH_LEN + UIP_SENDBUFFER_OFFSET : UIP_IPH_LEN + UIP_LLH_LEN) + upper_layer_memlen, + upper_layer_len - upper_layer_memlen + ); +#if ACTLOGLEVEL>=LOG_DEBUG + #if UIP_UDP + LogObject.uart_send_str(F("UIPEthernetClass::upper_layer_chksum(uint8_t proto) DEBUG:uip_packet(")); + #else + LogObject.uart_send_str(F("uip_tcpchksum(void) DEBUG:uip_packet(")); + #endif + LogObject.uart_send_dec(UIPEthernetClass::uip_packet); + LogObject.uart_send_str(F(")[")); + LogObject.uart_send_dec(UIP_IPH_LEN + UIP_LLH_LEN + upper_layer_memlen); + LogObject.uart_send_str(F("-")); + LogObject.uart_send_dec(UIP_IPH_LEN + UIP_LLH_LEN + upper_layer_len); + LogObject.uart_send_str(F("]: ")); + LogObject.uart_send_hexln(htons(sum)); +#endif + } + return (sum == 0) ? 0xffff : htons(sum); +} + +uint16_t +uip_ipchksum(void) +{ + return UIPEthernet.ipchksum(); +} + +#if UIP_UDP +uint16_t +uip_tcpchksum(void) +{ + uint16_t sum = UIPEthernet.upper_layer_chksum(UIP_PROTO_TCP); + return sum; +} + +uint16_t +uip_udpchksum(void) +{ + uint16_t sum = UIPEthernet.upper_layer_chksum(UIP_PROTO_UDP); + return sum; +} +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet-2.0.9/UIPEthernet.h b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet-2.0.9/UIPEthernet.h new file mode 100644 index 0000000..4d3e0eb --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet-2.0.9/UIPEthernet.h @@ -0,0 +1,166 @@ +/* + UIPEthernet.h - Arduino implementation of a uIP wrapper class. + Copyright (c) 2013 Norbert Truchsess + All rights reserved. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#ifndef UIPETHERNET_H +#define UIPETHERNET_H + +#include "ethernet_comp.h" +#if defined(__MBED__) + #include +#endif +#if defined(ARDUINO) + #include + #if defined(__STM32F3__) || (!defined(ARDUINO_ARCH_STM32) && defined(STM32F3)) || defined(__RFduino__) + #include "mbed/IPAddress.h" + #else + #include "IPAddress.h" + #endif +#endif +#include "utility/Enc28J60Network.h" +#include "utility/uipopt.h" +#include "Dhcp.h" +#if UIP_UDP + #include "UIPUdp.h" +#endif +#include "UIPClient.h" +#include "UIPServer.h" + +extern "C" +{ +#include "utility/uip.h" +} + +#define UIPETHERNET_FREEPACKET 1 +#define UIPETHERNET_SENDPACKET 2 +#define UIPETHERNET_BUFFERREAD 4 + +#define uip_ip_addr(addr, ip) do { \ + ((u16_t *)(addr))[0] = HTONS(((ip[0]) << 8) | (ip[1])); \ + ((u16_t *)(addr))[1] = HTONS(((ip[2]) << 8) | (ip[3])); \ + } while(0) + +#define ip_addr_uip(a) IPAddress(a[0] & 0xFF, a[0] >> 8 , a[1] & 0xFF, a[1] >> 8) //TODO this is not IPV6 capable + +#define uip_seteth_addr(eaddr) do {uip_ethaddr.addr[0] = eaddr[0]; \ + uip_ethaddr.addr[1] = eaddr[1];\ + uip_ethaddr.addr[2] = eaddr[2];\ + uip_ethaddr.addr[3] = eaddr[3];\ + uip_ethaddr.addr[4] = eaddr[4];\ + uip_ethaddr.addr[5] = eaddr[5];} while(0) + +#define BUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN]) + +enum EthernetLinkStatus { + Unknown, + LinkON, + LinkOFF +}; + +enum EthernetHardwareStatus { + EthernetNoHardware, + EthernetW5100, + EthernetW5200, + EthernetW5500, + EthernetENC28J60 = 10 +}; + +class UIPEthernetClass +{ +public: + UIPEthernetClass(); + + void init(const uint8_t pin); + + int begin(const uint8_t* mac); + void begin(const uint8_t* mac, IPAddress ip); + void begin(const uint8_t* mac, IPAddress ip, IPAddress dns); + void begin(const uint8_t* mac, IPAddress ip, IPAddress dns, IPAddress gateway); + void begin(const uint8_t* mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet); + + // maintain() must be called at regular intervals to process the incoming serial + // data and issue IP events to the sketch. It does not return until all IP + // events have been processed. Renews dhcp-lease if required. + int maintain(); + + EthernetLinkStatus linkStatus(); + EthernetHardwareStatus hardwareStatus(); + + // KH add to have similar function to Ethernet lib + // Certainly we can use void macAddress(uint8_t mac[]) to read from W5x00. + void MACAddress(uint8_t *mac_address) + { + memcpy(mac_address, _mac_address, sizeof(_mac_address)); + } + ////// + + IPAddress localIP(); + IPAddress subnetMask(); + IPAddress gatewayIP(); + IPAddress dnsServerIP(); + +private: + + // KH add to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + uint8_t _mac_address[6] ={0,}; + ////// + + static memhandle in_packet; + static memhandle uip_packet; + static uint8_t uip_hdrlen; + static uint8_t packetstate; + + static IPAddress _dnsServerAddress; + #if UIP_UDP + static DhcpClass* _dhcp; + #endif + static unsigned long periodic_timer; + + static void netInit(const uint8_t* mac); + static void configure(IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet); + + static void tick(); + + static bool network_send(); + + friend class UIPServer; + + friend class UIPClient; + + friend class UIPUDP; + + static uint16_t chksum(uint16_t sum, const uint8_t* data, uint16_t len); + static uint16_t ipchksum(void); +#if UIP_UDP + static uint16_t upper_layer_chksum(uint8_t proto); +#endif + friend uint16_t uip_ipchksum(void); + friend uint16_t uip_tcpchksum(void); + friend uint16_t uip_udpchksum(void); + + friend void uipclient_appcall(void); + friend void uipudp_appcall(void); + +#if UIP_CONF_IPV6 + uint16_t uip_icmp6chksum(void); +#endif /* UIP_CONF_IPV6 */ +}; + +extern UIPEthernetClass UIPEthernet; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet-2.0.9/utility/Enc28J60Network.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet-2.0.9/utility/Enc28J60Network.cpp new file mode 100644 index 0000000..8c405d6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet-2.0.9/utility/Enc28J60Network.cpp @@ -0,0 +1,1216 @@ +/* + Enc28J60NetworkClass.h + UIPEthernet network driver for Microchip ENC28J60 Ethernet Interface. + + Copyright (c) 2013 Norbert Truchsess + All rights reserved. + + based on enc28j60.c file from the AVRlib library by Pascal Stang. + For AVRlib See http://www.procyonengineering.com/ + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#include "Enc28J60Network.h" +#if defined(ARDUINO) + #include "Arduino.h" +#endif +#if defined(__MBED__) + #include + #include "mbed/millis.h" + #define delay(x) wait_ms(x) +#endif +#include "logging.h" + +// KH, For nRF52 +//#define ENC28J60_USE_SPILIB true + +uint8_t ENC28J60ControlCS = ENC28J60_CONTROL_CS; + +#if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + #if defined(STM32F2) + #include + #elif (defined(ARDUINO_ARCH_STM32) || !defined(STM32F3)) && !defined(__STM32F4__) + #include + extern SPIClass SPI; + //#elif defined(ARDUINO_ARCH_AMEBA) + //SPIClass SPI((void *)(&spi_obj), 11, 12, 13, 10); + //SPI _spi(SPI_MOSI,SPI_MISO,SPI_SCK,ENC28J60ControlCS); + #else + #include "HardwareSPI.h" + extern HardwareSPI SPI(1); + #endif + #endif + #if defined(__MBED__) + SPI _spi(SPI_MOSI,SPI_MISO,SPI_SCK); + DigitalOut _cs(ENC28J60ControlCS); + Serial LogObject(SERIAL_TX,SERIAL_RX); + #endif +#endif + +extern "C" { + #if defined(ARDUINO_ARCH_AVR) + // AVR-specific code + #include + #elif defined(ARDUINO_ARCH_SAM) + // SAM-specific code + #elif defined(ARDUINO_ARCH_SAMD) + // SAMD-specific code + #else + // generic, non-platform specific code + #endif +#include "enc28j60.h" +#include "uip.h" +} + +#if defined(ARDUINO) + // set CS to 0 = active + #define CSACTIVE digitalWrite(ENC28J60ControlCS, LOW) + // set CS to 1 = passive + #define CSPASSIVE digitalWrite(ENC28J60ControlCS, HIGH) +#endif +#if defined(__MBED__) + // set CS to 0 = active + #define CSACTIVE _cs=0 + // set CS to 1 = passive + #define CSPASSIVE _cs=1 +#endif + +// +#if defined(ARDUINO_ARCH_AVR) +#define waitspi() while(!(SPSR&(1<=LOG_DEBUG + LogObject.uart_send_str(F("ENC28J60::init DEBUG:csPin = ")); + LogObject.uart_send_decln(ENC28J60ControlCS); + LogObject.uart_send_str(F("ENC28J60::init DEBUG:miso = ")); + LogObject.uart_send_decln(SPI_MISO); + LogObject.uart_send_str(F("ENC28J60::init DEBUG:mosi = ")); + LogObject.uart_send_decln(SPI_MOSI); + LogObject.uart_send_str(F("ENC28J60::init DEBUG:sck = ")); + LogObject.uart_send_decln(SPI_SCK); + #endif +#if ENC28J60_USE_SPILIB + #if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_strln(F("ENC28J60::init DEBUG:Use SPI lib SPI.begin()")); + #endif + #if defined(ARDUINO) + #if defined(__STM32F3__) || (!defined(ARDUINO_ARCH_STM32) && defined(STM32F3)) || defined(__STM32F4__) + SPI.begin(SPI_9MHZ, MSBFIRST, 0); + #else + SPI.begin(); + #endif + #endif + #if defined(ARDUINO_ARCH_AVR) + // AVR-specific code + SPI.setClockDivider(SPI_CLOCK_DIV2); //results in 8MHZ at 16MHZ system clock. + #elif defined(ARDUINO_ARCH_SAM) + // SAM-specific code + SPI.setClockDivider(10); //defaults to 21 which results in aprox. 4MHZ. A 10 should result in a little more than 8MHZ. + #elif defined(ARDUINO_ARCH_SAMD) + // SAMD-specific code + // Should we set clock divider? + SPI.setClockDivider(10); + #elif defined(__STM32F1__) || defined(__STM32F3__) + // generic, non-platform specific code + #define USE_STM32F1_DMAC 1 //on STM32 + // BOARD_NR_SPI >= 1 BOARD_SPI1_NSS_PIN, BOARD_SPI1_SCK_PIN, BOARD_SPI1_MISO_PIN, BOARD_SPI1_MOSI_PIN + SPI.setBitOrder(MSBFIRST); + SPI.setDataMode(SPI_MODE0); + SPI.setClockDivider(SPI_CLOCK_DIV8); //value 8 the result is 9MHz at 72MHz clock. + #else + #if defined(ARDUINO) + #if !defined(__STM32F3__) && !defined(STM32F3) && !defined(__STM32F4__) + SPI.setBitOrder(MSBFIRST); + #endif + //Settings for ESP8266 + //SPI.setDataMode(SPI_MODE0); + //SPI.setClockDivider(SPI_CLOCK_DIV16); + #endif + #if defined(__MBED__) + _spi.format(8, 0); // 8bit, mode 0 + _spi.frequency(7000000); // 7MHz + #endif + #endif +#else + #if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_strln(F("ENC28J60::init DEBUG:Use Native hardware SPI")); + #endif + pinMode(SPI_MOSI, OUTPUT); + pinMode(SPI_SCK, OUTPUT); + pinMode(SPI_MISO, INPUT); + //Hardware SS must be configured as OUTPUT to enable SPI-master (regardless of which pin is configured as ENC28J60ControlCS) + pinMode(SS, OUTPUT); + digitalWrite(SS,HIGH); + + digitalWrite(SPI_MOSI, LOW); + digitalWrite(SPI_SCK, LOW); + + // initialize SPI interface + // master mode and Fosc/2 clock: + SPCR = (1<=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("ENC28J60::init DEBUG_V3:Before readOp(ENC28J60_READ_CTRL_REG, ESTAT)")); + #endif + nextPacketPtr = RXSTART_INIT; + while ((!readOp(ENC28J60_READ_CTRL_REG, ESTAT) & ESTAT_CLKRDY) && (timeout>0)) + { + timeout=timeout-1; + delay(10); + #if defined(ESP8266) + wdt_reset(); + #endif + } + #if ACTLOGLEVEL>=LOG_ERR + if (timeout==0) {LogObject.uart_send_strln(F("ENC28J60::init ERROR:TIMEOUT !!"));} + #endif + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("ENC28J60::init DEBUG_V3:After readOp(ENC28J60_READ_CTRL_REG, ESTAT)")); + #endif + // Rx start + writeRegPair(ERXSTL, RXSTART_INIT); + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("ENC28J60::init DEBUG_V3:After writeRegPair(ERXSTL, RXSTART_INIT)")); + #endif + // set receive pointer address + writeRegPair(ERXRDPTL, RXSTART_INIT); + // RX end + writeRegPair(ERXNDL, RXSTOP_INIT); + // TX start + //writeRegPair(ETXSTL, TXSTART_INIT); + // TX end + //writeRegPair(ETXNDL, TXSTOP_INIT); + // do bank 1 stuff, packet filter: + // For broadcast packets we allow only ARP packtets + // All other packets should be unicast only for our mac (MAADR) + // + // The pattern to match on is therefore + // Type ETH.DST + // ARP BROADCAST + // 06 08 -- ff ff ff ff ff ff -> ip checksum for theses bytes=f7f9 + // in binary these poitions are:11 0000 0011 1111 + // This is hex 303F->EPMM0=0x3f,EPMM1=0x30 + //TODO define specific pattern to receive dhcp-broadcast packages instead of setting ERFCON_BCEN! +// enableBroadcast(); // change to add ERXFCON_BCEN recommended by epam + writeReg(ERXFCON, ERXFCON_UCEN|ERXFCON_CRCEN|ERXFCON_PMEN|ERXFCON_BCEN); + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("ENC28J60::init DEBUG_V3:After writeReg(ERXFCON, ERXFCON_UCEN|ERXFCON_CRCEN|ERXFCON_PMEN|ERXFCON_BCEN)")); + #endif + #if defined(ESP8266) + wdt_reset(); + #endif + writeRegPair(EPMM0, 0x303f); + writeRegPair(EPMCSL, 0xf7f9); + // + // + // do bank 2 stuff + // enable MAC receive + // and bring MAC out of reset (writes 0x00 to MACON2) + writeRegPair(MACON1, MACON1_MARXEN|MACON1_TXPAUS|MACON1_RXPAUS); + // enable automatic padding to 60bytes and CRC operations + writeOp(ENC28J60_BIT_FIELD_SET, MACON3, MACON3_PADCFG0|MACON3_TXCRCEN|MACON3_FRMLNEN); + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("ENC28J60::init DEBUG_V3:After writeOp(ENC28J60_BIT_FIELD_SET, MACON3, MACON3_PADCFG0|MACON3_TXCRCEN|MACON3_FRMLNEN)")); + #endif + // set inter-frame gap (non-back-to-back) + writeRegPair(MAIPGL, 0x0C12); + // set inter-frame gap (back-to-back) + writeReg(MABBIPG, 0x12); + // Set the maximum packet size which the controller will accept + // Do not send packets longer than MAX_FRAMELEN: + writeRegPair(MAMXFLL, MAX_FRAMELEN); + // do bank 3 stuff + // write MAC address + // NOTE: MAC address in ENC28J60 is byte-backward + writeReg(MAADR5, macaddr[0]); + writeReg(MAADR4, macaddr[1]); + writeReg(MAADR3, macaddr[2]); + writeReg(MAADR2, macaddr[3]); + writeReg(MAADR1, macaddr[4]); + writeReg(MAADR0, macaddr[5]); + // no loopback of transmitted frames + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("ENC28J60::init DEBUG_V3:Before phyWrite(PHCON2, PHCON2_HDLDIS)")); + #endif + phyWrite(PHCON2, PHCON2_HDLDIS); + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("ENC28J60::init DEBUG_V3:After phyWrite(PHCON2, PHCON2_HDLDIS)")); + #endif + // switch to bank 0 + setBank(ECON1); + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("ENC28J60::init DEBUG_V3:After setBank(ECON1)")); + #endif + // enable interrutps + writeOp(ENC28J60_BIT_FIELD_SET, EIE, EIE_INTIE|EIE_PKTIE); + // enable packet reception + writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_RXEN); + //Configure leds + phyWrite(PHLCON,0x476); + + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("ENC28J60::init DEBUG_V3:Before readReg(EREVID);")); + #endif + erevid=readReg(EREVID); + if (erevid==0xFF) {erevid=0;} + // microchip forgot to step the number on the silcon when they + // released the revision B7. 6 is now rev B7. We still have + // to see what they do when they release B8. At the moment + // there is no B8 out yet + //if (erevid > 5) ++erevid; + #if ACTLOGLEVEL>=LOG_INFO + LogObject.uart_send_str(F("ENC28J60::init INFO: Chip erevid=")); + LogObject.uart_send_dec(erevid); + LogObject.uart_send_strln(F(" initialization completed.")); + #endif + +// return Enc28J60Network::erevid; +} + +memhandle +Enc28J60Network::receivePacket(void) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::receivePacket(void) DEBUG_V3:Function started")); + #endif + #if defined(ESP8266) + wdt_reset(); + #endif + uint8_t rxstat; + uint16_t len; + // check if a packet has been received and buffered + //if( !(readReg(EIR) & EIR_PKTIF) ){ + // The above does not work. See Rev. B4 Silicon Errata point 6. + #if ACTLOGLEVEL>=LOG_ERR + if (erevid==0) + { + LogObject.uart_send_strln(F("Enc28J60Network::receivePacket(void) ERROR:ENC28j50 Device not found !! Bypass receivePacket function !!")); + } + #endif + uint8_t epktcnt=readReg(EPKTCNT); + if ((erevid!=0) && (epktcnt!=0)) + { + uint16_t readPtr = nextPacketPtr+6 > RXSTOP_INIT ? nextPacketPtr+6-((RXSTOP_INIT + 1)-RXSTART_INIT) : nextPacketPtr+6; + // Set the read pointer to the start of the received packet + writeRegPair(ERDPTL, nextPacketPtr); + // read the next packet pointer + nextPacketPtr = readOp(ENC28J60_READ_BUF_MEM, 0); + nextPacketPtr |= readOp(ENC28J60_READ_BUF_MEM, 0) << 8; + // read the packet length (see datasheet page 43) + len = readOp(ENC28J60_READ_BUF_MEM, 0); + len |= readOp(ENC28J60_READ_BUF_MEM, 0) << 8; + len -= 4; //remove the CRC count + // read the receive status (see datasheet page 43) + rxstat = readOp(ENC28J60_READ_BUF_MEM, 0); + //rxstat |= readOp(ENC28J60_READ_BUF_MEM, 0) << 8; + #if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_str(F("Enc28J60Network::receivePacket(void) DEBUG:receivePacket [")); + LogObject.uart_send_hex(readPtr); + LogObject.uart_send_str(F("-")); + LogObject.uart_send_hex((readPtr+len) % (RXSTOP_INIT+1)); + LogObject.uart_send_str(F("], next: ")); + LogObject.uart_send_hex(nextPacketPtr); + LogObject.uart_send_str(F(", stat: ")); + LogObject.uart_send_hex(rxstat); + LogObject.uart_send_str(F(", Packet count: ")); + LogObject.uart_send_dec(epktcnt); + LogObject.uart_send_str(F(" -> ")); + LogObject.uart_send_strln((rxstat & 0x80)!=0 ? "OK" : "failed"); + #endif + // decrement the packet counter indicate we are done with this packet + writeOp(ENC28J60_BIT_FIELD_SET, ECON2, ECON2_PKTDEC); + // check CRC and symbol errors (see datasheet page 44, table 7-3): + // The ERXFCON.CRCEN is set by default. Normally we should not + // need to check this. + if (((rxstat & 0x80) != 0) && (nextPacketPtr<=RXSTOP_INIT)) + { + receivePkt.begin = readPtr; + receivePkt.size = len; + #if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_str(F("Enc28J60Network::receivePacket(void) DEBUG: rxstat OK. receivePkt.size=")); + LogObject.uart_send_decln(len); + #endif + return UIP_RECEIVEBUFFERHANDLE; + } + // Move the RX read pointer to the start of the next received packet + // This frees the memory we just read out + setERXRDPT(); + } + return (NOBLOCK); +} + +void +Enc28J60Network::setERXRDPT(void) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::setERXRDPT(void) DEBUG_V3:Function started")); + #endif + // Make sure the value is odd. See Rev. B1,B4,B5,B7 Silicon Errata issues 14 + uint16_t actnextPacketPtr = nextPacketPtr == RXSTART_INIT ? RXSTOP_INIT : nextPacketPtr-1; + #if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_str(F("Enc28J60Network::setERXRDPT(void) DEBUG:Set actnextPacketPtr:")); + LogObject.uart_send_hexln(actnextPacketPtr); + #endif + // datasheet: The ENC28J60 will always write up to, but not including + writeRegPair(ERXRDPTL, actnextPacketPtr); +} + +memaddress +Enc28J60Network::blockSize(memhandle handle) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::blockSize(memhandle handle) DEBUG_V3:Function started")); + #endif + return ((handle == NOBLOCK) || (erevid==0)) ? 0 : handle == UIP_RECEIVEBUFFERHANDLE ? receivePkt.size : blocks[handle].size; +} + +bool +Enc28J60Network::sendPacket(memhandle handle) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::sendPacket(memhandle handle) INFO:Function started")); + #endif + #if defined(ESP8266) + wdt_reset(); + #endif + if (erevid==0) + { + #if ACTLOGLEVEL>=LOG_ERR + LogObject.uart_send_strln(F("Enc28J60Network::sendPacket(memhandle handle) ERROR:ENC28j50 Device not found !! Bypass sendPacket function !!")); + #endif + return false; + } + + memblock *packet = &blocks[handle]; + uint16_t start = packet->begin; // includes the UIP_SENDBUFFER_OFFSET for control byte + uint16_t end = start + packet->size - 1 - UIP_SENDBUFFER_PADDING; // end = start + size - 1 and padding for TSV is no included + + // write control-byte (if not 0 anyway) + writeByte(start, 0); + + #if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_str(F("Enc28J60Network::sendPacket(memhandle handle) DEBUG:sendPacket(")); + LogObject.uart_send_dec(handle); + LogObject.uart_send_str(F(") [")); + LogObject.uart_send_hex(start); + LogObject.uart_send_str(F("-")); + LogObject.uart_send_hex(end); + LogObject.uart_send_str(F("]: ")); + for (uint16_t i=start; i<=end; i++) + { + LogObject.uart_send_hex(readByte(i)); + LogObject.uart_send_str(F(" ")); + } + LogObject.uart_send_strln(F("")); + #endif + + // TX start + writeRegPair(ETXSTL, start); + // Set the TXND pointer to correspond to the packet size given + writeRegPair(ETXNDL, end); + + bool success = false; + // See Rev. B7 Silicon Errata issues 12 and 13 + for (uint8_t retry = 0; retry < TX_COLLISION_RETRY_COUNT; retry++) + { + // Reset the transmit logic problem. Errata 12 + writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_TXRST); + writeOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_TXRST); + writeOp(ENC28J60_BIT_FIELD_CLR, EIR, EIR_TXERIF | EIR_TXIF); + + // send the contents of the transmit buffer onto the network + writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_TXRTS); + + uint8_t eir; + // wait for transmission to complete or fail + while (((eir = readReg(EIR)) & (EIR_TXIF | EIR_TXERIF)) == 0); + writeOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_TXRTS); + success = ((eir & EIR_TXERIF) == 0); + if (success) + break; // usual exit of the for(retry) loop + + // Errata 13 detection + uint8_t tsv4 = readByte(end + 4); + if (!(tsv4 & 0b00100000)) // is it "late collision" indicated in bit 29 of TSV? + break; // other fail, not the Errata 13 situation + #if ACTLOGLEVEL>=LOG_ERROR + LogObject.uart_send_strln(F("Enc28J60Network::sendPacket(memhandle handle) Errata 13 LATE COLLISION !!")); + #endif + } + + return success; +} + +uint16_t +Enc28J60Network::setReadPtr(memhandle handle, memaddress position, uint16_t len) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::setReadPtr(memhandle handle, memaddress position, uint16_t len) DEBUG_V3:Function started")); + #endif + memblock *packet = handle == UIP_RECEIVEBUFFERHANDLE ? &receivePkt : &blocks[handle]; + memaddress start = handle == UIP_RECEIVEBUFFERHANDLE && packet->begin + position > RXSTOP_INIT ? packet->begin + position-((RXSTOP_INIT + 1)-RXSTART_INIT) : packet->begin + position; + + writeRegPair(ERDPTL, start); + + if (len > packet->size - position) + len = packet->size - position; + return len; +} + +uint16_t +Enc28J60Network::readPacket(memhandle handle, memaddress position, uint8_t* buffer, uint16_t len) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::readPacket(memhandle handle, memaddress position, uint8_t* buffer, uint16_t len) DEBUG_V3:Function started")); + #endif + #if defined(ESP8266) + wdt_reset(); + #endif + len = setReadPtr(handle, position, len); + readBuffer(len, buffer); + #if ACTLOGLEVEL>=LOG_DEBUG_V2 + LogObject.uart_send_str(F("Enc28J60Network::readPacket(memhandle handle, memaddress position, uint8_t* buffer, uint16_t len) DEBUG_V2: Read bytes:")); + LogObject.uart_send_dec(len); + LogObject.uart_send_str(F(" save to block(")); + LogObject.uart_send_dec(handle); + LogObject.uart_send_str(F(") [")); + LogObject.uart_send_hex(position); + LogObject.uart_send_str(F("]: ")); + for (uint16_t i=0; i=LOG_DEBUG_V3 + LogObject.uart_send_str(F("Enc28J60Network::writePacket(memhandle handle, memaddress position, uint8_t* buffer, uint16_t len) DEBUG_V3:Function started with len:")); + LogObject.uart_send_decln(len); + #endif + #if defined(ESP8266) + wdt_reset(); + #endif + memblock *packet = &blocks[handle]; + uint16_t start = packet->begin + position; + + writeRegPair(EWRPTL, start); + + if (len > packet->size - position) + len = packet->size - position; + writeBuffer(len, buffer); + #if ACTLOGLEVEL>=LOG_DEBUG_V2 + LogObject.uart_send_str(F("Enc28J60Network::writePacket(memhandle handle, memaddress position, uint8_t* buffer, uint16_t len) DEBUG_V2: Write bytes:")); + LogObject.uart_send_dec(len); + LogObject.uart_send_str(F(" save to block(")); + LogObject.uart_send_dec(handle); + LogObject.uart_send_str(F(") [")); + LogObject.uart_send_hex(start); + LogObject.uart_send_str(F("]: ")); + for (uint16_t i=0; i=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::enableBroadcast (bool temporary) DEBUG_V3:Function started")); + #endif + writeRegByte(ERXFCON, readRegByte(ERXFCON) | ERXFCON_BCEN); + if(!temporary) + broadcast_enabled = true; +} + +void Enc28J60Network::disableBroadcast (bool temporary) { + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::disableBroadcast (bool temporary) DEBUG_V3:Function started")); + #endif + if(!temporary) + broadcast_enabled = false; + if(!broadcast_enabled) + writeRegByte(ERXFCON, readRegByte(ERXFCON) & ~ERXFCON_BCEN); +} + +void Enc28J60Network::enableMulticast (void) { + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::enableMulticast (void) DEBUG_V3:Function started")); + #endif + writeRegByte(ERXFCON, readRegByte(ERXFCON) | ERXFCON_MCEN); +} + +void Enc28J60Network::disableMulticast (void) { + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::disableMulticast (void) DEBUG_V3:Function started")); + #endif + writeRegByte(ERXFCON, readRegByte(ERXFCON) & ~ERXFCON_MCEN); +} + +uint8_t Enc28J60Network::readRegByte (uint8_t address) { + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::readRegByte (uint8_t address) DEBUG_V3:Function started")); + #endif + setBank(address); + return readOp(ENC28J60_READ_CTRL_REG, address); +} + +void Enc28J60Network::writeRegByte (uint8_t address, uint8_t data) { + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::writeRegByte (uint8_t address, uint8_t data) DEBUG_V3:Function started")); + #endif + setBank(address); + writeOp(ENC28J60_WRITE_CTRL_REG, address, data); +} + + +uint8_t Enc28J60Network::readByte(uint16_t addr) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::readByte(uint16_t addr) DEBUG_V3:Function started")); + #endif + #if defined(ESP8266) + wdt_reset(); + #endif + writeRegPair(ERDPTL, addr); + + CSACTIVE; + #if ENC28J60_USE_SPILIB + // issue read command + #if defined(ARDUINO) + SPI.transfer(ENC28J60_READ_BUF_MEM); + // read data + uint8_t c = SPI.transfer(0x00); + #endif + #if defined(__MBED__) + _spi.write(ENC28J60_READ_BUF_MEM); + // read data + uint8_t c = _spi.write(0x00); + #endif + CSPASSIVE; + return (c); + #else + // issue read command + SPDR = ENC28J60_READ_BUF_MEM; + waitspi(); + // read data + SPDR = 0x00; + waitspi(); + CSPASSIVE; + return (SPDR); + #endif +} + +void Enc28J60Network::writeByte(uint16_t addr, uint8_t data) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::writeByte(uint16_t addr, uint8_t data) DEBUG_V3:Function started")); + #endif + #if defined(ESP8266) + wdt_reset(); + #endif + writeRegPair(EWRPTL, addr); + + CSACTIVE; + #if ENC28J60_USE_SPILIB + // issue write command + #if defined(ARDUINO) + SPI.transfer(ENC28J60_WRITE_BUF_MEM); + // write data + SPI.transfer(data); + #endif + #if defined(__MBED__) + _spi.write(ENC28J60_WRITE_BUF_MEM); + // write data + _spi.write(data); + #endif + #else + // issue write command + SPDR = ENC28J60_WRITE_BUF_MEM; + waitspi(); + // write data + SPDR = data; + waitspi(); + #endif + CSPASSIVE; +} + +void +Enc28J60Network::copyPacket(memhandle dest_pkt, memaddress dest_pos, memhandle src_pkt, memaddress src_pos, uint16_t len) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::copyPacket(memhandle dest_pkt, memaddress dest_pos, memhandle src_pkt, memaddress src_pos, uint16_t len) DEBUG_V3:Function started")); + #endif + memblock *dest = &blocks[dest_pkt]; + memblock *src = src_pkt == UIP_RECEIVEBUFFERHANDLE ? &receivePkt : &blocks[src_pkt]; + memaddress start = src_pkt == UIP_RECEIVEBUFFERHANDLE && src->begin + src_pos > RXSTOP_INIT ? src->begin + src_pos-((RXSTOP_INIT + 1)-RXSTART_INIT) : src->begin + src_pos; + enc28J60_mempool_block_move_callback(dest->begin+dest_pos,start,len); + // setERXRDPT(); let it to freePacket after all packets are saved +} + +void +enc28J60_mempool_block_move_callback(memaddress dest, memaddress src, memaddress len) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("enc28J60_mempool_block_move_callback(memaddress dest, memaddress src, memaddress len) DEBUG_V3:Function started")); + #endif +//void +//Enc28J60Network::memblock_mv_cb(uint16_t dest, uint16_t src, uint16_t len) +//{ + //as ENC28J60 DMA is unable to copy single bytes: + if (len == 1) + { + Enc28J60Network::writeByte(dest,Enc28J60Network::readByte(src)); + } + else + { + // calculate address of last byte + len += src - 1; + + /* 1. Appropriately program the EDMAST, EDMAND + and EDMADST register pairs. The EDMAST + registers should point to the first byte to copy + from, the EDMAND registers should point to the + last byte to copy and the EDMADST registers + should point to the first byte in the destination + range. The destination range will always be + linear, never wrapping at any values except from + 8191 to 0 (the 8-Kbyte memory boundary). + Extreme care should be taken when + programming the start and end pointers to + prevent a never ending DMA operation which + would overwrite the entire 8-Kbyte buffer. + */ + Enc28J60Network::writeRegPair(EDMASTL, src); + Enc28J60Network::writeRegPair(EDMADSTL, dest); + + if ((src <= RXSTOP_INIT)&& (len > RXSTOP_INIT))len -= ((RXSTOP_INIT + 1)-RXSTART_INIT); + Enc28J60Network::writeRegPair(EDMANDL, len); + + /* + 2. If an interrupt at the end of the copy process is + desired, set EIE.DMAIE and EIE.INTIE and + clear EIR.DMAIF. + + 3. Verify that ECON1.CSUMEN is clear. */ + Enc28J60Network::writeOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_CSUMEN); + + /* 4. Start the DMA copy by setting ECON1.DMAST. */ + Enc28J60Network::writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_DMAST); + + // wait until runnig DMA is completed + while (Enc28J60Network::readOp(ENC28J60_READ_CTRL_REG, ECON1) & ECON1_DMAST) + { + delay(1); + } + } +} + +void +Enc28J60Network::freePacket(void) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::freePacket(void) DEBUG_V3:Function started")); + #endif + setERXRDPT(); +} + +uint8_t +Enc28J60Network::readOp(uint8_t op, uint8_t address) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::readOp(uint8_t op, uint8_t address) DEBUG_V3:Function started")); + #endif + CSACTIVE; + // issue read command + #if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + SPI.transfer(op | (address & ADDR_MASK)); + // read data + if(address & 0x80) + { + // do dummy read if needed (for mac and mii, see datasheet page 29) + SPI.transfer(0x00); + } + uint8_t c = SPI.transfer(0x00); + #endif + #if defined(__MBED__) + _spi.write(op | (address & ADDR_MASK)); + // read data + if(address & 0x80) + { + // do dummy read if needed (for mac and mii, see datasheet page 29) + _spi.write(0x00); + } + uint8_t c = _spi.write(0x00); + #endif + // release CS + CSPASSIVE; + return(c); + #else + // issue read command + SPDR = op | (address & ADDR_MASK); + waitspi(); + // read data + SPDR = 0x00; + waitspi(); + // do dummy read if needed (for mac and mii, see datasheet page 29) + if(address & 0x80) + { + SPDR = 0x00; + waitspi(); + } + // release CS + CSPASSIVE; + return(SPDR); + #endif + #if defined(ESP8266) + yield(); + #endif +} + +void +Enc28J60Network::writeOp(uint8_t op, uint8_t address, uint8_t data) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::writeOp(uint8_t op, uint8_t address, uint8_t data) DEBUG_V3:Function started")); + #endif + CSACTIVE; + // issue write command + #if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + SPI.transfer(op | (address & ADDR_MASK)); + // write data + SPI.transfer(data); + #endif + #if defined(__MBED__) + _spi.write(op | (address & ADDR_MASK)); + // write data + _spi.write(data); + #endif + #else + // issue write command + SPDR = op | (address & ADDR_MASK); + waitspi(); + // write data + SPDR = data; + waitspi(); + #endif + CSPASSIVE; + #if defined(ESP8266) + yield(); + #endif +} + +void +Enc28J60Network::readBuffer(uint16_t len, uint8_t* data) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::readBuffer(uint16_t len, uint8_t* data) DEBUG_V3:Function started")); + #endif + CSACTIVE; + // issue read command + #if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + SPI.transfer(ENC28J60_READ_BUF_MEM); + #endif + #if defined(__MBED__) + _spi.write(ENC28J60_READ_BUF_MEM); + #endif + #else + SPDR = ENC28J60_READ_BUF_MEM; + waitspi(); + #endif + while(len) + { + len--; + // read data + #if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + *data = SPI.transfer(0x00); + #endif + #if defined(__MBED__) + *data = _spi.write(0x00); + #endif + #else + SPDR = 0x00; + waitspi(); + *data = SPDR; + #endif + data++; + } + //*data='\0'; + CSPASSIVE; +} + +void +Enc28J60Network::writeBuffer(uint16_t len, uint8_t* data) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::writeBuffer(uint16_t len, uint8_t* data) DEBUG_V3:Function started")); + #endif + CSACTIVE; + // issue write command + #if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + SPI.transfer(ENC28J60_WRITE_BUF_MEM); + #endif + #if defined(__MBED__) + _spi.write(ENC28J60_WRITE_BUF_MEM); + #endif + #else + SPDR = ENC28J60_WRITE_BUF_MEM; + waitspi(); + #endif + while(len) + { + len--; + // write data + #if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + SPI.transfer(*data); + #endif + #if defined(__MBED__) + _spi.write(*data); + #endif + data++; + #else + SPDR = *data; + data++; + waitspi(); + #endif + } + CSPASSIVE; +} + +void +Enc28J60Network::setBank(uint8_t address) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::setBank(uint8_t address) DEBUG_V3:Function started")); + #endif + // set the bank (if needed) + if((address & BANK_MASK) != bank) + { + // set the bank + writeOp(ENC28J60_BIT_FIELD_CLR, ECON1, (ECON1_BSEL1|ECON1_BSEL0)); + writeOp(ENC28J60_BIT_FIELD_SET, ECON1, (address & BANK_MASK)>>5); + bank = (address & BANK_MASK); + } +} + +uint8_t +Enc28J60Network::readReg(uint8_t address) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::readReg(uint8_t address) DEBUG_V3:Function started")); + #endif + // set the bank + setBank(address); + // do the read + return readOp(ENC28J60_READ_CTRL_REG, address); +} + +void +Enc28J60Network::writeReg(uint8_t address, uint8_t data) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::writeReg(uint8_t address, uint8_t data) DEBUG_V3:Function started")); + #endif + // set the bank + setBank(address); + // do the write + writeOp(ENC28J60_WRITE_CTRL_REG, address, data); +} + +void +Enc28J60Network::writeRegPair(uint8_t address, uint16_t data) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::writeRegPair(uint8_t address, uint16_t data) DEBUG_V3:Function started")); + #endif + // set the bank + setBank(address); + // do the write + writeOp(ENC28J60_WRITE_CTRL_REG, address, (data&0xFF)); + writeOp(ENC28J60_WRITE_CTRL_REG, address+1, (data) >> 8); +} + +void +Enc28J60Network::phyWrite(uint8_t address, uint16_t data) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::phyWrite(uint8_t address, uint16_t data) DEBUG_V3:Function started")); + #endif + unsigned int timeout = 15; + // set the PHY register address + writeReg(MIREGADR, address); + // write the PHY data + writeRegPair(MIWRL, data); + // wait until the PHY write completes + while (readReg(MISTAT) & MISTAT_BUSY) + { + delay(10); + #if defined(ESP8266) + wdt_reset(); + #endif + if (--timeout == 0) + { + #if ACTLOGLEVEL>=LOG_ERR + LogObject.uart_send_strln(F("Enc28J60Network::phyWrite ERROR:TIMEOUT !!")); + #endif + return; + } + } +} + +uint16_t +Enc28J60Network::phyRead(uint8_t address) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::phyRead(uint8_t address) DEBUG_V3:Function started")); + #endif + unsigned int timeout = 15; + writeReg(MIREGADR,address); + writeReg(MICMD, MICMD_MIIRD); + // wait until the PHY read completes + while(readReg(MISTAT) & MISTAT_BUSY) + { + delay(10); + #if defined(ESP8266) + wdt_reset(); + #endif + if (--timeout == 0) + { + #if ACTLOGLEVEL>=LOG_ERR + LogObject.uart_send_strln(F("Enc28J60Network::phyRead ERROR:TIMEOUT !!")); + #endif + return 0; + } + } + writeReg(MICMD, 0); + return (readReg(MIRDL) | readReg(MIRDH) << 8); +} + +void +Enc28J60Network::clkout(uint8_t clk) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::clkout(uint8_t clk) DEBUG_V3:Function started")); + #endif + //setup clkout: 2 is 12.5MHz: + writeReg(ECOCON, clk & 0x7); +} + +uint16_t +Enc28J60Network::chksum(uint16_t sum, memhandle handle, memaddress pos, uint16_t len) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::chksum(uint16_t sum, memhandle handle, memaddress pos, uint16_t len) DEBUG_V3:Function started")); + #endif + uint16_t t; + len = setReadPtr(handle, pos, len)-1; + CSACTIVE; + // issue read command + #if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + SPI.transfer(ENC28J60_READ_BUF_MEM); + #endif + #if defined(__MBED__) + _spi.write(ENC28J60_READ_BUF_MEM); + #endif + #else + SPDR = ENC28J60_READ_BUF_MEM; + waitspi(); + #endif + uint16_t i; + for (i = 0; i < len; i+=2) + { + // read data + #if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + t = SPI.transfer(0x00) << 8; + t += SPI.transfer(0x00); + #endif + #if defined(__MBED__) + t = _spi.write(0x00) << 8; + t += _spi.write(0x00); + #endif + #else + SPDR = 0x00; + waitspi(); + t = SPDR << 8; + SPDR = 0x00; + waitspi(); + t += SPDR; + #endif + sum += t; + if(sum < t) + { + sum++; /* carry */ + } + } + if(i == len) + { + #if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + t = (SPI.transfer(0x00) << 8) + 0; + #endif + #if defined(__MBED__) + t = (_spi.write(0x00) << 8) + 0; + #endif + #else + SPDR = 0x00; + waitspi(); + t = (SPDR << 8) + 0; + #endif + sum += t; + if(sum < t) + { + sum++; /* carry */ + } + } + CSPASSIVE; + + /* Return sum in host byte order. */ + return sum; +} + +void +Enc28J60Network::powerOff(void) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::powerOff(void) DEBUG_V3:Function started")); + #endif + writeOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_RXEN); + delay(50); + writeOp(ENC28J60_BIT_FIELD_SET, ECON2, ECON2_VRPS); + delay(50); + writeOp(ENC28J60_BIT_FIELD_SET, ECON2, ECON2_PWRSV); +} + +void +Enc28J60Network::powerOn(void) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::powerOn(void) DEBUG_V3:Function started")); + #endif + writeOp(ENC28J60_BIT_FIELD_CLR, ECON2, ECON2_PWRSV); + delay(50); + writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_RXEN); + delay(50); +} + +// read erevid from object: +uint8_t +Enc28J60Network::geterevid(void) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_str(F("Enc28J60Network::geterevid(void) DEBUG_V3:Function started and return:")); + LogObject.uart_send_decln(erevid); + #endif + return(erevid); +} + +// read the phstat2 of the chip: +uint16_t +Enc28J60Network::PhyStatus(void) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_str(F("Enc28J60Network::PhyStatus(void) DEBUG_V3:Function started")); + LogObject.uart_send_decln(erevid); + #endif + uint16_t phstat2; + phstat2=phyRead(PHSTAT2); + if ((phstat2 & 0x20) > 0) {phstat2=phstat2 &0x100;} + phstat2=(phstat2 & 0xFF00) | erevid; + if ((phstat2 & 0x8000) > 0) {phstat2=0;} + return phstat2; +} + +bool +Enc28J60Network::linkStatus(void) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::linkStatus(void) DEBUG_V3:Function started")); + #endif + return (phyRead(PHSTAT2) & 0x0400) > 0; +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet-2.0.9/utility/Enc28J60Network.h b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet-2.0.9/utility/Enc28J60Network.h new file mode 100644 index 0000000..5174462 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet-2.0.9/utility/Enc28J60Network.h @@ -0,0 +1,337 @@ +/* + Enc28J60NetworkClass.h + UIPEthernet network driver for Microchip ENC28J60 Ethernet Interface. + + Copyright (c) 2013 Norbert Truchsess + All rights reserved. + + inspired by enc28j60.c file from the AVRlib library by Pascal Stang. + For AVRlib See http://www.procyonengineering.com/ + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#ifndef Enc28J60Network_H_ +#define Enc28J60Network_H_ + +// KH mod +#if defined(ESP32) + //pin SS already defined in ESP32 as pin 5, don't use this as conflict with SPIFFS, EEPROM, etc. + // Use in GPIO13 + #warning ENC28J60Network.h => use ESP32, change ENC28J60_CONTROL_CS/SS_PIN_DEFAULT to GPIO13, MOSI(23), MISO(19), SCK(18) + #define ENC28J60_CONTROL_CS 13 +#endif + +// KH, For nRF52 +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #include + #define ENC28J60_USE_SPILIB 1 + + #ifndef USE_THIS_SS_PIN + // default to pin 10 + #define ENC28J60_CONTROL_CS 10 + #else + #warning Using USE_THIS_SS_PIN in Enc28J60Network.h for nRF52 + #define ENC28J60_CONTROL_CS USE_THIS_SS_PIN + #endif +#endif + +// KH, For SAMD21/SAMD51 +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #include + #define ENC28J60_USE_SPILIB 1 + + #ifndef USE_THIS_SS_PIN + // default to pin 10 + #define ENC28J60_CONTROL_CS 10 + #else + #warning Using USE_THIS_SS_PIN in Enc28J60Network.h for SAMD + #define ENC28J60_CONTROL_CS USE_THIS_SS_PIN + #endif +#endif +////// + +#include "mempool.h" +#if defined(__MBED__) + #include + //UIPEthernet(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS); + #if defined(TARGET_LPC1768) + #define SPI_MOSI p11 + #define SPI_MISO p12 + #define SPI_SCK p13 + #define SPI_CS p8 + #elif defined(TARGET_LPC1114) + #define SPI_MOSI dp2 + #define SPI_MISO dp1 + #define SPI_SCK dp6 + #define SPI_CS dp25 + #elif defined(TARGET_LPC11U68) + #define SPI_MOSI P0_9 + #define SPI_MISO P0_8 + #define SPI_SCK P1_29 + #define SPI_CS P0_2 + #elif defined(TARGET_NUCLEO_F103RB) || defined(TARGET_NUCLEO_L152RE) || defined(TARGET_NUCLEO_F030R8) \ + || defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_L053R8) \ + || defined(TARGET_NUCLEO_F411RE) || defined(TARGET_NUCLEO_F334R8) || defined(TARGET_NUCLEO_F072RB) \ + || defined(TARGET_NUCLEO_F091RC) || defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F070RB) + #define SPI_MOSI D4 + #define SPI_MISO D5 + #define SPI_SCK D3 + #define SPI_CS D2 + #endif + #define ENC28J60_CONTROL_CS SPI_CS +#endif + +#if defined(STM32F3) || defined(STM32F2) //This is workaround for stm32duino STM32F2, and adafruit wiced feather STM32F2 + #define BOARD_SPI1_NSS_PIN PA4 + #define BOARD_SPI1_SCK_PIN PA5 + #define BOARD_SPI1_MISO_PIN PA6 + #define BOARD_SPI1_MOSI_PIN PA7 +#endif //This is workaround for stm32duino STM32F3, and adafruit wiced feather STM32F2 + +#if defined(BOARD_discovery_f4) + #define __STM32F4__ +#endif +#if defined(__MK20DX128__) || defined(__MKL26Z64__) + #include +#endif + +#if !defined(ENC28J60_CONTROL_CS) + #if defined(__AVR__) || defined(ESP8266) || defined(__RFduino__) + // Arduino Uno (__AVR__) SS defined to pin 10 + // Arduino Leonardo (ARDUINO_AVR_LEONARDO) SS defined to LED_BUILTIN_RX (17) + // Arduino Mega(__AVR_ATmega2560__) SS defined to pin 53 + // ESP8266 (ESP8266) SS defined to pin 15 + #if defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_MICRO) + #define ENC28J60_CONTROL_CS PIN_A10 + #warning "Using LEONARDO borad PIN_A10 for ENC28J60_CONTROL_CS. Use UIPEthernet::init(uint8_t) to change it." + #else + #define ENC28J60_CONTROL_CS SS + #endif + #elif defined(ARDUINO_ARCH_AMEBA) //Defined SS to pin 10 + #define ENC28J60_CONTROL_CS SS //PC_0 A5 10 + #elif defined(ARDUINO_ARCH_SAM) + // Arduino Due (ARDUINO_ARCH_SAM) BOARD_SPI_DEFAULT_SS (SS3) defined to pin 78 + //#define ENC28J60_CONTROL_CS BOARD_SPI_DEFAULT_SS + #define ENC28J60_CONTROL_CS BOARD_SPI_SS0 + #elif defined(ARDUINO_ARCH_SAMD) + #define ENC28J60_CONTROL_CS SS + #elif defined(__ARDUINO_ARC__) //Intel ARC32 Genuino 101 + #define ENC28J60_CONTROL_CS SS + #elif defined(__RFduino__) //RFduino + #define ENC28J60_CONTROL_CS SS + #elif defined(ARDUINO_ARCH_STM32) // STM32duino core + #define ENC28J60_CONTROL_CS SS + #elif defined(ARDUINO_ARCH_ESP32) // arduino-esp32 + #define ENC28J60_CONTROL_CS SS + #elif defined(STM32_MCU_SERIES) || defined(__STM32F1__) || defined(__STM32F3__) || defined(STM32F3) || defined(__STM32F4__) || defined(STM32F2) + #if defined(BOARD_SPI1_NSS_PIN) + #define ENC28J60_CONTROL_CS BOARD_SPI1_NSS_PIN + #elif defined(ARDUINO_STM32F4_NETDUINO2PLUS) + #define ENC28J60_CONTROL_CS PC8 + #else + #define ENC28J60_CONTROL_CS SPI.nssPin() + //#define ENC28J60_CONTROL_CS PA4 + #endif + #elif defined(__MK20DX128__) || defined(__MKL26Z64__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1062__) + #define ENC28J60_CONTROL_CS PIN_SPI_SS + #endif +#endif +#if !defined(ENC28J60_CONTROL_CS) + #warning "Default ENC28J60_CONTROL_CS could not be defined! Use UIPEthernet::init(uint8_t) to set it." + #define ENC28J60_CONTROL_CS 0 +#endif + +extern uint8_t ENC28J60ControlCS; + +#if !defined(SPI_MOSI) + #if defined(__AVR__) || defined(ESP8266) || defined(__RFduino__) + #define SPI_MOSI MOSI + #elif defined(ARDUINO_ARCH_AMEBA) + #define SPI_MOSI 11 //PC_2 + #elif defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD) + #define SPI_MOSI PIN_SPI_MOSI + #elif defined(__ARDUINO_ARC__) //Intel ARC32 Genuino 101 + #define SPI_MOSI MOSI + #elif defined(__RFduino__) //RFduino + #define SPI_MOSI MOSI + #elif defined(ARDUINO_ARCH_STM32) // STM32duino core + #define SPI_MOSI MOSI + #elif defined(ARDUINO_ARCH_ESP32) // arduino-esp32 + #define SPI_MOSI MOSI + #elif defined(STM32_MCU_SERIES) || defined(__STM32F1__) || defined(__STM32F3__) || defined(STM32F3) || defined(__STM32F4__) || defined(STM32F2) + #if defined(BOARD_SPI1_MOSI_PIN) + #define SPI_MOSI BOARD_SPI1_MOSI_PIN + #else + #define SPI_MOSI SPI.mosiPin() + #endif + #elif defined(__MK20DX128__) || defined(__MKL26Z64__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1062__) + #define SPI_MOSI PIN_SPI_MOSI + #endif +#endif +#if !defined(SPI_MOSI) + // KH mod + //#error "Not defined SPI_MOSI!" + #define SPI_MOSI MOSI + ////// +#endif + +#if !defined(SPI_MISO) + #if defined(__AVR__) || defined(ESP8266) || defined(__RFduino__) + #define SPI_MISO MISO + #elif defined(ARDUINO_ARCH_AMEBA) + #define SPI_MISO 12 //PC_3 + #elif defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD) + #define SPI_MISO PIN_SPI_MISO + #elif defined(__ARDUINO_ARC__) //Intel ARC32 Genuino 101 + #define SPI_MISO MISO + #elif defined(__RFduino__) //RFduino + #define SPI_MISO MISO + #elif defined(ARDUINO_ARCH_STM32) // STM32duino core + #define SPI_MISO MISO + #elif defined(ARDUINO_ARCH_ESP32) // arduino-esp32 + #define SPI_MISO MISO + #elif defined(STM32_MCU_SERIES) || defined(__STM32F1__) || defined(__STM32F3__) || defined(STM32F3) || defined(__STM32F4__) || defined(STM32F2) + #if defined(BOARD_SPI1_MISO_PIN) + #define SPI_MISO BOARD_SPI1_MISO_PIN + #else + #define SPI_MISO SPI.misoPin() + #endif + #elif defined(__MK20DX128__) || defined(__MKL26Z64__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1062__) + #define SPI_MISO PIN_SPI_MISO + #endif +#endif +#if !defined(SPI_MISO) + // KH mod + //#error "Not defined SPI_MISO!" + #define SPI_MISO MISO + ////// +#endif +#if !defined(SPI_SCK) + #if defined(__AVR__) || defined(ESP8266) || defined(__RFduino__) + #define SPI_SCK SCK + #elif defined(ARDUINO_ARCH_AMEBA) + #define SPI_SCK 13 //PC_1 A4 + #elif defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD) + #define SPI_SCK PIN_SPI_SCK + #elif defined(__ARDUINO_ARC__) //Intel ARC32 Genuino 101 + #define SPI_SCK SCK + #elif defined(__RFduino__) //RFduino + #define SPI_SCK SCK + #elif defined(ARDUINO_ARCH_STM32) // STM32duino core + #define SPI_SCK SCK + #elif defined(ARDUINO_ARCH_ESP32) // arduino-esp32 + #define SPI_SCK SCK + #elif defined(STM32_MCU_SERIES) || defined(__STM32F1__) || defined(__STM32F3__) || defined(STM32F3) || defined(__STM32F4__) || defined(STM32F2) + #if defined(BOARD_SPI1_SCK_PIN) + #define SPI_SCK BOARD_SPI1_SCK_PIN + #else + #define SPI_SCK SPI.sckPin() + #endif + #elif defined(__MK20DX128__) || defined(__MKL26Z64__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1062__) + #define SPI_SCK PIN_SPI_SCK + #endif +#endif +#if !defined(SPI_SCK) + // KH, For nRF52 + //#error "Not defined SPI_SCK!" + #define SPI_SCK SCK + ////// +#endif + +#if defined(__MBED__) || defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD) || defined(__ARDUINO_ARC__) || defined(__STM32F1__) || defined(__STM32F3__) || defined(STM32F3) || defined(__STM32F4__) || defined(STM32F2) || defined(ESP8266) || defined(ARDUINO_ARCH_AMEBA) || defined(__MK20DX128__) || defined(__MKL26Z64__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1062__) || defined(__RFduino__) || defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR) + #if defined(ARDUINO) && (!defined(ARDUINO_ARCH_STM32) && defined(STM32F3)) + #include "HardwareSPI.h" + #else + #include + #endif + #define ENC28J60_USE_SPILIB 1 +#endif + +#define UIP_RECEIVEBUFFERHANDLE 0xff + +#define UIP_SENDBUFFER_PADDING 7 +#define UIP_SENDBUFFER_OFFSET 1 + +/* + * Empfangen von ip-header, arp etc... + * wenn tcp/udp -> tcp/udp-callback -> assign new packet to connection + */ + +#define TX_COLLISION_RETRY_COUNT 10 + +class Enc28J60Network : public MemoryPool +{ + +private: + static uint16_t nextPacketPtr; + static uint8_t bank; + static uint8_t erevid; + + static struct memblock receivePkt; + + static bool broadcast_enabled; //!< True if broadcasts enabled (used to allow temporary disable of broadcast for DHCP or other internal functions) + + static uint8_t readOp(uint8_t op, uint8_t address); + static void writeOp(uint8_t op, uint8_t address, uint8_t data); + static uint16_t setReadPtr(memhandle handle, memaddress position, uint16_t len); + static void setERXRDPT(void); + static void readBuffer(uint16_t len, uint8_t* data); + static void writeBuffer(uint16_t len, uint8_t* data); + static uint8_t readByte(uint16_t addr); + static void writeByte(uint16_t addr, uint8_t data); + static void setBank(uint8_t address); + static uint8_t readReg(uint8_t address); + static void writeReg(uint8_t address, uint8_t data); + static void writeRegPair(uint8_t address, uint16_t data); + static void phyWrite(uint8_t address, uint16_t data); + static uint16_t phyRead(uint8_t address); + static void clkout(uint8_t clk); + + static void enableBroadcast (bool temporary); + static void disableBroadcast (bool temporary); + static void enableMulticast (void); + static void disableMulticast (void); + + static uint8_t readRegByte (uint8_t address); + static void writeRegByte (uint8_t address, uint8_t data); + + friend void enc28J60_mempool_block_move_callback(memaddress,memaddress,memaddress); + +public: + + void powerOn(void); + void powerOff(void); + static uint8_t geterevid(void); + uint16_t PhyStatus(void); + static bool linkStatus(void); + + static void init(uint8_t* macaddr); + static memhandle receivePacket(void); + static void freePacket(void); + static memaddress blockSize(memhandle handle); + static bool sendPacket(memhandle handle); + static uint16_t readPacket(memhandle handle, memaddress position, uint8_t* buffer, uint16_t len); + static uint16_t writePacket(memhandle handle, memaddress position, uint8_t* buffer, uint16_t len); + static void copyPacket(memhandle dest, memaddress dest_pos, memhandle src, memaddress src_pos, uint16_t len); + static uint16_t chksum(uint16_t sum, memhandle handle, memaddress pos, uint16_t len); +}; + +#endif /* Enc28J60NetworkClass_H_ */ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet/UIPEthernet.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet/UIPEthernet.cpp new file mode 100644 index 0000000..df35732 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet/UIPEthernet.cpp @@ -0,0 +1,641 @@ +/* + UIPEthernet.cpp - Arduino implementation of a uIP wrapper class. + Copyright (c) 2013 Norbert Truchsess + All rights reserved. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#if defined(ARDUINO) + #include +#endif +#if defined(__MBED__) + #include + #include "mbed/millis.h" +#endif +#include "UIPEthernet.h" +#include "utility/logging.h" +#include "utility/Enc28J60Network.h" + +#include "UIPUdp.h" + +extern "C" +{ +#include "utility/uipopt.h" +#include "utility/uip.h" +#include "utility/uip_arp.h" +#include "utility/uip_timer.h" +} + +#define ETH_HDR ((struct uip_eth_hdr *)&uip_buf[0]) + +memhandle UIPEthernetClass::in_packet(NOBLOCK); +memhandle UIPEthernetClass::uip_packet(NOBLOCK); +uint8_t UIPEthernetClass::uip_hdrlen(0); +uint8_t UIPEthernetClass::packetstate(0); + +unsigned long UIPEthernetClass::periodic_timer; + +IPAddress UIPEthernetClass::_dnsServerAddress; +#if UIP_UDP + DhcpClass* UIPEthernetClass::_dhcp(NULL); + static DhcpClass s_dhcp; // Placing this instance here is saving 40K to final *.bin (see bug below) +#endif + +// Because uIP isn't encapsulated within a class we have to use global +// variables, so we can only have one TCP/IP stack per program. + +UIPEthernetClass::UIPEthernetClass() +{ +} + +void UIPEthernetClass::init(const uint8_t pin) +{ + ENC28J60ControlCS = pin; +} + +#if UIP_UDP +int +UIPEthernetClass::begin(const uint8_t* mac) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var _mac_address + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac, sizeof(_mac_address)); + ////// + + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::begin(const uint8_t* mac) DEBUG_V3:Function started")); + #endif + //static DhcpClass s_dhcp; // <-- this is a bug ! + // I leave it there commented for history. It is bring all GCC "new" memory allocation code, making the *.bin almost 40K bigger. I've move it globally. + _dhcp = &s_dhcp; + // Initialise the basic info + netInit(mac); + + // Now try to get our config info from a DHCP server + int ret = _dhcp->beginWithDHCP((uint8_t*)mac); + if(ret == 1) + { + // We've successfully found a DHCP server and got our configuration info, so set things + // accordingly + configure(_dhcp->getLocalIp(),_dhcp->getDnsServerIp(),_dhcp->getGatewayIp(),_dhcp->getSubnetMask()); + } + return ret; +} +#endif + +void +UIPEthernetClass::begin(const uint8_t* mac, IPAddress ip) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var _mac_address + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac, sizeof(_mac_address)); + ////// + + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::begin(const uint8_t* mac, IPAddress ip) DEBUG_V3:Function started")); + #endif + IPAddress dns = ip; + dns[3] = 1; + begin(mac, ip, dns); +} + +void +UIPEthernetClass::begin(const uint8_t* mac, IPAddress ip, IPAddress dns) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var _mac_address + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac, sizeof(_mac_address)); + ////// + + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::begin(const uint8_t* mac, IPAddress ip, IPAddress dns) DEBUG_V3:Function started")); + #endif + IPAddress gateway = ip; + gateway[3] = 1; + begin(mac, ip, dns, gateway); +} + +void +UIPEthernetClass::begin(const uint8_t* mac, IPAddress ip, IPAddress dns, IPAddress gateway) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var _mac_address + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac, sizeof(_mac_address)); + ////// + + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::begin(const uint8_t* mac, IPAddress ip, IPAddress dns, IPAddress gateway) DEBUG_V3:Function started")); + #endif + IPAddress subnet(255, 255, 255, 0); + begin(mac, ip, dns, gateway, subnet); +} + +void +UIPEthernetClass::begin(const uint8_t* mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet) +{ + // KH mod to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + // Now store to private var _mac_address + //uint8_t _mac_address[6] ={0,}; + memcpy(_mac_address, mac, sizeof(_mac_address)); + ////// + + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::begin(const uint8_t* mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet) DEBUG_V3:Function started")); + #endif + netInit(mac); + configure(ip,dns,gateway,subnet); +} + +int UIPEthernetClass::maintain(){ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::maintain() DEBUG_V3:Function started")); + #endif + tick(); + int rc = DHCP_CHECK_NONE; +#if UIP_UDP + if(_dhcp != NULL){ + //we have a pointer to dhcp, use it + rc = _dhcp->checkLease(); + switch ( rc ){ + case DHCP_CHECK_NONE: + //nothing done + break; + case DHCP_CHECK_RENEW_OK: + case DHCP_CHECK_REBIND_OK: + //we might have got a new IP. + configure(_dhcp->getLocalIp(),_dhcp->getDnsServerIp(),_dhcp->getGatewayIp(),_dhcp->getSubnetMask()); + break; + default: + //this is actually a error, it will retry though + break; + } + } + return rc; +#endif +} + +EthernetLinkStatus UIPEthernetClass::linkStatus() +{ + if (!Enc28J60.geterevid()) + return Unknown; + return Enc28J60.linkStatus() ? LinkON : LinkOFF; +} + +IPAddress UIPEthernetClass::localIP() +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::localIP() DEBUG_V3:Function started")); + #endif + IPAddress ret; + uip_ipaddr_t a; + uip_gethostaddr(a); + return ip_addr_uip(a); +} + +IPAddress UIPEthernetClass::subnetMask() +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::subnetMask() DEBUG_V3:Function started")); + #endif + IPAddress ret; + uip_ipaddr_t a; + uip_getnetmask(a); + return ip_addr_uip(a); +} + +IPAddress UIPEthernetClass::gatewayIP() +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::gatewayIP() DEBUG_V3:Function started")); + #endif + IPAddress ret; + uip_ipaddr_t a; + uip_getdraddr(a); + return ip_addr_uip(a); +} + +IPAddress UIPEthernetClass::dnsServerIP() +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::dnsServerIP() DEBUG_V3:Function started")); + #endif + return _dnsServerAddress; +} + +void +UIPEthernetClass::tick() +{ +#if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::tick() DEBUG_V3:Function started")); +#endif +if (Enc28J60Network::geterevid()==0) + { + #if ACTLOGLEVEL>=LOG_ERR + LogObject.uart_send_strln(F("UIPEthernetClass::tick() ERROR:EREVID=0 -> Not found ENC28j60 device !! Function ended !!")); + #endif + return; + } +#if defined(ESP8266) + wdt_reset(); +#endif + if (in_packet == NOBLOCK) + { + in_packet = Enc28J60Network::receivePacket(); + #if ACTLOGLEVEL>=LOG_DEBUG + if (in_packet != NOBLOCK) + { + LogObject.uart_send_str(F("UIPEthernetClass::tick() DEBUG:receivePacket: ")); + LogObject.uart_send_decln(in_packet); + } + #endif + } + if (in_packet != NOBLOCK) + { + packetstate = UIPETHERNET_FREEPACKET; + uip_len = Enc28J60Network::blockSize(in_packet); + if (uip_len > 0) + { + Enc28J60Network::readPacket(in_packet,0,(uint8_t*)uip_buf,UIP_BUFSIZE); + if (ETH_HDR ->type == HTONS(UIP_ETHTYPE_IP)) + { + uip_packet = in_packet; //required for upper_layer_checksum of in_packet! + #if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_str(F("UIPEthernetClass::tick() DEBUG:readPacket type IP, uip_len: ")); + LogObject.uart_send_decln(uip_len); + #endif + uip_arp_ipin(); + uip_input(); + if (uip_len > 0) + { + uip_arp_out(); + network_send(); + } + } + else if (ETH_HDR ->type == HTONS(UIP_ETHTYPE_ARP)) + { + #if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_str(F("UIPEthernetClass::tick() DEBUG:readPacket type ARP, uip_len: ")); + LogObject.uart_send_decln(uip_len); + #endif + uip_arp_arpin(); + if (uip_len > 0) + { + network_send(); + } + } + } + if (in_packet != NOBLOCK && (packetstate & UIPETHERNET_FREEPACKET)) + { + #if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_str(F("UIPEthernetClass::tick() DEBUG:freeing packet: ")); + LogObject.uart_send_decln(in_packet); + #endif + Enc28J60Network::freePacket(); + in_packet = NOBLOCK; + } + } + + unsigned long now = millis(); + +#if UIP_CLIENT_TIMER >= 0 + bool periodic = (long)( now - periodic_timer ) >= 0; + for (int i = 0; i < UIP_CONNS; i++) + { +#else + if ((long)( now - periodic_timer ) >= 0) + { + periodic_timer = now + UIP_PERIODIC_TIMER; + + for (int i = 0; i < UIP_CONNS; i++) + { +#endif + + uip_conn = &uip_conns[i]; + +#if UIP_CLIENT_TIMER >= 0 + if (periodic) + { +#endif + + uip_process(UIP_TIMER); + +#if UIP_CLIENT_TIMER >= 0 + } + else + { + if (uip_conn!=NULL) + { + if (((uip_userdata_t*)uip_conn->appstate)!=NULL) + { + if ((long)( now - ((uip_userdata_t*)uip_conn->appstate)->timer) >= 0) + { + uip_process(UIP_POLL_REQUEST); + } + else + { + continue; + } + } + else + { + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::tick() DEBUG_V3:((uip_userdata_t*)uip_conn->appstate) is NULL")); + #endif + if ((long)( now - ((uip_userdata_t*)uip_conn)->timer) >= 0) + { + uip_process(UIP_POLL_REQUEST); + } + else + { + continue; + } + } + } + else + { + #if ACTLOGLEVEL>=LOG_ERR + LogObject.uart_send_strln(F("UIPEthernetClass::tick() ERROR:uip_conn is NULL")); + #endif + continue; + } + } +#endif + // If the above function invocation resulted in data that + // should be sent out on the Enc28J60Network, the global variable + // uip_len is set to a value > 0. + if (uip_len > 0) + { + uip_arp_out(); + network_send(); + } + } +#if UIP_CLIENT_TIMER >= 0 + if (periodic) + { + periodic_timer = now + UIP_PERIODIC_TIMER; +#endif +#if UIP_UDP + for (int i = 0; i < UIP_UDP_CONNS; i++) + { + uip_udp_periodic(i); + // If the above function invocation resulted in data that + // should be sent out on the Enc28J60Network, the global variable + // uip_len is set to a value > 0. */ + if (uip_len > 0) + { + UIPUDP::_send((uip_udp_userdata_t *)(uip_udp_conns[i].appstate)); + } + } +#endif /* UIP_UDP */ + } +} + +bool UIPEthernetClass::network_send() +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::network_send() DEBUG_V3:Function started")); + #endif + if (packetstate & UIPETHERNET_SENDPACKET) + { +#if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_str(F("UIPEthernetClass::network_send() DEBUG:uip_packet: ")); + LogObject.uart_send_dec(uip_packet); + LogObject.uart_send_str(F(", hdrlen: ")); + LogObject.uart_send_decln(uip_hdrlen); +#endif + Enc28J60Network::writePacket(uip_packet,0,uip_buf,uip_hdrlen); + packetstate &= ~ UIPETHERNET_SENDPACKET; + goto sendandfree; + } + uip_packet = Enc28J60Network::allocBlock(uip_len); + if (uip_packet != NOBLOCK) + { +#if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_str(F("UIPEthernetClass::network_send() DEBUG:uip_buf (uip_len): ")); + LogObject.uart_send_dec(uip_len); + LogObject.uart_send_str(F(", packet: ")); + LogObject.uart_send_decln(uip_packet); +#endif + Enc28J60Network::writePacket(uip_packet,0,uip_buf,uip_len); + goto sendandfree; + } + return false; +sendandfree: + Enc28J60Network::sendPacket(uip_packet); + Enc28J60Network::freeBlock(uip_packet); + uip_packet = NOBLOCK; + return true; +} + +void UIPEthernetClass::netInit(const uint8_t* mac) { + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::netInit(const uint8_t* mac) DEBUG_V3:Function started")); + #endif + periodic_timer = millis() + UIP_PERIODIC_TIMER; + + Enc28J60Network::init((uint8_t*)mac); + uip_seteth_addr(mac); + + uip_init(); + uip_arp_init(); +} + +void UIPEthernetClass::configure(IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet) { + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::configure(IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet) DEBUG_V3:Function started")); + #endif + uip_ipaddr_t ipaddr; + + uip_ip_addr(ipaddr, ip); + uip_sethostaddr(ipaddr); + + uip_ip_addr(ipaddr, gateway); + uip_setdraddr(ipaddr); + + uip_ip_addr(ipaddr, subnet); + uip_setnetmask(ipaddr); + + _dnsServerAddress = dns; +} + +UIPEthernetClass UIPEthernet; + +/*---------------------------------------------------------------------------*/ +uint16_t +UIPEthernetClass::chksum(uint16_t sum, const uint8_t *data, uint16_t len) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::chksum(uint16_t sum, const uint8_t *data, uint16_t len) DEBUG_V3:Function started")); + #endif + uint16_t t; + const uint8_t *dataptr; + const uint8_t *last_byte; + + dataptr = data; + last_byte = data + len - 1; + + while(dataptr < last_byte) { /* At least two more bytes */ + t = (dataptr[0] << 8) + dataptr[1]; + sum += t; + if(sum < t) { + sum++; /* carry */ + } + dataptr += 2; + } + + if(dataptr == last_byte) { + t = (dataptr[0] << 8) + 0; + sum += t; + if(sum < t) { + sum++; /* carry */ + } + } + + /* Return sum in host byte order. */ + return sum; +} + +/*---------------------------------------------------------------------------*/ + +uint16_t +UIPEthernetClass::ipchksum(void) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("UIPEthernetClass::ipchksum(void) DEBUG_V3:Function started")); + #endif + uint16_t sum; + + sum = chksum(0, &uip_buf[UIP_LLH_LEN], UIP_IPH_LEN); + return (sum == 0) ? 0xffff : htons(sum); +} + +/*---------------------------------------------------------------------------*/ +uint16_t +#if UIP_UDP +UIPEthernetClass::upper_layer_chksum(uint8_t proto) +#else +uip_tcpchksum(void) +#endif +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + #if UIP_UDP + LogObject.uart_send_strln(F("UIPEthernetClass::upper_layer_chksum(uint8_t proto) DEBUG_V3:Function started")); + #else + LogObject.uart_send_strln(F("uip_tcpchksum(void) INFO:Function started")); + #endif + #endif + uint16_t upper_layer_len; + uint16_t sum; + +#if UIP_CONF_IPV6 + upper_layer_len = (((u16_t)(BUF->len[0]) << 8) + BUF->len[1]); +#else /* UIP_CONF_IPV6 */ + upper_layer_len = (((u16_t)(BUF->len[0]) << 8) + BUF->len[1]) - UIP_IPH_LEN; +#endif /* UIP_CONF_IPV6 */ + + /* First sum pseudoheader. */ + + /* IP protocol and length fields. This addition cannot carry. */ +#if UIP_UDP + sum = upper_layer_len + proto; +#else + sum = upper_layer_len + UIP_PROTO_TCP; +#endif + /* Sum IP source and destination addresses. */ + sum = UIPEthernetClass::chksum(sum, (u8_t *)&BUF->srcipaddr[0], 2 * sizeof(uip_ipaddr_t)); + + uint8_t upper_layer_memlen; +#if UIP_UDP + switch(proto) + { +// case UIP_PROTO_ICMP: +// case UIP_PROTO_ICMP6: +// upper_layer_memlen = upper_layer_len; +// break; + case UIP_PROTO_UDP: + upper_layer_memlen = UIP_UDPH_LEN; + break; + default: +// case UIP_PROTO_TCP: +#endif + upper_layer_memlen = (BUF->tcpoffset >> 4) << 2; +#if UIP_UDP + break; + } +#endif + sum = UIPEthernetClass::chksum(sum, &uip_buf[UIP_IPH_LEN + UIP_LLH_LEN], upper_layer_memlen); +#if ACTLOGLEVEL>=LOG_DEBUG + #if UIP_UDP + LogObject.uart_send_str(F("UIPEthernetClass::upper_layer_chksum(uint8_t proto) DEBUG:uip_buf[")); + #else + LogObject.uart_send_str(F("uip_tcpchksum(void) DEBUG:uip_buf[")); + #endif + LogObject.uart_send_dec(UIP_IPH_LEN + UIP_LLH_LEN); + LogObject.uart_send_str(F("-")); + LogObject.uart_send_dec(UIP_IPH_LEN + UIP_LLH_LEN + upper_layer_memlen); + LogObject.uart_send_str(F("]: ")); + LogObject.uart_send_hexln(htons(sum)); +#endif + if (upper_layer_memlen < upper_layer_len) + { + sum = Enc28J60Network::chksum( + sum, + UIPEthernetClass::uip_packet, + UIP_IPH_LEN + UIP_LLH_LEN + upper_layer_memlen, + upper_layer_len - upper_layer_memlen + ); +#if ACTLOGLEVEL>=LOG_DEBUG + #if UIP_UDP + LogObject.uart_send_str(F("UIPEthernetClass::upper_layer_chksum(uint8_t proto) DEBUG:uip_packet(")); + #else + LogObject.uart_send_str(F("uip_tcpchksum(void) DEBUG:uip_packet(")); + #endif + LogObject.uart_send_dec(UIPEthernetClass::uip_packet); + LogObject.uart_send_str(F(")[")); + LogObject.uart_send_dec(UIP_IPH_LEN + UIP_LLH_LEN + upper_layer_memlen); + LogObject.uart_send_str(F("-")); + LogObject.uart_send_dec(UIP_IPH_LEN + UIP_LLH_LEN + upper_layer_len); + LogObject.uart_send_str(F("]: ")); + LogObject.uart_send_hexln(htons(sum)); +#endif + } + return (sum == 0) ? 0xffff : htons(sum); +} + +uint16_t +uip_ipchksum(void) +{ + return UIPEthernet.ipchksum(); +} + +#if UIP_UDP +uint16_t +uip_tcpchksum(void) +{ + uint16_t sum = UIPEthernet.upper_layer_chksum(UIP_PROTO_TCP); + return sum; +} + +uint16_t +uip_udpchksum(void) +{ + uint16_t sum = UIPEthernet.upper_layer_chksum(UIP_PROTO_UDP); + return sum; +} +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet/UIPEthernet.h b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet/UIPEthernet.h new file mode 100644 index 0000000..d02e538 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet/UIPEthernet.h @@ -0,0 +1,158 @@ +/* + UIPEthernet.h - Arduino implementation of a uIP wrapper class. + Copyright (c) 2013 Norbert Truchsess + All rights reserved. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#ifndef UIPETHERNET_H +#define UIPETHERNET_H + +#include "ethernet_comp.h" +#if defined(__MBED__) + #include +#endif +#if defined(ARDUINO) + #include + #if defined(__STM32F3__) || defined(STM32F3) || defined(__RFduino__) + #include "mbed/IPAddress.h" + #else + #include "IPAddress.h" + #endif +#endif +#include "utility/Enc28J60Network.h" +#include "utility/uipopt.h" +#include "Dhcp.h" +#if UIP_UDP + #include "UIPUdp.h" +#endif +#include "UIPClient.h" +#include "UIPServer.h" + +extern "C" +{ +#include "utility/uip_timer.h" +#include "utility/uip.h" +} + +#define UIPETHERNET_FREEPACKET 1 +#define UIPETHERNET_SENDPACKET 2 +#define UIPETHERNET_BUFFERREAD 4 + +#define uip_ip_addr(addr, ip) do { \ + ((u16_t *)(addr))[0] = HTONS(((ip[0]) << 8) | (ip[1])); \ + ((u16_t *)(addr))[1] = HTONS(((ip[2]) << 8) | (ip[3])); \ + } while(0) + +#define ip_addr_uip(a) IPAddress(a[0] & 0xFF, a[0] >> 8 , a[1] & 0xFF, a[1] >> 8) //TODO this is not IPV6 capable + +#define uip_seteth_addr(eaddr) do {uip_ethaddr.addr[0] = eaddr[0]; \ + uip_ethaddr.addr[1] = eaddr[1];\ + uip_ethaddr.addr[2] = eaddr[2];\ + uip_ethaddr.addr[3] = eaddr[3];\ + uip_ethaddr.addr[4] = eaddr[4];\ + uip_ethaddr.addr[5] = eaddr[5];} while(0) + +#define BUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN]) + +enum EthernetLinkStatus { + Unknown, + LinkON, + LinkOFF +}; + +class UIPEthernetClass +{ +public: + UIPEthernetClass(); + + void init(const uint8_t pin); + + int begin(const uint8_t* mac); + void begin(const uint8_t* mac, IPAddress ip); + void begin(const uint8_t* mac, IPAddress ip, IPAddress dns); + void begin(const uint8_t* mac, IPAddress ip, IPAddress dns, IPAddress gateway); + void begin(const uint8_t* mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet); + + // maintain() must be called at regular intervals to process the incoming serial + // data and issue IP events to the sketch. It does not return until all IP + // events have been processed. Renews dhcp-lease if required. + int maintain(); + + EthernetLinkStatus linkStatus(); + + // KH add to have similar function to Ethernet lib + // Certainly we can use void macAddress(uint8_t mac[]) to read from W5x00. + void MACAddress(uint8_t *mac_address) + { + memcpy(mac_address, _mac_address, sizeof(_mac_address)); + } + ////// + + IPAddress localIP(); + IPAddress subnetMask(); + IPAddress gatewayIP(); + IPAddress dnsServerIP(); + +private: + + // KH add to work with new func void MACAddress(uint8_t *mac_address); and SinricPro v2.5.1+ + uint8_t _mac_address[6] ={0,}; + ////// + + static memhandle in_packet; + static memhandle uip_packet; + static uint8_t uip_hdrlen; + static uint8_t packetstate; + + static IPAddress _dnsServerAddress; + #if UIP_UDP + static DhcpClass* _dhcp; + #endif + static unsigned long periodic_timer; + + static void netInit(const uint8_t* mac); + static void configure(IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet); + + static void tick(); + + static bool network_send(); + + friend class UIPServer; + + friend class UIPClient; + + friend class UIPUDP; + + static uint16_t chksum(uint16_t sum, const uint8_t* data, uint16_t len); + static uint16_t ipchksum(void); +#if UIP_UDP + static uint16_t upper_layer_chksum(uint8_t proto); +#endif + friend uint16_t uip_ipchksum(void); + friend uint16_t uip_tcpchksum(void); + friend uint16_t uip_udpchksum(void); + + friend void uipclient_appcall(void); + friend void uipudp_appcall(void); + +#if UIP_CONF_IPV6 + uint16_t uip_icmp6chksum(void); +#endif /* UIP_CONF_IPV6 */ +}; + +extern UIPEthernetClass UIPEthernet; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet/utility/Enc28J60Network.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet/utility/Enc28J60Network.cpp new file mode 100644 index 0000000..a280225 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet/utility/Enc28J60Network.cpp @@ -0,0 +1,1244 @@ +/* + Enc28J60NetworkClass.h + UIPEthernet network driver for Microchip ENC28J60 Ethernet Interface. + + Copyright (c) 2013 Norbert Truchsess + All rights reserved. + + based on enc28j60.c file from the AVRlib library by Pascal Stang. + For AVRlib See http://www.procyonengineering.com/ + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + + +#include "Enc28J60Network.h" +#if defined(ARDUINO) + #include "Arduino.h" +#endif +#if defined(__MBED__) + #include + #include "mbed/millis.h" + #define delay(x) wait_ms(x) +#endif +#include "logging.h" + +// KH, For nRF52 +//#define ENC28J60_USE_SPILIB true + +uint8_t ENC28J60ControlCS = ENC28J60_CONTROL_CS; + +#if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + #if defined(STM32F2) + #include + #elif !defined(STM32F3) && !defined(__STM32F4__) + #include + extern SPIClass SPI; + //#elif defined(ARDUINO_ARCH_AMEBA) + //SPIClass SPI((void *)(&spi_obj), 11, 12, 13, 10); + //SPI _spi(SPI_MOSI,SPI_MISO,SPI_SCK,ENC28J60ControlCS); + #else + #include "HardwareSPI.h" + extern HardwareSPI SPI(1); + #endif + #endif + #if defined(__MBED__) + SPI _spi(SPI_MOSI,SPI_MISO,SPI_SCK); + DigitalOut _cs(ENC28J60ControlCS); + Serial LogObject(SERIAL_TX,SERIAL_RX); + #endif +#endif + +extern "C" { + #if defined(ARDUINO_ARCH_AVR) + // AVR-specific code + #include + #elif defined(ARDUINO_ARCH_SAM) + // SAM-specific code + #elif defined(ARDUINO_ARCH_SAMD) + // SAMD-specific code + #else + // generic, non-platform specific code + #endif +#include "enc28j60.h" +#include "uip.h" +} + +#if defined(ARDUINO) + // set CS to 0 = active + #define CSACTIVE digitalWrite(ENC28J60ControlCS, LOW) + // set CS to 1 = passive + #define CSPASSIVE digitalWrite(ENC28J60ControlCS, HIGH) +#endif +#if defined(__MBED__) + // set CS to 0 = active + #define CSACTIVE _cs=0 + // set CS to 1 = passive + #define CSPASSIVE _cs=1 +#endif + +// +#if defined(ARDUINO_ARCH_AVR) +#define waitspi() while(!(SPSR&(1<=LOG_DEBUG + LogObject.uart_send_str(F("ENC28J60::init DEBUG:csPin = ")); + LogObject.uart_send_decln(ENC28J60ControlCS); + LogObject.uart_send_str(F("ENC28J60::init DEBUG:miso = ")); + LogObject.uart_send_decln(SPI_MISO); + LogObject.uart_send_str(F("ENC28J60::init DEBUG:mosi = ")); + LogObject.uart_send_decln(SPI_MOSI); + LogObject.uart_send_str(F("ENC28J60::init DEBUG:sck = ")); + LogObject.uart_send_decln(SPI_SCK); + #endif +#if ENC28J60_USE_SPILIB + #if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_strln(F("ENC28J60::init DEBUG:Use SPI lib SPI.begin()")); + #endif + #if defined(ARDUINO) + #if defined(__STM32F3__) || defined(STM32F3) || defined(__STM32F4__) + SPI.begin(SPI_9MHZ, MSBFIRST, 0); + #else + SPI.begin(); + #endif + #endif + #if defined(ARDUINO_ARCH_AVR) + // AVR-specific code + SPI.setClockDivider(SPI_CLOCK_DIV2); //results in 8MHZ at 16MHZ system clock. + #elif defined(ARDUINO_ARCH_SAM) + // SAM-specific code + SPI.setClockDivider(10); //defaults to 21 which results in aprox. 4MHZ. A 10 should result in a little more than 8MHZ. + #elif defined(ARDUINO_ARCH_SAMD) + // SAMD-specific code + // Should we set clock divider? + SPI.setClockDivider(10); + #elif defined(__STM32F1__) || defined(__STM32F3__) + // generic, non-platform specific code + #define USE_STM32F1_DMAC 1 //on STM32 + // BOARD_NR_SPI >= 1 BOARD_SPI1_NSS_PIN, BOARD_SPI1_SCK_PIN, BOARD_SPI1_MISO_PIN, BOARD_SPI1_MOSI_PIN + SPI.setBitOrder(MSBFIRST); + SPI.setDataMode(SPI_MODE0); + SPI.setClockDivider(SPI_CLOCK_DIV8); //value 8 the result is 9MHz at 72MHz clock. + #else + #if defined(ARDUINO) + #if !defined(__STM32F3__) && !defined(STM32F3) && !defined(__STM32F4__) + SPI.setBitOrder(MSBFIRST); + #endif + //Settings for ESP8266 + //SPI.setDataMode(SPI_MODE0); + //SPI.setClockDivider(SPI_CLOCK_DIV16); + #endif + #if defined(__MBED__) + _spi.format(8, 0); // 8bit, mode 0 + _spi.frequency(7000000); // 7MHz + #endif + #endif +#else + #if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_strln(F("ENC28J60::init DEBUG:Use Native hardware SPI")); + #endif + pinMode(SPI_MOSI, OUTPUT); + pinMode(SPI_SCK, OUTPUT); + pinMode(SPI_MISO, INPUT); + //Hardware SS must be configured as OUTPUT to enable SPI-master (regardless of which pin is configured as ENC28J60ControlCS) + pinMode(SS, OUTPUT); + digitalWrite(SS,HIGH); + + digitalWrite(SPI_MOSI, LOW); + digitalWrite(SPI_SCK, LOW); + + // initialize SPI interface + // master mode and Fosc/2 clock: + SPCR = (1<=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("ENC28J60::init DEBUG_V3:Before readOp(ENC28J60_READ_CTRL_REG, ESTAT)")); + #endif + nextPacketPtr = RXSTART_INIT; + while ((!readOp(ENC28J60_READ_CTRL_REG, ESTAT) & ESTAT_CLKRDY) && (timeout>0)) + { + timeout=timeout-1; + delay(10); + #if defined(ESP8266) + wdt_reset(); + #endif + } + #if ACTLOGLEVEL>=LOG_ERR + if (timeout==0) {LogObject.uart_send_strln(F("ENC28J60::init ERROR:TIMEOUT !!"));} + #endif + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("ENC28J60::init DEBUG_V3:After readOp(ENC28J60_READ_CTRL_REG, ESTAT)")); + #endif + // Rx start + writeRegPair(ERXSTL, RXSTART_INIT); + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("ENC28J60::init DEBUG_V3:After writeRegPair(ERXSTL, RXSTART_INIT)")); + #endif + // set receive pointer address + writeRegPair(ERXRDPTL, RXSTART_INIT); + // RX end + writeRegPair(ERXNDL, RXSTOP_INIT); + // TX start + //writeRegPair(ETXSTL, TXSTART_INIT); + // TX end + //writeRegPair(ETXNDL, TXSTOP_INIT); + // do bank 1 stuff, packet filter: + // For broadcast packets we allow only ARP packtets + // All other packets should be unicast only for our mac (MAADR) + // + // The pattern to match on is therefore + // Type ETH.DST + // ARP BROADCAST + // 06 08 -- ff ff ff ff ff ff -> ip checksum for theses bytes=f7f9 + // in binary these poitions are:11 0000 0011 1111 + // This is hex 303F->EPMM0=0x3f,EPMM1=0x30 + //TODO define specific pattern to receive dhcp-broadcast packages instead of setting ERFCON_BCEN! +// enableBroadcast(); // change to add ERXFCON_BCEN recommended by epam + writeReg(ERXFCON, ERXFCON_UCEN|ERXFCON_CRCEN|ERXFCON_PMEN|ERXFCON_BCEN); + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("ENC28J60::init DEBUG_V3:After writeReg(ERXFCON, ERXFCON_UCEN|ERXFCON_CRCEN|ERXFCON_PMEN|ERXFCON_BCEN)")); + #endif + #if defined(ESP8266) + wdt_reset(); + #endif + writeRegPair(EPMM0, 0x303f); + writeRegPair(EPMCSL, 0xf7f9); + // + // + // do bank 2 stuff + // enable MAC receive + // and bring MAC out of reset (writes 0x00 to MACON2) + writeRegPair(MACON1, MACON1_MARXEN|MACON1_TXPAUS|MACON1_RXPAUS); + // enable automatic padding to 60bytes and CRC operations + writeOp(ENC28J60_BIT_FIELD_SET, MACON3, MACON3_PADCFG0|MACON3_TXCRCEN|MACON3_FRMLNEN); + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("ENC28J60::init DEBUG_V3:After writeOp(ENC28J60_BIT_FIELD_SET, MACON3, MACON3_PADCFG0|MACON3_TXCRCEN|MACON3_FRMLNEN)")); + #endif + // set inter-frame gap (non-back-to-back) + writeRegPair(MAIPGL, 0x0C12); + // set inter-frame gap (back-to-back) + writeReg(MABBIPG, 0x12); + // Set the maximum packet size which the controller will accept + // Do not send packets longer than MAX_FRAMELEN: + writeRegPair(MAMXFLL, MAX_FRAMELEN); + // do bank 3 stuff + // write MAC address + // NOTE: MAC address in ENC28J60 is byte-backward + writeReg(MAADR5, macaddr[0]); + writeReg(MAADR4, macaddr[1]); + writeReg(MAADR3, macaddr[2]); + writeReg(MAADR2, macaddr[3]); + writeReg(MAADR1, macaddr[4]); + writeReg(MAADR0, macaddr[5]); + // no loopback of transmitted frames + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("ENC28J60::init DEBUG_V3:Before phyWrite(PHCON2, PHCON2_HDLDIS)")); + #endif + phyWrite(PHCON2, PHCON2_HDLDIS); + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("ENC28J60::init DEBUG_V3:After phyWrite(PHCON2, PHCON2_HDLDIS)")); + #endif + // switch to bank 0 + setBank(ECON1); + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("ENC28J60::init DEBUG_V3:After setBank(ECON1)")); + #endif + // enable interrutps + writeOp(ENC28J60_BIT_FIELD_SET, EIE, EIE_INTIE|EIE_PKTIE); + // enable packet reception + writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_RXEN); + //Configure leds + phyWrite(PHLCON,0x476); + + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("ENC28J60::init DEBUG_V3:Before readReg(EREVID);")); + #endif + erevid=readReg(EREVID); + if (erevid==0xFF) {erevid=0;} + // microchip forgot to step the number on the silcon when they + // released the revision B7. 6 is now rev B7. We still have + // to see what they do when they release B8. At the moment + // there is no B8 out yet + //if (erevid > 5) ++erevid; + #if ACTLOGLEVEL>=LOG_INFO + LogObject.uart_send_str(F("ENC28J60::init INFO: Chip erevid=")); + LogObject.uart_send_dec(erevid); + LogObject.uart_send_strln(F(" initialization completed.")); + #endif + +// return Enc28J60Network::erevid; +} + +memhandle +Enc28J60Network::receivePacket(void) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::receivePacket(void) DEBUG_V3:Function started")); + #endif + #if defined(ESP8266) + wdt_reset(); + #endif + uint8_t rxstat; + uint16_t len; + // check if a packet has been received and buffered + //if( !(readReg(EIR) & EIR_PKTIF) ){ + // The above does not work. See Rev. B4 Silicon Errata point 6. + #if ACTLOGLEVEL>=LOG_ERR + if (erevid==0) + { + LogObject.uart_send_strln(F("Enc28J60Network::receivePacket(void) ERROR:ENC28j50 Device not found !! Bypass receivePacket function !!")); + } + #endif + uint8_t epktcnt=readReg(EPKTCNT); + if ((erevid!=0) && (epktcnt!=0)) + { + uint16_t readPtr = nextPacketPtr+6 > RXSTOP_INIT ? nextPacketPtr+6-RXSTOP_INIT+RXSTART_INIT : nextPacketPtr+6; + // Set the read pointer to the start of the received packet + writeRegPair(ERDPTL, nextPacketPtr); + // read the next packet pointer + nextPacketPtr = readOp(ENC28J60_READ_BUF_MEM, 0); + nextPacketPtr |= readOp(ENC28J60_READ_BUF_MEM, 0) << 8; + // read the packet length (see datasheet page 43) + len = readOp(ENC28J60_READ_BUF_MEM, 0); + len |= readOp(ENC28J60_READ_BUF_MEM, 0) << 8; + len -= 4; //remove the CRC count + // read the receive status (see datasheet page 43) + rxstat = readOp(ENC28J60_READ_BUF_MEM, 0); + //rxstat |= readOp(ENC28J60_READ_BUF_MEM, 0) << 8; + #if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_str(F("Enc28J60Network::receivePacket(void) DEBUG:receivePacket [")); + LogObject.uart_send_hex(readPtr); + LogObject.uart_send_str(F("-")); + LogObject.uart_send_hex((readPtr+len) % (RXSTOP_INIT+1)); + LogObject.uart_send_str(F("], next: ")); + LogObject.uart_send_hex(nextPacketPtr); + LogObject.uart_send_str(F(", stat: ")); + LogObject.uart_send_hex(rxstat); + LogObject.uart_send_str(F(", Packet count: ")); + LogObject.uart_send_dec(epktcnt); + LogObject.uart_send_str(F(" -> ")); + LogObject.uart_send_strln((rxstat & 0x80)!=0 ? "OK" : "failed"); + #endif + // decrement the packet counter indicate we are done with this packet + writeOp(ENC28J60_BIT_FIELD_SET, ECON2, ECON2_PKTDEC); + // check CRC and symbol errors (see datasheet page 44, table 7-3): + // The ERXFCON.CRCEN is set by default. Normally we should not + // need to check this. + if (((rxstat & 0x80) != 0) && (nextPacketPtr<=RXSTOP_INIT)) + { + receivePkt.begin = readPtr; + receivePkt.size = len; + #if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_str(F("Enc28J60Network::receivePacket(void) DEBUG: rxstat OK. receivePkt.size=")); + LogObject.uart_send_decln(len); + #endif + return UIP_RECEIVEBUFFERHANDLE; + } + // Move the RX read pointer to the start of the next received packet + // This frees the memory we just read out + setERXRDPT(); + } + return (NOBLOCK); +} + +void +Enc28J60Network::setERXRDPT(void) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::setERXRDPT(void) DEBUG_V3:Function started")); + #endif + // Make sure the value is odd. See Rev. B1,B4,B5,B7 Silicon Errata issues 14 + uint16_t actnextPacketPtr = nextPacketPtr == RXSTART_INIT ? RXSTOP_INIT : nextPacketPtr-1; + #if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_str(F("Enc28J60Network::setERXRDPT(void) DEBUG:Set actnextPacketPtr:")); + LogObject.uart_send_hexln(actnextPacketPtr); + #endif + // datasheet: The ENC28J60 will always write up to, but not including + writeRegPair(ERXRDPTL, actnextPacketPtr); +} + +memaddress +Enc28J60Network::blockSize(memhandle handle) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::blockSize(memhandle handle) DEBUG_V3:Function started")); + #endif + return ((handle == NOBLOCK) || (erevid==0)) ? 0 : handle == UIP_RECEIVEBUFFERHANDLE ? receivePkt.size : blocks[handle].size; +} + +void +Enc28J60Network::sendPacket(memhandle handle) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::sendPacket(memhandle handle) INFO:Function started")); + #endif + #if defined(ESP8266) + wdt_reset(); + #endif + if (erevid==0) + { + #if ACTLOGLEVEL>=LOG_ERR + LogObject.uart_send_strln(F("Enc28J60Network::sendPacket(memhandle handle) ERROR:ENC28j50 Device not found !! Bypass sendPacket function !!")); + #endif + return; + } + + memblock *packet = &blocks[handle]; + uint16_t start = packet->begin-1; + uint16_t end = start + packet->size; + + // backup data at control-byte position + uint8_t data = readByte(start); + // write control-byte (if not 0 anyway) + if (data) + writeByte(start, 0); + + #if ACTLOGLEVEL>=LOG_DEBUG + LogObject.uart_send_str(F("Enc28J60Network::sendPacket(memhandle handle) DEBUG:sendPacket(")); + LogObject.uart_send_dec(handle); + LogObject.uart_send_str(F(") [")); + LogObject.uart_send_hex(start); + LogObject.uart_send_str(F("-")); + LogObject.uart_send_hex(end); + LogObject.uart_send_str(F("]: ")); + for (uint16_t i=start; i<=end; i++) + { + LogObject.uart_send_hex(readByte(i)); + LogObject.uart_send_str(F(" ")); + } + LogObject.uart_send_strln(F("")); + #endif + + // TX start + writeRegPair(ETXSTL, start); + // Set the TXND pointer to correspond to the packet size given + writeRegPair(ETXNDL, end); + // send the contents of the transmit buffer onto the network + + unsigned int retry = TX_COLLISION_RETRY_COUNT; + unsigned int timeout = 100; + do + { + // seydamir added + // Reset the transmit logic problem. See Rev. B7 Silicon Errata issues 12 and 13 + writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_TXRST); + writeOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_TXRST); + writeOp(ENC28J60_BIT_FIELD_CLR, EIR, EIR_TXERIF | EIR_TXIF); + // end + + writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_TXRTS); + // Reset the transmit logic problem. See Rev. B4 Silicon Errata point 12. + //if( (readReg(EIR) & EIR_TXERIF) ) + // { + // writeOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_TXRTS); + // } + + timeout = 100; + while (((readReg(EIR) & (EIR_TXIF | EIR_TXERIF)) == 0) && (timeout>0)) + { + timeout=timeout-1; + delay(10); + #if defined(ESP8266) + wdt_reset(); + #endif + } + if (timeout==0) + { + /* Transmit hardware probably hung, try again later. */ + /* Shouldn't happen according to errata 12 and 13. */ + writeOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_TXRTS); + #if ACTLOGLEVEL>=LOG_WARN + LogObject.uart_send_strln(F("Enc28J60Network::sendPacket(memhandle handle) WARNING:Collision")); + #endif + retry=retry-1; + } + } while ((timeout == 0) && (retry != 0)); + + //restore data on control-byte position + if (data) + writeByte(start, data); + + if (retry == 0) + { + #if ACTLOGLEVEL>=LOG_ERROR + LogObject.uart_send_strln(F("Enc28J60Network::sendPacket(memhandle handle) ERROR:COLLISION !!")); + #endif + return; + } +} + +uint16_t +Enc28J60Network::setReadPtr(memhandle handle, memaddress position, uint16_t len) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::setReadPtr(memhandle handle, memaddress position, uint16_t len) DEBUG_V3:Function started")); + #endif + memblock *packet = handle == UIP_RECEIVEBUFFERHANDLE ? &receivePkt : &blocks[handle]; + memaddress start = handle == UIP_RECEIVEBUFFERHANDLE && packet->begin + position > RXSTOP_INIT ? packet->begin + position-RXSTOP_INIT+RXSTART_INIT : packet->begin + position; + + writeRegPair(ERDPTL, start); + + if (len > packet->size - position) + len = packet->size - position; + return len; +} + +uint16_t +Enc28J60Network::readPacket(memhandle handle, memaddress position, uint8_t* buffer, uint16_t len) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::readPacket(memhandle handle, memaddress position, uint8_t* buffer, uint16_t len) DEBUG_V3:Function started")); + #endif + #if defined(ESP8266) + wdt_reset(); + #endif + len = setReadPtr(handle, position, len); + readBuffer(len, buffer); + #if ACTLOGLEVEL>=LOG_DEBUG_V2 + LogObject.uart_send_str(F("Enc28J60Network::readPacket(memhandle handle, memaddress position, uint8_t* buffer, uint16_t len) DEBUG_V2: Read bytes:")); + LogObject.uart_send_dec(len); + LogObject.uart_send_str(F(" save to block(")); + LogObject.uart_send_dec(handle); + LogObject.uart_send_str(F(") [")); + LogObject.uart_send_hex(position); + LogObject.uart_send_str(F("]: ")); + for (uint16_t i=0; i=LOG_DEBUG_V3 + LogObject.uart_send_str(F("Enc28J60Network::writePacket(memhandle handle, memaddress position, uint8_t* buffer, uint16_t len) DEBUG_V3:Function started with len:")); + LogObject.uart_send_decln(len); + #endif + #if defined(ESP8266) + wdt_reset(); + #endif + memblock *packet = &blocks[handle]; + uint16_t start = packet->begin + position; + + writeRegPair(EWRPTL, start); + + if (len > packet->size - position) + len = packet->size - position; + writeBuffer(len, buffer); + #if ACTLOGLEVEL>=LOG_DEBUG_V2 + LogObject.uart_send_str(F("Enc28J60Network::writePacket(memhandle handle, memaddress position, uint8_t* buffer, uint16_t len) DEBUG_V2: Write bytes:")); + LogObject.uart_send_dec(len); + LogObject.uart_send_str(F(" save to block(")); + LogObject.uart_send_dec(handle); + LogObject.uart_send_str(F(") [")); + LogObject.uart_send_hex(start); + LogObject.uart_send_str(F("]: ")); + for (uint16_t i=0; i=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::enableBroadcast (bool temporary) DEBUG_V3:Function started")); + #endif + writeRegByte(ERXFCON, readRegByte(ERXFCON) | ERXFCON_BCEN); + if(!temporary) + broadcast_enabled = true; +} + +void Enc28J60Network::disableBroadcast (bool temporary) { + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::disableBroadcast (bool temporary) DEBUG_V3:Function started")); + #endif + if(!temporary) + broadcast_enabled = false; + if(!broadcast_enabled) + writeRegByte(ERXFCON, readRegByte(ERXFCON) & ~ERXFCON_BCEN); +} + +void Enc28J60Network::enableMulticast (void) { + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::enableMulticast (void) DEBUG_V3:Function started")); + #endif + writeRegByte(ERXFCON, readRegByte(ERXFCON) | ERXFCON_MCEN); +} + +void Enc28J60Network::disableMulticast (void) { + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::disableMulticast (void) DEBUG_V3:Function started")); + #endif + writeRegByte(ERXFCON, readRegByte(ERXFCON) & ~ERXFCON_MCEN); +} + +uint8_t Enc28J60Network::readRegByte (uint8_t address) { + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::readRegByte (uint8_t address) DEBUG_V3:Function started")); + #endif + setBank(address); + return readOp(ENC28J60_READ_CTRL_REG, address); +} + +void Enc28J60Network::writeRegByte (uint8_t address, uint8_t data) { + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::writeRegByte (uint8_t address, uint8_t data) DEBUG_V3:Function started")); + #endif + setBank(address); + writeOp(ENC28J60_WRITE_CTRL_REG, address, data); +} + + +uint8_t Enc28J60Network::readByte(uint16_t addr) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::readByte(uint16_t addr) DEBUG_V3:Function started")); + #endif + #if defined(ESP8266) + wdt_reset(); + #endif + writeRegPair(ERDPTL, addr); + + CSACTIVE; + #if ENC28J60_USE_SPILIB + // issue read command + #if defined(ARDUINO) + SPI.transfer(ENC28J60_READ_BUF_MEM); + // read data + uint8_t c = SPI.transfer(0x00); + #endif + #if defined(__MBED__) + _spi.write(ENC28J60_READ_BUF_MEM); + // read data + uint8_t c = _spi.write(0x00); + #endif + CSPASSIVE; + return (c); + #else + // issue read command + SPDR = ENC28J60_READ_BUF_MEM; + waitspi(); + // read data + SPDR = 0x00; + waitspi(); + CSPASSIVE; + return (SPDR); + #endif +} + +void Enc28J60Network::writeByte(uint16_t addr, uint8_t data) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::writeByte(uint16_t addr, uint8_t data) DEBUG_V3:Function started")); + #endif + #if defined(ESP8266) + wdt_reset(); + #endif + writeRegPair(EWRPTL, addr); + + CSACTIVE; + #if ENC28J60_USE_SPILIB + // issue write command + #if defined(ARDUINO) + SPI.transfer(ENC28J60_WRITE_BUF_MEM); + // write data + SPI.transfer(data); + #endif + #if defined(__MBED__) + _spi.write(ENC28J60_WRITE_BUF_MEM); + // write data + _spi.write(data); + #endif + #else + // issue write command + SPDR = ENC28J60_WRITE_BUF_MEM; + waitspi(); + // write data + SPDR = data; + waitspi(); + #endif + CSPASSIVE; +} + +void +Enc28J60Network::copyPacket(memhandle dest_pkt, memaddress dest_pos, memhandle src_pkt, memaddress src_pos, uint16_t len) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::copyPacket(memhandle dest_pkt, memaddress dest_pos, memhandle src_pkt, memaddress src_pos, uint16_t len) DEBUG_V3:Function started")); + #endif + memblock *dest = &blocks[dest_pkt]; + memblock *src = src_pkt == UIP_RECEIVEBUFFERHANDLE ? &receivePkt : &blocks[src_pkt]; + memaddress start = src_pkt == UIP_RECEIVEBUFFERHANDLE && src->begin + src_pos > RXSTOP_INIT ? src->begin + src_pos-RXSTOP_INIT+RXSTART_INIT : src->begin + src_pos; + enc28J60_mempool_block_move_callback(dest->begin+dest_pos,start,len); + // setERXRDPT(); let it to freePacket after all packets are saved +} + +void +enc28J60_mempool_block_move_callback(memaddress dest, memaddress src, memaddress len) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("enc28J60_mempool_block_move_callback(memaddress dest, memaddress src, memaddress len) DEBUG_V3:Function started")); + #endif +//void +//Enc28J60Network::memblock_mv_cb(uint16_t dest, uint16_t src, uint16_t len) +//{ + //as ENC28J60 DMA is unable to copy single bytes: + if (len == 1) + { + Enc28J60Network::writeByte(dest,Enc28J60Network::readByte(src)); + } + else + { + // calculate address of last byte + len += src - 1; + + /* 1. Appropriately program the EDMAST, EDMAND + and EDMADST register pairs. The EDMAST + registers should point to the first byte to copy + from, the EDMAND registers should point to the + last byte to copy and the EDMADST registers + should point to the first byte in the destination + range. The destination range will always be + linear, never wrapping at any values except from + 8191 to 0 (the 8-Kbyte memory boundary). + Extreme care should be taken when + programming the start and end pointers to + prevent a never ending DMA operation which + would overwrite the entire 8-Kbyte buffer. + */ + Enc28J60Network::writeRegPair(EDMASTL, src); + Enc28J60Network::writeRegPair(EDMADSTL, dest); + + if ((src <= RXSTOP_INIT)&& (len > RXSTOP_INIT))len -= ((RXSTOP_INIT + 1)-RXSTART_INIT); + Enc28J60Network::writeRegPair(EDMANDL, len); + + /* + 2. If an interrupt at the end of the copy process is + desired, set EIE.DMAIE and EIE.INTIE and + clear EIR.DMAIF. + + 3. Verify that ECON1.CSUMEN is clear. */ + Enc28J60Network::writeOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_CSUMEN); + + /* 4. Start the DMA copy by setting ECON1.DMAST. */ + Enc28J60Network::writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_DMAST); + + // wait until runnig DMA is completed + while (Enc28J60Network::readOp(ENC28J60_READ_CTRL_REG, ECON1) & ECON1_DMAST) + { + delay(1); + } + } +} + +void +Enc28J60Network::freePacket(void) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::freePacket(void) DEBUG_V3:Function started")); + #endif + setERXRDPT(); +} + +uint8_t +Enc28J60Network::readOp(uint8_t op, uint8_t address) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::readOp(uint8_t op, uint8_t address) DEBUG_V3:Function started")); + #endif + CSACTIVE; + // issue read command + #if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + SPI.transfer(op | (address & ADDR_MASK)); + // read data + if(address & 0x80) + { + // do dummy read if needed (for mac and mii, see datasheet page 29) + SPI.transfer(0x00); + } + uint8_t c = SPI.transfer(0x00); + #endif + #if defined(__MBED__) + _spi.write(op | (address & ADDR_MASK)); + // read data + if(address & 0x80) + { + // do dummy read if needed (for mac and mii, see datasheet page 29) + _spi.write(0x00); + } + uint8_t c = _spi.write(0x00); + #endif + // release CS + CSPASSIVE; + return(c); + #else + // issue read command + SPDR = op | (address & ADDR_MASK); + waitspi(); + // read data + SPDR = 0x00; + waitspi(); + // do dummy read if needed (for mac and mii, see datasheet page 29) + if(address & 0x80) + { + SPDR = 0x00; + waitspi(); + } + // release CS + CSPASSIVE; + return(SPDR); + #endif + #if defined(ESP8266) + yield(); + #endif +} + +void +Enc28J60Network::writeOp(uint8_t op, uint8_t address, uint8_t data) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::writeOp(uint8_t op, uint8_t address, uint8_t data) DEBUG_V3:Function started")); + #endif + CSACTIVE; + // issue write command + #if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + SPI.transfer(op | (address & ADDR_MASK)); + // write data + SPI.transfer(data); + #endif + #if defined(__MBED__) + _spi.write(op | (address & ADDR_MASK)); + // write data + _spi.write(data); + #endif + #else + // issue write command + SPDR = op | (address & ADDR_MASK); + waitspi(); + // write data + SPDR = data; + waitspi(); + #endif + CSPASSIVE; + #if defined(ESP8266) + yield(); + #endif +} + +void +Enc28J60Network::readBuffer(uint16_t len, uint8_t* data) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::readBuffer(uint16_t len, uint8_t* data) DEBUG_V3:Function started")); + #endif + CSACTIVE; + // issue read command + #if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + SPI.transfer(ENC28J60_READ_BUF_MEM); + #endif + #if defined(__MBED__) + _spi.write(ENC28J60_READ_BUF_MEM); + #endif + #else + SPDR = ENC28J60_READ_BUF_MEM; + waitspi(); + #endif + while(len) + { + len--; + // read data + #if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + *data = SPI.transfer(0x00); + #endif + #if defined(__MBED__) + *data = _spi.write(0x00); + #endif + #else + SPDR = 0x00; + waitspi(); + *data = SPDR; + #endif + data++; + } + //*data='\0'; + CSPASSIVE; +} + +void +Enc28J60Network::writeBuffer(uint16_t len, uint8_t* data) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::writeBuffer(uint16_t len, uint8_t* data) DEBUG_V3:Function started")); + #endif + CSACTIVE; + // issue write command + #if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + SPI.transfer(ENC28J60_WRITE_BUF_MEM); + #endif + #if defined(__MBED__) + _spi.write(ENC28J60_WRITE_BUF_MEM); + #endif + #else + SPDR = ENC28J60_WRITE_BUF_MEM; + waitspi(); + #endif + while(len) + { + len--; + // write data + #if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + SPI.transfer(*data); + #endif + #if defined(__MBED__) + _spi.write(*data); + #endif + data++; + #else + SPDR = *data; + data++; + waitspi(); + #endif + } + CSPASSIVE; +} + +void +Enc28J60Network::setBank(uint8_t address) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::setBank(uint8_t address) DEBUG_V3:Function started")); + #endif + // set the bank (if needed) + if((address & BANK_MASK) != bank) + { + // set the bank + writeOp(ENC28J60_BIT_FIELD_CLR, ECON1, (ECON1_BSEL1|ECON1_BSEL0)); + writeOp(ENC28J60_BIT_FIELD_SET, ECON1, (address & BANK_MASK)>>5); + bank = (address & BANK_MASK); + } +} + +uint8_t +Enc28J60Network::readReg(uint8_t address) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::readReg(uint8_t address) DEBUG_V3:Function started")); + #endif + // set the bank + setBank(address); + // do the read + return readOp(ENC28J60_READ_CTRL_REG, address); +} + +void +Enc28J60Network::writeReg(uint8_t address, uint8_t data) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::writeReg(uint8_t address, uint8_t data) DEBUG_V3:Function started")); + #endif + // set the bank + setBank(address); + // do the write + writeOp(ENC28J60_WRITE_CTRL_REG, address, data); +} + +void +Enc28J60Network::writeRegPair(uint8_t address, uint16_t data) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::writeRegPair(uint8_t address, uint16_t data) DEBUG_V3:Function started")); + #endif + // set the bank + setBank(address); + // do the write + writeOp(ENC28J60_WRITE_CTRL_REG, address, (data&0xFF)); + writeOp(ENC28J60_WRITE_CTRL_REG, address+1, (data) >> 8); +} + +void +Enc28J60Network::phyWrite(uint8_t address, uint16_t data) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::phyWrite(uint8_t address, uint16_t data) DEBUG_V3:Function started")); + #endif + unsigned int timeout = 15; + // set the PHY register address + writeReg(MIREGADR, address); + // write the PHY data + writeRegPair(MIWRL, data); + // wait until the PHY write completes + while (readReg(MISTAT) & MISTAT_BUSY) + { + delay(10); + #if defined(ESP8266) + wdt_reset(); + #endif + if (--timeout == 0) + { + #if ACTLOGLEVEL>=LOG_ERR + LogObject.uart_send_strln(F("Enc28J60Network::phyWrite ERROR:TIMEOUT !!")); + #endif + return; + } + } +} + +uint16_t +Enc28J60Network::phyRead(uint8_t address) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::phyRead(uint8_t address) DEBUG_V3:Function started")); + #endif + unsigned int timeout = 15; + writeReg(MIREGADR,address); + writeReg(MICMD, MICMD_MIIRD); + // wait until the PHY read completes + while(readReg(MISTAT) & MISTAT_BUSY) + { + delay(10); + #if defined(ESP8266) + wdt_reset(); + #endif + if (--timeout == 0) + { + #if ACTLOGLEVEL>=LOG_ERR + LogObject.uart_send_strln(F("Enc28J60Network::phyRead ERROR:TIMEOUT !!")); + #endif + return 0; + } + } + writeReg(MICMD, 0); + return (readReg(MIRDL) | readReg(MIRDH) << 8); +} + +void +Enc28J60Network::clkout(uint8_t clk) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::clkout(uint8_t clk) DEBUG_V3:Function started")); + #endif + //setup clkout: 2 is 12.5MHz: + writeReg(ECOCON, clk & 0x7); +} + +uint16_t +Enc28J60Network::chksum(uint16_t sum, memhandle handle, memaddress pos, uint16_t len) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::chksum(uint16_t sum, memhandle handle, memaddress pos, uint16_t len) DEBUG_V3:Function started")); + #endif + uint16_t t; + len = setReadPtr(handle, pos, len)-1; + CSACTIVE; + // issue read command + #if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + SPI.transfer(ENC28J60_READ_BUF_MEM); + #endif + #if defined(__MBED__) + _spi.write(ENC28J60_READ_BUF_MEM); + #endif + #else + SPDR = ENC28J60_READ_BUF_MEM; + waitspi(); + #endif + uint16_t i; + for (i = 0; i < len; i+=2) + { + // read data + #if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + t = SPI.transfer(0x00) << 8; + t += SPI.transfer(0x00); + #endif + #if defined(__MBED__) + t = _spi.write(0x00) << 8; + t += _spi.write(0x00); + #endif + #else + SPDR = 0x00; + waitspi(); + t = SPDR << 8; + SPDR = 0x00; + waitspi(); + t += SPDR; + #endif + sum += t; + if(sum < t) + { + sum++; /* carry */ + } + } + if(i == len) + { + #if ENC28J60_USE_SPILIB + #if defined(ARDUINO) + t = (SPI.transfer(0x00) << 8) + 0; + #endif + #if defined(__MBED__) + t = (_spi.write(0x00) << 8) + 0; + #endif + #else + SPDR = 0x00; + waitspi(); + t = (SPDR << 8) + 0; + #endif + sum += t; + if(sum < t) + { + sum++; /* carry */ + } + } + CSPASSIVE; + + /* Return sum in host byte order. */ + return sum; +} + +void +Enc28J60Network::powerOff(void) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::powerOff(void) DEBUG_V3:Function started")); + #endif + writeOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_RXEN); + delay(50); + writeOp(ENC28J60_BIT_FIELD_SET, ECON2, ECON2_VRPS); + delay(50); + writeOp(ENC28J60_BIT_FIELD_SET, ECON2, ECON2_PWRSV); +} + +void +Enc28J60Network::powerOn(void) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::powerOn(void) DEBUG_V3:Function started")); + #endif + writeOp(ENC28J60_BIT_FIELD_CLR, ECON2, ECON2_PWRSV); + delay(50); + writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_RXEN); + delay(50); +} + +// read erevid from object: +uint8_t +Enc28J60Network::geterevid(void) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_str(F("Enc28J60Network::geterevid(void) DEBUG_V3:Function started and return:")); + LogObject.uart_send_decln(erevid); + #endif + return(erevid); +} + +// read the phstat2 of the chip: +uint16_t +Enc28J60Network::PhyStatus(void) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_str(F("Enc28J60Network::PhyStatus(void) DEBUG_V3:Function started")); + LogObject.uart_send_decln(erevid); + #endif + uint16_t phstat2; + phstat2=phyRead(PHSTAT2); + if ((phstat2 & 0x20) > 0) {phstat2=phstat2 &0x100;} + phstat2=(phstat2 & 0xFF00) | erevid; + if ((phstat2 & 0x8000) > 0) {phstat2=0;} + return phstat2; +} + +bool +Enc28J60Network::linkStatus(void) +{ + #if ACTLOGLEVEL>=LOG_DEBUG_V3 + LogObject.uart_send_strln(F("Enc28J60Network::linkStatus(void) DEBUG_V3:Function started")); + #endif + return (phyRead(PHSTAT2) & 0x0400) > 0; +} + +Enc28J60Network Enc28J60; diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet/utility/Enc28J60Network.h b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet/utility/Enc28J60Network.h new file mode 100644 index 0000000..8f5e446 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/UIPEthernet/utility/Enc28J60Network.h @@ -0,0 +1,331 @@ +/* + Enc28J60NetworkClass.h + UIPEthernet network driver for Microchip ENC28J60 Ethernet Interface. + + Copyright (c) 2013 Norbert Truchsess + All rights reserved. + + inspired by enc28j60.c file from the AVRlib library by Pascal Stang. + For AVRlib See http://www.procyonengineering.com/ + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#ifndef Enc28J60Network_H_ +#define Enc28J60Network_H_ + +#if defined(ESP32) + //pin SS already defined in ESP32 as pin 5, don't use this as conflict with SPIFFS, EEPROM, etc. + // Use in GPIO13 + #warning ENC28J60Network.h => use ESP32, change ENC28J60_CONTROL_CS/SS_PIN_DEFAULT to GPIO13, MOSI(23), MISO(19), SCK(18) + #define ENC28J60_CONTROL_CS 13 +#endif + +// KH, For nRF52 +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #include + #define ENC28J60_USE_SPILIB 1 + + #ifndef USE_THIS_SS_PIN + // default to pin 10 + #define ENC28J60_CONTROL_CS 10 + #else + #warning Using USE_THIS_SS_PIN in Enc28J60Network.h for nRF52 + #define ENC28J60_CONTROL_CS USE_THIS_SS_PIN + #endif +#endif + +// KH, For SAMD21/SAMD51 +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #include + #define ENC28J60_USE_SPILIB 1 + + #ifndef USE_THIS_SS_PIN + // default to pin 10 + #define ENC28J60_CONTROL_CS 10 + #else + #warning Using USE_THIS_SS_PIN in Enc28J60Network.h for SAMD + #define ENC28J60_CONTROL_CS USE_THIS_SS_PIN + #endif +#endif + +#include "mempool.h" +#if defined(__MBED__) + #include + //UIPEthernet(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS); + #if defined(TARGET_LPC1768) + #define SPI_MOSI p11 + #define SPI_MISO p12 + #define SPI_SCK p13 + #define SPI_CS p8 + #elif defined(TARGET_LPC1114) + #define SPI_MOSI dp2 + #define SPI_MISO dp1 + #define SPI_SCK dp6 + #define SPI_CS dp25 + #elif defined(TARGET_LPC11U68) + #define SPI_MOSI P0_9 + #define SPI_MISO P0_8 + #define SPI_SCK P1_29 + #define SPI_CS P0_2 + #elif defined(TARGET_NUCLEO_F103RB) || defined(TARGET_NUCLEO_L152RE) || defined(TARGET_NUCLEO_F030R8) \ + || defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_L053R8) \ + || defined(TARGET_NUCLEO_F411RE) || defined(TARGET_NUCLEO_F334R8) || defined(TARGET_NUCLEO_F072RB) \ + || defined(TARGET_NUCLEO_F091RC) || defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F070RB) + #define SPI_MOSI D4 + #define SPI_MISO D5 + #define SPI_SCK D3 + #define SPI_CS D2 + #endif + #define ENC28J60_CONTROL_CS SPI_CS +#endif + +#if defined(STM32F3) || defined(STM32F2) //This is workaround for stm32duino STM32F2, and adafruit wiced feather STM32F2 + #define BOARD_SPI1_NSS_PIN PA4 + #define BOARD_SPI1_SCK_PIN PA5 + #define BOARD_SPI1_MISO_PIN PA6 + #define BOARD_SPI1_MOSI_PIN PA7 +#endif //This is workaround for stm32duino STM32F3, and adafruit wiced feather STM32F2 + +#if defined(BOARD_discovery_f4) + #define __STM32F4__ +#endif +#if defined(__MK20DX128__) || defined(__MKL26Z64__) + #include +#endif + +#if !defined(ENC28J60_CONTROL_CS) + #if defined(__AVR__) || defined(ESP8266) || defined(__RFduino__) + // Arduino Uno (__AVR__) SS defined to pin 10 + // Arduino Leonardo (ARDUINO_AVR_LEONARDO) SS defined to LED_BUILTIN_RX (17) + // Arduino Mega(__AVR_ATmega2560__) SS defined to pin 53 + // ESP8266 (ESP8266) SS defined to pin 15 + #if defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_MICRO) + #define ENC28J60_CONTROL_CS PIN_A10 + #warning "Using LEONARDO borad PIN_A10 for ENC28J60_CONTROL_CS. Use UIPEthernet::init(uint8_t) to change it." + #else + #define ENC28J60_CONTROL_CS SS + #endif + #elif defined(ARDUINO_ARCH_AMEBA) //Defined SS to pin 10 + #define ENC28J60_CONTROL_CS SS //PC_0 A5 10 + #elif defined(ARDUINO_ARCH_SAM) + // Arduino Due (ARDUINO_ARCH_SAM) BOARD_SPI_DEFAULT_SS (SS3) defined to pin 78 + //#define ENC28J60_CONTROL_CS BOARD_SPI_DEFAULT_SS + #define ENC28J60_CONTROL_CS BOARD_SPI_SS0 + #elif defined(ARDUINO_ARCH_SAMD) + #define ENC28J60_CONTROL_CS SS + #elif defined(__ARDUINO_ARC__) //Intel ARC32 Genuino 101 + #define ENC28J60_CONTROL_CS SS + #elif defined(__RFduino__) //RFduino + #define ENC28J60_CONTROL_CS SS + #elif defined(ARDUINO_ARCH_STM32) // STM32duino core + #define ENC28J60_CONTROL_CS SS + #elif defined(ARDUINO_ARCH_ESP32) // arduino-esp32 + #define ENC28J60_CONTROL_CS SS + #elif defined(STM32_MCU_SERIES) || defined(__STM32F1__) || defined(__STM32F3__) || defined(STM32F3) || defined(__STM32F4__) || defined(STM32F2) + #if defined(BOARD_SPI1_NSS_PIN) + #define ENC28J60_CONTROL_CS BOARD_SPI1_NSS_PIN + #elif defined(ARDUINO_STM32F4_NETDUINO2PLUS) + #define ENC28J60_CONTROL_CS PC8 + #else + #define ENC28J60_CONTROL_CS SPI.nssPin() + //#define ENC28J60_CONTROL_CS PA4 + #endif + #elif defined(__MK20DX128__) || defined(__MKL26Z64__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1062__) + #define ENC28J60_CONTROL_CS PIN_SPI_SS + #endif +#endif +#if !defined(ENC28J60_CONTROL_CS) + #warning "Default ENC28J60_CONTROL_CS could not be defined! Use UIPEthernet::init(uint8_t) to set it." + #define ENC28J60_CONTROL_CS 0 +#endif + +extern uint8_t ENC28J60ControlCS; + +#if !defined(SPI_MOSI) + #if defined(__AVR__) || defined(ESP8266) || defined(__RFduino__) + #define SPI_MOSI MOSI + #elif defined(ARDUINO_ARCH_AMEBA) + #define SPI_MOSI 11 //PC_2 + #elif defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD) + #define SPI_MOSI PIN_SPI_MOSI + #elif defined(__ARDUINO_ARC__) //Intel ARC32 Genuino 101 + #define SPI_MOSI MOSI + #elif defined(__RFduino__) //RFduino + #define SPI_MOSI MOSI + #elif defined(ARDUINO_ARCH_STM32) // STM32duino core + #define SPI_MOSI MOSI + #elif defined(ARDUINO_ARCH_ESP32) // arduino-esp32 + #define SPI_MOSI MOSI + #elif defined(STM32_MCU_SERIES) || defined(__STM32F1__) || defined(__STM32F3__) || defined(STM32F3) || defined(__STM32F4__) || defined(STM32F2) + #if defined(BOARD_SPI1_MOSI_PIN) + #define SPI_MOSI BOARD_SPI1_MOSI_PIN + #else + #define SPI_MOSI SPI.mosiPin() + #endif + #elif defined(__MK20DX128__) || defined(__MKL26Z64__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1062__) + #define SPI_MOSI PIN_SPI_MOSI + #endif +#endif +#if !defined(SPI_MOSI) + //#error "Not defined SPI_MOSI!" + #define SPI_MOSI MOSI +#endif + +#if !defined(SPI_MISO) + #if defined(__AVR__) || defined(ESP8266) || defined(__RFduino__) + #define SPI_MISO MISO + #elif defined(ARDUINO_ARCH_AMEBA) + #define SPI_MISO 12 //PC_3 + #elif defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD) + #define SPI_MISO PIN_SPI_MISO + #elif defined(__ARDUINO_ARC__) //Intel ARC32 Genuino 101 + #define SPI_MISO MISO + #elif defined(__RFduino__) //RFduino + #define SPI_MISO MISO + #elif defined(ARDUINO_ARCH_STM32) // STM32duino core + #define SPI_MISO MISO + #elif defined(ARDUINO_ARCH_ESP32) // arduino-esp32 + #define SPI_MISO MISO + #elif defined(STM32_MCU_SERIES) || defined(__STM32F1__) || defined(__STM32F3__) || defined(STM32F3) || defined(__STM32F4__) || defined(STM32F2) + #if defined(BOARD_SPI1_MISO_PIN) + #define SPI_MISO BOARD_SPI1_MISO_PIN + #else + #define SPI_MISO SPI.misoPin() + #endif + #elif defined(__MK20DX128__) || defined(__MKL26Z64__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1062__) + #define SPI_MISO PIN_SPI_MISO + #endif +#endif +#if !defined(SPI_MISO) + //#error "Not defined SPI_MISO!" + #define SPI_MISO MISO +#endif +#if !defined(SPI_SCK) + #if defined(__AVR__) || defined(ESP8266) || defined(__RFduino__) + #define SPI_SCK SCK + #elif defined(ARDUINO_ARCH_AMEBA) + #define SPI_SCK 13 //PC_1 A4 + #elif defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD) + #define SPI_SCK PIN_SPI_SCK + #elif defined(__ARDUINO_ARC__) //Intel ARC32 Genuino 101 + #define SPI_SCK SCK + #elif defined(__RFduino__) //RFduino + #define SPI_SCK SCK + #elif defined(ARDUINO_ARCH_STM32) // STM32duino core + #define SPI_SCK SCK + #elif defined(ARDUINO_ARCH_ESP32) // arduino-esp32 + #define SPI_SCK SCK + #elif defined(STM32_MCU_SERIES) || defined(__STM32F1__) || defined(__STM32F3__) || defined(STM32F3) || defined(__STM32F4__) || defined(STM32F2) + #if defined(BOARD_SPI1_SCK_PIN) + #define SPI_SCK BOARD_SPI1_SCK_PIN + #else + #define SPI_SCK SPI.sckPin() + #endif + #elif defined(__MK20DX128__) || defined(__MKL26Z64__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1062__) + #define SPI_SCK PIN_SPI_SCK + #endif +#endif + +#if !defined(SPI_SCK) + // For nRF52 + //#error "Not defined SPI_SCK!" + #define SPI_SCK SCK +#endif + +#if defined(__MBED__) || defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD) || defined(__ARDUINO_ARC__) || defined(__STM32F1__) || defined(__STM32F3__) || defined(STM32F3) || defined(__STM32F4__) || defined(STM32F2) || defined(ESP8266) || defined(ARDUINO_ARCH_AMEBA) || defined(__MK20DX128__) || defined(__MKL26Z64__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1062__) || defined(__RFduino__) || defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR) + #if defined(ARDUINO) && defined(STM32F3) + #include "HardwareSPI.h" + #else + #include + #endif + #define ENC28J60_USE_SPILIB 1 +#endif + + + +#define UIP_RECEIVEBUFFERHANDLE 0xff + +/* + * Empfangen von ip-header, arp etc... + * wenn tcp/udp -> tcp/udp-callback -> assign new packet to connection + */ + +#define TX_COLLISION_RETRY_COUNT 10 + +class Enc28J60Network : public MemoryPool +{ + +private: + static uint16_t nextPacketPtr; + static uint8_t bank; + static uint8_t erevid; + + static struct memblock receivePkt; + + static bool broadcast_enabled; //!< True if broadcasts enabled (used to allow temporary disable of broadcast for DHCP or other internal functions) + + static uint8_t readOp(uint8_t op, uint8_t address); + static void writeOp(uint8_t op, uint8_t address, uint8_t data); + static uint16_t setReadPtr(memhandle handle, memaddress position, uint16_t len); + static void setERXRDPT(void); + static void readBuffer(uint16_t len, uint8_t* data); + static void writeBuffer(uint16_t len, uint8_t* data); + static uint8_t readByte(uint16_t addr); + static void writeByte(uint16_t addr, uint8_t data); + static void setBank(uint8_t address); + static uint8_t readReg(uint8_t address); + static void writeReg(uint8_t address, uint8_t data); + static void writeRegPair(uint8_t address, uint16_t data); + static void phyWrite(uint8_t address, uint16_t data); + static uint16_t phyRead(uint8_t address); + static void clkout(uint8_t clk); + + static void enableBroadcast (bool temporary); + static void disableBroadcast (bool temporary); + static void enableMulticast (void); + static void disableMulticast (void); + + static uint8_t readRegByte (uint8_t address); + static void writeRegByte (uint8_t address, uint8_t data); + + friend void enc28J60_mempool_block_move_callback(memaddress,memaddress,memaddress); + +public: + + void powerOn(void); + void powerOff(void); + static uint8_t geterevid(void); + uint16_t PhyStatus(void); + static bool linkStatus(void); + + static void init(uint8_t* macaddr); + static memhandle receivePacket(void); + static void freePacket(void); + static memaddress blockSize(memhandle handle); + static void sendPacket(memhandle handle); + static uint16_t readPacket(memhandle handle, memaddress position, uint8_t* buffer, uint16_t len); + static uint16_t writePacket(memhandle handle, memaddress position, uint8_t* buffer, uint16_t len); + static void copyPacket(memhandle dest, memaddress dest_pos, memhandle src, memaddress src_pos, uint16_t len); + static uint16_t chksum(uint16_t sum, memhandle handle, memaddress pos, uint16_t len); +}; + +extern Enc28J60Network Enc28J60; +#endif /* Enc28J60NetworkClass_H_ */ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/esp32/cores/esp32/Server.h b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/esp32/cores/esp32/Server.h new file mode 100644 index 0000000..e1e299d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/LibraryPatches/esp32/cores/esp32/Server.h @@ -0,0 +1,35 @@ +/* + Server.h - Base class that provides Server + Copyright (c) 2011 Adrian McEwen. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef server_h +#define server_h + +#include "Print.h" + +class Server: public Print +{ +public: + // KH, change to fix compiler error for EthernetWebServer + // error: cannot declare field 'EthernetWebServer::_server' to be of abstract type 'EthernetServer' + // virtual void begin(uint16_t port=0) =0; + //virtual void begin() = 0; + void begin() {}; +}; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Fab_SAM_Arduino/hardware/samd/1.6.18-alpha2/boards.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Fab_SAM_Arduino/hardware/samd/1.6.18-alpha2/boards.txt new file mode 100644 index 0000000..ec3f9ff --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Fab_SAM_Arduino/hardware/samd/1.6.18-alpha2/boards.txt @@ -0,0 +1,1730 @@ +# Copyright (c) 2014-2017 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +menu.cpu=Microcontroller +menu.clock=Clock Source +menu.usb=USB Config +menu.serial=Serial Config +menu.bootloader=Bootloader Size +menu.timer=Timer PWM Frequency +menu.float=Floating Point +menu.config=Build Options + +# Generic D11C14A +d11c14a.name=Generic D11C14A +d11c14a.vid.0=0x16D0 +d11c14a.pid.0=0x1557 +d11c14a.vid.1=0x16D0 +d11c14a.pid.1=0x1856 +d11c14a.vid.2=0x16D0 +d11c14a.pid.2=0x1B41 +d11c14a.vid.3=0x16D0 +d11c14a.pid.3=0x1B40 +d11c14a.vid.4=0x16D0 +d11c14a.pid.4=0x1A0C +d11c14a.vid.5=0x16D0 +d11c14a.pid.5=0x1856 +d11c14a.build.mcu=cortex-m0plus +d11c14a.build.mathlib=arm_cortexM0l_math +d11c14a.build.f_cpu=48000000L +d11c14a.build.usb_product="D11C14A" +d11c14a.build.usb_manufacturer="Fab Foundation" +d11c14a.build.board=SAMD_ZERO +d11c14a.build.core=arduino +d11c14a.build.variant=Generic_D11C14A +d11c14a.build.variant_system_lib= +d11c14a.build.vid=0x16D0 +d11c14a.upload.protocol=sam-ba +d11c14a.bootloader.tool=openocd +d11c14a.menu.float.default=Print & String use auto-promoted doubles only +d11c14a.menu.float.default.build.floatconfig=FLOAT_BOTH_DOUBLES_ONLY +d11c14a.menu.float.print=Print uses separate singles and doubles +d11c14a.menu.float.print.build.floatconfig=FLOAT_PRINT_SINGLES_DOUBLES +d11c14a.menu.float.string=String uses separate singles and doubles +d11c14a.menu.float.string.build.floatconfig=FLOAT_STRING_SINGLES_DOUBLES +d11c14a.menu.float.both=Print & String use separate singles and doubles +d11c14a.menu.float.both.build.floatconfig=FLOAT_BOTH_SINGLES_DOUBLES +d11c14a.menu.config.disabled=config.h disabled +d11c14a.menu.config.disabled.build.buildconfig=CONFIG_H_DISABLED +d11c14a.menu.config.enabled=config.h enabled (mostly code size reductions) +d11c14a.menu.config.enabled.build.buildconfig=CONFIG_H_ENABLED +d11c14a.menu.clock.internal_usb=INTERNAL_USB_CALIBRATED_OSCILLATOR +d11c14a.menu.clock.internal_usb.build.clockconfig=CLOCKCONFIG_INTERNAL_USB +d11c14a.menu.clock.internal=INTERNAL_OSCILLATOR +d11c14a.menu.clock.internal.build.clockconfig=CLOCKCONFIG_INTERNAL +d11c14a.menu.clock.crystal_32k=32KHZ_CRYSTAL +d11c14a.menu.clock.crystal_32k.build.clockconfig=CLOCKCONFIG_32768HZ_CRYSTAL +d11c14a.menu.clock.crystal_hs=HIGH_SPEED_CRYSTAL +d11c14a.menu.clock.crystal_hs.build.clockconfig=CLOCKCONFIG_HS_CRYSTAL +d11c14a.menu.timer.timer_732Hz=732.4Hz (16-bit) +d11c14a.menu.timer.timer_732Hz.build.timerconfig=TIMER_732Hz +d11c14a.menu.timer.timer_366Hz=366.2Hz (16-bit) +d11c14a.menu.timer.timer_366Hz.build.timerconfig=TIMER_366Hz +d11c14a.menu.timer.timer_244Hz=244.1Hz (16-bit) +d11c14a.menu.timer.timer_244Hz.build.timerconfig=TIMER_244Hz +d11c14a.menu.timer.timer_183Hz=183.1Hz (16-bit) +d11c14a.menu.timer.timer_183Hz.build.timerconfig=TIMER_183Hz +d11c14a.menu.timer.timer_146Hz=146.5Hz (16-bit) +d11c14a.menu.timer.timer_146Hz.build.timerconfig=TIMER_146Hz +d11c14a.menu.timer.timer_122Hz=122.1Hz (16-bit) +d11c14a.menu.timer.timer_122Hz.build.timerconfig=TIMER_122Hz +d11c14a.menu.timer.timer_105Hz=104.6Hz (16-bit) +d11c14a.menu.timer.timer_105Hz.build.timerconfig=TIMER_105Hz +d11c14a.menu.timer.timer_81Hz=81.38Hz (16-bit) +d11c14a.menu.timer.timer_81Hz.build.timerconfig=TIMER_81Hz +d11c14a.menu.timer.timer_61Hz=61.04Hz (16-bit) +d11c14a.menu.timer.timer_61Hz.build.timerconfig=TIMER_61Hz +d11c14a.menu.timer.timer_31Hz=30.52Hz (16-bit) +d11c14a.menu.timer.timer_31Hz.build.timerconfig=TIMER_31Hz +d11c14a.menu.timer.timer_187500Hz=187500Hz (8-bit) +d11c14a.menu.timer.timer_187500Hz.build.timerconfig=TIMER_187500Hz +d11c14a.menu.timer.timer_93750Hz=93750Hz (8-bit) +d11c14a.menu.timer.timer_93750Hz.build.timerconfig=TIMER_93750Hz +d11c14a.menu.timer.timer_62500Hz=62500Hz (8-bit) +d11c14a.menu.timer.timer_62500Hz.build.timerconfig=TIMER_62500Hz +d11c14a.menu.timer.timer_37500Hz=37500Hz (8-bit) +d11c14a.menu.timer.timer_37500Hz.build.timerconfig=TIMER_37500Hz +d11c14a.menu.timer.timer_20833Hz=20833Hz (8-bit) +d11c14a.menu.timer.timer_20833Hz.build.timerconfig=TIMER_20833Hz +d11c14a.menu.timer.timer_12500Hz=12500Hz (8-bit) +d11c14a.menu.timer.timer_12500Hz.build.timerconfig=TIMER_12500Hz +d11c14a.menu.timer.timer_7500Hz=7500Hz (8-bit) +d11c14a.menu.timer.timer_7500Hz.build.timerconfig=TIMER_7500Hz +d11c14a.menu.timer.timer_4166Hz=4166Hz (8-bit) +d11c14a.menu.timer.timer_4166Hz.build.timerconfig=TIMER_4166Hz +d11c14a.menu.timer.timer_2930Hz=2930Hz (8-bit) +d11c14a.menu.timer.timer_2930Hz.build.timerconfig=TIMER_2930Hz +d11c14a.menu.timer.timer_1465Hz=1465Hz (8-bit) +d11c14a.menu.timer.timer_1465Hz.build.timerconfig=TIMER_1465Hz +d11c14a.build.extra_flags=-D__SAMD11C14A__ {build.usb_flags} -DARM_MATH_CM0PLUS +d11c14a.build.ldscript=flash_16KB.ld +d11c14a.build.openocdscript=openocd_scripts/SAMD11C14A.cfg +d11c14a.bootloader.file=zero/binaries/sam_ba_SAMD11C14A.bin +d11c14a.menu.bootloader.4kb=4KB_BOOTLOADER +d11c14a.menu.bootloader.4kb.build.bootloader_size=__4KB_BOOTLOADER__ +d11c14a.menu.bootloader.4kb.build.ldscript_path=linker_scripts/gcc/4KB_Bootloader +d11c14a.menu.bootloader.4kb.upload.tool=Fab_SAM_Arduino:bossac +d11c14a.menu.bootloader.4kb.upload.use_1200bps_touch=true +d11c14a.menu.bootloader.4kb.upload.wait_for_upload_port=true +d11c14a.menu.bootloader.4kb.upload.native_usb=true +d11c14a.menu.bootloader.4kb.upload.maximum_size=12288 +d11c14a.menu.bootloader.0kb=NO_BOOTLOADER +d11c14a.menu.bootloader.0kb.build.bootloader_size=__NO_BOOTLOADER__ +d11c14a.menu.bootloader.0kb.build.ldscript_path=linker_scripts/gcc/No_Bootloader +d11c14a.menu.bootloader.0kb.upload.tool=openocd +d11c14a.menu.bootloader.0kb.upload.use_1200bps_touch=false +d11c14a.menu.bootloader.0kb.upload.wait_for_upload_port=false +d11c14a.menu.bootloader.0kb.upload.native_usb=false +d11c14a.menu.bootloader.0kb.upload.maximum_size=16384 +d11c14a.menu.serial.one_uart=ONE_UART_ONE_WIRE_NO_SPI +d11c14a.menu.serial.one_uart.build.serialcom_uart=ONE_UART +d11c14a.menu.serial.one_uart.build.serialcom_wire=ONE_WIRE +d11c14a.menu.serial.one_uart.build.serialcom_spi=NO_SPI +d11c14a.menu.serial.two_uart=TWO_UART_NO_WIRE_NO_SPI +d11c14a.menu.serial.two_uart.build.serialcom_uart=TWO_UART +d11c14a.menu.serial.two_uart.build.serialcom_wire=NO_WIRE +d11c14a.menu.serial.two_uart.build.serialcom_spi=NO_SPI +d11c14a.menu.serial.one_uart_no_wire_one_spi=ONE_UART_NO_WIRE_ONE_SPI +d11c14a.menu.serial.one_uart_no_wire_one_spi.build.serialcom_uart=ONE_UART +d11c14a.menu.serial.one_uart_no_wire_one_spi.build.serialcom_wire=NO_WIRE +d11c14a.menu.serial.one_uart_no_wire_one_spi.build.serialcom_spi=ONE_SPI +d11c14a.menu.serial.no_uart=NO_UART_ONE_WIRE_ONE_SPI +d11c14a.menu.serial.no_uart.build.serialcom_uart=NO_UART +d11c14a.menu.serial.no_uart.build.serialcom_wire=ONE_WIRE +d11c14a.menu.serial.no_uart.build.serialcom_spi=ONE_SPI +d11c14a.menu.usb.cdc=CDC_ONLY +d11c14a.menu.usb.cdc.build.usbcom=CDC_ONLY +d11c14a.menu.usb.cdc.build.pid=0x1557 +d11c14a.menu.usb.cdc_hid=CDC_HID +d11c14a.menu.usb.cdc_hid.build.usbcom=CDC_HID +d11c14a.menu.usb.cdc_hid.build.pid=0x1856 +d11c14a.menu.usb.withcdc=WITH_CDC +d11c14a.menu.usb.withcdc.build.usbcom=WITH_CDC +d11c14a.menu.usb.withcdc.build.pid=0x1B41 +d11c14a.menu.usb.hid=HID_ONLY +d11c14a.menu.usb.hid.build.usbcom=HID_ONLY +d11c14a.menu.usb.hid.build.pid=0x1B40 +d11c14a.menu.usb.nocdc=WITHOUT_CDC +d11c14a.menu.usb.nocdc.build.usbcom=WITHOUT_CDC +d11c14a.menu.usb.nocdc.build.pid=0x1A0C +d11c14a.menu.usb.none=USB_DISABLED +d11c14a.menu.usb.none.build.usbcom=USB_DISABLED +d11c14a.menu.usb.none.build.pid=0x1856 + +# Generic D11D14AS +d11d14as.name=Generic D11D14AS +d11d14as.vid.0=0x16D0 +d11d14as.pid.0=0x2557 +d11d14as.vid.1=0x16D0 +d11d14as.pid.1=0x2856 +d11d14as.vid.2=0x16D0 +d11d14as.pid.2=0x2B41 +d11d14as.vid.3=0x16D0 +d11d14as.pid.3=0x2B40 +d11d14as.vid.4=0x16D0 +d11d14as.pid.4=0x2A0C +d11d14as.vid.5=0x16D0 +d11d14as.pid.5=0x2856 +d11d14as.build.mcu=cortex-m0plus +d11d14as.build.mathlib=arm_cortexM0l_math +d11d14as.build.f_cpu=48000000L +d11d14as.build.usb_product="D11D14AS" +d11d14as.build.usb_manufacturer="Fab Foundation" +d11d14as.build.board=SAMD_ZERO +d11d14as.build.core=arduino +d11d14as.build.variant=Generic_D11D14AS +d11d14as.build.variant_system_lib= +d11d14as.build.vid=0x16D0 +d11d14as.upload.protocol=sam-ba +d11d14as.bootloader.tool=openocd +d11d14as.menu.float.default=Print & String use auto-promoted doubles only +d11d14as.menu.float.default.build.floatconfig=FLOAT_BOTH_DOUBLES_ONLY +d11d14as.menu.float.print=Print uses separate singles and doubles +d11d14as.menu.float.print.build.floatconfig=FLOAT_PRINT_SINGLES_DOUBLES +d11d14as.menu.float.string=String uses separate singles and doubles +d11d14as.menu.float.string.build.floatconfig=FLOAT_STRING_SINGLES_DOUBLES +d11d14as.menu.float.both=Print & String use separate singles and doubles +d11d14as.menu.float.both.build.floatconfig=FLOAT_BOTH_SINGLES_DOUBLES +d11d14as.menu.config.disabled=config.h disabled +d11d14as.menu.config.disabled.build.buildconfig=CONFIG_H_DISABLED +d11d14as.menu.config.enabled=config.h enabled (mostly code size reductions) +d11d14as.menu.config.enabled.build.buildconfig=CONFIG_H_ENABLED +d11d14as.menu.clock.internal_usb=INTERNAL_USB_CALIBRATED_OSCILLATOR +d11d14as.menu.clock.internal_usb.build.clockconfig=CLOCKCONFIG_INTERNAL_USB +d11d14as.menu.clock.internal=INTERNAL_OSCILLATOR +d11d14as.menu.clock.internal.build.clockconfig=CLOCKCONFIG_INTERNAL +d11d14as.menu.clock.crystal_32k=32KHZ_CRYSTAL +d11d14as.menu.clock.crystal_32k.build.clockconfig=CLOCKCONFIG_32768HZ_CRYSTAL +d11d14as.menu.clock.crystal_hs=HIGH_SPEED_CRYSTAL +d11d14as.menu.clock.crystal_hs.build.clockconfig=CLOCKCONFIG_HS_CRYSTAL +d11d14as.menu.timer.timer_732Hz=732.4Hz (16-bit) +d11d14as.menu.timer.timer_732Hz.build.timerconfig=TIMER_732Hz +d11d14as.menu.timer.timer_366Hz=366.2Hz (16-bit) +d11d14as.menu.timer.timer_366Hz.build.timerconfig=TIMER_366Hz +d11d14as.menu.timer.timer_244Hz=244.1Hz (16-bit) +d11d14as.menu.timer.timer_244Hz.build.timerconfig=TIMER_244Hz +d11d14as.menu.timer.timer_183Hz=183.1Hz (16-bit) +d11d14as.menu.timer.timer_183Hz.build.timerconfig=TIMER_183Hz +d11d14as.menu.timer.timer_146Hz=146.5Hz (16-bit) +d11d14as.menu.timer.timer_146Hz.build.timerconfig=TIMER_146Hz +d11d14as.menu.timer.timer_122Hz=122.1Hz (16-bit) +d11d14as.menu.timer.timer_122Hz.build.timerconfig=TIMER_122Hz +d11d14as.menu.timer.timer_105Hz=104.6Hz (16-bit) +d11d14as.menu.timer.timer_105Hz.build.timerconfig=TIMER_105Hz +d11d14as.menu.timer.timer_81Hz=81.38Hz (16-bit) +d11d14as.menu.timer.timer_81Hz.build.timerconfig=TIMER_81Hz +d11d14as.menu.timer.timer_61Hz=61.04Hz (16-bit) +d11d14as.menu.timer.timer_61Hz.build.timerconfig=TIMER_61Hz +d11d14as.menu.timer.timer_31Hz=30.52Hz (16-bit) +d11d14as.menu.timer.timer_31Hz.build.timerconfig=TIMER_31Hz +d11d14as.menu.timer.timer_187500Hz=187500Hz (8-bit) +d11d14as.menu.timer.timer_187500Hz.build.timerconfig=TIMER_187500Hz +d11d14as.menu.timer.timer_93750Hz=93750Hz (8-bit) +d11d14as.menu.timer.timer_93750Hz.build.timerconfig=TIMER_93750Hz +d11d14as.menu.timer.timer_62500Hz=62500Hz (8-bit) +d11d14as.menu.timer.timer_62500Hz.build.timerconfig=TIMER_62500Hz +d11d14as.menu.timer.timer_37500Hz=37500Hz (8-bit) +d11d14as.menu.timer.timer_37500Hz.build.timerconfig=TIMER_37500Hz +d11d14as.menu.timer.timer_20833Hz=20833Hz (8-bit) +d11d14as.menu.timer.timer_20833Hz.build.timerconfig=TIMER_20833Hz +d11d14as.menu.timer.timer_12500Hz=12500Hz (8-bit) +d11d14as.menu.timer.timer_12500Hz.build.timerconfig=TIMER_12500Hz +d11d14as.menu.timer.timer_7500Hz=7500Hz (8-bit) +d11d14as.menu.timer.timer_7500Hz.build.timerconfig=TIMER_7500Hz +d11d14as.menu.timer.timer_4166Hz=4166Hz (8-bit) +d11d14as.menu.timer.timer_4166Hz.build.timerconfig=TIMER_4166Hz +d11d14as.menu.timer.timer_2930Hz=2930Hz (8-bit) +d11d14as.menu.timer.timer_2930Hz.build.timerconfig=TIMER_2930Hz +d11d14as.menu.timer.timer_1465Hz=1465Hz (8-bit) +d11d14as.menu.timer.timer_1465Hz.build.timerconfig=TIMER_1465Hz +d11d14as.build.extra_flags=-D__SAMD11D14AS__ {build.usb_flags} -DARM_MATH_CM0PLUS +d11d14as.build.ldscript=flash_16KB.ld +d11d14as.build.openocdscript=openocd_scripts/SAMD11D14AS.cfg +d11d14as.bootloader.file=zero/binaries/sam_ba_SAMD11D14AS.bin +d11d14as.menu.bootloader.4kb=4KB_BOOTLOADER +d11d14as.menu.bootloader.4kb.build.bootloader_size=__4KB_BOOTLOADER__ +d11d14as.menu.bootloader.4kb.build.ldscript_path=linker_scripts/gcc/4KB_Bootloader +d11d14as.menu.bootloader.4kb.upload.tool=Fab_SAM_Arduino:bossac +d11d14as.menu.bootloader.4kb.upload.use_1200bps_touch=true +d11d14as.menu.bootloader.4kb.upload.wait_for_upload_port=true +d11d14as.menu.bootloader.4kb.upload.native_usb=true +d11d14as.menu.bootloader.4kb.upload.maximum_size=12288 +d11d14as.menu.bootloader.0kb=NO_BOOTLOADER +d11d14as.menu.bootloader.0kb.build.bootloader_size=__NO_BOOTLOADER__ +d11d14as.menu.bootloader.0kb.build.ldscript_path=linker_scripts/gcc/No_Bootloader +d11d14as.menu.bootloader.0kb.upload.tool=openocd +d11d14as.menu.bootloader.0kb.upload.use_1200bps_touch=false +d11d14as.menu.bootloader.0kb.upload.wait_for_upload_port=false +d11d14as.menu.bootloader.0kb.upload.native_usb=false +d11d14as.menu.bootloader.0kb.upload.maximum_size=16384 +d11d14as.menu.serial.one_uart=ONE_UART_ONE_WIRE_ONE_SPI +d11d14as.menu.serial.one_uart.build.serialcom_uart=ONE_UART +d11d14as.menu.serial.one_uart.build.serialcom_wire=ONE_WIRE +d11d14as.menu.serial.one_uart.build.serialcom_spi=ONE_SPI +d11d14as.menu.serial.no_uart=NO_UART_ONE_WIRE_ONE_SPI +d11d14as.menu.serial.no_uart.build.serialcom_uart=NO_UART +d11d14as.menu.serial.no_uart.build.serialcom_wire=ONE_WIRE +d11d14as.menu.serial.no_uart.build.serialcom_spi=ONE_SPI +d11d14as.menu.serial.two_uart=TWO_UART_ONE_WIRE_NO_SPI +d11d14as.menu.serial.two_uart.build.serialcom_uart=TWO_UART +d11d14as.menu.serial.two_uart.build.serialcom_wire=ONE_WIRE +d11d14as.menu.serial.two_uart.build.serialcom_spi=NO_SPI +d11d14as.menu.usb.cdc=CDC_ONLY +d11d14as.menu.usb.cdc.build.usbcom=CDC_ONLY +d11d14as.menu.usb.cdc.build.pid=0x2557 +d11d14as.menu.usb.cdc_hid=CDC_HID +d11d14as.menu.usb.cdc_hid.build.usbcom=CDC_HID +d11d14as.menu.usb.cdc_hid.build.pid=0x2856 +d11d14as.menu.usb.withcdc=WITH_CDC +d11d14as.menu.usb.withcdc.build.usbcom=WITH_CDC +d11d14as.menu.usb.withcdc.build.pid=0x2B41 +d11d14as.menu.usb.hid=HID_ONLY +d11d14as.menu.usb.hid.build.usbcom=HID_ONLY +d11d14as.menu.usb.hid.build.pid=0x2B40 +d11d14as.menu.usb.nocdc=WITHOUT_CDC +d11d14as.menu.usb.nocdc.build.usbcom=WITHOUT_CDC +d11d14as.menu.usb.nocdc.build.pid=0x2A0C +d11d14as.menu.usb.none=USB_DISABLED +d11d14as.menu.usb.none.build.usbcom=USB_DISABLED +d11d14as.menu.usb.none.build.pid=0x2856 + +# Generic D11D14AM +d11d14am.name=Generic D11D14AM +d11d14am.vid.0=0x16D0 +d11d14am.pid.0=0x3557 +d11d14am.vid.1=0x16D0 +d11d14am.pid.1=0x3856 +d11d14am.vid.2=0x16D0 +d11d14am.pid.2=0x3B41 +d11d14am.vid.3=0x16D0 +d11d14am.pid.3=0x3B40 +d11d14am.vid.4=0x16D0 +d11d14am.pid.4=0x3A0C +d11d14am.vid.5=0x16D0 +d11d14am.pid.5=0x3856 +d11d14am.build.mcu=cortex-m0plus +d11d14am.build.mathlib=arm_cortexM0l_math +d11d14am.build.f_cpu=48000000L +d11d14am.build.usb_product="MT-D11" +d11d14am.build.usb_manufacturer="Fab Foundation" +d11d14am.build.board=SAMD_ZERO +d11d14am.build.core=arduino +d11d14am.build.variant=Generic_D11D14AM +d11d14am.build.variant_system_lib= +d11d14am.build.vid=0x16D0 +d11d14am.upload.protocol=sam-ba +d11d14am.bootloader.tool=openocd +d11d14am.menu.float.default=Print & String use auto-promoted doubles only +d11d14am.menu.float.default.build.floatconfig=FLOAT_BOTH_DOUBLES_ONLY +d11d14am.menu.float.print=Print uses separate singles and doubles +d11d14am.menu.float.print.build.floatconfig=FLOAT_PRINT_SINGLES_DOUBLES +d11d14am.menu.float.string=String uses separate singles and doubles +d11d14am.menu.float.string.build.floatconfig=FLOAT_STRING_SINGLES_DOUBLES +d11d14am.menu.float.both=Print & String use separate singles and doubles +d11d14am.menu.float.both.build.floatconfig=FLOAT_BOTH_SINGLES_DOUBLES +d11d14am.menu.config.disabled=config.h disabled +d11d14am.menu.config.disabled.build.buildconfig=CONFIG_H_DISABLED +d11d14am.menu.config.enabled=config.h enabled (mostly code size reductions) +d11d14am.menu.config.enabled.build.buildconfig=CONFIG_H_ENABLED +d11d14am.menu.clock.crystal_32k=32KHZ_CRYSTAL +d11d14am.menu.clock.crystal_32k.build.clockconfig=CLOCKCONFIG_32768HZ_CRYSTAL +d11d14am.menu.clock.crystal_hs=HIGH_SPEED_CRYSTAL +d11d14am.menu.clock.crystal_hs.build.clockconfig=CLOCKCONFIG_HS_CRYSTAL +d11d14am.menu.clock.internal=INTERNAL_OSCILLATOR +d11d14am.menu.clock.internal.build.clockconfig=CLOCKCONFIG_INTERNAL +d11d14am.menu.clock.internal_usb=INTERNAL_USB_CALIBRATED_OSCILLATOR +d11d14am.menu.clock.internal_usb.build.clockconfig=CLOCKCONFIG_INTERNAL_USB +d11d14am.menu.timer.timer_732Hz=732.4Hz (16-bit) +d11d14am.menu.timer.timer_732Hz.build.timerconfig=TIMER_732Hz +d11d14am.menu.timer.timer_366Hz=366.2Hz (16-bit) +d11d14am.menu.timer.timer_366Hz.build.timerconfig=TIMER_366Hz +d11d14am.menu.timer.timer_244Hz=244.1Hz (16-bit) +d11d14am.menu.timer.timer_244Hz.build.timerconfig=TIMER_244Hz +d11d14am.menu.timer.timer_183Hz=183.1Hz (16-bit) +d11d14am.menu.timer.timer_183Hz.build.timerconfig=TIMER_183Hz +d11d14am.menu.timer.timer_146Hz=146.5Hz (16-bit) +d11d14am.menu.timer.timer_146Hz.build.timerconfig=TIMER_146Hz +d11d14am.menu.timer.timer_122Hz=122.1Hz (16-bit) +d11d14am.menu.timer.timer_122Hz.build.timerconfig=TIMER_122Hz +d11d14am.menu.timer.timer_105Hz=104.6Hz (16-bit) +d11d14am.menu.timer.timer_105Hz.build.timerconfig=TIMER_105Hz +d11d14am.menu.timer.timer_81Hz=81.38Hz (16-bit) +d11d14am.menu.timer.timer_81Hz.build.timerconfig=TIMER_81Hz +d11d14am.menu.timer.timer_61Hz=61.04Hz (16-bit) +d11d14am.menu.timer.timer_61Hz.build.timerconfig=TIMER_61Hz +d11d14am.menu.timer.timer_31Hz=30.52Hz (16-bit) +d11d14am.menu.timer.timer_31Hz.build.timerconfig=TIMER_31Hz +d11d14am.menu.timer.timer_187500Hz=187500Hz (8-bit) +d11d14am.menu.timer.timer_187500Hz.build.timerconfig=TIMER_187500Hz +d11d14am.menu.timer.timer_93750Hz=93750Hz (8-bit) +d11d14am.menu.timer.timer_93750Hz.build.timerconfig=TIMER_93750Hz +d11d14am.menu.timer.timer_62500Hz=62500Hz (8-bit) +d11d14am.menu.timer.timer_62500Hz.build.timerconfig=TIMER_62500Hz +d11d14am.menu.timer.timer_37500Hz=37500Hz (8-bit) +d11d14am.menu.timer.timer_37500Hz.build.timerconfig=TIMER_37500Hz +d11d14am.menu.timer.timer_20833Hz=20833Hz (8-bit) +d11d14am.menu.timer.timer_20833Hz.build.timerconfig=TIMER_20833Hz +d11d14am.menu.timer.timer_12500Hz=12500Hz (8-bit) +d11d14am.menu.timer.timer_12500Hz.build.timerconfig=TIMER_12500Hz +d11d14am.menu.timer.timer_7500Hz=7500Hz (8-bit) +d11d14am.menu.timer.timer_7500Hz.build.timerconfig=TIMER_7500Hz +d11d14am.menu.timer.timer_4166Hz=4166Hz (8-bit) +d11d14am.menu.timer.timer_4166Hz.build.timerconfig=TIMER_4166Hz +d11d14am.menu.timer.timer_2930Hz=2930Hz (8-bit) +d11d14am.menu.timer.timer_2930Hz.build.timerconfig=TIMER_2930Hz +d11d14am.menu.timer.timer_1465Hz=1465Hz (8-bit) +d11d14am.menu.timer.timer_1465Hz.build.timerconfig=TIMER_1465Hz +d11d14am.build.extra_flags=-D__SAMD11D14AM__ {build.usb_flags} -DARM_MATH_CM0PLUS +d11d14am.build.ldscript=flash_16KB.ld +d11d14am.build.openocdscript=openocd_scripts/SAMD11D14AM.cfg +d11d14am.bootloader.file=zero/binaries/sam_ba_SAMD11D14AM.bin +d11d14am.menu.bootloader.4kb=4KB_BOOTLOADER +d11d14am.menu.bootloader.4kb.build.bootloader_size=__4KB_BOOTLOADER__ +d11d14am.menu.bootloader.4kb.build.ldscript_path=linker_scripts/gcc/4KB_Bootloader +d11d14am.menu.bootloader.4kb.upload.tool=Fab_SAM_Arduino:bossac +d11d14am.menu.bootloader.4kb.upload.use_1200bps_touch=true +d11d14am.menu.bootloader.4kb.upload.wait_for_upload_port=true +d11d14am.menu.bootloader.4kb.upload.native_usb=true +d11d14am.menu.bootloader.4kb.upload.maximum_size=12288 +d11d14am.menu.bootloader.0kb=NO_BOOTLOADER +d11d14am.menu.bootloader.0kb.build.bootloader_size=__NO_BOOTLOADER__ +d11d14am.menu.bootloader.0kb.build.ldscript_path=linker_scripts/gcc/No_Bootloader +d11d14am.menu.bootloader.0kb.upload.tool=openocd +d11d14am.menu.bootloader.0kb.upload.use_1200bps_touch=false +d11d14am.menu.bootloader.0kb.upload.wait_for_upload_port=false +d11d14am.menu.bootloader.0kb.upload.native_usb=false +d11d14am.menu.bootloader.0kb.upload.maximum_size=16384 +d11d14am.menu.serial.one_uart=ONE_UART_ONE_WIRE_ONE_SPI +d11d14am.menu.serial.one_uart.build.serialcom_uart=ONE_UART +d11d14am.menu.serial.one_uart.build.serialcom_wire=ONE_WIRE +d11d14am.menu.serial.one_uart.build.serialcom_spi=ONE_SPI +d11d14am.menu.serial.no_uart=NO_UART_ONE_WIRE_ONE_SPI +d11d14am.menu.serial.no_uart.build.serialcom_uart=NO_UART +d11d14am.menu.serial.no_uart.build.serialcom_wire=ONE_WIRE +d11d14am.menu.serial.no_uart.build.serialcom_spi=ONE_SPI +d11d14am.menu.serial.two_uart=TWO_UART_ONE_WIRE_NO_SPI +d11d14am.menu.serial.two_uart.build.serialcom_uart=TWO_UART +d11d14am.menu.serial.two_uart.build.serialcom_wire=ONE_WIRE +d11d14am.menu.serial.two_uart.build.serialcom_spi=NO_SPI +d11d14am.menu.usb.cdc=CDC_ONLY +d11d14am.menu.usb.cdc.build.usbcom=CDC_ONLY +d11d14am.menu.usb.cdc.build.pid=0x3557 +d11d14am.menu.usb.cdc_hid=CDC_HID +d11d14am.menu.usb.cdc_hid.build.usbcom=CDC_HID +d11d14am.menu.usb.cdc_hid.build.pid=0x3856 +d11d14am.menu.usb.withcdc=WITH_CDC +d11d14am.menu.usb.withcdc.build.usbcom=WITH_CDC +d11d14am.menu.usb.withcdc.build.pid=0x3B41 +d11d14am.menu.usb.hid=HID_ONLY +d11d14am.menu.usb.hid.build.usbcom=HID_ONLY +d11d14am.menu.usb.hid.build.pid=0x3B40 +d11d14am.menu.usb.nocdc=WITHOUT_CDC +d11d14am.menu.usb.nocdc.build.usbcom=WITHOUT_CDC +d11d14am.menu.usb.nocdc.build.pid=0x3A0C +d11d14am.menu.usb.none=USB_DISABLED +d11d14am.menu.usb.none.build.usbcom=USB_DISABLED +d11d14am.menu.usb.none.build.pid=0x3856 + +# Generic x21E +x21e.name=Generic x21E +x21e.vid.0=0x16D0 +x21e.pid.0=0x4557 +x21e.vid.1=0x16D0 +x21e.pid.1=0x4856 +x21e.vid.2=0x16D0 +x21e.pid.2=0x4B41 +x21e.vid.3=0x16D0 +x21e.pid.3=0x4B40 +x21e.vid.4=0x16D0 +x21e.pid.4=0x4A0C +x21e.vid.5=0x16D0 +x21e.pid.5=0x4856 +x21e.build.mcu=cortex-m0plus +x21e.build.mathlib=arm_cortexM0l_math +x21e.build.f_cpu=48000000L +x21e.build.usb_product="x21E" +x21e.build.usb_manufacturer="Fab Foundation" +x21e.build.board=SAMD_ZERO +x21e.build.core=arduino +x21e.build.variant=Generic_x21E +x21e.build.variant_system_lib= +x21e.build.vid=0x16D0 +x21e.upload.protocol=sam-ba +x21e.bootloader.tool=openocd +x21e.menu.float.default=Print & String use auto-promoted doubles only +x21e.menu.float.default.build.floatconfig=FLOAT_BOTH_DOUBLES_ONLY +x21e.menu.float.print=Print uses separate singles and doubles +x21e.menu.float.print.build.floatconfig=FLOAT_PRINT_SINGLES_DOUBLES +x21e.menu.float.string=String uses separate singles and doubles +x21e.menu.float.string.build.floatconfig=FLOAT_STRING_SINGLES_DOUBLES +x21e.menu.float.both=Print & String use separate singles and doubles +x21e.menu.float.both.build.floatconfig=FLOAT_BOTH_SINGLES_DOUBLES +x21e.menu.config.disabled=config.h disabled +x21e.menu.config.disabled.build.buildconfig=CONFIG_H_DISABLED +x21e.menu.config.enabled=config.h enabled (mostly code size reductions) +x21e.menu.config.enabled.build.buildconfig=CONFIG_H_ENABLED +x21e.menu.clock.internal_usb=INTERNAL_USB_CALIBRATED_OSCILLATOR +x21e.menu.clock.internal_usb.build.clockconfig=CLOCKCONFIG_INTERNAL_USB +x21e.menu.clock.internal=INTERNAL_OSCILLATOR +x21e.menu.clock.internal.build.clockconfig=CLOCKCONFIG_INTERNAL +x21e.menu.clock.crystal_32k=32KHZ_CRYSTAL +x21e.menu.clock.crystal_32k.build.clockconfig=CLOCKCONFIG_32768HZ_CRYSTAL +x21e.menu.clock.crystal_hs=HIGH_SPEED_CRYSTAL +x21e.menu.clock.crystal_hs.build.clockconfig=CLOCKCONFIG_HS_CRYSTAL +x21e.menu.timer.timer_732Hz=732.4Hz (16-bit) +x21e.menu.timer.timer_732Hz.build.timerconfig=TIMER_732Hz +x21e.menu.timer.timer_366Hz=366.2Hz (16-bit) +x21e.menu.timer.timer_366Hz.build.timerconfig=TIMER_366Hz +x21e.menu.timer.timer_244Hz=244.1Hz (16-bit) +x21e.menu.timer.timer_244Hz.build.timerconfig=TIMER_244Hz +x21e.menu.timer.timer_183Hz=183.1Hz (16-bit) +x21e.menu.timer.timer_183Hz.build.timerconfig=TIMER_183Hz +x21e.menu.timer.timer_146Hz=146.5Hz (16-bit) +x21e.menu.timer.timer_146Hz.build.timerconfig=TIMER_146Hz +x21e.menu.timer.timer_122Hz=122.1Hz (16-bit) +x21e.menu.timer.timer_122Hz.build.timerconfig=TIMER_122Hz +x21e.menu.timer.timer_105Hz=104.6Hz (16-bit) +x21e.menu.timer.timer_105Hz.build.timerconfig=TIMER_105Hz +x21e.menu.timer.timer_81Hz=81.38Hz (16-bit) +x21e.menu.timer.timer_81Hz.build.timerconfig=TIMER_81Hz +x21e.menu.timer.timer_61Hz=61.04Hz (16-bit) +x21e.menu.timer.timer_61Hz.build.timerconfig=TIMER_61Hz +x21e.menu.timer.timer_31Hz=30.52Hz (16-bit) +x21e.menu.timer.timer_31Hz.build.timerconfig=TIMER_31Hz +x21e.menu.timer.timer_187500Hz=187500Hz (8-bit) +x21e.menu.timer.timer_187500Hz.build.timerconfig=TIMER_187500Hz +x21e.menu.timer.timer_93750Hz=93750Hz (8-bit) +x21e.menu.timer.timer_93750Hz.build.timerconfig=TIMER_93750Hz +x21e.menu.timer.timer_62500Hz=62500Hz (8-bit) +x21e.menu.timer.timer_62500Hz.build.timerconfig=TIMER_62500Hz +x21e.menu.timer.timer_37500Hz=37500Hz (8-bit) +x21e.menu.timer.timer_37500Hz.build.timerconfig=TIMER_37500Hz +x21e.menu.timer.timer_20833Hz=20833Hz (8-bit) +x21e.menu.timer.timer_20833Hz.build.timerconfig=TIMER_20833Hz +x21e.menu.timer.timer_12500Hz=12500Hz (8-bit) +x21e.menu.timer.timer_12500Hz.build.timerconfig=TIMER_12500Hz +x21e.menu.timer.timer_7500Hz=7500Hz (8-bit) +x21e.menu.timer.timer_7500Hz.build.timerconfig=TIMER_7500Hz +x21e.menu.timer.timer_4166Hz=4166Hz (8-bit) +x21e.menu.timer.timer_4166Hz.build.timerconfig=TIMER_4166Hz +x21e.menu.timer.timer_2930Hz=2930Hz (8-bit) +x21e.menu.timer.timer_2930Hz.build.timerconfig=TIMER_2930Hz +x21e.menu.timer.timer_1465Hz=1465Hz (8-bit) +x21e.menu.timer.timer_1465Hz.build.timerconfig=TIMER_1465Hz +x21e.menu.cpu.samd21e15a=SAMD21E15A +x21e.menu.cpu.samd21e15a.upload.maximum_size=24576 +x21e.menu.cpu.samd21e15a.build.extra_flags=-D__SAMD21E15A__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21e.menu.cpu.samd21e15a.build.ldscript=flash_32KB.ld +x21e.menu.cpu.samd21e15a.build.openocdscript=openocd_scripts/SAMD21E15A.cfg +x21e.menu.cpu.samd21e15a.bootloader.file=zero/binaries/sam_ba_SAMD21E15A.bin +x21e.menu.cpu.samd21e16a=SAMD21E16A +x21e.menu.cpu.samd21e16a.upload.maximum_size=57344 +x21e.menu.cpu.samd21e16a.build.extra_flags=-D__SAMD21E16A__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21e.menu.cpu.samd21e16a.build.ldscript=flash_64KB.ld +x21e.menu.cpu.samd21e16a.build.openocdscript=openocd_scripts/SAMD21E16A.cfg +x21e.menu.cpu.samd21e16a.bootloader.file=zero/binaries/sam_ba_SAMD21E16A.bin +x21e.menu.cpu.samd21e17a=SAMD21E17A +x21e.menu.cpu.samd21e17a.upload.maximum_size=122880 +x21e.menu.cpu.samd21e17a.build.extra_flags=-D__SAMD21E17A__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21e.menu.cpu.samd21e17a.build.ldscript=flash_128KB.ld +x21e.menu.cpu.samd21e17a.build.openocdscript=openocd_scripts/SAMD21E17A.cfg +x21e.menu.cpu.samd21e17a.bootloader.file=zero/binaries/sam_ba_SAMD21E17A.bin +x21e.menu.cpu.samd21e18a=SAMD21E18A +x21e.menu.cpu.samd21e18a.upload.maximum_size=253952 +x21e.menu.cpu.samd21e18a.build.extra_flags=-D__SAMD21E18A__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21e.menu.cpu.samd21e18a.build.ldscript=flash_256KB.ld +x21e.menu.cpu.samd21e18a.build.openocdscript=openocd_scripts/SAMD21E18A.cfg +x21e.menu.cpu.samd21e18a.bootloader.file=zero/binaries/sam_ba_SAMD21E18A.bin +x21e.menu.cpu.saml21e15b=SAML21E15B +x21e.menu.cpu.saml21e15b.upload.maximum_size=24576 +x21e.menu.cpu.saml21e15b.build.extra_flags=-D__SAML21E15B__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21e.menu.cpu.saml21e15b.build.ldscript=flash_32KB.ld +x21e.menu.cpu.saml21e15b.build.openocdscript=openocd_scripts/SAML21E15B.cfg +x21e.menu.cpu.saml21e15b.bootloader.file=zero/binaries/sam_ba_SAML21E15B.bin +x21e.menu.cpu.saml21e16b=SAML21E16B +x21e.menu.cpu.saml21e16b.upload.maximum_size=57344 +x21e.menu.cpu.saml21e16b.build.extra_flags=-D__SAML21E16B__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21e.menu.cpu.saml21e16b.build.ldscript=flash_64KB.ld +x21e.menu.cpu.saml21e16b.build.openocdscript=openocd_scripts/SAML21E16B.cfg +x21e.menu.cpu.saml21e16b.bootloader.file=zero/binaries/sam_ba_SAML21E16B.bin +x21e.menu.cpu.saml21e17b=SAML21E17B +x21e.menu.cpu.saml21e17b.upload.maximum_size=122880 +x21e.menu.cpu.saml21e17b.build.extra_flags=-D__SAML21E17B__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21e.menu.cpu.saml21e17b.build.ldscript=flash_128KB.ld +x21e.menu.cpu.saml21e17b.build.openocdscript=openocd_scripts/SAML21E17B.cfg +x21e.menu.cpu.saml21e17b.bootloader.file=zero/binaries/sam_ba_SAML21E17B.bin +x21e.menu.cpu.saml21e18b=SAML21E18B +x21e.menu.cpu.saml21e18b.upload.maximum_size=253952 +x21e.menu.cpu.saml21e18b.build.extra_flags=-D__SAML21E18B__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21e.menu.cpu.saml21e18b.build.ldscript=flash_256KB.ld +x21e.menu.cpu.saml21e18b.build.openocdscript=openocd_scripts/SAML21E18B.cfg +x21e.menu.cpu.saml21e18b.bootloader.file=zero/binaries/sam_ba_SAML21E18B.bin +x21e.menu.cpu.samc21e15a=SAMC21E15A +x21e.menu.cpu.samc21e15a.upload.maximum_size=24576 +x21e.menu.cpu.samc21e15a.build.extra_flags=-D__SAMC21E15A__ -DARM_MATH_CM0PLUS +x21e.menu.cpu.samc21e15a.build.ldscript=flash_32KB.ld +x21e.menu.cpu.samc21e15a.build.openocdscript=openocd_scripts/SAMC21E15A.cfg +x21e.menu.cpu.samc21e15a.bootloader.file=zero/binaries/sam_ba_SAMC21E15A.bin +x21e.menu.cpu.samc21e16a=SAMC21E16A +x21e.menu.cpu.samc21e16a.upload.maximum_size=57344 +x21e.menu.cpu.samc21e16a.build.extra_flags=-D__SAMC21E16A__ -DARM_MATH_CM0PLUS +x21e.menu.cpu.samc21e16a.build.ldscript=flash_64KB.ld +x21e.menu.cpu.samc21e16a.build.openocdscript=openocd_scripts/SAMC21E16A.cfg +x21e.menu.cpu.samc21e16a.bootloader.file=zero/binaries/sam_ba_SAMC21E16A.bin +x21e.menu.cpu.samc21e17a=SAMC21E17A +x21e.menu.cpu.samc21e17a.upload.maximum_size=122880 +x21e.menu.cpu.samc21e17a.build.extra_flags=-D__SAMC21E17A__ -DARM_MATH_CM0PLUS +x21e.menu.cpu.samc21e17a.build.ldscript=flash_128KB.ld +x21e.menu.cpu.samc21e17a.build.openocdscript=openocd_scripts/SAMC21E17A.cfg +x21e.menu.cpu.samc21e17a.bootloader.file=zero/binaries/sam_ba_SAMC21E17A.bin +x21e.menu.cpu.samc21e18a=SAMC21E18A +x21e.menu.cpu.samc21e18a.upload.maximum_size=253952 +x21e.menu.cpu.samc21e18a.build.extra_flags=-D__SAMC21E18A__ -DARM_MATH_CM0PLUS +x21e.menu.cpu.samc21e18a.build.ldscript=flash_256KB.ld +x21e.menu.cpu.samc21e18a.build.openocdscript=openocd_scripts/SAMC21E18A.cfg +x21e.menu.cpu.samc21e18a.bootloader.file=zero/binaries/sam_ba_SAMC21E18A.bin +x21e.menu.bootloader.8kb=8KB_BOOTLOADER +x21e.menu.bootloader.8kb.build.bootloader_size=__8KB_BOOTLOADER__ +x21e.menu.bootloader.8kb.build.ldscript_path=linker_scripts/gcc/8KB_Bootloader +x21e.menu.bootloader.8kb.upload.tool=Fab_SAM_Arduino:bossac +x21e.menu.bootloader.8kb.upload.use_1200bps_touch=true +x21e.menu.bootloader.8kb.upload.wait_for_upload_port=true +x21e.menu.bootloader.8kb.upload.native_usb=true +x21e.menu.bootloader.16kb=16KB_BOOTLOADER +x21e.menu.bootloader.16kb.build.bootloader_size=__16KB_BOOTLOADER__ +x21e.menu.bootloader.16kb.build.ldscript_path=linker_scripts/gcc/16KB_Bootloader +x21e.menu.bootloader.16kb.upload.tool=Fab_SAM_Arduino:bossac +x21e.menu.bootloader.16kb.upload.use_1200bps_touch=true +x21e.menu.bootloader.16kb.upload.wait_for_upload_port=true +x21e.menu.bootloader.16kb.upload.native_usb=true +x21e.menu.bootloader.0kb=NO_BOOTLOADER +x21e.menu.bootloader.0kb.build.bootloader_size=__NO_BOOTLOADER__ +x21e.menu.bootloader.0kb.build.ldscript_path=linker_scripts/gcc/No_Bootloader +x21e.menu.bootloader.0kb.upload.tool=openocd +x21e.menu.bootloader.0kb.upload.use_1200bps_touch=false +x21e.menu.bootloader.0kb.upload.wait_for_upload_port=false +x21e.menu.bootloader.0kb.upload.native_usb=false +x21e.menu.serial.one_uart=ONE_UART_ONE_WIRE_ONE_SPI +x21e.menu.serial.one_uart.build.serialcom_uart=ONE_UART +x21e.menu.serial.one_uart.build.serialcom_wire=ONE_WIRE +x21e.menu.serial.one_uart.build.serialcom_spi=ONE_SPI +x21e.menu.serial.one_uart_one_wire_two_spi=ONE_UART_ONE_WIRE_TWO_SPI +x21e.menu.serial.one_uart_one_wire_two_spi.build.serialcom_uart=ONE_UART +x21e.menu.serial.one_uart_one_wire_two_spi.build.serialcom_wire=ONE_WIRE +x21e.menu.serial.one_uart_one_wire_two_spi.build.serialcom_spi=TWO_SPI +x21e.menu.serial.one_uart_two_wire_one_spi=ONE_UART_TWO_WIRE_ONE_SPI +x21e.menu.serial.one_uart_two_wire_one_spi.build.serialcom_uart=ONE_UART +x21e.menu.serial.one_uart_two_wire_one_spi.build.serialcom_wire=TWO_WIRE +x21e.menu.serial.one_uart_two_wire_one_spi.build.serialcom_spi=ONE_SPI +x21e.menu.serial.two_uart=TWO_UART_ONE_WIRE_ONE_SPI +x21e.menu.serial.two_uart.build.serialcom_uart=TWO_UART +x21e.menu.serial.two_uart.build.serialcom_wire=ONE_WIRE +x21e.menu.serial.two_uart.build.serialcom_spi=ONE_SPI +x21e.menu.serial.three_uart_one_wire_no_spi=THREE_UART_ONE_WIRE_NO_SPI +x21e.menu.serial.three_uart_one_wire_no_spi.build.serialcom_uart=THREE_UART +x21e.menu.serial.three_uart_one_wire_no_spi.build.serialcom_wire=ONE_WIRE +x21e.menu.serial.three_uart_one_wire_no_spi.build.serialcom_spi=NO_SPI +x21e.menu.serial.three_uart_no_wire_one_spi=THREE_UART_NO_WIRE_ONE_SPI +x21e.menu.serial.three_uart_no_wire_one_spi.build.serialcom_uart=THREE_UART +x21e.menu.serial.three_uart_no_wire_one_spi.build.serialcom_wire=NO_WIRE +x21e.menu.serial.three_uart_no_wire_one_spi.build.serialcom_spi=ONE_SPI +x21e.menu.serial.four_uart=FOUR_UART_NO_WIRE_NO_SPI +x21e.menu.serial.four_uart.build.serialcom_uart=FOUR_UART +x21e.menu.serial.four_uart.build.serialcom_wire=NO_WIRE +x21e.menu.serial.four_uart.build.serialcom_spi=NO_SPI +x21e.menu.serial.no_uart_one_wire_two_spi=NO_UART_ONE_WIRE_TWO_SPI +x21e.menu.serial.no_uart_one_wire_two_spi.build.serialcom_uart=NO_UART +x21e.menu.serial.no_uart_one_wire_two_spi.build.serialcom_wire=ONE_WIRE +x21e.menu.serial.no_uart_one_wire_two_spi.build.serialcom_spi=TWO_SPI +x21e.menu.serial.four_uart_one_wire_one_spi=FOUR_UART_ONE_WIRE_ONE_SPI (L21 only) +x21e.menu.serial.four_uart_one_wire_one_spi.build.serialcom_uart=FOUR_UART +x21e.menu.serial.four_uart_one_wire_one_spi.build.serialcom_wire=ONE_WIRE +x21e.menu.serial.four_uart_one_wire_one_spi.build.serialcom_spi=ONE_SPI +x21e.menu.serial.five_uart_no_wire_one_spi=FIVE_UART_NO_WIRE_ONE_SPI (L21 only) +x21e.menu.serial.five_uart_no_wire_one_spi.build.serialcom_uart=FIVE_UART +x21e.menu.serial.five_uart_no_wire_one_spi.build.serialcom_wire=NO_WIRE +x21e.menu.serial.five_uart_no_wire_one_spi.build.serialcom_spi=ONE_SPI +x21e.menu.serial.five_uart_one_wire_no_spi=FIVE_UART_ONE_WIRE_NO_SPI (L21 only) +x21e.menu.serial.five_uart_one_wire_no_spi.build.serialcom_uart=FIVE_UART +x21e.menu.serial.five_uart_one_wire_no_spi.build.serialcom_wire=ONE_WIRE +x21e.menu.serial.five_uart_one_wire_no_spi.build.serialcom_spi=NO_SPI +x21e.menu.serial.six_uart=SIX_UART_NO_WIRE_NO_SPI (L21 only) +x21e.menu.serial.six_uart.build.serialcom_uart=SIX_UART +x21e.menu.serial.six_uart.build.serialcom_wire=NO_WIRE +x21e.menu.serial.six_uart.build.serialcom_spi=NO_SPI +x21e.menu.usb.cdc=CDC_ONLY +x21e.menu.usb.cdc.build.usbcom=CDC_ONLY +x21e.menu.usb.cdc.build.pid=0x4557 +x21e.menu.usb.cdc_hid=CDC_HID +x21e.menu.usb.cdc_hid.build.usbcom=CDC_HID +x21e.menu.usb.cdc_hid.build.pid=0x4856 +x21e.menu.usb.withcdc=WITH_CDC +x21e.menu.usb.withcdc.build.usbcom=WITH_CDC +x21e.menu.usb.withcdc.build.pid=0x4B41 +x21e.menu.usb.hid=HID_ONLY +x21e.menu.usb.hid.build.usbcom=HID_ONLY +x21e.menu.usb.hid.build.pid=0x4B40 +x21e.menu.usb.nocdc=WITHOUT_CDC +x21e.menu.usb.nocdc.build.usbcom=WITHOUT_CDC +x21e.menu.usb.nocdc.build.pid=0x4A0C +x21e.menu.usb.none=USB_DISABLED +x21e.menu.usb.none.build.usbcom=USB_DISABLED +x21e.menu.usb.none.build.pid=0x4856 + +# Generic x21G +x21g.name=Generic x21G +x21g.vid.0=0x16D0 +x21g.pid.0=0x5557 +x21g.vid.1=0x16D0 +x21g.pid.1=0x5856 +x21g.vid.2=0x16D0 +x21g.pid.2=0x5B41 +x21g.vid.3=0x16D0 +x21g.pid.3=0x5B40 +x21g.vid.4=0x16D0 +x21g.pid.4=0x5A0C +x21g.vid.5=0x16D0 +x21g.pid.5=0x5856 +x21g.build.usb_manufacturer="Fab Foundation" +x21g.build.board=SAMD_ZERO +x21g.build.core=arduino +x21g.build.variant=Generic_xx1G +x21g.build.variant_system_lib= +x21g.build.vid=0x16D0 +x21g.upload.protocol=sam-ba +x21g.bootloader.tool=openocd +x21g.menu.float.default=Print & String use auto-promoted doubles only +x21g.menu.float.default.build.floatconfig=FLOAT_BOTH_DOUBLES_ONLY +x21g.menu.float.print=Print uses separate singles and doubles +x21g.menu.float.print.build.floatconfig=FLOAT_PRINT_SINGLES_DOUBLES +x21g.menu.float.string=String uses separate singles and doubles +x21g.menu.float.string.build.floatconfig=FLOAT_STRING_SINGLES_DOUBLES +x21g.menu.float.both=Print & String use separate singles and doubles +x21g.menu.float.both.build.floatconfig=FLOAT_BOTH_SINGLES_DOUBLES +x21g.menu.config.disabled=config.h disabled +x21g.menu.config.disabled.build.buildconfig=CONFIG_H_DISABLED +x21g.menu.config.enabled=config.h enabled (mostly code size reductions) +x21g.menu.config.enabled.build.buildconfig=CONFIG_H_ENABLED +x21g.menu.clock.internal_usb=INTERNAL_USB_CALIBRATED_OSCILLATOR +x21g.menu.clock.internal_usb.build.clockconfig=CLOCKCONFIG_INTERNAL_USB +x21g.menu.clock.internal=INTERNAL_OSCILLATOR +x21g.menu.clock.internal.build.clockconfig=CLOCKCONFIG_INTERNAL +x21g.menu.clock.crystal_32k=32KHZ_CRYSTAL +x21g.menu.clock.crystal_32k.build.clockconfig=CLOCKCONFIG_32768HZ_CRYSTAL +x21g.menu.clock.crystal_hs=HIGH_SPEED_CRYSTAL +x21g.menu.clock.crystal_hs.build.clockconfig=CLOCKCONFIG_HS_CRYSTAL +x21g.menu.timer.timer_732Hz=732.4Hz (16-bit) +x21g.menu.timer.timer_732Hz.build.timerconfig=TIMER_732Hz +x21g.menu.timer.timer_366Hz=366.2Hz (16-bit) +x21g.menu.timer.timer_366Hz.build.timerconfig=TIMER_366Hz +x21g.menu.timer.timer_244Hz=244.1Hz (16-bit) +x21g.menu.timer.timer_244Hz.build.timerconfig=TIMER_244Hz +x21g.menu.timer.timer_183Hz=183.1Hz (16-bit) +x21g.menu.timer.timer_183Hz.build.timerconfig=TIMER_183Hz +x21g.menu.timer.timer_146Hz=146.5Hz (16-bit) +x21g.menu.timer.timer_146Hz.build.timerconfig=TIMER_146Hz +x21g.menu.timer.timer_122Hz=122.1Hz (16-bit) +x21g.menu.timer.timer_122Hz.build.timerconfig=TIMER_122Hz +x21g.menu.timer.timer_105Hz=104.6Hz (16-bit) +x21g.menu.timer.timer_105Hz.build.timerconfig=TIMER_105Hz +x21g.menu.timer.timer_81Hz=81.38Hz (16-bit) +x21g.menu.timer.timer_81Hz.build.timerconfig=TIMER_81Hz +x21g.menu.timer.timer_61Hz=61.04Hz (16-bit) +x21g.menu.timer.timer_61Hz.build.timerconfig=TIMER_61Hz +x21g.menu.timer.timer_31Hz=30.52Hz (16-bit) +x21g.menu.timer.timer_31Hz.build.timerconfig=TIMER_31Hz +x21g.menu.timer.timer_187500Hz=187500Hz (8-bit) +x21g.menu.timer.timer_187500Hz.build.timerconfig=TIMER_187500Hz +x21g.menu.timer.timer_93750Hz=93750Hz (8-bit) +x21g.menu.timer.timer_93750Hz.build.timerconfig=TIMER_93750Hz +x21g.menu.timer.timer_62500Hz=62500Hz (8-bit) +x21g.menu.timer.timer_62500Hz.build.timerconfig=TIMER_62500Hz +x21g.menu.timer.timer_37500Hz=37500Hz (8-bit) +x21g.menu.timer.timer_37500Hz.build.timerconfig=TIMER_37500Hz +x21g.menu.timer.timer_20833Hz=20833Hz (8-bit) +x21g.menu.timer.timer_20833Hz.build.timerconfig=TIMER_20833Hz +x21g.menu.timer.timer_12500Hz=12500Hz (8-bit) +x21g.menu.timer.timer_12500Hz.build.timerconfig=TIMER_12500Hz +x21g.menu.timer.timer_7500Hz=7500Hz (8-bit) +x21g.menu.timer.timer_7500Hz.build.timerconfig=TIMER_7500Hz +x21g.menu.timer.timer_4166Hz=4166Hz (8-bit) +x21g.menu.timer.timer_4166Hz.build.timerconfig=TIMER_4166Hz +x21g.menu.timer.timer_2930Hz=2930Hz (8-bit) +x21g.menu.timer.timer_2930Hz.build.timerconfig=TIMER_2930Hz +x21g.menu.timer.timer_1465Hz=1465Hz (8-bit) +x21g.menu.timer.timer_1465Hz.build.timerconfig=TIMER_1465Hz +x21g.menu.cpu.samd21g17a=SAMD21G17A +x21g.menu.cpu.samd21g17a.upload.maximum_size=122880 +x21g.menu.cpu.samd21g17a.build.mcu=cortex-m0plus +x21g.menu.cpu.samd21g17a.build.mathlib=arm_cortexM0l_math +x21g.menu.cpu.samd21g17a.build.f_cpu=48000000L +x21g.menu.cpu.samd21g17a.build.usb_product="D21" +x21g.menu.cpu.samd21g17a.build.extra_flags=-D__SAMD21G17A__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21g.menu.cpu.samd21g17a.build.ldscript=flash_128KB.ld +x21g.menu.cpu.samd21g17a.build.openocdscript=openocd_scripts/SAMD21G17A.cfg +x21g.menu.cpu.samd21g17a.bootloader.file=zero/binaries/sam_ba_SAMD21G17A.bin +x21g.menu.cpu.samd21g18a=SAMD21G18A +x21g.menu.cpu.samd21g18a.upload.maximum_size=253952 +x21g.menu.cpu.samd21g18a.build.mcu=cortex-m0plus +x21g.menu.cpu.samd21g18a.build.mathlib=arm_cortexM0l_math +x21g.menu.cpu.samd21g18a.build.f_cpu=48000000L +x21g.menu.cpu.samd21g18a.build.usb_product="D21" +x21g.menu.cpu.samd21g18a.build.extra_flags=-D__SAMD21G18A__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21g.menu.cpu.samd21g18a.build.ldscript=flash_256KB.ld +x21g.menu.cpu.samd21g18a.build.openocdscript=openocd_scripts/SAMD21G18A.cfg +x21g.menu.cpu.samd21g18a.bootloader.file=zero/binaries/sam_ba_SAMD21G18A.bin +x21g.menu.cpu.samd21g15a=SAMD21G15A +x21g.menu.cpu.samd21g15a.upload.maximum_size=24576 +x21g.menu.cpu.samd21g15a.build.mcu=cortex-m0plus +x21g.menu.cpu.samd21g15a.build.mathlib=arm_cortexM0l_math +x21g.menu.cpu.samd21g15a.build.f_cpu=48000000L +x21g.menu.cpu.samd21g15a.build.usb_product="D21" +x21g.menu.cpu.samd21g15a.build.extra_flags=-D__SAMD21G15A__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21g.menu.cpu.samd21g15a.build.ldscript=flash_32KB.ld +x21g.menu.cpu.samd21g15a.build.openocdscript=openocd_scripts/SAMD21G15A.cfg +x21g.menu.cpu.samd21g15a.bootloader.file=zero/binaries/sam_ba_SAMD21G15A.bin +x21g.menu.cpu.samd21g16a=SAMD21G16A +x21g.menu.cpu.samd21g16a.upload.maximum_size=57344 +x21g.menu.cpu.samd21g16a.build.mcu=cortex-m0plus +x21g.menu.cpu.samd21g16a.build.mathlib=arm_cortexM0l_math +x21g.menu.cpu.samd21g16a.build.f_cpu=48000000L +x21g.menu.cpu.samd21g16a.build.usb_product="D21" +x21g.menu.cpu.samd21g16a.build.extra_flags=-D__SAMD21G16A__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21g.menu.cpu.samd21g16a.build.ldscript=flash_64KB.ld +x21g.menu.cpu.samd21g16a.build.openocdscript=openocd_scripts/SAMD21G16A.cfg +x21g.menu.cpu.samd21g16a.bootloader.file=zero/binaries/sam_ba_SAMD21G16A.bin +x21g.menu.cpu.saml21g17b=SAML21G17B +x21g.menu.cpu.saml21g17b.upload.maximum_size=122880 +x21g.menu.cpu.saml21g17b.build.mcu=cortex-m0plus +x21g.menu.cpu.saml21g17b.build.mathlib=arm_cortexM0l_math +x21g.menu.cpu.saml21g17b.build.f_cpu=48000000L +x21g.menu.cpu.saml21g17b.build.usb_product="L21" +x21g.menu.cpu.saml21g17b.build.extra_flags=-D__SAML21G17B__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21g.menu.cpu.saml21g17b.build.ldscript=flash_128KB.ld +x21g.menu.cpu.saml21g17b.build.openocdscript=openocd_scripts/SAML21G17B.cfg +x21g.menu.cpu.saml21g17b.bootloader.file=zero/binaries/sam_ba_SAML21G17B.bin +x21g.menu.cpu.saml21g18b=SAML21G18B +x21g.menu.cpu.saml21g18b.upload.maximum_size=253952 +x21g.menu.cpu.saml21g18b.build.mcu=cortex-m0plus +x21g.menu.cpu.saml21g18b.build.mathlib=arm_cortexM0l_math +x21g.menu.cpu.saml21g18b.build.f_cpu=48000000L +x21g.menu.cpu.saml21g18b.build.usb_product="L21" +x21g.menu.cpu.saml21g18b.build.extra_flags=-D__SAML21G18B__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21g.menu.cpu.saml21g18b.build.ldscript=flash_256KB.ld +x21g.menu.cpu.saml21g18b.build.openocdscript=openocd_scripts/SAML21G18B.cfg +x21g.menu.cpu.saml21g18b.bootloader.file=zero/binaries/sam_ba_SAML21G18B.bin +x21g.menu.cpu.saml21g15b=SAML21G15B +x21g.menu.cpu.saml21g15b.upload.maximum_size=24576 +x21g.menu.cpu.saml21g15b.build.mcu=cortex-m0plus +x21g.menu.cpu.saml21g15b.build.mathlib=arm_cortexM0l_math +x21g.menu.cpu.saml21g15b.build.f_cpu=48000000L +x21g.menu.cpu.saml21g15b.build.usb_product="L21" +x21g.menu.cpu.saml21g15b.build.extra_flags=-D__SAML21G15B__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21g.menu.cpu.saml21g15b.build.ldscript=flash_32KB.ld +x21g.menu.cpu.saml21g15b.build.openocdscript=openocd_scripts/SAML21G15B.cfg +x21g.menu.cpu.saml21g15b.bootloader.file=zero/binaries/sam_ba_SAML21G15B.bin +x21g.menu.cpu.saml21g16b=SAML21G16B +x21g.menu.cpu.saml21g16b.upload.maximum_size=57344 +x21g.menu.cpu.saml21g16b.build.mcu=cortex-m0plus +x21g.menu.cpu.saml21g16b.build.mathlib=arm_cortexM0l_math +x21g.menu.cpu.saml21g16b.build.f_cpu=48000000L +x21g.menu.cpu.saml21g16b.build.usb_product="L21" +x21g.menu.cpu.saml21g16b.build.extra_flags=-D__SAML21G16B__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21g.menu.cpu.saml21g16b.build.ldscript=flash_64KB.ld +x21g.menu.cpu.saml21g16b.build.openocdscript=openocd_scripts/SAML21G16B.cfg +x21g.menu.cpu.saml21g16b.bootloader.file=zero/binaries/sam_ba_SAML21G16B.bin +x21g.menu.cpu.samc21g17a=SAMC21G17A +x21g.menu.cpu.samc21g17a.upload.maximum_size=122880 +x21g.menu.cpu.samc21g17a.build.mcu=cortex-m0plus +x21g.menu.cpu.samc21g17a.build.mathlib=arm_cortexM0l_math +x21g.menu.cpu.samc21g17a.build.f_cpu=48000000L +x21g.menu.cpu.samc21g17a.build.usb_product="C21" +x21g.menu.cpu.samc21g17a.build.extra_flags=-D__SAMC21G17A__ -DARM_MATH_CM0PLUS +x21g.menu.cpu.samc21g17a.build.ldscript=flash_128KB.ld +x21g.menu.cpu.samc21g17a.build.openocdscript=openocd_scripts/SAMC21G17A.cfg +x21g.menu.cpu.samc21g17a.bootloader.file=zero/binaries/sam_ba_SAMC21G17A.bin +x21g.menu.cpu.samc21g18a=SAMC21G18A +x21g.menu.cpu.samc21g18a.upload.maximum_size=253952 +x21g.menu.cpu.samc21g18a.build.mcu=cortex-m0plus +x21g.menu.cpu.samc21g18a.build.mathlib=arm_cortexM0l_math +x21g.menu.cpu.samc21g18a.build.f_cpu=48000000L +x21g.menu.cpu.samc21g18a.build.usb_product="C21" +x21g.menu.cpu.samc21g18a.build.extra_flags=-D__SAMC21G18A__ -DARM_MATH_CM0PLUS +x21g.menu.cpu.samc21g18a.build.ldscript=flash_256KB.ld +x21g.menu.cpu.samc21g18a.build.openocdscript=openocd_scripts/SAMC21G18A.cfg +x21g.menu.cpu.samc21g18a.bootloader.file=zero/binaries/sam_ba_SAMC21G18A.bin +x21g.menu.cpu.samc21g15a=SAMC21G15A +x21g.menu.cpu.samc21g15a.upload.maximum_size=24576 +x21g.menu.cpu.samc21g15a.build.mcu=cortex-m0plus +x21g.menu.cpu.samc21g15a.build.mathlib=arm_cortexM0l_math +x21g.menu.cpu.samc21g15a.build.f_cpu=48000000L +x21g.menu.cpu.samc21g15a.build.usb_product="C21" +x21g.menu.cpu.samc21g15a.build.extra_flags=-D__SAMC21G15A__ -DARM_MATH_CM0PLUS +x21g.menu.cpu.samc21g15a.build.ldscript=flash_32KB.ld +x21g.menu.cpu.samc21g15a.build.openocdscript=openocd_scripts/SAMC21G15A.cfg +x21g.menu.cpu.samc21g15a.bootloader.file=zero/binaries/sam_ba_SAMC21G15A.bin +x21g.menu.cpu.samc21g16a=SAMC21G16A +x21g.menu.cpu.samc21g16a.upload.maximum_size=57344 +x21g.menu.cpu.samc21g16a.build.mcu=cortex-m0plus +x21g.menu.cpu.samc21g16a.build.mathlib=arm_cortexM0l_math +x21g.menu.cpu.samc21g16a.build.f_cpu=48000000L +x21g.menu.cpu.samc21g16a.build.usb_product="C21" +x21g.menu.cpu.samc21g16a.build.extra_flags=-D__SAMC21G16A__ -DARM_MATH_CM0PLUS +x21g.menu.cpu.samc21g16a.build.ldscript=flash_64KB.ld +x21g.menu.cpu.samc21g16a.build.openocdscript=openocd_scripts/SAMC21G16A.cfg +x21g.menu.cpu.samc21g16a.bootloader.file=zero/binaries/sam_ba_SAMC21G16A.bin +x21g.menu.bootloader.8kb=8KB_BOOTLOADER +x21g.menu.bootloader.8kb.build.bootloader_size=__8KB_BOOTLOADER__ +x21g.menu.bootloader.8kb.build.ldscript_path=linker_scripts/gcc/8KB_Bootloader +x21g.menu.bootloader.8kb.upload.tool=Fab_SAM_Arduino:bossac +x21g.menu.bootloader.8kb.upload.use_1200bps_touch=true +x21g.menu.bootloader.8kb.upload.wait_for_upload_port=true +x21g.menu.bootloader.8kb.upload.native_usb=true +x21g.menu.bootloader.16kb=16KB_BOOTLOADER +x21g.menu.bootloader.16kb.build.bootloader_size=__16KB_BOOTLOADER__ +x21g.menu.bootloader.16kb.build.ldscript_path=linker_scripts/gcc/16KB_Bootloader +x21g.menu.bootloader.16kb.upload.tool=Fab_SAM_Arduino:bossac +x21g.menu.bootloader.16kb.upload.use_1200bps_touch=true +x21g.menu.bootloader.16kb.upload.wait_for_upload_port=true +x21g.menu.bootloader.16kb.upload.native_usb=true +x21g.menu.bootloader.0kb=NO_BOOTLOADER +x21g.menu.bootloader.0kb.build.bootloader_size=__NO_BOOTLOADER__ +x21g.menu.bootloader.0kb.build.ldscript_path=linker_scripts/gcc/No_Bootloader +x21g.menu.bootloader.0kb.upload.tool=openocd +x21g.menu.bootloader.0kb.upload.use_1200bps_touch=false +x21g.menu.bootloader.0kb.upload.wait_for_upload_port=false +x21g.menu.bootloader.0kb.upload.native_usb=false +x21g.menu.serial.one_uart=ONE_UART_ONE_WIRE_ONE_SPI +x21g.menu.serial.one_uart.build.serialcom_uart=ONE_UART +x21g.menu.serial.one_uart.build.serialcom_wire=ONE_WIRE +x21g.menu.serial.one_uart.build.serialcom_spi=ONE_SPI +x21g.menu.serial.one_uart_two_spi=ONE_UART_ONE_WIRE_TWO_SPI +x21g.menu.serial.one_uart_two_spi.build.serialcom_uart=ONE_UART +x21g.menu.serial.one_uart_two_spi.build.serialcom_wire=ONE_WIRE +x21g.menu.serial.one_uart_two_spi.build.serialcom_spi=TWO_SPI +x21g.menu.serial.one_uart_two_wire=ONE_UART_TWO_WIRE_ONE_SPI +x21g.menu.serial.one_uart_two_wire.build.serialcom_uart=ONE_UART +x21g.menu.serial.one_uart_two_wire.build.serialcom_wire=TWO_WIRE +x21g.menu.serial.one_uart_two_wire.build.serialcom_spi=ONE_SPI +x21g.menu.serial.two_uart=TWO_UART_ONE_WIRE_ONE_SPI +x21g.menu.serial.two_uart.build.serialcom_uart=TWO_UART +x21g.menu.serial.two_uart.build.serialcom_wire=ONE_WIRE +x21g.menu.serial.two_uart.build.serialcom_spi=ONE_SPI +x21g.menu.serial.two_uart_two_spi=TWO_UART_ONE_WIRE_TWO_SPI +x21g.menu.serial.two_uart_two_spi.build.serialcom_uart=TWO_UART +x21g.menu.serial.two_uart_two_spi.build.serialcom_wire=ONE_WIRE +x21g.menu.serial.two_uart_two_spi.build.serialcom_spi=TWO_SPI +x21g.menu.serial.two_uart_two_wire=TWO_UART_TWO_WIRE_ONE_SPI +x21g.menu.serial.two_uart_two_wire.build.serialcom_uart=TWO_UART +x21g.menu.serial.two_uart_two_wire.build.serialcom_wire=TWO_WIRE +x21g.menu.serial.two_uart_two_wire.build.serialcom_spi=ONE_SPI +x21g.menu.serial.three_uart=THREE_UART_ONE_WIRE_ONE_SPI +x21g.menu.serial.three_uart.build.serialcom_uart=THREE_UART +x21g.menu.serial.three_uart.build.serialcom_wire=ONE_WIRE +x21g.menu.serial.three_uart.build.serialcom_spi=ONE_SPI +x21g.menu.serial.three_uart_two_spi=THREE_UART_ONE_WIRE_TWO_SPI +x21g.menu.serial.three_uart_two_spi.build.serialcom_uart=THREE_UART +x21g.menu.serial.three_uart_two_spi.build.serialcom_wire=ONE_WIRE +x21g.menu.serial.three_uart_two_spi.build.serialcom_spi=TWO_SPI +x21g.menu.serial.three_uart_two_wire=THREE_UART_TWO_WIRE_ONE_SPI +x21g.menu.serial.three_uart_two_wire.build.serialcom_uart=THREE_UART +x21g.menu.serial.three_uart_two_wire.build.serialcom_wire=TWO_WIRE +x21g.menu.serial.three_uart_two_wire.build.serialcom_spi=ONE_SPI +x21g.menu.serial.no_uart=NO_UART_ONE_WIRE_ONE_SPI +x21g.menu.serial.no_uart.build.serialcom_uart=NO_UART +x21g.menu.serial.no_uart.build.serialcom_wire=ONE_WIRE +x21g.menu.serial.no_uart.build.serialcom_spi=ONE_SPI +x21g.menu.usb.cdc=CDC_ONLY +x21g.menu.usb.cdc.build.usbcom=CDC_ONLY +x21g.menu.usb.cdc.build.pid=0x5557 +x21g.menu.usb.cdc_hid=CDC_HID +x21g.menu.usb.cdc_hid.build.usbcom=CDC_HID +x21g.menu.usb.cdc_hid.build.pid=0x5856 +x21g.menu.usb.withcdc=WITH_CDC +x21g.menu.usb.withcdc.build.usbcom=WITH_CDC +x21g.menu.usb.withcdc.build.pid=0x5B41 +x21g.menu.usb.hid=HID_ONLY +x21g.menu.usb.hid.build.usbcom=HID_ONLY +x21g.menu.usb.hid.build.pid=0x5B40 +x21g.menu.usb.nocdc=WITHOUT_CDC +x21g.menu.usb.nocdc.build.usbcom=WITHOUT_CDC +x21g.menu.usb.nocdc.build.pid=0x5A0C +x21g.menu.usb.none=USB_DISABLED +x21g.menu.usb.none.build.usbcom=USB_DISABLED +x21g.menu.usb.none.build.pid=0x5856 + +# Generic x21J +x21j.name=Generic x21J +x21j.vid.0=0x16D0 +x21j.pid.0=0x6557 +x21j.vid.1=0x16D0 +x21j.pid.1=0x6856 +x21j.vid.2=0x16D0 +x21j.pid.2=0x6B41 +x21j.vid.3=0x16D0 +x21j.pid.3=0x6B40 +x21j.vid.4=0x16D0 +x21j.pid.4=0x6A0C +x21j.vid.5=0x16D0 +x21j.pid.5=0x6856 +x21j.build.usb_manufacturer="Fab Foundation" +x21j.build.board=SAMD_ZERO +x21j.build.core=arduino +x21j.build.variant=Generic_xx1J +x21j.build.variant_system_lib= +x21j.build.vid=0x16D0 +x21j.upload.protocol=sam-ba +x21j.bootloader.tool=openocd +x21j.menu.float.default=Print & String use auto-promoted doubles only +x21j.menu.float.default.build.floatconfig=FLOAT_BOTH_DOUBLES_ONLY +x21j.menu.float.print=Print uses separate singles and doubles +x21j.menu.float.print.build.floatconfig=FLOAT_PRINT_SINGLES_DOUBLES +x21j.menu.float.string=String uses separate singles and doubles +x21j.menu.float.string.build.floatconfig=FLOAT_STRING_SINGLES_DOUBLES +x21j.menu.float.both=Print & String use separate singles and doubles +x21j.menu.float.both.build.floatconfig=FLOAT_BOTH_SINGLES_DOUBLES +x21j.menu.config.disabled=config.h disabled +x21j.menu.config.disabled.build.buildconfig=CONFIG_H_DISABLED +x21j.menu.config.enabled=config.h enabled (mostly code size reductions) +x21j.menu.config.enabled.build.buildconfig=CONFIG_H_ENABLED +x21j.menu.clock.internal_usb=INTERNAL_USB_CALIBRATED_OSCILLATOR +x21j.menu.clock.internal_usb.build.clockconfig=CLOCKCONFIG_INTERNAL_USB +x21j.menu.clock.internal=INTERNAL_OSCILLATOR +x21j.menu.clock.internal.build.clockconfig=CLOCKCONFIG_INTERNAL +x21j.menu.clock.crystal_32k=32KHZ_CRYSTAL +x21j.menu.clock.crystal_32k.build.clockconfig=CLOCKCONFIG_32768HZ_CRYSTAL +x21j.menu.clock.crystal_hs=HIGH_SPEED_CRYSTAL +x21j.menu.clock.crystal_hs.build.clockconfig=CLOCKCONFIG_HS_CRYSTAL +x21j.menu.timer.timer_732Hz=732.4Hz (16-bit) +x21j.menu.timer.timer_732Hz.build.timerconfig=TIMER_732Hz +x21j.menu.timer.timer_366Hz=366.2Hz (16-bit) +x21j.menu.timer.timer_366Hz.build.timerconfig=TIMER_366Hz +x21j.menu.timer.timer_244Hz=244.1Hz (16-bit) +x21j.menu.timer.timer_244Hz.build.timerconfig=TIMER_244Hz +x21j.menu.timer.timer_183Hz=183.1Hz (16-bit) +x21j.menu.timer.timer_183Hz.build.timerconfig=TIMER_183Hz +x21j.menu.timer.timer_146Hz=146.5Hz (16-bit) +x21j.menu.timer.timer_146Hz.build.timerconfig=TIMER_146Hz +x21j.menu.timer.timer_122Hz=122.1Hz (16-bit) +x21j.menu.timer.timer_122Hz.build.timerconfig=TIMER_122Hz +x21j.menu.timer.timer_105Hz=104.6Hz (16-bit) +x21j.menu.timer.timer_105Hz.build.timerconfig=TIMER_105Hz +x21j.menu.timer.timer_81Hz=81.38Hz (16-bit) +x21j.menu.timer.timer_81Hz.build.timerconfig=TIMER_81Hz +x21j.menu.timer.timer_61Hz=61.04Hz (16-bit) +x21j.menu.timer.timer_61Hz.build.timerconfig=TIMER_61Hz +x21j.menu.timer.timer_31Hz=30.52Hz (16-bit) +x21j.menu.timer.timer_31Hz.build.timerconfig=TIMER_31Hz +x21j.menu.timer.timer_187500Hz=187500Hz (8-bit) +x21j.menu.timer.timer_187500Hz.build.timerconfig=TIMER_187500Hz +x21j.menu.timer.timer_93750Hz=93750Hz (8-bit) +x21j.menu.timer.timer_93750Hz.build.timerconfig=TIMER_93750Hz +x21j.menu.timer.timer_62500Hz=62500Hz (8-bit) +x21j.menu.timer.timer_62500Hz.build.timerconfig=TIMER_62500Hz +x21j.menu.timer.timer_37500Hz=37500Hz (8-bit) +x21j.menu.timer.timer_37500Hz.build.timerconfig=TIMER_37500Hz +x21j.menu.timer.timer_20833Hz=20833Hz (8-bit) +x21j.menu.timer.timer_20833Hz.build.timerconfig=TIMER_20833Hz +x21j.menu.timer.timer_12500Hz=12500Hz (8-bit) +x21j.menu.timer.timer_12500Hz.build.timerconfig=TIMER_12500Hz +x21j.menu.timer.timer_7500Hz=7500Hz (8-bit) +x21j.menu.timer.timer_7500Hz.build.timerconfig=TIMER_7500Hz +x21j.menu.timer.timer_4166Hz=4166Hz (8-bit) +x21j.menu.timer.timer_4166Hz.build.timerconfig=TIMER_4166Hz +x21j.menu.timer.timer_2930Hz=2930Hz (8-bit) +x21j.menu.timer.timer_2930Hz.build.timerconfig=TIMER_2930Hz +x21j.menu.timer.timer_1465Hz=1465Hz (8-bit) +x21j.menu.timer.timer_1465Hz.build.timerconfig=TIMER_1465Hz +x21j.menu.cpu.samd21j17a=SAMD21J17A +x21j.menu.cpu.samd21j17a.upload.maximum_size=122880 +x21j.menu.cpu.samd21j17a.build.mcu=cortex-m0plus +x21j.menu.cpu.samd21j17a.build.mathlib=arm_cortexM0l_math +x21j.menu.cpu.samd21j17a.build.f_cpu=48000000L +x21j.menu.cpu.samd21j17a.build.usb_product="Xeno D21" +x21j.menu.cpu.samd21j17a.build.extra_flags=-D__SAMD21J17A__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21j.menu.cpu.samd21j17a.build.ldscript=flash_128KB.ld +x21j.menu.cpu.samd21j17a.build.openocdscript=openocd_scripts/SAMD21J17A.cfg +x21j.menu.cpu.samd21j17a.bootloader.file=zero/binaries/sam_ba_SAMD21J17A.bin +x21j.menu.cpu.samd21j18a=SAMD21J18A +x21j.menu.cpu.samd21j18a.upload.maximum_size=253952 +x21j.menu.cpu.samd21j18a.build.mcu=cortex-m0plus +x21j.menu.cpu.samd21j18a.build.mathlib=arm_cortexM0l_math +x21j.menu.cpu.samd21j18a.build.f_cpu=48000000L +x21j.menu.cpu.samd21j18a.build.usb_product="Xeno D21" +x21j.menu.cpu.samd21j18a.build.extra_flags=-D__SAMD21J18A__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21j.menu.cpu.samd21j18a.build.ldscript=flash_256KB.ld +x21j.menu.cpu.samd21j18a.build.openocdscript=openocd_scripts/SAMD21J18A.cfg +x21j.menu.cpu.samd21j18a.bootloader.file=zero/binaries/sam_ba_SAMD21J18A.bin +x21j.menu.cpu.samd21j15a=SAMD21J15A +x21j.menu.cpu.samd21j15a.upload.maximum_size=24576 +x21j.menu.cpu.samd21j15a.build.mcu=cortex-m0plus +x21j.menu.cpu.samd21j15a.build.mathlib=arm_cortexM0l_math +x21j.menu.cpu.samd21j15a.build.f_cpu=48000000L +x21j.menu.cpu.samd21j15a.build.usb_product="Xeno D21" +x21j.menu.cpu.samd21j15a.build.extra_flags=-D__SAMD21J15A__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21j.menu.cpu.samd21j15a.build.ldscript=flash_32KB.ld +x21j.menu.cpu.samd21j15a.build.openocdscript=openocd_scripts/SAMD21J15A.cfg +x21j.menu.cpu.samd21j15a.bootloader.file=zero/binaries/sam_ba_SAMD21J15A.bin +x21j.menu.cpu.samd21j16a=SAMD21J16A +x21j.menu.cpu.samd21j16a.upload.maximum_size=57344 +x21j.menu.cpu.samd21j16a.build.mcu=cortex-m0plus +x21j.menu.cpu.samd21j16a.build.mathlib=arm_cortexM0l_math +x21j.menu.cpu.samd21j16a.build.f_cpu=48000000L +x21j.menu.cpu.samd21j16a.build.usb_product="Xeno D21" +x21j.menu.cpu.samd21j16a.build.extra_flags=-D__SAMD21J16A__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21j.menu.cpu.samd21j16a.build.ldscript=flash_64KB.ld +x21j.menu.cpu.samd21j16a.build.openocdscript=openocd_scripts/SAMD21J16A.cfg +x21j.menu.cpu.samd21j16a.bootloader.file=zero/binaries/sam_ba_SAMD21J16A.bin +x21j.menu.cpu.saml21j17b=SAML21J17B +x21j.menu.cpu.saml21j17b.upload.maximum_size=122880 +x21j.menu.cpu.saml21j17b.build.mcu=cortex-m0plus +x21j.menu.cpu.saml21j17b.build.mathlib=arm_cortexM0l_math +x21j.menu.cpu.saml21j17b.build.f_cpu=48000000L +x21j.menu.cpu.saml21j17b.build.usb_product="Xeno L21" +x21j.menu.cpu.saml21j17b.build.extra_flags=-D__SAML21J17B__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21j.menu.cpu.saml21j17b.build.ldscript=flash_128KB.ld +x21j.menu.cpu.saml21j17b.build.openocdscript=openocd_scripts/SAML21J17B.cfg +x21j.menu.cpu.saml21j17b.bootloader.file=zero/binaries/sam_ba_SAML21J17B.bin +x21j.menu.cpu.saml21j18b=SAML21J18B +x21j.menu.cpu.saml21j18b.upload.maximum_size=253952 +x21j.menu.cpu.saml21j18b.build.mcu=cortex-m0plus +x21j.menu.cpu.saml21j18b.build.mathlib=arm_cortexM0l_math +x21j.menu.cpu.saml21j18b.build.f_cpu=48000000L +x21j.menu.cpu.saml21j18b.build.usb_product="Xeno L21" +x21j.menu.cpu.saml21j18b.build.extra_flags=-D__SAML21J18B__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21j.menu.cpu.saml21j18b.build.ldscript=flash_256KB.ld +x21j.menu.cpu.saml21j18b.build.openocdscript=openocd_scripts/SAML21J18B.cfg +x21j.menu.cpu.saml21j18b.bootloader.file=zero/binaries/sam_ba_SAML21J18B.bin +x21j.menu.cpu.saml21j16b=SAML21J16B +x21j.menu.cpu.saml21j16b.upload.maximum_size=57344 +x21j.menu.cpu.saml21j16b.build.mcu=cortex-m0plus +x21j.menu.cpu.saml21j16b.build.mathlib=arm_cortexM0l_math +x21j.menu.cpu.saml21j16b.build.f_cpu=48000000L +x21j.menu.cpu.saml21j16b.build.usb_product="Xeno L21" +x21j.menu.cpu.saml21j16b.build.extra_flags=-D__SAML21J16B__ {build.usb_flags} -DARM_MATH_CM0PLUS +x21j.menu.cpu.saml21j16b.build.ldscript=flash_64KB.ld +x21j.menu.cpu.saml21j16b.build.openocdscript=openocd_scripts/SAML21J16B.cfg +x21j.menu.cpu.saml21j16b.bootloader.file=zero/binaries/sam_ba_SAML21J16B.bin +x21j.menu.cpu.samc21j17a=SAMC21J17A +x21j.menu.cpu.samc21j17a.upload.maximum_size=122880 +x21j.menu.cpu.samc21j17a.build.mcu=cortex-m0plus +x21j.menu.cpu.samc21j17a.build.mathlib=arm_cortexM0l_math +x21j.menu.cpu.samc21j17a.build.f_cpu=48000000L +x21j.menu.cpu.samc21j17a.build.usb_product="Xeno C21" +x21j.menu.cpu.samc21j17a.build.extra_flags=-D__SAMC21J17A__ -DARM_MATH_CM0PLUS +x21j.menu.cpu.samc21j17a.build.ldscript=flash_128KB.ld +x21j.menu.cpu.samc21j17a.build.openocdscript=openocd_scripts/SAMC21J17A.cfg +x21j.menu.cpu.samc21j17a.bootloader.file=zero/binaries/sam_ba_SAMC21J17A.bin +x21j.menu.cpu.samc21j18a=SAMC21J18A +x21j.menu.cpu.samc21j18a.upload.maximum_size=253952 +x21j.menu.cpu.samc21j18a.build.mcu=cortex-m0plus +x21j.menu.cpu.samc21j18a.build.mathlib=arm_cortexM0l_math +x21j.menu.cpu.samc21j18a.build.f_cpu=48000000L +x21j.menu.cpu.samc21j18a.build.usb_product="Xeno C21" +x21j.menu.cpu.samc21j18a.build.extra_flags=-D__SAMC21J18A__ -DARM_MATH_CM0PLUS +x21j.menu.cpu.samc21j18a.build.ldscript=flash_256KB.ld +x21j.menu.cpu.samc21j18a.build.openocdscript=openocd_scripts/SAMC21J18A.cfg +x21j.menu.cpu.samc21j18a.bootloader.file=zero/binaries/sam_ba_SAMC21J18A.bin +x21j.menu.cpu.samc21j15a=SAMC21J15A +x21j.menu.cpu.samc21j15a.upload.maximum_size=24576 +x21j.menu.cpu.samc21j15a.build.mcu=cortex-m0plus +x21j.menu.cpu.samc21j15a.build.mathlib=arm_cortexM0l_math +x21j.menu.cpu.samc21j15a.build.f_cpu=48000000L +x21j.menu.cpu.samc21j15a.build.usb_product="Xeno C21" +x21j.menu.cpu.samc21j15a.build.extra_flags=-D__SAMC21J15A__ -DARM_MATH_CM0PLUS +x21j.menu.cpu.samc21j15a.build.ldscript=flash_32KB.ld +x21j.menu.cpu.samc21j15a.build.openocdscript=openocd_scripts/SAMC21J15A.cfg +x21j.menu.cpu.samc21j15a.bootloader.file=zero/binaries/sam_ba_SAMC21J15A.bin +x21j.menu.cpu.samc21j16a=SAMC21J16A +x21j.menu.cpu.samc21j16a.upload.maximum_size=57344 +x21j.menu.cpu.samc21j16a.build.mcu=cortex-m0plus +x21j.menu.cpu.samc21j16a.build.mathlib=arm_cortexM0l_math +x21j.menu.cpu.samc21j16a.build.f_cpu=48000000L +x21j.menu.cpu.samc21j16a.build.usb_product="Xeno C21" +x21j.menu.cpu.samc21j16a.build.extra_flags=-D__SAMC21J16A__ -DARM_MATH_CM0PLUS +x21j.menu.cpu.samc21j16a.build.ldscript=flash_64KB.ld +x21j.menu.cpu.samc21j16a.build.openocdscript=openocd_scripts/SAMC21J16A.cfg +x21j.menu.cpu.samc21j16a.bootloader.file=zero/binaries/sam_ba_SAMC21J16A.bin +x21j.menu.bootloader.8kb=8KB_BOOTLOADER +x21j.menu.bootloader.8kb.build.bootloader_size=__8KB_BOOTLOADER__ +x21j.menu.bootloader.8kb.build.ldscript_path=linker_scripts/gcc/8KB_Bootloader +x21j.menu.bootloader.8kb.upload.tool=Fab_SAM_Arduino:bossac +x21j.menu.bootloader.8kb.upload.use_1200bps_touch=true +x21j.menu.bootloader.8kb.upload.wait_for_upload_port=true +x21j.menu.bootloader.8kb.upload.native_usb=true +x21j.menu.bootloader.16kb=16KB_BOOTLOADER +x21j.menu.bootloader.16kb.build.bootloader_size=__16KB_BOOTLOADER__ +x21j.menu.bootloader.16kb.build.ldscript_path=linker_scripts/gcc/16KB_Bootloader +x21j.menu.bootloader.16kb.upload.tool=Fab_SAM_Arduino:bossac +x21j.menu.bootloader.16kb.upload.use_1200bps_touch=true +x21j.menu.bootloader.16kb.upload.wait_for_upload_port=true +x21j.menu.bootloader.16kb.upload.native_usb=true +x21j.menu.bootloader.0kb=NO_BOOTLOADER +x21j.menu.bootloader.0kb.build.bootloader_size=__NO_BOOTLOADER__ +x21j.menu.bootloader.0kb.build.ldscript_path=linker_scripts/gcc/No_Bootloader +x21j.menu.bootloader.0kb.upload.tool=openocd +x21j.menu.bootloader.0kb.upload.use_1200bps_touch=false +x21j.menu.bootloader.0kb.upload.wait_for_upload_port=false +x21j.menu.bootloader.0kb.upload.native_usb=false +x21j.menu.serial.one_uart=ONE_UART_ONE_WIRE_ONE_SPI +x21j.menu.serial.one_uart.build.serialcom_uart=ONE_UART +x21j.menu.serial.one_uart.build.serialcom_wire=ONE_WIRE +x21j.menu.serial.one_uart.build.serialcom_spi=ONE_SPI +x21j.menu.serial.one_uart_two_spi=ONE_UART_ONE_WIRE_TWO_SPI +x21j.menu.serial.one_uart_two_spi.build.serialcom_uart=ONE_UART +x21j.menu.serial.one_uart_two_spi.build.serialcom_wire=ONE_WIRE +x21j.menu.serial.one_uart_two_spi.build.serialcom_spi=TWO_SPI +x21j.menu.serial.one_uart_two_wire=ONE_UART_TWO_WIRE_ONE_SPI +x21j.menu.serial.one_uart_two_wire.build.serialcom_uart=ONE_UART +x21j.menu.serial.one_uart_two_wire.build.serialcom_wire=TWO_WIRE +x21j.menu.serial.one_uart_two_wire.build.serialcom_spi=ONE_SPI +x21j.menu.serial.two_uart=TWO_UART_ONE_WIRE_ONE_SPI +x21j.menu.serial.two_uart.build.serialcom_uart=TWO_UART +x21j.menu.serial.two_uart.build.serialcom_wire=ONE_WIRE +x21j.menu.serial.two_uart.build.serialcom_spi=ONE_SPI +x21j.menu.serial.two_uart_two_spi=TWO_UART_ONE_WIRE_TWO_SPI +x21j.menu.serial.two_uart_two_spi.build.serialcom_uart=TWO_UART +x21j.menu.serial.two_uart_two_spi.build.serialcom_wire=ONE_WIRE +x21j.menu.serial.two_uart_two_spi.build.serialcom_spi=TWO_SPI +x21j.menu.serial.two_uart_two_wire=TWO_UART_TWO_WIRE_ONE_SPI +x21j.menu.serial.two_uart_two_wire.build.serialcom_uart=TWO_UART +x21j.menu.serial.two_uart_two_wire.build.serialcom_wire=TWO_WIRE +x21j.menu.serial.two_uart_two_wire.build.serialcom_spi=ONE_SPI +x21j.menu.serial.three_uart=THREE_UART_ONE_WIRE_ONE_SPI +x21j.menu.serial.three_uart.build.serialcom_uart=THREE_UART +x21j.menu.serial.three_uart.build.serialcom_wire=ONE_WIRE +x21j.menu.serial.three_uart.build.serialcom_spi=ONE_SPI +x21j.menu.serial.three_uart_two_spi=THREE_UART_ONE_WIRE_TWO_SPI +x21j.menu.serial.three_uart_two_spi.build.serialcom_uart=THREE_UART +x21j.menu.serial.three_uart_two_spi.build.serialcom_wire=ONE_WIRE +x21j.menu.serial.three_uart_two_spi.build.serialcom_spi=TWO_SPI +x21j.menu.serial.three_uart_two_wire=THREE_UART_TWO_WIRE_ONE_SPI +x21j.menu.serial.three_uart_two_wire.build.serialcom_uart=THREE_UART +x21j.menu.serial.three_uart_two_wire.build.serialcom_wire=TWO_WIRE +x21j.menu.serial.three_uart_two_wire.build.serialcom_spi=ONE_SPI +x21j.menu.serial.no_uart=NO_UART_ONE_WIRE_ONE_SPI +x21j.menu.serial.no_uart.build.serialcom_uart=NO_UART +x21j.menu.serial.no_uart.build.serialcom_wire=ONE_WIRE +x21j.menu.serial.no_uart.build.serialcom_spi=ONE_SPI +x21j.menu.usb.cdc=CDC_ONLY +x21j.menu.usb.cdc.build.usbcom=CDC_ONLY +x21j.menu.usb.cdc.build.pid=0x6557 +x21j.menu.usb.cdc_hid=CDC_HID +x21j.menu.usb.cdc_hid.build.usbcom=CDC_HID +x21j.menu.usb.cdc_hid.build.pid=0x6856 +x21j.menu.usb.withcdc=WITH_CDC +x21j.menu.usb.withcdc.build.usbcom=WITH_CDC +x21j.menu.usb.withcdc.build.pid=0x6B41 +x21j.menu.usb.hid=HID_ONLY +x21j.menu.usb.hid.build.usbcom=HID_ONLY +x21j.menu.usb.hid.build.pid=0x6B40 +x21j.menu.usb.nocdc=WITHOUT_CDC +x21j.menu.usb.nocdc.build.usbcom=WITHOUT_CDC +x21j.menu.usb.nocdc.build.pid=0x6A0C +x21j.menu.usb.none=USB_DISABLED +x21j.menu.usb.none.build.usbcom=USB_DISABLED +x21j.menu.usb.none.build.pid=0x6856 + +# Generic D51G +d51g.name=Generic D51G +d51g.vid.0=0x16D0 +d51g.pid.0=0x7557 +d51g.vid.1=0x16D0 +d51g.pid.1=0x7856 +d51g.vid.2=0x16D0 +d51g.pid.2=0x7B41 +d51g.vid.3=0x16D0 +d51g.pid.3=0x7B40 +d51g.vid.4=0x16D0 +d51g.pid.4=0x7A0C +d51g.vid.5=0x16D0 +d51g.pid.5=0x7856 +d51g.build.usb_manufacturer="Fab Foundation" + +# KH mod +#d51g.build.board=SAMD_ZERO +d51g.build.board=__SAMD51__ +###### + +d51g.build.core=arduino + +# KH mod +#d51g.build.variant=Generic_D51G +d51g.build.variant=Generic_xx1G +###### + +d51g.build.variant_system_lib= +d51g.build.vid=0x16D0 +d51g.upload.protocol=sam-ba +d51g.bootloader.tool=openocd +d51g.menu.float.default=Print & String use auto-promoted doubles only +d51g.menu.float.default.build.floatconfig=FLOAT_BOTH_DOUBLES_ONLY +d51g.menu.float.print=Print uses separate singles and doubles +d51g.menu.float.print.build.floatconfig=FLOAT_PRINT_SINGLES_DOUBLES +d51g.menu.float.string=String uses separate singles and doubles +d51g.menu.float.string.build.floatconfig=FLOAT_STRING_SINGLES_DOUBLES +d51g.menu.float.both=Print & String use separate singles and doubles +d51g.menu.float.both.build.floatconfig=FLOAT_BOTH_SINGLES_DOUBLES +d51g.menu.config.disabled=config.h disabled +d51g.menu.config.disabled.build.buildconfig=CONFIG_H_DISABLED +d51g.menu.config.enabled=config.h enabled (mostly code size reductions) +d51g.menu.config.enabled.build.buildconfig=CONFIG_H_ENABLED +d51g.menu.clock.internal_usb=INTERNAL_USB_CALIBRATED_OSCILLATOR +d51g.menu.clock.internal_usb.build.clockconfig=CLOCKCONFIG_INTERNAL_USB +d51g.menu.clock.internal=INTERNAL_OSCILLATOR +d51g.menu.clock.internal.build.clockconfig=CLOCKCONFIG_INTERNAL +d51g.menu.clock.crystal_32k=32KHZ_CRYSTAL +d51g.menu.clock.crystal_32k.build.clockconfig=CLOCKCONFIG_32768HZ_CRYSTAL +d51g.menu.clock.crystal_hs=HIGH_SPEED_CRYSTAL +d51g.menu.clock.crystal_hs.build.clockconfig=CLOCKCONFIG_HS_CRYSTAL +d51g.menu.timer.timer_732Hz=732.4Hz (16-bit) +d51g.menu.timer.timer_732Hz.build.timerconfig=TIMER_732Hz +d51g.menu.timer.timer_366Hz=366.2Hz (16-bit) +d51g.menu.timer.timer_366Hz.build.timerconfig=TIMER_366Hz +d51g.menu.timer.timer_244Hz=244.1Hz (16-bit) +d51g.menu.timer.timer_244Hz.build.timerconfig=TIMER_244Hz +d51g.menu.timer.timer_183Hz=183.1Hz (16-bit) +d51g.menu.timer.timer_183Hz.build.timerconfig=TIMER_183Hz +d51g.menu.timer.timer_146Hz=146.5Hz (16-bit) +d51g.menu.timer.timer_146Hz.build.timerconfig=TIMER_146Hz +d51g.menu.timer.timer_122Hz=122.1Hz (16-bit) +d51g.menu.timer.timer_122Hz.build.timerconfig=TIMER_122Hz +d51g.menu.timer.timer_105Hz=104.6Hz (16-bit) +d51g.menu.timer.timer_105Hz.build.timerconfig=TIMER_105Hz +d51g.menu.timer.timer_81Hz=81.38Hz (16-bit) +d51g.menu.timer.timer_81Hz.build.timerconfig=TIMER_81Hz +d51g.menu.timer.timer_61Hz=61.04Hz (16-bit) +d51g.menu.timer.timer_61Hz.build.timerconfig=TIMER_61Hz +d51g.menu.timer.timer_31Hz=30.52Hz (16-bit) +d51g.menu.timer.timer_31Hz.build.timerconfig=TIMER_31Hz +d51g.menu.timer.timer_187500Hz=187500Hz (8-bit) +d51g.menu.timer.timer_187500Hz.build.timerconfig=TIMER_187500Hz +d51g.menu.timer.timer_93750Hz=93750Hz (8-bit) +d51g.menu.timer.timer_93750Hz.build.timerconfig=TIMER_93750Hz +d51g.menu.timer.timer_62500Hz=62500Hz (8-bit) +d51g.menu.timer.timer_62500Hz.build.timerconfig=TIMER_62500Hz +d51g.menu.timer.timer_37500Hz=37500Hz (8-bit) +d51g.menu.timer.timer_37500Hz.build.timerconfig=TIMER_37500Hz +d51g.menu.timer.timer_20833Hz=20833Hz (8-bit) +d51g.menu.timer.timer_20833Hz.build.timerconfig=TIMER_20833Hz +d51g.menu.timer.timer_12500Hz=12500Hz (8-bit) +d51g.menu.timer.timer_12500Hz.build.timerconfig=TIMER_12500Hz +d51g.menu.timer.timer_7500Hz=7500Hz (8-bit) +d51g.menu.timer.timer_7500Hz.build.timerconfig=TIMER_7500Hz +d51g.menu.timer.timer_4166Hz=4166Hz (8-bit) +d51g.menu.timer.timer_4166Hz.build.timerconfig=TIMER_4166Hz +d51g.menu.timer.timer_2930Hz=2930Hz (8-bit) +d51g.menu.timer.timer_2930Hz.build.timerconfig=TIMER_2930Hz +d51g.menu.timer.timer_1465Hz=1465Hz (16-bit) +d51g.menu.timer.timer_1465Hz.build.timerconfig=TIMER_1465Hz +d51g.menu.cpu.samd51g18a_120=SAMD51G18A_120MHz +d51g.menu.cpu.samd51g18a_120.upload.maximum_size=253952 +d51g.menu.cpu.samd51g18a_120.build.mcu=cortex-m4 +d51g.menu.cpu.samd51g18a_120.build.mathlib=arm_cortexM4lf_math +d51g.menu.cpu.samd51g18a_120.build.f_cpu=120000000L +d51g.menu.cpu.samd51g18a_120.build.usb_product="Xeno Mini D51" + +# KH mod +#d51g.menu.cpu.samd51g18a_120.build.extra_flags=-D__SAMD51G18A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 +#d51g.menu.cpu.samd51g18a_120.build.extra_flags=-D__SAMD51G18A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 -D__SAMD51__ +d51g.menu.cpu.samd51g18a_120.build.extra_flags=-D__SAMD51G18A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 -D__SAMD51__ +###### + + +d51g.menu.cpu.samd51g18a_120.build.ldscript=flash_m4f_256KB.ld +d51g.menu.cpu.samd51g18a_120.build.openocdscript=openocd_scripts/SAMD51G18A.cfg +d51g.menu.cpu.samd51g18a_120.bootloader.file=zero/binaries/sam_ba_SAMD51G18A.bin +d51g.menu.cpu.samd51g18a_48=SAMD51G18A_48MHz +d51g.menu.cpu.samd51g18a_48.upload.maximum_size=253952 +d51g.menu.cpu.samd51g18a_48.build.mcu=cortex-m4 +d51g.menu.cpu.samd51g18a_48.build.mathlib=arm_cortexM4lf_math +d51g.menu.cpu.samd51g18a_48.build.f_cpu=48000000L +d51g.menu.cpu.samd51g18a_48.build.usb_product="Xeno Mini D51" + +# KH mod +#d51g.menu.cpu.samd51g18a_48.build.extra_flags=-D__SAMD51G18A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 +d51g.menu.cpu.samd51g18a_48.build.extra_flags=-D__SAMD51G18A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 -D__SAMD51__ +###### + +d51g.menu.cpu.samd51g18a_48.build.ldscript=flash_m4f_256KB.ld +d51g.menu.cpu.samd51g18a_48.build.openocdscript=openocd_scripts/SAMD51G18A.cfg +d51g.menu.cpu.samd51g18a_48.bootloader.file=zero/binaries/sam_ba_SAMD51G18A.bin +d51g.menu.cpu.samd51g19a_120=SAMD51G19A_120MHz +d51g.menu.cpu.samd51g19a_120.upload.maximum_size=516096 +d51g.menu.cpu.samd51g19a_120.build.mcu=cortex-m4 +d51g.menu.cpu.samd51g19a_120.build.mathlib=arm_cortexM4lf_math +d51g.menu.cpu.samd51g19a_120.build.f_cpu=120000000L +d51g.menu.cpu.samd51g19a_120.build.usb_product="Xeno Mini D51" + +# KH mod +#d51g.menu.cpu.samd51g19a_120.build.extra_flags=-D__SAMD51G19A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 +d51g.menu.cpu.samd51g19a_120.build.extra_flags=-D__SAMD51G19A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 -D__SAMD51__ +###### + +d51g.menu.cpu.samd51g19a_120.build.ldscript=flash_m4f_512KB.ld +d51g.menu.cpu.samd51g19a_120.build.openocdscript=openocd_scripts/SAMD51G19A.cfg +d51g.menu.cpu.samd51g19a_120.bootloader.file=zero/binaries/sam_ba_SAMD51G19A.bin +d51g.menu.cpu.samd51g19a_48=SAMD51G19A_48MHz +d51g.menu.cpu.samd51g19a_48.upload.maximum_size=516096 +d51g.menu.cpu.samd51g19a_48.build.mcu=cortex-m4 +d51g.menu.cpu.samd51g19a_48.build.mathlib=arm_cortexM4lf_math +d51g.menu.cpu.samd51g19a_48.build.f_cpu=48000000L +d51g.menu.cpu.samd51g19a_48.build.usb_product="Xeno Mini D51" + +# KH mod +#d51g.menu.cpu.samd51g19a_48.build.extra_flags=-D__SAMD51G19A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 +d51g.menu.cpu.samd51g19a_48.build.extra_flags=-D__SAMD51G19A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 -D__SAMD51__ +###### + +d51g.menu.cpu.samd51g19a_48.build.ldscript=flash_m4f_512KB.ld +d51g.menu.cpu.samd51g19a_48.build.openocdscript=openocd_scripts/SAMD51G19A.cfg +d51g.menu.cpu.samd51g19a_48.bootloader.file=zero/binaries/sam_ba_SAMD51G19A.bin +d51g.menu.bootloader.8kb=8KB_BOOTLOADER +d51g.menu.bootloader.8kb.build.bootloader_size=__8KB_BOOTLOADER__ +d51g.menu.bootloader.8kb.build.ldscript_path=linker_scripts/gcc/8KB_Bootloader +d51g.menu.bootloader.8kb.upload.tool=Fab_SAM_Arduino:bossac +d51g.menu.bootloader.8kb.upload.use_1200bps_touch=true +d51g.menu.bootloader.8kb.upload.wait_for_upload_port=true +d51g.menu.bootloader.8kb.upload.native_usb=true +d51g.menu.bootloader.16kb=16KB_BOOTLOADER +d51g.menu.bootloader.16kb.build.bootloader_size=__16KB_BOOTLOADER__ +d51g.menu.bootloader.16kb.build.ldscript_path=linker_scripts/gcc/16KB_Bootloader +d51g.menu.bootloader.16kb.upload.tool=Fab_SAM_Arduino:bossac +d51g.menu.bootloader.16kb.upload.use_1200bps_touch=true +d51g.menu.bootloader.16kb.upload.wait_for_upload_port=true +d51g.menu.bootloader.16kb.upload.native_usb=true +d51g.menu.bootloader.0kb=NO_BOOTLOADER +d51g.menu.bootloader.0kb.build.bootloader_size=__NO_BOOTLOADER__ +d51g.menu.bootloader.0kb.build.ldscript_path=linker_scripts/gcc/No_Bootloader +d51g.menu.bootloader.0kb.upload.tool=openocd +d51g.menu.bootloader.0kb.upload.use_1200bps_touch=false +d51g.menu.bootloader.0kb.upload.wait_for_upload_port=false +d51g.menu.bootloader.0kb.upload.native_usb=false +d51g.menu.serial.one_uart=ONE_UART_ONE_WIRE_ONE_SPI +d51g.menu.serial.one_uart.build.serialcom_uart=ONE_UART +d51g.menu.serial.one_uart.build.serialcom_wire=ONE_WIRE +d51g.menu.serial.one_uart.build.serialcom_spi=ONE_SPI +d51g.menu.serial.one_uart_two_spi=ONE_UART_ONE_WIRE_TWO_SPI +d51g.menu.serial.one_uart_two_spi.build.serialcom_uart=ONE_UART +d51g.menu.serial.one_uart_two_spi.build.serialcom_wire=ONE_WIRE +d51g.menu.serial.one_uart_two_spi.build.serialcom_spi=TWO_SPI +d51g.menu.serial.one_uart_two_wire=ONE_UART_TWO_WIRE_ONE_SPI +d51g.menu.serial.one_uart_two_wire.build.serialcom_uart=ONE_UART +d51g.menu.serial.one_uart_two_wire.build.serialcom_wire=TWO_WIRE +d51g.menu.serial.one_uart_two_wire.build.serialcom_spi=ONE_SPI +d51g.menu.serial.two_uart=TWO_UART_ONE_WIRE_ONE_SPI +d51g.menu.serial.two_uart.build.serialcom_uart=TWO_UART +d51g.menu.serial.two_uart.build.serialcom_wire=ONE_WIRE +d51g.menu.serial.two_uart.build.serialcom_spi=ONE_SPI +d51g.menu.serial.two_uart_two_spi=TWO_UART_ONE_WIRE_TWO_SPI +d51g.menu.serial.two_uart_two_spi.build.serialcom_uart=TWO_UART +d51g.menu.serial.two_uart_two_spi.build.serialcom_wire=ONE_WIRE +d51g.menu.serial.two_uart_two_spi.build.serialcom_spi=TWO_SPI +d51g.menu.serial.two_uart_two_wire=TWO_UART_TWO_WIRE_ONE_SPI +d51g.menu.serial.two_uart_two_wire.build.serialcom_uart=TWO_UART +d51g.menu.serial.two_uart_two_wire.build.serialcom_wire=TWO_WIRE +d51g.menu.serial.two_uart_two_wire.build.serialcom_spi=ONE_SPI +d51g.menu.serial.three_uart=THREE_UART_ONE_WIRE_ONE_SPI +d51g.menu.serial.three_uart.build.serialcom_uart=THREE_UART +d51g.menu.serial.three_uart.build.serialcom_wire=ONE_WIRE +d51g.menu.serial.three_uart.build.serialcom_spi=ONE_SPI +d51g.menu.serial.three_uart_two_spi=THREE_UART_ONE_WIRE_TWO_SPI +d51g.menu.serial.three_uart_two_spi.build.serialcom_uart=THREE_UART +d51g.menu.serial.three_uart_two_spi.build.serialcom_wire=ONE_WIRE +d51g.menu.serial.three_uart_two_spi.build.serialcom_spi=TWO_SPI +d51g.menu.serial.three_uart_two_wire=THREE_UART_TWO_WIRE_ONE_SPI +d51g.menu.serial.three_uart_two_wire.build.serialcom_uart=THREE_UART +d51g.menu.serial.three_uart_two_wire.build.serialcom_wire=TWO_WIRE +d51g.menu.serial.three_uart_two_wire.build.serialcom_spi=ONE_SPI +d51g.menu.serial.no_uart=NO_UART_ONE_WIRE_ONE_SPI +d51g.menu.serial.no_uart.build.serialcom_uart=NO_UART +d51g.menu.serial.no_uart.build.serialcom_wire=ONE_WIRE +d51g.menu.serial.no_uart.build.serialcom_spi=ONE_SPI +d51g.menu.usb.cdc=CDC_ONLY +d51g.menu.usb.cdc.build.usbcom=CDC_ONLY +d51g.menu.usb.cdc.build.pid=0x7557 +d51g.menu.usb.cdc_hid=CDC_HID +d51g.menu.usb.cdc_hid.build.usbcom=CDC_HID +d51g.menu.usb.cdc_hid.build.pid=0x7856 +d51g.menu.usb.withcdc=WITH_CDC +d51g.menu.usb.withcdc.build.usbcom=WITH_CDC +d51g.menu.usb.withcdc.build.pid=0x7B41 +d51g.menu.usb.hid=HID_ONLY +d51g.menu.usb.hid.build.usbcom=HID_ONLY +d51g.menu.usb.hid.build.pid=0x7B40 +d51g.menu.usb.nocdc=WITHOUT_CDC +d51g.menu.usb.nocdc.build.usbcom=WITHOUT_CDC +d51g.menu.usb.nocdc.build.pid=0x7A0C +d51g.menu.usb.none=USB_DISABLED +d51g.menu.usb.none.build.usbcom=USB_DISABLED +d51g.menu.usb.none.build.pid=0x7856 + +# Generic D51J +d51j.name=Generic D51J +d51j.vid.0=0x16D0 +d51j.pid.0=0x8557 +d51j.vid.1=0x16D0 +d51j.pid.1=0x8856 +d51j.vid.2=0x16D0 +d51j.pid.2=0x8B41 +d51j.vid.3=0x16D0 +d51j.pid.3=0x8B40 +d51j.vid.4=0x16D0 +d51j.pid.4=0x8A0C +d51j.vid.5=0x16D0 +d51j.pid.5=0x8856 +d51j.build.usb_manufacturer="Fab Foundation" + +# KH mod +#d51j.build.board=SAMD_ZERO +d51j.build.board=__SAMD51__ +###### + +d51j.build.core=arduino +d51j.build.variant=Generic_xx1J +d51j.build.variant_system_lib= +d51j.build.vid=0x16D0 +d51j.upload.protocol=sam-ba +d51j.bootloader.tool=openocd +d51j.menu.float.default=Print & String use auto-promoted doubles only +d51j.menu.float.default.build.floatconfig=FLOAT_BOTH_DOUBLES_ONLY +d51j.menu.float.print=Print uses separate singles and doubles +d51j.menu.float.print.build.floatconfig=FLOAT_PRINT_SINGLES_DOUBLES +d51j.menu.float.string=String uses separate singles and doubles +d51j.menu.float.string.build.floatconfig=FLOAT_STRING_SINGLES_DOUBLES +d51j.menu.float.both=Print & String use separate singles and doubles +d51j.menu.float.both.build.floatconfig=FLOAT_BOTH_SINGLES_DOUBLES +d51j.menu.config.disabled=config.h disabled +d51j.menu.config.disabled.build.buildconfig=CONFIG_H_DISABLED +d51j.menu.config.enabled=config.h enabled (mostly code size reductions) +d51j.menu.config.enabled.build.buildconfig=CONFIG_H_ENABLED +d51j.menu.clock.internal_usb=INTERNAL_USB_CALIBRATED_OSCILLATOR +d51j.menu.clock.internal_usb.build.clockconfig=CLOCKCONFIG_INTERNAL_USB +d51j.menu.clock.internal=INTERNAL_OSCILLATOR +d51j.menu.clock.internal.build.clockconfig=CLOCKCONFIG_INTERNAL +d51j.menu.clock.crystal_32k=32KHZ_CRYSTAL +d51j.menu.clock.crystal_32k.build.clockconfig=CLOCKCONFIG_32768HZ_CRYSTAL +d51j.menu.clock.crystal_hs=HIGH_SPEED_CRYSTAL +d51j.menu.clock.crystal_hs.build.clockconfig=CLOCKCONFIG_HS_CRYSTAL +d51j.menu.timer.timer_732Hz=732.4Hz (16-bit) +d51j.menu.timer.timer_732Hz.build.timerconfig=TIMER_732Hz +d51j.menu.timer.timer_366Hz=366.2Hz (16-bit) +d51j.menu.timer.timer_366Hz.build.timerconfig=TIMER_366Hz +d51j.menu.timer.timer_244Hz=244.1Hz (16-bit) +d51j.menu.timer.timer_244Hz.build.timerconfig=TIMER_244Hz +d51j.menu.timer.timer_183Hz=183.1Hz (16-bit) +d51j.menu.timer.timer_183Hz.build.timerconfig=TIMER_183Hz +d51j.menu.timer.timer_146Hz=146.5Hz (16-bit) +d51j.menu.timer.timer_146Hz.build.timerconfig=TIMER_146Hz +d51j.menu.timer.timer_122Hz=122.1Hz (16-bit) +d51j.menu.timer.timer_122Hz.build.timerconfig=TIMER_122Hz +d51j.menu.timer.timer_105Hz=104.6Hz (16-bit) +d51j.menu.timer.timer_105Hz.build.timerconfig=TIMER_105Hz +d51j.menu.timer.timer_81Hz=81.38Hz (16-bit) +d51j.menu.timer.timer_81Hz.build.timerconfig=TIMER_81Hz +d51j.menu.timer.timer_61Hz=61.04Hz (16-bit) +d51j.menu.timer.timer_61Hz.build.timerconfig=TIMER_61Hz +d51j.menu.timer.timer_31Hz=30.52Hz (16-bit) +d51j.menu.timer.timer_31Hz.build.timerconfig=TIMER_31Hz +d51j.menu.timer.timer_187500Hz=187500Hz (8-bit) +d51j.menu.timer.timer_187500Hz.build.timerconfig=TIMER_187500Hz +d51j.menu.timer.timer_93750Hz=93750Hz (8-bit) +d51j.menu.timer.timer_93750Hz.build.timerconfig=TIMER_93750Hz +d51j.menu.timer.timer_62500Hz=62500Hz (8-bit) +d51j.menu.timer.timer_62500Hz.build.timerconfig=TIMER_62500Hz +d51j.menu.timer.timer_37500Hz=37500Hz (8-bit) +d51j.menu.timer.timer_37500Hz.build.timerconfig=TIMER_37500Hz +d51j.menu.timer.timer_20833Hz=20833Hz (8-bit) +d51j.menu.timer.timer_20833Hz.build.timerconfig=TIMER_20833Hz +d51j.menu.timer.timer_12500Hz=12500Hz (8-bit) +d51j.menu.timer.timer_12500Hz.build.timerconfig=TIMER_12500Hz +d51j.menu.timer.timer_7500Hz=7500Hz (8-bit) +d51j.menu.timer.timer_7500Hz.build.timerconfig=TIMER_7500Hz +d51j.menu.timer.timer_4166Hz=4166Hz (8-bit) +d51j.menu.timer.timer_4166Hz.build.timerconfig=TIMER_4166Hz +d51j.menu.timer.timer_2930Hz=2930Hz (8-bit) +d51j.menu.timer.timer_2930Hz.build.timerconfig=TIMER_2930Hz +d51j.menu.timer.timer_1465Hz=1465Hz (16-bit) +d51j.menu.timer.timer_1465Hz.build.timerconfig=TIMER_1465Hz +d51j.menu.cpu.samd51j18a_120=SAMD51J18A_120MHz +d51j.menu.cpu.samd51j18a_120.upload.maximum_size=253952 +d51j.menu.cpu.samd51j18a_120.build.mcu=cortex-m4 +d51j.menu.cpu.samd51j18a_120.build.mathlib=arm_cortexM4lf_math +d51j.menu.cpu.samd51j18a_120.build.f_cpu=120000000L +d51j.menu.cpu.samd51j18a_120.build.usb_product="Xeno D51" + +# KH mod +#d51j.menu.cpu.samd51j18a_120.build.extra_flags=-D__SAMD51J18A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 +d51j.menu.cpu.samd51j18a_120.build.extra_flags=-D__SAMD51J18A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 -D__SAMD51__ +###### + +d51j.menu.cpu.samd51j18a_120.build.ldscript=flash_m4f_256KB.ld +d51j.menu.cpu.samd51j18a_120.build.openocdscript=openocd_scripts/SAMD51J18A.cfg +d51j.menu.cpu.samd51j18a_120.bootloader.file=zero/binaries/sam_ba_SAMD51J18A.bin +d51j.menu.cpu.samd51j18a_48=SAMD51J18A_48MHz +d51j.menu.cpu.samd51j18a_48.upload.maximum_size=253952 +d51j.menu.cpu.samd51j18a_48.build.mcu=cortex-m4 +d51j.menu.cpu.samd51j18a_48.build.mathlib=arm_cortexM4lf_math +d51j.menu.cpu.samd51j18a_48.build.f_cpu=48000000L +d51j.menu.cpu.samd51j18a_48.build.usb_product="Xeno D51" + +# KH mod +#d51j.menu.cpu.samd51j18a_48.build.extra_flags=-D__SAMD51J18A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 +d51j.menu.cpu.samd51j18a_48.build.extra_flags=-D__SAMD51J18A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 -D__SAMD51__ +###### + +d51j.menu.cpu.samd51j18a_48.build.ldscript=flash_m4f_256KB.ld +d51j.menu.cpu.samd51j18a_48.build.openocdscript=openocd_scripts/SAMD51J18A.cfg +d51j.menu.cpu.samd51j18a_48.bootloader.file=zero/binaries/sam_ba_SAMD51J18A.bin +d51j.menu.cpu.samd51j19a_120=SAMD51J19A_120MHz +d51j.menu.cpu.samd51j19a_120.upload.maximum_size=516096 +d51j.menu.cpu.samd51j19a_120.build.mcu=cortex-m4 +d51j.menu.cpu.samd51j19a_120.build.mathlib=arm_cortexM4lf_math +d51j.menu.cpu.samd51j19a_120.build.f_cpu=120000000L +d51j.menu.cpu.samd51j19a_120.build.usb_product="Xeno D51" + +# KH mod +#d51j.menu.cpu.samd51j19a_120.build.extra_flags=-D__SAMD51J19A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 +d51j.menu.cpu.samd51j19a_120.build.extra_flags=-D__SAMD51J19A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 -D__SAMD51__ +###### + +d51j.menu.cpu.samd51j19a_120.build.ldscript=flash_m4f_512KB.ld +d51j.menu.cpu.samd51j19a_120.build.openocdscript=openocd_scripts/SAMD51J19A.cfg +d51j.menu.cpu.samd51j19a_120.bootloader.file=zero/binaries/sam_ba_SAMD51J19A.bin +d51j.menu.cpu.samd51j19a_48=SAMD51J19A_48MHz +d51j.menu.cpu.samd51j19a_48.upload.maximum_size=516096 +d51j.menu.cpu.samd51j19a_48.build.mcu=cortex-m4 +d51j.menu.cpu.samd51j19a_48.build.mathlib=arm_cortexM4lf_math +d51j.menu.cpu.samd51j19a_48.build.f_cpu=48000000L +d51j.menu.cpu.samd51j19a_48.build.usb_product="Xeno D51" + +# KH mod +#d51j.menu.cpu.samd51j19a_48.build.extra_flags=-D__SAMD51J19A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 +d51j.menu.cpu.samd51j19a_48.build.extra_flags=-D__SAMD51J19A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 -D__SAMD51__ +###### + +d51j.menu.cpu.samd51j19a_48.build.ldscript=flash_m4f_512KB.ld +d51j.menu.cpu.samd51j19a_48.build.openocdscript=openocd_scripts/SAMD51J19A.cfg +d51j.menu.cpu.samd51j19a_48.bootloader.file=zero/binaries/sam_ba_SAMD51J19A.bin +d51j.menu.cpu.samd51j20a_120=SAMD51J20A_120MHz +d51j.menu.cpu.samd51j20a_120.upload.maximum_size=1040384 +d51j.menu.cpu.samd51j20a_120.build.mcu=cortex-m4 +d51j.menu.cpu.samd51j20a_120.build.mathlib=arm_cortexM4lf_math +d51j.menu.cpu.samd51j20a_120.build.f_cpu=120000000L +d51j.menu.cpu.samd51j20a_120.build.usb_product="Xeno D51" + +# KH mod +#d51j.menu.cpu.samd51j20a_120.build.extra_flags=-D__SAMD51J20A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 +d51j.menu.cpu.samd51j20a_120.build.extra_flags=-D__SAMD51J20A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 -D__SAMD51__ +###### + +d51j.menu.cpu.samd51j20a_120.build.ldscript=flash_m4f_1MB.ld +d51j.menu.cpu.samd51j20a_120.build.openocdscript=openocd_scripts/SAMD51J20A.cfg +d51j.menu.cpu.samd51j20a_120.bootloader.file=zero/binaries/sam_ba_SAMD51J20A.bin +d51j.menu.cpu.samd51j20a_48=SAMD51J20A_48MHz +d51j.menu.cpu.samd51j20a_48.upload.maximum_size=1040384 +d51j.menu.cpu.samd51j20a_48.build.mcu=cortex-m4 +d51j.menu.cpu.samd51j20a_48.build.mathlib=arm_cortexM4lf_math +d51j.menu.cpu.samd51j20a_48.build.f_cpu=48000000L +d51j.menu.cpu.samd51j20a_48.build.usb_product="Xeno D51" + +# KH mod +#d51j.menu.cpu.samd51j20a_48.build.extra_flags=-D__SAMD51J20A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 +d51j.menu.cpu.samd51j20a_48.build.extra_flags=-D__SAMD51J20A__ {build.usb_flags} -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 -D__SAMD51__ +###### + +d51j.menu.cpu.samd51j20a_48.build.ldscript=flash_m4f_1MB.ld +d51j.menu.cpu.samd51j20a_48.build.openocdscript=openocd_scripts/SAMD51J20A.cfg +d51j.menu.cpu.samd51j20a_48.bootloader.file=zero/binaries/sam_ba_SAMD51J20A.bin +d51j.menu.bootloader.8kb=8KB_BOOTLOADER +d51j.menu.bootloader.8kb.build.bootloader_size=__8KB_BOOTLOADER__ +d51j.menu.bootloader.8kb.build.ldscript_path=linker_scripts/gcc/8KB_Bootloader +d51j.menu.bootloader.8kb.upload.tool=Fab_SAM_Arduino:bossac +d51j.menu.bootloader.8kb.upload.use_1200bps_touch=true +d51j.menu.bootloader.8kb.upload.wait_for_upload_port=true +d51j.menu.bootloader.8kb.upload.native_usb=true +d51j.menu.bootloader.16kb=16KB_BOOTLOADER +d51j.menu.bootloader.16kb.build.bootloader_size=__16KB_BOOTLOADER__ +d51j.menu.bootloader.16kb.build.ldscript_path=linker_scripts/gcc/16KB_Bootloader +d51j.menu.bootloader.16kb.upload.tool=Fab_SAM_Arduino:bossac +d51j.menu.bootloader.16kb.upload.use_1200bps_touch=true +d51j.menu.bootloader.16kb.upload.wait_for_upload_port=true +d51j.menu.bootloader.16kb.upload.native_usb=true +d51j.menu.bootloader.0kb=NO_BOOTLOADER +d51j.menu.bootloader.0kb.build.bootloader_size=__NO_BOOTLOADER__ +d51j.menu.bootloader.0kb.build.ldscript_path=linker_scripts/gcc/No_Bootloader +d51j.menu.bootloader.0kb.upload.tool=openocd +d51j.menu.bootloader.0kb.upload.use_1200bps_touch=false +d51j.menu.bootloader.0kb.upload.wait_for_upload_port=false +d51j.menu.bootloader.0kb.upload.native_usb=false +d51j.menu.serial.one_uart=ONE_UART_ONE_WIRE_ONE_SPI +d51j.menu.serial.one_uart.build.serialcom_uart=ONE_UART +d51j.menu.serial.one_uart.build.serialcom_wire=ONE_WIRE +d51j.menu.serial.one_uart.build.serialcom_spi=ONE_SPI +d51j.menu.serial.one_uart_two_spi=ONE_UART_ONE_WIRE_TWO_SPI +d51j.menu.serial.one_uart_two_spi.build.serialcom_uart=ONE_UART +d51j.menu.serial.one_uart_two_spi.build.serialcom_wire=ONE_WIRE +d51j.menu.serial.one_uart_two_spi.build.serialcom_spi=TWO_SPI +d51j.menu.serial.one_uart_two_wire=ONE_UART_TWO_WIRE_ONE_SPI +d51j.menu.serial.one_uart_two_wire.build.serialcom_uart=ONE_UART +d51j.menu.serial.one_uart_two_wire.build.serialcom_wire=TWO_WIRE +d51j.menu.serial.one_uart_two_wire.build.serialcom_spi=ONE_SPI +d51j.menu.serial.two_uart=TWO_UART_ONE_WIRE_ONE_SPI +d51j.menu.serial.two_uart.build.serialcom_uart=TWO_UART +d51j.menu.serial.two_uart.build.serialcom_wire=ONE_WIRE +d51j.menu.serial.two_uart.build.serialcom_spi=ONE_SPI +d51j.menu.serial.two_uart_two_spi=TWO_UART_ONE_WIRE_TWO_SPI +d51j.menu.serial.two_uart_two_spi.build.serialcom_uart=TWO_UART +d51j.menu.serial.two_uart_two_spi.build.serialcom_wire=ONE_WIRE +d51j.menu.serial.two_uart_two_spi.build.serialcom_spi=TWO_SPI +d51j.menu.serial.two_uart_two_wire=TWO_UART_TWO_WIRE_ONE_SPI +d51j.menu.serial.two_uart_two_wire.build.serialcom_uart=TWO_UART +d51j.menu.serial.two_uart_two_wire.build.serialcom_wire=TWO_WIRE +d51j.menu.serial.two_uart_two_wire.build.serialcom_spi=ONE_SPI +d51j.menu.serial.three_uart=THREE_UART_ONE_WIRE_ONE_SPI +d51j.menu.serial.three_uart.build.serialcom_uart=THREE_UART +d51j.menu.serial.three_uart.build.serialcom_wire=ONE_WIRE +d51j.menu.serial.three_uart.build.serialcom_spi=ONE_SPI +d51j.menu.serial.three_uart_two_spi=THREE_UART_ONE_WIRE_TWO_SPI +d51j.menu.serial.three_uart_two_spi.build.serialcom_uart=THREE_UART +d51j.menu.serial.three_uart_two_spi.build.serialcom_wire=ONE_WIRE +d51j.menu.serial.three_uart_two_spi.build.serialcom_spi=TWO_SPI +d51j.menu.serial.three_uart_two_wire=THREE_UART_TWO_WIRE_ONE_SPI +d51j.menu.serial.three_uart_two_wire.build.serialcom_uart=THREE_UART +d51j.menu.serial.three_uart_two_wire.build.serialcom_wire=TWO_WIRE +d51j.menu.serial.three_uart_two_wire.build.serialcom_spi=ONE_SPI +d51j.menu.serial.no_uart=NO_UART_ONE_WIRE_ONE_SPI +d51j.menu.serial.no_uart.build.serialcom_uart=NO_UART +d51j.menu.serial.no_uart.build.serialcom_wire=ONE_WIRE +d51j.menu.serial.no_uart.build.serialcom_spi=ONE_SPI +d51j.menu.usb.cdc=CDC_ONLY +d51j.menu.usb.cdc.build.usbcom=CDC_ONLY +d51j.menu.usb.cdc.build.pid=0x8557 +d51j.menu.usb.cdc_hid=CDC_HID +d51j.menu.usb.cdc_hid.build.usbcom=CDC_HID +d51j.menu.usb.cdc_hid.build.pid=0x8856 +d51j.menu.usb.withcdc=WITH_CDC +d51j.menu.usb.withcdc.build.usbcom=WITH_CDC +d51j.menu.usb.withcdc.build.pid=0x8B41 +d51j.menu.usb.hid=HID_ONLY +d51j.menu.usb.hid.build.usbcom=HID_ONLY +d51j.menu.usb.hid.build.pid=0x8B40 +d51j.menu.usb.nocdc=WITHOUT_CDC +d51j.menu.usb.nocdc.build.usbcom=WITHOUT_CDC +d51j.menu.usb.nocdc.build.pid=0x8A0C +d51j.menu.usb.none=USB_DISABLED +d51j.menu.usb.none.build.usbcom=USB_DISABLED +d51j.menu.usb.none.build.pid=0x8856 diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Maixduino/hardware/k210/0.3.10/cores/arduino/Stream.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Maixduino/hardware/k210/0.3.10/cores/arduino/Stream.h new file mode 100644 index 0000000..a7479d0 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Maixduino/hardware/k210/0.3.10/cores/arduino/Stream.h @@ -0,0 +1,129 @@ +/* + Stream.h - base class for character-based streams. + Copyright (c) 2010 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + parsing functions based on TextFinder library by Michael Margolis +*/ + +#ifndef Stream_h +#define Stream_h + +#include +#include "Print.h" + +// compatability macros for testing +/* +#define getInt() parseInt() +#define getInt(ignore) parseInt(ignore) +#define getFloat() parseFloat() +#define getFloat(ignore) parseFloat(ignore) +#define getString( pre_string, post_string, buffer, length) +readBytesBetween( pre_string, terminator, buffer, length) +*/ + +// This enumeration provides the lookahead options for parseInt(), parseFloat() +// The rules set out here are used until either the first valid character is found +// or a time out occurs due to lack of input. +enum LookaheadMode{ + SKIP_ALL, // All invalid characters are ignored. + SKIP_NONE, // Nothing is skipped, and the stream is not touched unless the first waiting character is valid. + SKIP_WHITESPACE // Only tabs, spaces, line feeds & carriage returns are skipped. +}; + +#define NO_IGNORE_CHAR '\x01' // a char not found in a valid ASCII numeric field + +class Stream : public Print +{ + protected: + unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read + unsigned long _startMillis = 0; // used for timeout measurement + int timedRead(); // read stream with timeout + int timedPeek(); // peek stream with timeout + int peekNextDigit(LookaheadMode lookahead, bool detectDecimal); // returns the next numeric digit in the stream or -1 if timeout + + public: + virtual int available() = 0; + virtual int read() = 0; + virtual int peek() = 0; + + Stream() {_timeout=1000;} + +// parsing methods + + void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second + unsigned long getTimeout(void) { return _timeout; } + + bool find(char *target); // reads data from the stream until the target string is found + bool find(uint8_t *target) { return find ((char *)target); } + // returns true if target string is found, false if timed out (see setTimeout) + + bool find(char *target, size_t length); // reads data from the stream until the target string of given length is found + bool find(uint8_t *target, size_t length) { return find ((char *)target, length); } + // returns true if target string is found, false if timed out + + bool find(char target) { return find (&target, 1); } + + bool findUntil(char *target, char *terminator); // as find but search ends if the terminator string is found + bool findUntil(uint8_t *target, char *terminator) { return findUntil((char *)target, terminator); } + + bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen); // as above but search ends if the terminate string is found + bool findUntil(uint8_t *target, size_t targetLen, char *terminate, size_t termLen) {return findUntil((char *)target, targetLen, terminate, termLen); } + + long parseInt(LookaheadMode lookahead = SKIP_ALL, char ignore = NO_IGNORE_CHAR); + // returns the first valid (long) integer value from the current position. + // lookahead determines how parseInt looks ahead in the stream. + // See LookaheadMode enumeration at the top of the file. + // Lookahead is terminated by the first character that is not a valid part of an integer. + // Once parsing commences, 'ignore' will be skipped in the stream. + + float parseFloat(LookaheadMode lookahead = SKIP_ALL, char ignore = NO_IGNORE_CHAR); + // float version of parseInt + + size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer + size_t readBytes( uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); } + // terminates if length characters have been read or timeout (see setTimeout) + // returns the number of characters placed in the buffer (0 means no valid data found) + + size_t readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character + size_t readBytesUntil( char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); } + // terminates if length characters have been read, timeout, or if the terminator character detected + // returns the number of characters placed in the buffer (0 means no valid data found) + + // Arduino String functions to be added here + String readString(); + String readStringUntil(char terminator); + + protected: + long parseInt(char ignore) { return parseInt(SKIP_ALL, ignore); } + float parseFloat(char ignore) { return parseFloat(SKIP_ALL, ignore); } + // These overload exists for compatibility with any class that has derived + // Stream and used parseFloat/Int with a custom ignore character. To keep + // the public API simple, these overload remains protected. + + struct MultiTarget { + const char *str; // string you're searching for + size_t len; // length of string you're searching for + size_t index; // index used by the search routine. + }; + + // This allows you to search for an arbitrary number of strings. + // Returns index of the target that is found first or -1 if timeout occurs. + int findMulti(struct MultiTarget *targets, int tCount); +}; + +#undef NO_IGNORE_CHAR +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Maixduino/hardware/k210/0.3.11/cores/arduino/Stream.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Maixduino/hardware/k210/0.3.11/cores/arduino/Stream.h new file mode 100644 index 0000000..a7479d0 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Maixduino/hardware/k210/0.3.11/cores/arduino/Stream.h @@ -0,0 +1,129 @@ +/* + Stream.h - base class for character-based streams. + Copyright (c) 2010 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + parsing functions based on TextFinder library by Michael Margolis +*/ + +#ifndef Stream_h +#define Stream_h + +#include +#include "Print.h" + +// compatability macros for testing +/* +#define getInt() parseInt() +#define getInt(ignore) parseInt(ignore) +#define getFloat() parseFloat() +#define getFloat(ignore) parseFloat(ignore) +#define getString( pre_string, post_string, buffer, length) +readBytesBetween( pre_string, terminator, buffer, length) +*/ + +// This enumeration provides the lookahead options for parseInt(), parseFloat() +// The rules set out here are used until either the first valid character is found +// or a time out occurs due to lack of input. +enum LookaheadMode{ + SKIP_ALL, // All invalid characters are ignored. + SKIP_NONE, // Nothing is skipped, and the stream is not touched unless the first waiting character is valid. + SKIP_WHITESPACE // Only tabs, spaces, line feeds & carriage returns are skipped. +}; + +#define NO_IGNORE_CHAR '\x01' // a char not found in a valid ASCII numeric field + +class Stream : public Print +{ + protected: + unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read + unsigned long _startMillis = 0; // used for timeout measurement + int timedRead(); // read stream with timeout + int timedPeek(); // peek stream with timeout + int peekNextDigit(LookaheadMode lookahead, bool detectDecimal); // returns the next numeric digit in the stream or -1 if timeout + + public: + virtual int available() = 0; + virtual int read() = 0; + virtual int peek() = 0; + + Stream() {_timeout=1000;} + +// parsing methods + + void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second + unsigned long getTimeout(void) { return _timeout; } + + bool find(char *target); // reads data from the stream until the target string is found + bool find(uint8_t *target) { return find ((char *)target); } + // returns true if target string is found, false if timed out (see setTimeout) + + bool find(char *target, size_t length); // reads data from the stream until the target string of given length is found + bool find(uint8_t *target, size_t length) { return find ((char *)target, length); } + // returns true if target string is found, false if timed out + + bool find(char target) { return find (&target, 1); } + + bool findUntil(char *target, char *terminator); // as find but search ends if the terminator string is found + bool findUntil(uint8_t *target, char *terminator) { return findUntil((char *)target, terminator); } + + bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen); // as above but search ends if the terminate string is found + bool findUntil(uint8_t *target, size_t targetLen, char *terminate, size_t termLen) {return findUntil((char *)target, targetLen, terminate, termLen); } + + long parseInt(LookaheadMode lookahead = SKIP_ALL, char ignore = NO_IGNORE_CHAR); + // returns the first valid (long) integer value from the current position. + // lookahead determines how parseInt looks ahead in the stream. + // See LookaheadMode enumeration at the top of the file. + // Lookahead is terminated by the first character that is not a valid part of an integer. + // Once parsing commences, 'ignore' will be skipped in the stream. + + float parseFloat(LookaheadMode lookahead = SKIP_ALL, char ignore = NO_IGNORE_CHAR); + // float version of parseInt + + size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer + size_t readBytes( uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); } + // terminates if length characters have been read or timeout (see setTimeout) + // returns the number of characters placed in the buffer (0 means no valid data found) + + size_t readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character + size_t readBytesUntil( char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); } + // terminates if length characters have been read, timeout, or if the terminator character detected + // returns the number of characters placed in the buffer (0 means no valid data found) + + // Arduino String functions to be added here + String readString(); + String readStringUntil(char terminator); + + protected: + long parseInt(char ignore) { return parseInt(SKIP_ALL, ignore); } + float parseFloat(char ignore) { return parseFloat(SKIP_ALL, ignore); } + // These overload exists for compatibility with any class that has derived + // Stream and used parseFloat/Int with a custom ignore character. To keep + // the public API simple, these overload remains protected. + + struct MultiTarget { + const char *str; // string you're searching for + size_t len; // length of string you're searching for + size_t index; // index used by the search routine. + }; + + // This allows you to search for an arbitrary number of strings. + // Returns index of the target that is found first or -1 if timeout occurs. + int findMulti(struct MultiTarget *targets, int tCount); +}; + +#undef NO_IGNORE_CHAR +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/1.9.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/1.9.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h new file mode 100644 index 0000000..d133b23 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/1.9.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h @@ -0,0 +1,513 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf_default.h + * @brief HAL default configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_DEFAULT_H +#define __STM32F4xx_HAL_CONF_DEFAULT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief Include the default list of modules to be used in the HAL driver + * and manage module deactivation + */ +#include "stm32yyxx_hal_conf.h" +#if 0 +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +#define HAL_CAN_MODULE_ENABLED +/*#define HAL_CAN_LEGACY_MODULE_ENABLED*/ +#define HAL_CRC_MODULE_ENABLED +#define HAL_CEC_MODULE_ENABLED +#define HAL_CRYP_MODULE_ENABLED +#define HAL_DAC_MODULE_ENABLED +#define HAL_DCMI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_DMA2D_MODULE_ENABLED +#define HAL_ETH_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_NAND_MODULE_ENABLED +#define HAL_NOR_MODULE_ENABLED +#define HAL_PCCARD_MODULE_ENABLED +#define HAL_SRAM_MODULE_ENABLED +#define HAL_SDRAM_MODULE_ENABLED +#define HAL_HASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_SMBUS_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +#define HAL_IWDG_MODULE_ENABLED +#define HAL_LTDC_MODULE_ENABLED +#define HAL_DSI_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_QSPI_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_RNG_MODULE_ENABLED +#define HAL_RTC_MODULE_ENABLED +#define HAL_SAI_MODULE_ENABLED +#define HAL_SD_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +#define HAL_IRDA_MODULE_ENABLED +#define HAL_SMARTCARD_MODULE_ENABLED +#define HAL_WWDG_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_PCD_MODULE_ENABLED +#define HAL_HCD_MODULE_ENABLED +#define HAL_FMPI2C_MODULE_ENABLED +#define HAL_SPDIFRX_MODULE_ENABLED +#define HAL_DFSDM_MODULE_ENABLED +#define HAL_LPTIM_MODULE_ENABLED +#define HAL_MMC_MODULE_ENABLED +#endif + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) +#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) +#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) +#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz */ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) +#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz +The real value may vary depending on the variations +in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) +#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) +#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) +#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#if !defined (VDD_VALUE) +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#endif +#if !defined (TICK_INT_PRIORITY) +#define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */ +#endif +#if !defined (USE_RTOS) +#define USE_RTOS 0U +#endif +#if !defined (PREFETCH_ENABLE) +#define PREFETCH_ENABLE 1U +#endif +#if !defined (INSTRUCTION_CACHE_ENABLE) +#define INSTRUCTION_CACHE_ENABLE 1U +#endif +#if !defined (DATA_CACHE_ENABLE) +#define DATA_CACHE_ENABLE 1U +#endif + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB (5U) /* 5 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB (5U) /* 5 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ +/* LAN8742A PHY Address*/ +//////////////////////////////// +//#define LAN8742A_PHY_ADDRESS 0x00U +/* Section 2: PHY configuration section */ +#if !defined (LAN8742A_PHY_ADDRESS) + /* LAN8742A PHY Address*/ + #define LAN8742A_PHY_ADDRESS 0x00U +#endif +//////////////////////////////// +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x000000FFU +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY 0x00000FFFU + +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ + +#define PHY_SR ((uint16_t)0x1F) /*!< PHY special control/ status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0004) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0010) /*!< PHY Duplex mask */ + + +#define PHY_ISFR ((uint16_t)0x1D) /*!< PHY Interrupt Source Flag register Offset */ +#define PHY_IMR ((uint16_t)0x1E) /*!< PHY Interrupt Mask register Offset */ +#define PHY_ISFR_INT4 ((uint16_t)0x0010) /*!< PHY Link down inturrupt */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ +#if !defined (USE_SPI_CRC) +#define USE_SPI_CRC 0U +#endif + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED +#include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED +#include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED +#include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED +#include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED +#include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED +#include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED +#include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED +#include "stm32f4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED +#include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED +#include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED +#include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED +#include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED +#include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED +#include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED +#include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED +#include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED +#include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED +#include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED +#include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED +#include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED +#include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED +#include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED +#include "stm32f4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED +#include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED +#include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED +#include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED +#include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED +#include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED +#include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED +#include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED +#include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED +#include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED +#include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED +#include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED +#include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED +#include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED +#include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED +#include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED +#include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED +#include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED +#include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED +#include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED +#include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED +#include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED +#include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED +#include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED +#include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else +#define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_DEFAULT_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/1.9.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/1.9.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h new file mode 100644 index 0000000..6659ec3 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/1.9.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h @@ -0,0 +1,511 @@ +/** + ****************************************************************************** + * @file stm32f7xx_hal_conf_default.h + * @brief HAL default configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F7xx_HAL_CONF_DEFAULT_H +#define __STM32F7xx_HAL_CONF_DEFAULT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief Include the default list of modules to be used in the HAL driver + * and manage module deactivation + */ +#include "stm32yyxx_hal_conf.h" +#if 0 +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +#define HAL_CAN_MODULE_ENABLED +#define HAL_CAN_LEGACY_MODULE_ENABLED +#define HAL_CEC_MODULE_ENABLED +#define HAL_CRC_MODULE_ENABLED +#define HAL_CRYP_MODULE_ENABLED +#define HAL_DAC_MODULE_ENABLED +#define HAL_DCMI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_DMA2D_MODULE_ENABLED +#define HAL_ETH_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_NAND_MODULE_ENABLED +#define HAL_NOR_MODULE_ENABLED +#define HAL_SRAM_MODULE_ENABLED +#define HAL_SDRAM_MODULE_ENABLED +#define HAL_HASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +#define HAL_IWDG_MODULE_ENABLED +#define HAL_LPTIM_MODULE_ENABLED +#define HAL_LTDC_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_QSPI_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_RNG_MODULE_ENABLED +#define HAL_RTC_MODULE_ENABLED +#define HAL_SAI_MODULE_ENABLED +#define HAL_SD_MODULE_ENABLED +#define HAL_SPDIFRX_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +#define HAL_IRDA_MODULE_ENABLED +#define HAL_SMARTCARD_MODULE_ENABLED +#define HAL_WWDG_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_PCD_MODULE_ENABLED +#define HAL_HCD_MODULE_ENABLED +#define HAL_DFSDM_MODULE_ENABLED +#define HAL_DSI_MODULE_ENABLED +#define HAL_JPEG_MODULE_ENABLED +#define HAL_MDIOS_MODULE_ENABLED +#define HAL_SMBUS_MODULE_ENABLED +#define HAL_MMC_MODULE_ENABLED +#endif + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) +#define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) +#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) +#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) +#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz +The real value may vary depending on the variations +in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) +#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) +#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) +#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#if !defined (VDD_VALUE) +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#endif +#if !defined (TICK_INT_PRIORITY) +#define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */ +#endif +#if !defined (USE_RTOS) +#define USE_RTOS 0U +#endif +#if !defined (PREFETCH_ENABLE) +#define PREFETCH_ENABLE 1U /* To enable prefetch */ +#endif +#if !defined (ART_ACCLERATOR_ENABLE) +#define ART_ACCLERATOR_ENABLE 1U /* To enable ART Accelerator */ +#endif + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIOS register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1 */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ +/* LAN8742A PHY Address*/ +//////////////////////////////// +//#define LAN8742A_PHY_ADDRESS 0x00U +/* Section 2: PHY configuration section */ +#if !defined (LAN8742A_PHY_ADDRESS) + /* LAN8742A PHY Address*/ + #define LAN8742A_PHY_ADDRESS 0x00U +#endif +//////////////////////////////// +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x00000FFFU +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY 0x00000FFFU + +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x00U) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x01U) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ + +#define PHY_SR ((uint16_t)0x1FU) /*!< PHY special control/ status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0004U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0010U) /*!< PHY Duplex mask */ + + +#define PHY_ISFR ((uint16_t)0x01DU) /*!< PHY Interrupt Source Flag register Offset */ +#define PHY_IMR ((uint16_t)0x001E) /*!< PHY Interrupt Mask register Offset */ +#define PHY_ISFR_INT4 ((uint16_t)0x0010U) /*!< PHY Link down inturrupt */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ +#if !defined (USE_SPI_CRC) +#define USE_SPI_CRC 0U +#endif + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED +#include "stm32f7xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED +#include "stm32f7xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED +#include "stm32f7xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED +#include "stm32f7xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED +#include "stm32f7xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED +#include "stm32f7xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED +#include "stm32f7xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED +#include "stm32f7xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED +#include "stm32f7xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED +#include "stm32f7xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED +#include "stm32f7xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED +#include "stm32f7xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED +#include "stm32f7xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED +#include "stm32f7xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED +#include "stm32f7xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED +#include "stm32f7xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED +#include "stm32f7xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED +#include "stm32f7xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED +#include "stm32f7xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED +#include "stm32f7xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED +#include "stm32f7xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED +#include "stm32f7xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED +#include "stm32f7xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED +#include "stm32f7xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32f7xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED +#include "stm32f7xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED +#include "stm32f7xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED +#include "stm32f7xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED +#include "stm32f7xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED +#include "stm32f7xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED +#include "stm32f7xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED +#include "stm32f7xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED +#include "stm32f7xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED +#include "stm32f7xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED +#include "stm32f7xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED +#include "stm32f7xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED +#include "stm32f7xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED +#include "stm32f7xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED +#include "stm32f7xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED +#include "stm32f7xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED +#include "stm32f7xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED +#include "stm32f7xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED +#include "stm32f7xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED +#include "stm32f7xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_JPEG_MODULE_ENABLED +#include "stm32f7xx_hal_jpeg.h" +#endif /* HAL_JPEG_MODULE_ENABLED */ + +#ifdef HAL_MDIOS_MODULE_ENABLED +#include "stm32f7xx_hal_mdios.h" +#endif /* HAL_MDIOS_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED +#include "stm32f7xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED +#include "stm32f7xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else +#define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F7xx_HAL_CONF_DEFAULT_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/1.9.0/variants/NUCLEO_F767ZI/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/1.9.0/variants/NUCLEO_F767ZI/variant.h new file mode 100644 index 0000000..f68b249 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/1.9.0/variants/NUCLEO_F767ZI/variant.h @@ -0,0 +1,185 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_ARDUINO_STM32_ +#define _VARIANT_ARDUINO_STM32_ + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +#define PG9 0 +#define PG14 1 +#define PF15 2 +#define PE13 3 +#define PF14 4 +#define PE11 5 +#define PE9 6 +#define PF13 7 +#define PF12 8 +#define PD15 9 +#define PD14 10 +#define PA7 A10 +#define PA6 A11 +#define PA5 A12 +#define PB9 14 +#define PB8 15 +#define PC6 16 +#define PB15 17 +#define PB13 18 +#define PB12 19 +#define PA15 20 +#define PC7 21 +#define PB5 22 +#define PB3 23 +#define PA4 A13 +#define PB4 25 +#define PB6 26 +#define PB2 27 +#define PD13 28 +#define PD12 29 +#define PD11 30 +#define PE2 31 +#define PA0 A14 +#define PB0 33 // LED_GREEN +#define PE0 34 +#define PB11 35 +#define PB10 36 +#define PE15 37 +#define PE14 38 +#define PE12 39 +#define PE10 40 +#define PE7 41 +#define PE8 42 +#define PC8 43 +#define PC9 44 +#define PC10 45 +#define PC11 46 +#define PC12 47 +#define PD2 48 +#define PG2 49 +#define PG3 50 +#define PD7 51 +#define PD6 52 +#define PD5 53 +#define PD4 54 +#define PD3 55 +// 56 is PE2 (31) +#define PE4 57 +#define PE5 58 +#define PE6 59 +#define PE3 60 +#define PF8 A15 +#define PF7 A16 +#define PF9 A17 +#define PG1 64 +#define PG0 65 +#define PD1 66 +#define PD0 67 +#define PF0 68 +#define PF1 69 +#define PF2 70 +// 71 is PA7 (11) +// 72 is NC +#define PB7 73 // LED_BLUE +#define PB14 74 // LED_RED +#define PC13 75 // USER_BTN +#define PD9 76 // Serial Rx +#define PD8 77 // Serial Tx +#define PA3 A0 +#define PC0 A1 +#define PC3 A2 +#define PF3 A3 +#define PF5 A4 +#define PF10 A5 +#define PB1 A6 +#define PC2 A7 +#define PF4 A8 +#define PF6 A9 + +// This must be a literal +#define NUM_DIGITAL_PINS 88 +// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 18 + +// On-board LED pin number +#define LED_BUILTIN PB0 +#define LED_GREEN LED_BUILTIN +#define LED_BLUE PB7 +#define LED_RED PB14 + +// On-board user button +#define USER_BTN PC13 + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#define TIMER_TONE TIM6 +#define TIMER_SERVO TIM7 + +// UART Definitions +#define SERIAL_UART_INSTANCE 3 //Connected to ST-Link + +// Serial pin used for console (ex: stlink) +// Rerquired by Firmata +#define PIN_SERIAL_RX PD9 +#define PIN_SERIAL_TX PD8 + +/* Extra HAL modules */ +#define HAL_DAC_MODULE_ENABLED +#define HAL_ETH_MODULE_ENABLED + +// Last Flash sector used for EEPROM emulation, address/sector depends on single/dual bank configuration. +// By default 2MB single bank +#define FLASH_BASE_ADDRESS 0x081C0000 +#define FLASH_DATA_SECTOR 11 + +#ifdef __cplusplus +} // extern "C" +#endif +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + // These serial port names are intended to allow libraries and architecture-neutral + // sketches to automatically default to the correct port name for a particular type + // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, + // the first hardware serial port whose RX/TX pins are not dedicated to another use. + // + // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor + // + // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial + // + // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library + // + // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. + // + // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX + // pins are NOT connected to anything by default. + #define SERIAL_PORT_MONITOR Serial + + // KH mod to add Serial1, for ESP-AT + //#define SERIAL_PORT_HARDWARE Serial + #define SERIAL_PORT_HARDWARE Serial1 +#endif + +#endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/1.9.0/variants/NUCLEO_L053R8/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/1.9.0/variants/NUCLEO_L053R8/variant.h new file mode 100644 index 0000000..0cb2cfa --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/1.9.0/variants/NUCLEO_L053R8/variant.h @@ -0,0 +1,145 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_ARDUINO_STM32_ +#define _VARIANT_ARDUINO_STM32_ + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +#define PA3 0 +#define PA2 1 +#define PA10 2 +#define PB3 3 +#define PB5 4 +#define PB4 5 +#define PB10 6 +#define PA8 7 +#define PA9 8 +#define PC7 9 +#define PB6 10 +#define PA7 A6 +#define PA6 A7 +#define PA5 13 +#define PB9 14 +#define PB8 15 +// ST Morpho +// CN7 Left Side +#define PC10 16 +#define PC12 17 +// 18 is NC - BOOT0 +#define PA13 19 // SWD +#define PA14 20 // SWD +#define PA15 21 +#define PB7 22 +#define PC13 23 +#define PC14 24 +#define PC15 25 +#define PH0 26 +#define PH1 27 +#define PC2 A8 +#define PC3 A9 +// CN7 Right Side +#define PC11 30 +#define PD2 31 +// CN10 Left Side +#define PC9 32 +// CN10 Right side +#define PC8 33 +#define PC6 34 +#define PC5 A10 +#define PA12 36 +#define PA11 37 +#define PB12 38 +#define PB11 39 +#define PB2 40 +#define PB1 41 +#define PB15 42 +#define PB14 43 +#define PB13 44 +#define PC4 A11 +#define PA0 A0 +#define PA1 A1 +#define PA4 A2 +#define PB0 A3 +#define PC1 A4 +#define PC0 A5 + +// This must be a literal +#define NUM_DIGITAL_PINS 52 +// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 12 + +// On-board LED pin number +#define LED_BUILTIN 13 +#define LED_GREEN LED_BUILTIN + +// On-board user button +#define USER_BTN PC13 + +// Timer Definitions +// Use TIM6 when possible as servo and tone don't need GPIO output pin +#define TIMER_TONE TIM6 +#define TIMER_SERVO TIM2 + +// UART Definitions +#define SERIAL_UART_INSTANCE 2 //Connected to ST-Link +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata +#define PIN_SERIAL_RX 0 +#define PIN_SERIAL_TX 1 + +/* Extra HAL modules */ +#define HAL_DAC_MODULE_ENABLED + +#ifdef __cplusplus +} // extern "C" +#endif +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + // These serial port names are intended to allow libraries and architecture-neutral + // sketches to automatically default to the correct port name for a particular type + // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, + // the first hardware serial port whose RX/TX pins are not dedicated to another use. + // + // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor + // + // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial + // + // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library + // + // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. + // + // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX + // pins are NOT connected to anything by default. + #define SERIAL_PORT_MONITOR Serial + + // KH mod to add Serial1, for ESP-AT + //#define SERIAL_PORT_HARDWARE Serial + #define SERIAL_PORT_HARDWARE Serial1 +#endif + +#endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.0.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.0.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h new file mode 100644 index 0000000..3e2bbf8 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.0.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h @@ -0,0 +1,519 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf_default.h + * @brief HAL default configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_DEFAULT_H +#define __STM32F4xx_HAL_CONF_DEFAULT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief Include the default list of modules to be used in the HAL driver + * and manage module deactivation + */ +#include "stm32yyxx_hal_conf.h" +#if 0 +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +#define HAL_CAN_MODULE_ENABLED +/*#define HAL_CAN_LEGACY_MODULE_ENABLED*/ +#define HAL_CRC_MODULE_ENABLED +#define HAL_CEC_MODULE_ENABLED +#define HAL_CRYP_MODULE_ENABLED +#define HAL_DAC_MODULE_ENABLED +#define HAL_DCMI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_DMA2D_MODULE_ENABLED +#define HAL_ETH_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_NAND_MODULE_ENABLED +#define HAL_NOR_MODULE_ENABLED +#define HAL_PCCARD_MODULE_ENABLED +#define HAL_SRAM_MODULE_ENABLED +#define HAL_SDRAM_MODULE_ENABLED +#define HAL_HASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_SMBUS_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +#define HAL_IWDG_MODULE_ENABLED +#define HAL_LTDC_MODULE_ENABLED +#define HAL_DSI_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_QSPI_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_RNG_MODULE_ENABLED +#define HAL_RTC_MODULE_ENABLED +#define HAL_SAI_MODULE_ENABLED +#define HAL_SD_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +#define HAL_IRDA_MODULE_ENABLED +#define HAL_SMARTCARD_MODULE_ENABLED +#define HAL_WWDG_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_PCD_MODULE_ENABLED +#define HAL_HCD_MODULE_ENABLED +#define HAL_FMPI2C_MODULE_ENABLED +#define HAL_FMPSMBUS_MODULE_ENABLED +#define HAL_SPDIFRX_MODULE_ENABLED +#define HAL_DFSDM_MODULE_ENABLED +#define HAL_LPTIM_MODULE_ENABLED +#define HAL_MMC_MODULE_ENABLED +#endif + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) +#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) +#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) +#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz */ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) +#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz +The real value may vary depending on the variations +in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) +#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) +#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) +#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#if !defined (VDD_VALUE) +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#endif +#if !defined (TICK_INT_PRIORITY) +#define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */ +#endif +#if !defined (USE_RTOS) +#define USE_RTOS 0U +#endif +#if !defined (PREFETCH_ENABLE) +#define PREFETCH_ENABLE 1U +#endif +#if !defined (INSTRUCTION_CACHE_ENABLE) +#define INSTRUCTION_CACHE_ENABLE 1U +#endif +#if !defined (DATA_CACHE_ENABLE) +#define DATA_CACHE_ENABLE 1U +#endif + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_FMPSMBUS_REGISTER_CALLBACKS 0U /* FMPSMBUS register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB (5U) /* 5 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB (5U) /* 5 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ +/* LAN8742A PHY Address*/ +//////////////////////////////// +//#define LAN8742A_PHY_ADDRESS 0x00U +/* Section 2: PHY configuration section */ +#if !defined (LAN8742A_PHY_ADDRESS) + /* LAN8742A PHY Address*/ + #define LAN8742A_PHY_ADDRESS 0x00U +#endif +//////////////////////////////// +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x000000FFU +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY 0x00000FFFU + +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ + +#define PHY_SR ((uint16_t)0x1F) /*!< PHY special control/ status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0004) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0010) /*!< PHY Duplex mask */ + + +#define PHY_ISFR ((uint16_t)0x1D) /*!< PHY Interrupt Source Flag register Offset */ +#define PHY_IMR ((uint16_t)0x1E) /*!< PHY Interrupt Mask register Offset */ +#define PHY_ISFR_INT4 ((uint16_t)0x0010) /*!< PHY Link down inturrupt */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ +#if !defined (USE_SPI_CRC) +#define USE_SPI_CRC 0U +#endif + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED +#include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED +#include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED +#include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED +#include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED +#include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED +#include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED +#include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED +#include "stm32f4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED +#include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED +#include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED +#include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED +#include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED +#include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED +#include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED +#include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED +#include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED +#include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED +#include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED +#include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED +#include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED +#include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED +#include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED +#include "stm32f4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED +#include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED +#include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED +#include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED +#include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED +#include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED +#include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED +#include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED +#include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED +#include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED +#include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED +#include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED +#include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED +#include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED +#include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED +#include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED +#include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED +#include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED +#include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED +#include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED +#include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED +#include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_FMPSMBUS_MODULE_ENABLED +#include "stm32f4xx_hal_fmpsmbus.h" +#endif /* HAL_FMPSMBUS_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED +#include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED +#include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED +#include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else +#define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_DEFAULT_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.0.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.0.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h new file mode 100644 index 0000000..6659ec3 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.0.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h @@ -0,0 +1,511 @@ +/** + ****************************************************************************** + * @file stm32f7xx_hal_conf_default.h + * @brief HAL default configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F7xx_HAL_CONF_DEFAULT_H +#define __STM32F7xx_HAL_CONF_DEFAULT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief Include the default list of modules to be used in the HAL driver + * and manage module deactivation + */ +#include "stm32yyxx_hal_conf.h" +#if 0 +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +#define HAL_CAN_MODULE_ENABLED +#define HAL_CAN_LEGACY_MODULE_ENABLED +#define HAL_CEC_MODULE_ENABLED +#define HAL_CRC_MODULE_ENABLED +#define HAL_CRYP_MODULE_ENABLED +#define HAL_DAC_MODULE_ENABLED +#define HAL_DCMI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_DMA2D_MODULE_ENABLED +#define HAL_ETH_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_NAND_MODULE_ENABLED +#define HAL_NOR_MODULE_ENABLED +#define HAL_SRAM_MODULE_ENABLED +#define HAL_SDRAM_MODULE_ENABLED +#define HAL_HASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +#define HAL_IWDG_MODULE_ENABLED +#define HAL_LPTIM_MODULE_ENABLED +#define HAL_LTDC_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_QSPI_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_RNG_MODULE_ENABLED +#define HAL_RTC_MODULE_ENABLED +#define HAL_SAI_MODULE_ENABLED +#define HAL_SD_MODULE_ENABLED +#define HAL_SPDIFRX_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +#define HAL_IRDA_MODULE_ENABLED +#define HAL_SMARTCARD_MODULE_ENABLED +#define HAL_WWDG_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_PCD_MODULE_ENABLED +#define HAL_HCD_MODULE_ENABLED +#define HAL_DFSDM_MODULE_ENABLED +#define HAL_DSI_MODULE_ENABLED +#define HAL_JPEG_MODULE_ENABLED +#define HAL_MDIOS_MODULE_ENABLED +#define HAL_SMBUS_MODULE_ENABLED +#define HAL_MMC_MODULE_ENABLED +#endif + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) +#define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) +#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) +#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) +#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz +The real value may vary depending on the variations +in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) +#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) +#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) +#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#if !defined (VDD_VALUE) +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#endif +#if !defined (TICK_INT_PRIORITY) +#define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */ +#endif +#if !defined (USE_RTOS) +#define USE_RTOS 0U +#endif +#if !defined (PREFETCH_ENABLE) +#define PREFETCH_ENABLE 1U /* To enable prefetch */ +#endif +#if !defined (ART_ACCLERATOR_ENABLE) +#define ART_ACCLERATOR_ENABLE 1U /* To enable ART Accelerator */ +#endif + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIOS register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1 */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ +/* LAN8742A PHY Address*/ +//////////////////////////////// +//#define LAN8742A_PHY_ADDRESS 0x00U +/* Section 2: PHY configuration section */ +#if !defined (LAN8742A_PHY_ADDRESS) + /* LAN8742A PHY Address*/ + #define LAN8742A_PHY_ADDRESS 0x00U +#endif +//////////////////////////////// +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x00000FFFU +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY 0x00000FFFU + +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x00U) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x01U) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ + +#define PHY_SR ((uint16_t)0x1FU) /*!< PHY special control/ status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0004U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0010U) /*!< PHY Duplex mask */ + + +#define PHY_ISFR ((uint16_t)0x01DU) /*!< PHY Interrupt Source Flag register Offset */ +#define PHY_IMR ((uint16_t)0x001E) /*!< PHY Interrupt Mask register Offset */ +#define PHY_ISFR_INT4 ((uint16_t)0x0010U) /*!< PHY Link down inturrupt */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ +#if !defined (USE_SPI_CRC) +#define USE_SPI_CRC 0U +#endif + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED +#include "stm32f7xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED +#include "stm32f7xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED +#include "stm32f7xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED +#include "stm32f7xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED +#include "stm32f7xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED +#include "stm32f7xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED +#include "stm32f7xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED +#include "stm32f7xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED +#include "stm32f7xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED +#include "stm32f7xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED +#include "stm32f7xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED +#include "stm32f7xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED +#include "stm32f7xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED +#include "stm32f7xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED +#include "stm32f7xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED +#include "stm32f7xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED +#include "stm32f7xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED +#include "stm32f7xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED +#include "stm32f7xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED +#include "stm32f7xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED +#include "stm32f7xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED +#include "stm32f7xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED +#include "stm32f7xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED +#include "stm32f7xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32f7xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED +#include "stm32f7xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED +#include "stm32f7xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED +#include "stm32f7xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED +#include "stm32f7xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED +#include "stm32f7xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED +#include "stm32f7xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED +#include "stm32f7xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED +#include "stm32f7xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED +#include "stm32f7xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED +#include "stm32f7xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED +#include "stm32f7xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED +#include "stm32f7xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED +#include "stm32f7xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED +#include "stm32f7xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED +#include "stm32f7xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED +#include "stm32f7xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED +#include "stm32f7xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED +#include "stm32f7xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED +#include "stm32f7xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_JPEG_MODULE_ENABLED +#include "stm32f7xx_hal_jpeg.h" +#endif /* HAL_JPEG_MODULE_ENABLED */ + +#ifdef HAL_MDIOS_MODULE_ENABLED +#include "stm32f7xx_hal_mdios.h" +#endif /* HAL_MDIOS_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED +#include "stm32f7xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED +#include "stm32f7xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else +#define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F7xx_HAL_CONF_DEFAULT_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.0.0/variants/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/variant_NUCLEO_F767ZI.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.0.0/variants/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/variant_NUCLEO_F767ZI.h new file mode 100644 index 0000000..e8eaf79 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.0.0/variants/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/variant_NUCLEO_F767ZI.h @@ -0,0 +1,274 @@ +/* + ******************************************************************************* + * Copyright (c) 2020-2021, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* +*/ +#pragma once + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +#define PG9 0 +#define PG14 1 +#define PF15 2 +#define PE13 3 +#define PF14 4 +#define PE11 5 +#define PE9 6 +#define PF13 7 +#define PF12 8 +#define PD15 9 +#define PD14 10 +#define PA7 PIN_A10 +#define PA6 PIN_A11 +#define PA5 PIN_A12 +#define PB9 14 +#define PB8 15 +#define PC6 16 +#define PB15 17 +#define PB13 18 +#define PB12 19 +#define PA15 20 +#define PC7 21 +#define PB5 22 +#define PB3 23 +#define PA4 PIN_A13 +#define PB4 25 +#define PB6 26 +#define PB2 27 +#define PD13 28 +#define PD12 29 +#define PD11 30 +#define PE2 31 +#define PA0 PIN_A14 +#define PB0 PIN_A23 // LED_GREEN +#define PE0 34 +#define PB11 35 +#define PB10 36 +#define PE15 37 +#define PE14 38 +#define PE12 39 +#define PE10 40 +#define PE7 41 +#define PE8 42 +#define PC8 43 +#define PC9 44 +#define PC10 45 +#define PC11 46 +#define PC12 47 +#define PD2 48 +#define PG2 49 +#define PG3 50 +#define PD7 51 +#define PD6 52 +#define PD5 53 +#define PD4 54 +#define PD3 55 +// 56 is PE2 (31) +#define PE4 57 +#define PE5 58 +#define PE6 59 +#define PE3 60 +#define PF8 PIN_A15 +#define PF7 PIN_A16 +#define PF9 PIN_A17 +#define PG1 64 +#define PG0 65 +#define PD1 66 +#define PD0 67 +#define PF0 68 +#define PF1 69 +#define PF2 70 +// 71 is PA7 (11) +// 72 is NC +#define PB7 73 // LED_BLUE +#define PB14 74 // LED_RED +#define PC13 75 // USER_BTN +#define PD9 76 // Serial Rx +#define PD8 77 // Serial Tx +#define PA3 PIN_A0 +#define PC0 PIN_A1 +#define PC3 PIN_A2 +#define PF3 PIN_A3 +#define PF5 PIN_A4 +#define PF10 PIN_A5 +#define PB1 PIN_A6 +#define PC2 PIN_A7 +#define PF4 PIN_A8 +#define PF6 PIN_A9 +// ST Morpho +#define PA1 PIN_A18 +#define PA2 PIN_A19 +#define PA8 90 +#define PA9 91 +#define PA10 92 +#define PA11 93 +#define PA12 94 +#define PA13 95 // SWD +#define PA14 96 // SWD +#define PC1 PIN_A20 +#define PC4 PIN_A21 +#define PC5 PIN_A22 +#define PC14 100 +#define PC15 101 +#define PD10 102 +#define PE1 103 +#define PF11 104 +#define PG4 105 +#define PG5 106 +#define PG6 107 +#define PG7 108 +#define PG8 109 +#define PG10 110 +#define PG11 111 +#define PG12 112 +#define PG13 113 +#define PG15 114 +#define PH0 115 // MCO +#define PH1 116 + +// Alternate pins number +#define PA0_ALT1 (PA0 | ALT1) +#define PA0_ALT2 (PA0 | ALT2) +#define PA1_ALT1 (PA1 | ALT1) +#define PA1_ALT2 (PA1 | ALT2) +#define PA2_ALT1 (PA2 | ALT1) +#define PA2_ALT2 (PA2 | ALT2) +#define PA3_ALT1 (PA3 | ALT1) +#define PA3_ALT2 (PA3 | ALT2) +#define PA4_ALT1 (PA4 | ALT1) +#define PA5_ALT1 (PA5 | ALT1) +#define PA6_ALT1 (PA6 | ALT1) +#define PA7_ALT1 (PA7 | ALT1) +#define PA7_ALT2 (PA7 | ALT2) +#define PA7_ALT3 (PA7 | ALT3) +#define PA15_ALT1 (PA15 | ALT1) +#define PB0_ALT1 (PB0 | ALT1) +#define PB0_ALT2 (PB0 | ALT2) +#define PB1_ALT1 (PB1 | ALT1) +#define PB1_ALT2 (PB1 | ALT2) +#define PB3_ALT1 (PB3 | ALT1) +#define PB4_ALT1 (PB4 | ALT1) +#define PB5_ALT1 (PB5 | ALT1) +#define PB8_ALT1 (PB8 | ALT1) +#define PB9_ALT1 (PB9 | ALT1) +#define PB14_ALT1 (PB14 | ALT1) +#define PB14_ALT2 (PB14 | ALT2) +#define PB15_ALT1 (PB15 | ALT1) +#define PB15_ALT2 (PB15 | ALT2) +#define PC0_ALT1 (PC0 | ALT1) +#define PC0_ALT2 (PC0 | ALT2) +#define PC1_ALT1 (PC1 | ALT1) +#define PC1_ALT2 (PC1 | ALT2) +#define PC2_ALT1 (PC2 | ALT1) +#define PC2_ALT2 (PC2 | ALT2) +#define PC3_ALT1 (PC3 | ALT1) +#define PC3_ALT2 (PC3 | ALT2) +#define PC4_ALT1 (PC4 | ALT1) +#define PC5_ALT1 (PC5 | ALT1) +#define PC6_ALT1 (PC6 | ALT1) +#define PC7_ALT1 (PC7 | ALT1) +#define PC8_ALT1 (PC8 | ALT1) +#define PC9_ALT1 (PC9 | ALT1) +#define PC10_ALT1 (PC10 | ALT1) +#define PC11_ALT1 (PC11 | ALT1) + +// This must be a literal +#define NUM_DIGITAL_PINS 117 +// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 24 + +// On-board LED pin number +#ifndef LED_BUILTIN + #define LED_BUILTIN PB0 +#endif +#define LED_GREEN LED_BUILTIN +#define LED_BLUE PB7 +#define LED_RED PB14 + +// On-board user button +#ifndef USER_BTN + #define USER_BTN PC13 +#endif + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifndef TIMER_TONE + #define TIMER_TONE TIM6 +#endif +#ifndef TIMER_SERVO + #define TIMER_SERVO TIM7 +#endif + +// UART Definitions +#ifndef SERIAL_UART_INSTANCE + #define SERIAL_UART_INSTANCE 3 //Connected to ST-Link +#endif +// Serial pin used for console (ex: stlink) +// Rerquired by Firmata +#ifndef PIN_SERIAL_RX + #define PIN_SERIAL_RX PD9 +#endif +#ifndef PIN_SERIAL_TX + #define PIN_SERIAL_TX PD8 +#endif + +// Value of the External oscillator in Hz +#define HSE_VALUE 8000000U + +/* Extra HAL modules */ +#if !defined(HAL_DAC_MODULE_DISABLED) + #define HAL_DAC_MODULE_ENABLED +#endif +#if !defined(HAL_ETH_MODULE_DISABLED) + #define HAL_ETH_MODULE_ENABLED +#endif +#if !defined(HAL_QSPI_MODULE_DISABLED) + #define HAL_QSPI_MODULE_ENABLED +#endif +#if !defined(HAL_SD_MODULE_DISABLED) + #define HAL_SD_MODULE_ENABLED +#endif + +// Last Flash sector used for EEPROM emulation, address/sector depends on single/dual bank configuration. +// By default 2MB single bank +#define FLASH_BASE_ADDRESS 0x081C0000 +#define FLASH_DATA_SECTOR 11 + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + // These serial port names are intended to allow libraries and architecture-neutral + // sketches to automatically default to the correct port name for a particular type + // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, + // the first hardware serial port whose RX/TX pins are not dedicated to another use. + // + // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor + // + // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial + // + // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library + // + // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. + // + // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX + // pins are NOT connected to anything by default. + #ifndef SERIAL_PORT_MONITOR + #define SERIAL_PORT_MONITOR Serial + #endif + #ifndef SERIAL_PORT_HARDWARE + // KH mod to add Serial1, for ESP-AT + //#define SERIAL_PORT_HARDWARE Serial + #define SERIAL_PORT_HARDWARE Serial1 + #endif +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.0.0/variants/L052R(6-8)H_L053R(6-8)H/variant_generic.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.0.0/variants/L052R(6-8)H_L053R(6-8)H/variant_generic.h new file mode 100644 index 0000000..43ba241 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.0.0/variants/L052R(6-8)H_L053R(6-8)H/variant_generic.h @@ -0,0 +1,173 @@ +/* + ******************************************************************************* + * Copyright (c) 2020-2021, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* + */ +#pragma once + +/*---------------------------------------------------------------------------- + * STM32 pins number + *----------------------------------------------------------------------------*/ +#define PA0 PIN_A0 +#define PA1 PIN_A1 +#define PA2 PIN_A2 +#define PA3 PIN_A3 +#define PA4 PIN_A4 +#define PA5 PIN_A5 +#define PA6 PIN_A6 +#define PA7 PIN_A7 +#define PA8 8 +#define PA9 9 +#define PA10 10 +#define PA11 11 +#define PA12 12 +#define PA13 13 +#define PA14 14 +#define PA15 15 +#define PB0 PIN_A8 +#define PB1 PIN_A9 +#define PB2 18 +#define PB3 19 +#define PB4 20 +#define PB5 21 +#define PB6 22 +#define PB7 23 +#define PB8 24 +#define PB9 25 +#define PB10 26 +#define PB11 27 +#define PB12 28 +#define PB13 29 +#define PB14 30 +#define PB15 31 +#define PC0 PIN_A10 +#define PC1 PIN_A11 +#define PC2 PIN_A12 +#define PC4 PIN_A13 +#define PC5 PIN_A14 +#define PC6 37 +#define PC7 38 +#define PC8 39 +#define PC9 40 +#define PC10 41 +#define PC11 42 +#define PC12 43 +#define PC13 44 +#define PC14 45 +#define PC15 46 +#define PD2 47 +#define PH0 48 +#define PH1 49 + +// Alternate pins number +#define PA2_ALT1 (PA2 | ALT1) +#define PA3_ALT1 (PA3 | ALT1) + +#define NUM_DIGITAL_PINS 50 +#define NUM_ANALOG_INPUTS 15 + +// On-board LED pin number +#ifndef LED_BUILTIN + #define LED_BUILTIN PNUM_NOT_DEFINED +#endif + +// On-board user button +#ifndef USER_BTN + #define USER_BTN PNUM_NOT_DEFINED +#endif + +// SPI definitions +#ifndef PIN_SPI_SS + #define PIN_SPI_SS PA4 +#endif +#ifndef PIN_SPI_SS1 + #define PIN_SPI_SS1 PA15 +#endif +#ifndef PIN_SPI_SS2 + #define PIN_SPI_SS2 PNUM_NOT_DEFINED +#endif +#ifndef PIN_SPI_SS3 + #define PIN_SPI_SS3 PNUM_NOT_DEFINED +#endif +#ifndef PIN_SPI_MOSI + #define PIN_SPI_MOSI PA7 +#endif +#ifndef PIN_SPI_MISO + #define PIN_SPI_MISO PA6 +#endif +#ifndef PIN_SPI_SCK + #define PIN_SPI_SCK PA5 +#endif + +// I2C definitions +#ifndef PIN_WIRE_SDA + #define PIN_WIRE_SDA PB7 +#endif +#ifndef PIN_WIRE_SCL + #define PIN_WIRE_SCL PB6 +#endif + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifndef TIMER_TONE + #define TIMER_TONE TIM6 +#endif +#ifndef TIMER_SERVO + #define TIMER_SERVO TIM21 +#endif + +// UART Definitions +#ifndef SERIAL_UART_INSTANCE + #define SERIAL_UART_INSTANCE 2 +#endif + +// Default pin used for generic 'Serial' instance +// Mandatory for Firmata +#ifndef PIN_SERIAL_RX + #define PIN_SERIAL_RX PA3 +#endif +#ifndef PIN_SERIAL_TX + #define PIN_SERIAL_TX PA2 +#endif + +// Extra HAL modules +#if !defined(HAL_DAC_MODULE_DISABLED) + #define HAL_DAC_MODULE_ENABLED +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + // These serial port names are intended to allow libraries and architecture-neutral + // sketches to automatically default to the correct port name for a particular type + // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, + // the first hardware serial port whose RX/TX pins are not dedicated to another use. + // + // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor + // + // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial + // + // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library + // + // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. + // + // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX + // pins are NOT connected to anything by default. + #ifndef SERIAL_PORT_MONITOR + #define SERIAL_PORT_MONITOR Serial + #endif + #ifndef SERIAL_PORT_HARDWARE + // KH mod to add Serial1, for ESP-AT + //#define SERIAL_PORT_HARDWARE Serial + #define SERIAL_PORT_HARDWARE Serial1 + #endif +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.0.0/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/variant_NUCLEO_F767ZI.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.0.0/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/variant_NUCLEO_F767ZI.h new file mode 100644 index 0000000..e8eaf79 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.0.0/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/variant_NUCLEO_F767ZI.h @@ -0,0 +1,274 @@ +/* + ******************************************************************************* + * Copyright (c) 2020-2021, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* +*/ +#pragma once + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +#define PG9 0 +#define PG14 1 +#define PF15 2 +#define PE13 3 +#define PF14 4 +#define PE11 5 +#define PE9 6 +#define PF13 7 +#define PF12 8 +#define PD15 9 +#define PD14 10 +#define PA7 PIN_A10 +#define PA6 PIN_A11 +#define PA5 PIN_A12 +#define PB9 14 +#define PB8 15 +#define PC6 16 +#define PB15 17 +#define PB13 18 +#define PB12 19 +#define PA15 20 +#define PC7 21 +#define PB5 22 +#define PB3 23 +#define PA4 PIN_A13 +#define PB4 25 +#define PB6 26 +#define PB2 27 +#define PD13 28 +#define PD12 29 +#define PD11 30 +#define PE2 31 +#define PA0 PIN_A14 +#define PB0 PIN_A23 // LED_GREEN +#define PE0 34 +#define PB11 35 +#define PB10 36 +#define PE15 37 +#define PE14 38 +#define PE12 39 +#define PE10 40 +#define PE7 41 +#define PE8 42 +#define PC8 43 +#define PC9 44 +#define PC10 45 +#define PC11 46 +#define PC12 47 +#define PD2 48 +#define PG2 49 +#define PG3 50 +#define PD7 51 +#define PD6 52 +#define PD5 53 +#define PD4 54 +#define PD3 55 +// 56 is PE2 (31) +#define PE4 57 +#define PE5 58 +#define PE6 59 +#define PE3 60 +#define PF8 PIN_A15 +#define PF7 PIN_A16 +#define PF9 PIN_A17 +#define PG1 64 +#define PG0 65 +#define PD1 66 +#define PD0 67 +#define PF0 68 +#define PF1 69 +#define PF2 70 +// 71 is PA7 (11) +// 72 is NC +#define PB7 73 // LED_BLUE +#define PB14 74 // LED_RED +#define PC13 75 // USER_BTN +#define PD9 76 // Serial Rx +#define PD8 77 // Serial Tx +#define PA3 PIN_A0 +#define PC0 PIN_A1 +#define PC3 PIN_A2 +#define PF3 PIN_A3 +#define PF5 PIN_A4 +#define PF10 PIN_A5 +#define PB1 PIN_A6 +#define PC2 PIN_A7 +#define PF4 PIN_A8 +#define PF6 PIN_A9 +// ST Morpho +#define PA1 PIN_A18 +#define PA2 PIN_A19 +#define PA8 90 +#define PA9 91 +#define PA10 92 +#define PA11 93 +#define PA12 94 +#define PA13 95 // SWD +#define PA14 96 // SWD +#define PC1 PIN_A20 +#define PC4 PIN_A21 +#define PC5 PIN_A22 +#define PC14 100 +#define PC15 101 +#define PD10 102 +#define PE1 103 +#define PF11 104 +#define PG4 105 +#define PG5 106 +#define PG6 107 +#define PG7 108 +#define PG8 109 +#define PG10 110 +#define PG11 111 +#define PG12 112 +#define PG13 113 +#define PG15 114 +#define PH0 115 // MCO +#define PH1 116 + +// Alternate pins number +#define PA0_ALT1 (PA0 | ALT1) +#define PA0_ALT2 (PA0 | ALT2) +#define PA1_ALT1 (PA1 | ALT1) +#define PA1_ALT2 (PA1 | ALT2) +#define PA2_ALT1 (PA2 | ALT1) +#define PA2_ALT2 (PA2 | ALT2) +#define PA3_ALT1 (PA3 | ALT1) +#define PA3_ALT2 (PA3 | ALT2) +#define PA4_ALT1 (PA4 | ALT1) +#define PA5_ALT1 (PA5 | ALT1) +#define PA6_ALT1 (PA6 | ALT1) +#define PA7_ALT1 (PA7 | ALT1) +#define PA7_ALT2 (PA7 | ALT2) +#define PA7_ALT3 (PA7 | ALT3) +#define PA15_ALT1 (PA15 | ALT1) +#define PB0_ALT1 (PB0 | ALT1) +#define PB0_ALT2 (PB0 | ALT2) +#define PB1_ALT1 (PB1 | ALT1) +#define PB1_ALT2 (PB1 | ALT2) +#define PB3_ALT1 (PB3 | ALT1) +#define PB4_ALT1 (PB4 | ALT1) +#define PB5_ALT1 (PB5 | ALT1) +#define PB8_ALT1 (PB8 | ALT1) +#define PB9_ALT1 (PB9 | ALT1) +#define PB14_ALT1 (PB14 | ALT1) +#define PB14_ALT2 (PB14 | ALT2) +#define PB15_ALT1 (PB15 | ALT1) +#define PB15_ALT2 (PB15 | ALT2) +#define PC0_ALT1 (PC0 | ALT1) +#define PC0_ALT2 (PC0 | ALT2) +#define PC1_ALT1 (PC1 | ALT1) +#define PC1_ALT2 (PC1 | ALT2) +#define PC2_ALT1 (PC2 | ALT1) +#define PC2_ALT2 (PC2 | ALT2) +#define PC3_ALT1 (PC3 | ALT1) +#define PC3_ALT2 (PC3 | ALT2) +#define PC4_ALT1 (PC4 | ALT1) +#define PC5_ALT1 (PC5 | ALT1) +#define PC6_ALT1 (PC6 | ALT1) +#define PC7_ALT1 (PC7 | ALT1) +#define PC8_ALT1 (PC8 | ALT1) +#define PC9_ALT1 (PC9 | ALT1) +#define PC10_ALT1 (PC10 | ALT1) +#define PC11_ALT1 (PC11 | ALT1) + +// This must be a literal +#define NUM_DIGITAL_PINS 117 +// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 24 + +// On-board LED pin number +#ifndef LED_BUILTIN + #define LED_BUILTIN PB0 +#endif +#define LED_GREEN LED_BUILTIN +#define LED_BLUE PB7 +#define LED_RED PB14 + +// On-board user button +#ifndef USER_BTN + #define USER_BTN PC13 +#endif + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifndef TIMER_TONE + #define TIMER_TONE TIM6 +#endif +#ifndef TIMER_SERVO + #define TIMER_SERVO TIM7 +#endif + +// UART Definitions +#ifndef SERIAL_UART_INSTANCE + #define SERIAL_UART_INSTANCE 3 //Connected to ST-Link +#endif +// Serial pin used for console (ex: stlink) +// Rerquired by Firmata +#ifndef PIN_SERIAL_RX + #define PIN_SERIAL_RX PD9 +#endif +#ifndef PIN_SERIAL_TX + #define PIN_SERIAL_TX PD8 +#endif + +// Value of the External oscillator in Hz +#define HSE_VALUE 8000000U + +/* Extra HAL modules */ +#if !defined(HAL_DAC_MODULE_DISABLED) + #define HAL_DAC_MODULE_ENABLED +#endif +#if !defined(HAL_ETH_MODULE_DISABLED) + #define HAL_ETH_MODULE_ENABLED +#endif +#if !defined(HAL_QSPI_MODULE_DISABLED) + #define HAL_QSPI_MODULE_ENABLED +#endif +#if !defined(HAL_SD_MODULE_DISABLED) + #define HAL_SD_MODULE_ENABLED +#endif + +// Last Flash sector used for EEPROM emulation, address/sector depends on single/dual bank configuration. +// By default 2MB single bank +#define FLASH_BASE_ADDRESS 0x081C0000 +#define FLASH_DATA_SECTOR 11 + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + // These serial port names are intended to allow libraries and architecture-neutral + // sketches to automatically default to the correct port name for a particular type + // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, + // the first hardware serial port whose RX/TX pins are not dedicated to another use. + // + // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor + // + // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial + // + // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library + // + // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. + // + // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX + // pins are NOT connected to anything by default. + #ifndef SERIAL_PORT_MONITOR + #define SERIAL_PORT_MONITOR Serial + #endif + #ifndef SERIAL_PORT_HARDWARE + // KH mod to add Serial1, for ESP-AT + //#define SERIAL_PORT_HARDWARE Serial + #define SERIAL_PORT_HARDWARE Serial1 + #endif +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.0.0/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/variant_generic.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.0.0/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/variant_generic.h new file mode 100644 index 0000000..43ba241 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.0.0/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/variant_generic.h @@ -0,0 +1,173 @@ +/* + ******************************************************************************* + * Copyright (c) 2020-2021, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* + */ +#pragma once + +/*---------------------------------------------------------------------------- + * STM32 pins number + *----------------------------------------------------------------------------*/ +#define PA0 PIN_A0 +#define PA1 PIN_A1 +#define PA2 PIN_A2 +#define PA3 PIN_A3 +#define PA4 PIN_A4 +#define PA5 PIN_A5 +#define PA6 PIN_A6 +#define PA7 PIN_A7 +#define PA8 8 +#define PA9 9 +#define PA10 10 +#define PA11 11 +#define PA12 12 +#define PA13 13 +#define PA14 14 +#define PA15 15 +#define PB0 PIN_A8 +#define PB1 PIN_A9 +#define PB2 18 +#define PB3 19 +#define PB4 20 +#define PB5 21 +#define PB6 22 +#define PB7 23 +#define PB8 24 +#define PB9 25 +#define PB10 26 +#define PB11 27 +#define PB12 28 +#define PB13 29 +#define PB14 30 +#define PB15 31 +#define PC0 PIN_A10 +#define PC1 PIN_A11 +#define PC2 PIN_A12 +#define PC4 PIN_A13 +#define PC5 PIN_A14 +#define PC6 37 +#define PC7 38 +#define PC8 39 +#define PC9 40 +#define PC10 41 +#define PC11 42 +#define PC12 43 +#define PC13 44 +#define PC14 45 +#define PC15 46 +#define PD2 47 +#define PH0 48 +#define PH1 49 + +// Alternate pins number +#define PA2_ALT1 (PA2 | ALT1) +#define PA3_ALT1 (PA3 | ALT1) + +#define NUM_DIGITAL_PINS 50 +#define NUM_ANALOG_INPUTS 15 + +// On-board LED pin number +#ifndef LED_BUILTIN + #define LED_BUILTIN PNUM_NOT_DEFINED +#endif + +// On-board user button +#ifndef USER_BTN + #define USER_BTN PNUM_NOT_DEFINED +#endif + +// SPI definitions +#ifndef PIN_SPI_SS + #define PIN_SPI_SS PA4 +#endif +#ifndef PIN_SPI_SS1 + #define PIN_SPI_SS1 PA15 +#endif +#ifndef PIN_SPI_SS2 + #define PIN_SPI_SS2 PNUM_NOT_DEFINED +#endif +#ifndef PIN_SPI_SS3 + #define PIN_SPI_SS3 PNUM_NOT_DEFINED +#endif +#ifndef PIN_SPI_MOSI + #define PIN_SPI_MOSI PA7 +#endif +#ifndef PIN_SPI_MISO + #define PIN_SPI_MISO PA6 +#endif +#ifndef PIN_SPI_SCK + #define PIN_SPI_SCK PA5 +#endif + +// I2C definitions +#ifndef PIN_WIRE_SDA + #define PIN_WIRE_SDA PB7 +#endif +#ifndef PIN_WIRE_SCL + #define PIN_WIRE_SCL PB6 +#endif + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifndef TIMER_TONE + #define TIMER_TONE TIM6 +#endif +#ifndef TIMER_SERVO + #define TIMER_SERVO TIM21 +#endif + +// UART Definitions +#ifndef SERIAL_UART_INSTANCE + #define SERIAL_UART_INSTANCE 2 +#endif + +// Default pin used for generic 'Serial' instance +// Mandatory for Firmata +#ifndef PIN_SERIAL_RX + #define PIN_SERIAL_RX PA3 +#endif +#ifndef PIN_SERIAL_TX + #define PIN_SERIAL_TX PA2 +#endif + +// Extra HAL modules +#if !defined(HAL_DAC_MODULE_DISABLED) + #define HAL_DAC_MODULE_ENABLED +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + // These serial port names are intended to allow libraries and architecture-neutral + // sketches to automatically default to the correct port name for a particular type + // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, + // the first hardware serial port whose RX/TX pins are not dedicated to another use. + // + // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor + // + // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial + // + // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library + // + // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. + // + // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX + // pins are NOT connected to anything by default. + #ifndef SERIAL_PORT_MONITOR + #define SERIAL_PORT_MONITOR Serial + #endif + #ifndef SERIAL_PORT_HARDWARE + // KH mod to add Serial1, for ESP-AT + //#define SERIAL_PORT_HARDWARE Serial + #define SERIAL_PORT_HARDWARE Serial1 + #endif +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.1.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.1.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h new file mode 100644 index 0000000..ec7da13 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.1.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h @@ -0,0 +1,519 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf_default.h + * @brief HAL default configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_DEFAULT_H +#define __STM32F4xx_HAL_CONF_DEFAULT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief Include the default list of modules to be used in the HAL driver + * and manage module deactivation + */ +#include "stm32yyxx_hal_conf.h" +#if 0 +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +#define HAL_CAN_MODULE_ENABLED +/*#define HAL_CAN_LEGACY_MODULE_ENABLED*/ +#define HAL_CRC_MODULE_ENABLED +#define HAL_CEC_MODULE_ENABLED +#define HAL_CRYP_MODULE_ENABLED +#define HAL_DAC_MODULE_ENABLED +#define HAL_DCMI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_DMA2D_MODULE_ENABLED +#define HAL_ETH_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_NAND_MODULE_ENABLED +#define HAL_NOR_MODULE_ENABLED +#define HAL_PCCARD_MODULE_ENABLED +#define HAL_SRAM_MODULE_ENABLED +#define HAL_SDRAM_MODULE_ENABLED +#define HAL_HASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_SMBUS_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +#define HAL_IWDG_MODULE_ENABLED +#define HAL_LTDC_MODULE_ENABLED +#define HAL_DSI_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_QSPI_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_RNG_MODULE_ENABLED +#define HAL_RTC_MODULE_ENABLED +#define HAL_SAI_MODULE_ENABLED +#define HAL_SD_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +#define HAL_IRDA_MODULE_ENABLED +#define HAL_SMARTCARD_MODULE_ENABLED +#define HAL_WWDG_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_PCD_MODULE_ENABLED +#define HAL_HCD_MODULE_ENABLED +#define HAL_FMPI2C_MODULE_ENABLED +#define HAL_FMPSMBUS_MODULE_ENABLED +#define HAL_SPDIFRX_MODULE_ENABLED +#define HAL_DFSDM_MODULE_ENABLED +#define HAL_LPTIM_MODULE_ENABLED +#define HAL_MMC_MODULE_ENABLED +#endif + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) +#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) +#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) +#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz */ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) +#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz +The real value may vary depending on the variations +in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) +#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) +#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) +#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#if !defined (VDD_VALUE) +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#endif +#if !defined (TICK_INT_PRIORITY) +#define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */ +#endif +#if !defined (USE_RTOS) +#define USE_RTOS 0U +#endif +#if !defined (PREFETCH_ENABLE) +#define PREFETCH_ENABLE 1U +#endif +#if !defined (INSTRUCTION_CACHE_ENABLE) +#define INSTRUCTION_CACHE_ENABLE 1U +#endif +#if !defined (DATA_CACHE_ENABLE) +#define DATA_CACHE_ENABLE 1U +#endif + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_FMPSMBUS_REGISTER_CALLBACKS 0U /* FMPSMBUS register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB (5U) /* 5 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB (5U) /* 5 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ +/* LAN8742A PHY Address*/ +//////////////////////////////// +//#define LAN8742A_PHY_ADDRESS 0x00U +/* Section 2: PHY configuration section */ +#if !defined (LAN8742A_PHY_ADDRESS) + /* KH, LAN8742A PHY Address*/ + #define LAN8742A_PHY_ADDRESS 0x00U +#endif +//////////////////////////////// +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x000000FFU +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY 0x00000FFFU + +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ + +#define PHY_SR ((uint16_t)0x1F) /*!< PHY special control/ status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0004) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0010) /*!< PHY Duplex mask */ + + +#define PHY_ISFR ((uint16_t)0x1D) /*!< PHY Interrupt Source Flag register Offset */ +#define PHY_IMR ((uint16_t)0x1E) /*!< PHY Interrupt Mask register Offset */ +#define PHY_ISFR_INT4 ((uint16_t)0x0010) /*!< PHY Link down inturrupt */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ +#if !defined (USE_SPI_CRC) +#define USE_SPI_CRC 0U +#endif + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED +#include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED +#include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED +#include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED +#include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED +#include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED +#include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED +#include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED +#include "stm32f4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED +#include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED +#include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED +#include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED +#include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED +#include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED +#include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED +#include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED +#include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED +#include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED +#include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED +#include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED +#include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED +#include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED +#include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED +#include "stm32f4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED +#include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED +#include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED +#include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED +#include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED +#include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED +#include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED +#include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED +#include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED +#include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED +#include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED +#include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED +#include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED +#include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED +#include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED +#include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED +#include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED +#include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED +#include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED +#include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED +#include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED +#include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_FMPSMBUS_MODULE_ENABLED +#include "stm32f4xx_hal_fmpsmbus.h" +#endif /* HAL_FMPSMBUS_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED +#include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED +#include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED +#include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else +#define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_DEFAULT_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.1.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.1.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h new file mode 100644 index 0000000..3bcd06c --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.1.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h @@ -0,0 +1,511 @@ +/** + ****************************************************************************** + * @file stm32f7xx_hal_conf_default.h + * @brief HAL default configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F7xx_HAL_CONF_DEFAULT_H +#define __STM32F7xx_HAL_CONF_DEFAULT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief Include the default list of modules to be used in the HAL driver + * and manage module deactivation + */ +#include "stm32yyxx_hal_conf.h" +#if 0 +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +#define HAL_CAN_MODULE_ENABLED +#define HAL_CAN_LEGACY_MODULE_ENABLED +#define HAL_CEC_MODULE_ENABLED +#define HAL_CRC_MODULE_ENABLED +#define HAL_CRYP_MODULE_ENABLED +#define HAL_DAC_MODULE_ENABLED +#define HAL_DCMI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_DMA2D_MODULE_ENABLED +#define HAL_ETH_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_NAND_MODULE_ENABLED +#define HAL_NOR_MODULE_ENABLED +#define HAL_SRAM_MODULE_ENABLED +#define HAL_SDRAM_MODULE_ENABLED +#define HAL_HASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +#define HAL_IWDG_MODULE_ENABLED +#define HAL_LPTIM_MODULE_ENABLED +#define HAL_LTDC_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_QSPI_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_RNG_MODULE_ENABLED +#define HAL_RTC_MODULE_ENABLED +#define HAL_SAI_MODULE_ENABLED +#define HAL_SD_MODULE_ENABLED +#define HAL_SPDIFRX_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +#define HAL_IRDA_MODULE_ENABLED +#define HAL_SMARTCARD_MODULE_ENABLED +#define HAL_WWDG_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_PCD_MODULE_ENABLED +#define HAL_HCD_MODULE_ENABLED +#define HAL_DFSDM_MODULE_ENABLED +#define HAL_DSI_MODULE_ENABLED +#define HAL_JPEG_MODULE_ENABLED +#define HAL_MDIOS_MODULE_ENABLED +#define HAL_SMBUS_MODULE_ENABLED +#define HAL_MMC_MODULE_ENABLED +#endif + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) +#define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) +#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) +#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) +#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz +The real value may vary depending on the variations +in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) +#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) +#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) +#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#if !defined (VDD_VALUE) +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#endif +#if !defined (TICK_INT_PRIORITY) +#define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */ +#endif +#if !defined (USE_RTOS) +#define USE_RTOS 0U +#endif +#if !defined (PREFETCH_ENABLE) +#define PREFETCH_ENABLE 1U /* To enable prefetch */ +#endif +#if !defined (ART_ACCLERATOR_ENABLE) +#define ART_ACCLERATOR_ENABLE 1U /* To enable ART Accelerator */ +#endif + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIOS register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1 */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ +/* LAN8742A PHY Address*/ +//////////////////////////////// +//#define LAN8742A_PHY_ADDRESS 0x00U +/* Section 2: PHY configuration section */ +#if !defined (LAN8742A_PHY_ADDRESS) + /* KH, LAN8742A PHY Address*/ + #define LAN8742A_PHY_ADDRESS 0x00U +#endif +//////////////////////////////// +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x00000FFFU +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY 0x00000FFFU + +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x00U) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x01U) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ + +#define PHY_SR ((uint16_t)0x1FU) /*!< PHY special control/ status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0004U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0010U) /*!< PHY Duplex mask */ + + +#define PHY_ISFR ((uint16_t)0x01DU) /*!< PHY Interrupt Source Flag register Offset */ +#define PHY_IMR ((uint16_t)0x001E) /*!< PHY Interrupt Mask register Offset */ +#define PHY_ISFR_INT4 ((uint16_t)0x0010U) /*!< PHY Link down inturrupt */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ +#if !defined (USE_SPI_CRC) +#define USE_SPI_CRC 0U +#endif + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED +#include "stm32f7xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED +#include "stm32f7xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED +#include "stm32f7xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED +#include "stm32f7xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED +#include "stm32f7xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED +#include "stm32f7xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED +#include "stm32f7xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED +#include "stm32f7xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED +#include "stm32f7xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED +#include "stm32f7xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED +#include "stm32f7xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED +#include "stm32f7xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED +#include "stm32f7xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED +#include "stm32f7xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED +#include "stm32f7xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED +#include "stm32f7xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED +#include "stm32f7xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED +#include "stm32f7xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED +#include "stm32f7xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED +#include "stm32f7xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED +#include "stm32f7xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED +#include "stm32f7xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED +#include "stm32f7xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED +#include "stm32f7xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32f7xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED +#include "stm32f7xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED +#include "stm32f7xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED +#include "stm32f7xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED +#include "stm32f7xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED +#include "stm32f7xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED +#include "stm32f7xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED +#include "stm32f7xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED +#include "stm32f7xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED +#include "stm32f7xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED +#include "stm32f7xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED +#include "stm32f7xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED +#include "stm32f7xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED +#include "stm32f7xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED +#include "stm32f7xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED +#include "stm32f7xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED +#include "stm32f7xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED +#include "stm32f7xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED +#include "stm32f7xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED +#include "stm32f7xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_JPEG_MODULE_ENABLED +#include "stm32f7xx_hal_jpeg.h" +#endif /* HAL_JPEG_MODULE_ENABLED */ + +#ifdef HAL_MDIOS_MODULE_ENABLED +#include "stm32f7xx_hal_mdios.h" +#endif /* HAL_MDIOS_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED +#include "stm32f7xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED +#include "stm32f7xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else +#define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F7xx_HAL_CONF_DEFAULT_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.1.0/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/variant_NUCLEO_F767ZI.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.1.0/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/variant_NUCLEO_F767ZI.h new file mode 100644 index 0000000..e8eaf79 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.1.0/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/variant_NUCLEO_F767ZI.h @@ -0,0 +1,274 @@ +/* + ******************************************************************************* + * Copyright (c) 2020-2021, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* +*/ +#pragma once + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +#define PG9 0 +#define PG14 1 +#define PF15 2 +#define PE13 3 +#define PF14 4 +#define PE11 5 +#define PE9 6 +#define PF13 7 +#define PF12 8 +#define PD15 9 +#define PD14 10 +#define PA7 PIN_A10 +#define PA6 PIN_A11 +#define PA5 PIN_A12 +#define PB9 14 +#define PB8 15 +#define PC6 16 +#define PB15 17 +#define PB13 18 +#define PB12 19 +#define PA15 20 +#define PC7 21 +#define PB5 22 +#define PB3 23 +#define PA4 PIN_A13 +#define PB4 25 +#define PB6 26 +#define PB2 27 +#define PD13 28 +#define PD12 29 +#define PD11 30 +#define PE2 31 +#define PA0 PIN_A14 +#define PB0 PIN_A23 // LED_GREEN +#define PE0 34 +#define PB11 35 +#define PB10 36 +#define PE15 37 +#define PE14 38 +#define PE12 39 +#define PE10 40 +#define PE7 41 +#define PE8 42 +#define PC8 43 +#define PC9 44 +#define PC10 45 +#define PC11 46 +#define PC12 47 +#define PD2 48 +#define PG2 49 +#define PG3 50 +#define PD7 51 +#define PD6 52 +#define PD5 53 +#define PD4 54 +#define PD3 55 +// 56 is PE2 (31) +#define PE4 57 +#define PE5 58 +#define PE6 59 +#define PE3 60 +#define PF8 PIN_A15 +#define PF7 PIN_A16 +#define PF9 PIN_A17 +#define PG1 64 +#define PG0 65 +#define PD1 66 +#define PD0 67 +#define PF0 68 +#define PF1 69 +#define PF2 70 +// 71 is PA7 (11) +// 72 is NC +#define PB7 73 // LED_BLUE +#define PB14 74 // LED_RED +#define PC13 75 // USER_BTN +#define PD9 76 // Serial Rx +#define PD8 77 // Serial Tx +#define PA3 PIN_A0 +#define PC0 PIN_A1 +#define PC3 PIN_A2 +#define PF3 PIN_A3 +#define PF5 PIN_A4 +#define PF10 PIN_A5 +#define PB1 PIN_A6 +#define PC2 PIN_A7 +#define PF4 PIN_A8 +#define PF6 PIN_A9 +// ST Morpho +#define PA1 PIN_A18 +#define PA2 PIN_A19 +#define PA8 90 +#define PA9 91 +#define PA10 92 +#define PA11 93 +#define PA12 94 +#define PA13 95 // SWD +#define PA14 96 // SWD +#define PC1 PIN_A20 +#define PC4 PIN_A21 +#define PC5 PIN_A22 +#define PC14 100 +#define PC15 101 +#define PD10 102 +#define PE1 103 +#define PF11 104 +#define PG4 105 +#define PG5 106 +#define PG6 107 +#define PG7 108 +#define PG8 109 +#define PG10 110 +#define PG11 111 +#define PG12 112 +#define PG13 113 +#define PG15 114 +#define PH0 115 // MCO +#define PH1 116 + +// Alternate pins number +#define PA0_ALT1 (PA0 | ALT1) +#define PA0_ALT2 (PA0 | ALT2) +#define PA1_ALT1 (PA1 | ALT1) +#define PA1_ALT2 (PA1 | ALT2) +#define PA2_ALT1 (PA2 | ALT1) +#define PA2_ALT2 (PA2 | ALT2) +#define PA3_ALT1 (PA3 | ALT1) +#define PA3_ALT2 (PA3 | ALT2) +#define PA4_ALT1 (PA4 | ALT1) +#define PA5_ALT1 (PA5 | ALT1) +#define PA6_ALT1 (PA6 | ALT1) +#define PA7_ALT1 (PA7 | ALT1) +#define PA7_ALT2 (PA7 | ALT2) +#define PA7_ALT3 (PA7 | ALT3) +#define PA15_ALT1 (PA15 | ALT1) +#define PB0_ALT1 (PB0 | ALT1) +#define PB0_ALT2 (PB0 | ALT2) +#define PB1_ALT1 (PB1 | ALT1) +#define PB1_ALT2 (PB1 | ALT2) +#define PB3_ALT1 (PB3 | ALT1) +#define PB4_ALT1 (PB4 | ALT1) +#define PB5_ALT1 (PB5 | ALT1) +#define PB8_ALT1 (PB8 | ALT1) +#define PB9_ALT1 (PB9 | ALT1) +#define PB14_ALT1 (PB14 | ALT1) +#define PB14_ALT2 (PB14 | ALT2) +#define PB15_ALT1 (PB15 | ALT1) +#define PB15_ALT2 (PB15 | ALT2) +#define PC0_ALT1 (PC0 | ALT1) +#define PC0_ALT2 (PC0 | ALT2) +#define PC1_ALT1 (PC1 | ALT1) +#define PC1_ALT2 (PC1 | ALT2) +#define PC2_ALT1 (PC2 | ALT1) +#define PC2_ALT2 (PC2 | ALT2) +#define PC3_ALT1 (PC3 | ALT1) +#define PC3_ALT2 (PC3 | ALT2) +#define PC4_ALT1 (PC4 | ALT1) +#define PC5_ALT1 (PC5 | ALT1) +#define PC6_ALT1 (PC6 | ALT1) +#define PC7_ALT1 (PC7 | ALT1) +#define PC8_ALT1 (PC8 | ALT1) +#define PC9_ALT1 (PC9 | ALT1) +#define PC10_ALT1 (PC10 | ALT1) +#define PC11_ALT1 (PC11 | ALT1) + +// This must be a literal +#define NUM_DIGITAL_PINS 117 +// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 24 + +// On-board LED pin number +#ifndef LED_BUILTIN + #define LED_BUILTIN PB0 +#endif +#define LED_GREEN LED_BUILTIN +#define LED_BLUE PB7 +#define LED_RED PB14 + +// On-board user button +#ifndef USER_BTN + #define USER_BTN PC13 +#endif + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifndef TIMER_TONE + #define TIMER_TONE TIM6 +#endif +#ifndef TIMER_SERVO + #define TIMER_SERVO TIM7 +#endif + +// UART Definitions +#ifndef SERIAL_UART_INSTANCE + #define SERIAL_UART_INSTANCE 3 //Connected to ST-Link +#endif +// Serial pin used for console (ex: stlink) +// Rerquired by Firmata +#ifndef PIN_SERIAL_RX + #define PIN_SERIAL_RX PD9 +#endif +#ifndef PIN_SERIAL_TX + #define PIN_SERIAL_TX PD8 +#endif + +// Value of the External oscillator in Hz +#define HSE_VALUE 8000000U + +/* Extra HAL modules */ +#if !defined(HAL_DAC_MODULE_DISABLED) + #define HAL_DAC_MODULE_ENABLED +#endif +#if !defined(HAL_ETH_MODULE_DISABLED) + #define HAL_ETH_MODULE_ENABLED +#endif +#if !defined(HAL_QSPI_MODULE_DISABLED) + #define HAL_QSPI_MODULE_ENABLED +#endif +#if !defined(HAL_SD_MODULE_DISABLED) + #define HAL_SD_MODULE_ENABLED +#endif + +// Last Flash sector used for EEPROM emulation, address/sector depends on single/dual bank configuration. +// By default 2MB single bank +#define FLASH_BASE_ADDRESS 0x081C0000 +#define FLASH_DATA_SECTOR 11 + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + // These serial port names are intended to allow libraries and architecture-neutral + // sketches to automatically default to the correct port name for a particular type + // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, + // the first hardware serial port whose RX/TX pins are not dedicated to another use. + // + // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor + // + // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial + // + // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library + // + // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. + // + // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX + // pins are NOT connected to anything by default. + #ifndef SERIAL_PORT_MONITOR + #define SERIAL_PORT_MONITOR Serial + #endif + #ifndef SERIAL_PORT_HARDWARE + // KH mod to add Serial1, for ESP-AT + //#define SERIAL_PORT_HARDWARE Serial + #define SERIAL_PORT_HARDWARE Serial1 + #endif +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.1.0/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/variant_generic.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.1.0/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/variant_generic.h new file mode 100644 index 0000000..43ba241 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.1.0/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/variant_generic.h @@ -0,0 +1,173 @@ +/* + ******************************************************************************* + * Copyright (c) 2020-2021, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* + */ +#pragma once + +/*---------------------------------------------------------------------------- + * STM32 pins number + *----------------------------------------------------------------------------*/ +#define PA0 PIN_A0 +#define PA1 PIN_A1 +#define PA2 PIN_A2 +#define PA3 PIN_A3 +#define PA4 PIN_A4 +#define PA5 PIN_A5 +#define PA6 PIN_A6 +#define PA7 PIN_A7 +#define PA8 8 +#define PA9 9 +#define PA10 10 +#define PA11 11 +#define PA12 12 +#define PA13 13 +#define PA14 14 +#define PA15 15 +#define PB0 PIN_A8 +#define PB1 PIN_A9 +#define PB2 18 +#define PB3 19 +#define PB4 20 +#define PB5 21 +#define PB6 22 +#define PB7 23 +#define PB8 24 +#define PB9 25 +#define PB10 26 +#define PB11 27 +#define PB12 28 +#define PB13 29 +#define PB14 30 +#define PB15 31 +#define PC0 PIN_A10 +#define PC1 PIN_A11 +#define PC2 PIN_A12 +#define PC4 PIN_A13 +#define PC5 PIN_A14 +#define PC6 37 +#define PC7 38 +#define PC8 39 +#define PC9 40 +#define PC10 41 +#define PC11 42 +#define PC12 43 +#define PC13 44 +#define PC14 45 +#define PC15 46 +#define PD2 47 +#define PH0 48 +#define PH1 49 + +// Alternate pins number +#define PA2_ALT1 (PA2 | ALT1) +#define PA3_ALT1 (PA3 | ALT1) + +#define NUM_DIGITAL_PINS 50 +#define NUM_ANALOG_INPUTS 15 + +// On-board LED pin number +#ifndef LED_BUILTIN + #define LED_BUILTIN PNUM_NOT_DEFINED +#endif + +// On-board user button +#ifndef USER_BTN + #define USER_BTN PNUM_NOT_DEFINED +#endif + +// SPI definitions +#ifndef PIN_SPI_SS + #define PIN_SPI_SS PA4 +#endif +#ifndef PIN_SPI_SS1 + #define PIN_SPI_SS1 PA15 +#endif +#ifndef PIN_SPI_SS2 + #define PIN_SPI_SS2 PNUM_NOT_DEFINED +#endif +#ifndef PIN_SPI_SS3 + #define PIN_SPI_SS3 PNUM_NOT_DEFINED +#endif +#ifndef PIN_SPI_MOSI + #define PIN_SPI_MOSI PA7 +#endif +#ifndef PIN_SPI_MISO + #define PIN_SPI_MISO PA6 +#endif +#ifndef PIN_SPI_SCK + #define PIN_SPI_SCK PA5 +#endif + +// I2C definitions +#ifndef PIN_WIRE_SDA + #define PIN_WIRE_SDA PB7 +#endif +#ifndef PIN_WIRE_SCL + #define PIN_WIRE_SCL PB6 +#endif + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifndef TIMER_TONE + #define TIMER_TONE TIM6 +#endif +#ifndef TIMER_SERVO + #define TIMER_SERVO TIM21 +#endif + +// UART Definitions +#ifndef SERIAL_UART_INSTANCE + #define SERIAL_UART_INSTANCE 2 +#endif + +// Default pin used for generic 'Serial' instance +// Mandatory for Firmata +#ifndef PIN_SERIAL_RX + #define PIN_SERIAL_RX PA3 +#endif +#ifndef PIN_SERIAL_TX + #define PIN_SERIAL_TX PA2 +#endif + +// Extra HAL modules +#if !defined(HAL_DAC_MODULE_DISABLED) + #define HAL_DAC_MODULE_ENABLED +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + // These serial port names are intended to allow libraries and architecture-neutral + // sketches to automatically default to the correct port name for a particular type + // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, + // the first hardware serial port whose RX/TX pins are not dedicated to another use. + // + // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor + // + // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial + // + // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library + // + // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. + // + // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX + // pins are NOT connected to anything by default. + #ifndef SERIAL_PORT_MONITOR + #define SERIAL_PORT_MONITOR Serial + #endif + #ifndef SERIAL_PORT_HARDWARE + // KH mod to add Serial1, for ESP-AT + //#define SERIAL_PORT_HARDWARE Serial + #define SERIAL_PORT_HARDWARE Serial1 + #endif +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.2.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.2.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h new file mode 100644 index 0000000..ec7da13 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.2.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h @@ -0,0 +1,519 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf_default.h + * @brief HAL default configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_DEFAULT_H +#define __STM32F4xx_HAL_CONF_DEFAULT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief Include the default list of modules to be used in the HAL driver + * and manage module deactivation + */ +#include "stm32yyxx_hal_conf.h" +#if 0 +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +#define HAL_CAN_MODULE_ENABLED +/*#define HAL_CAN_LEGACY_MODULE_ENABLED*/ +#define HAL_CRC_MODULE_ENABLED +#define HAL_CEC_MODULE_ENABLED +#define HAL_CRYP_MODULE_ENABLED +#define HAL_DAC_MODULE_ENABLED +#define HAL_DCMI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_DMA2D_MODULE_ENABLED +#define HAL_ETH_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_NAND_MODULE_ENABLED +#define HAL_NOR_MODULE_ENABLED +#define HAL_PCCARD_MODULE_ENABLED +#define HAL_SRAM_MODULE_ENABLED +#define HAL_SDRAM_MODULE_ENABLED +#define HAL_HASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_SMBUS_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +#define HAL_IWDG_MODULE_ENABLED +#define HAL_LTDC_MODULE_ENABLED +#define HAL_DSI_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_QSPI_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_RNG_MODULE_ENABLED +#define HAL_RTC_MODULE_ENABLED +#define HAL_SAI_MODULE_ENABLED +#define HAL_SD_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +#define HAL_IRDA_MODULE_ENABLED +#define HAL_SMARTCARD_MODULE_ENABLED +#define HAL_WWDG_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_PCD_MODULE_ENABLED +#define HAL_HCD_MODULE_ENABLED +#define HAL_FMPI2C_MODULE_ENABLED +#define HAL_FMPSMBUS_MODULE_ENABLED +#define HAL_SPDIFRX_MODULE_ENABLED +#define HAL_DFSDM_MODULE_ENABLED +#define HAL_LPTIM_MODULE_ENABLED +#define HAL_MMC_MODULE_ENABLED +#endif + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) +#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) +#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) +#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz */ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) +#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz +The real value may vary depending on the variations +in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) +#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) +#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) +#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#if !defined (VDD_VALUE) +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#endif +#if !defined (TICK_INT_PRIORITY) +#define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */ +#endif +#if !defined (USE_RTOS) +#define USE_RTOS 0U +#endif +#if !defined (PREFETCH_ENABLE) +#define PREFETCH_ENABLE 1U +#endif +#if !defined (INSTRUCTION_CACHE_ENABLE) +#define INSTRUCTION_CACHE_ENABLE 1U +#endif +#if !defined (DATA_CACHE_ENABLE) +#define DATA_CACHE_ENABLE 1U +#endif + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_FMPSMBUS_REGISTER_CALLBACKS 0U /* FMPSMBUS register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB (5U) /* 5 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB (5U) /* 5 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ +/* LAN8742A PHY Address*/ +//////////////////////////////// +//#define LAN8742A_PHY_ADDRESS 0x00U +/* Section 2: PHY configuration section */ +#if !defined (LAN8742A_PHY_ADDRESS) + /* KH, LAN8742A PHY Address*/ + #define LAN8742A_PHY_ADDRESS 0x00U +#endif +//////////////////////////////// +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x000000FFU +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY 0x00000FFFU + +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ + +#define PHY_SR ((uint16_t)0x1F) /*!< PHY special control/ status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0004) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0010) /*!< PHY Duplex mask */ + + +#define PHY_ISFR ((uint16_t)0x1D) /*!< PHY Interrupt Source Flag register Offset */ +#define PHY_IMR ((uint16_t)0x1E) /*!< PHY Interrupt Mask register Offset */ +#define PHY_ISFR_INT4 ((uint16_t)0x0010) /*!< PHY Link down inturrupt */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ +#if !defined (USE_SPI_CRC) +#define USE_SPI_CRC 0U +#endif + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED +#include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED +#include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED +#include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED +#include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED +#include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED +#include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED +#include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED +#include "stm32f4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED +#include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED +#include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED +#include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED +#include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED +#include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED +#include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED +#include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED +#include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED +#include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED +#include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED +#include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED +#include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED +#include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED +#include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED +#include "stm32f4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED +#include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED +#include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED +#include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED +#include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED +#include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED +#include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED +#include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED +#include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED +#include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED +#include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED +#include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED +#include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED +#include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED +#include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED +#include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED +#include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED +#include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED +#include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED +#include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED +#include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED +#include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_FMPSMBUS_MODULE_ENABLED +#include "stm32f4xx_hal_fmpsmbus.h" +#endif /* HAL_FMPSMBUS_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED +#include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED +#include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED +#include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else +#define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_DEFAULT_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.2.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.2.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h new file mode 100644 index 0000000..3bcd06c --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.2.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h @@ -0,0 +1,511 @@ +/** + ****************************************************************************** + * @file stm32f7xx_hal_conf_default.h + * @brief HAL default configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F7xx_HAL_CONF_DEFAULT_H +#define __STM32F7xx_HAL_CONF_DEFAULT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief Include the default list of modules to be used in the HAL driver + * and manage module deactivation + */ +#include "stm32yyxx_hal_conf.h" +#if 0 +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +#define HAL_CAN_MODULE_ENABLED +#define HAL_CAN_LEGACY_MODULE_ENABLED +#define HAL_CEC_MODULE_ENABLED +#define HAL_CRC_MODULE_ENABLED +#define HAL_CRYP_MODULE_ENABLED +#define HAL_DAC_MODULE_ENABLED +#define HAL_DCMI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_DMA2D_MODULE_ENABLED +#define HAL_ETH_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_NAND_MODULE_ENABLED +#define HAL_NOR_MODULE_ENABLED +#define HAL_SRAM_MODULE_ENABLED +#define HAL_SDRAM_MODULE_ENABLED +#define HAL_HASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +#define HAL_IWDG_MODULE_ENABLED +#define HAL_LPTIM_MODULE_ENABLED +#define HAL_LTDC_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_QSPI_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_RNG_MODULE_ENABLED +#define HAL_RTC_MODULE_ENABLED +#define HAL_SAI_MODULE_ENABLED +#define HAL_SD_MODULE_ENABLED +#define HAL_SPDIFRX_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +#define HAL_IRDA_MODULE_ENABLED +#define HAL_SMARTCARD_MODULE_ENABLED +#define HAL_WWDG_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_PCD_MODULE_ENABLED +#define HAL_HCD_MODULE_ENABLED +#define HAL_DFSDM_MODULE_ENABLED +#define HAL_DSI_MODULE_ENABLED +#define HAL_JPEG_MODULE_ENABLED +#define HAL_MDIOS_MODULE_ENABLED +#define HAL_SMBUS_MODULE_ENABLED +#define HAL_MMC_MODULE_ENABLED +#endif + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) +#define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) +#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) +#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) +#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz +The real value may vary depending on the variations +in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) +#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) +#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) +#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#if !defined (VDD_VALUE) +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#endif +#if !defined (TICK_INT_PRIORITY) +#define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */ +#endif +#if !defined (USE_RTOS) +#define USE_RTOS 0U +#endif +#if !defined (PREFETCH_ENABLE) +#define PREFETCH_ENABLE 1U /* To enable prefetch */ +#endif +#if !defined (ART_ACCLERATOR_ENABLE) +#define ART_ACCLERATOR_ENABLE 1U /* To enable ART Accelerator */ +#endif + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIOS register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1 */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ +/* LAN8742A PHY Address*/ +//////////////////////////////// +//#define LAN8742A_PHY_ADDRESS 0x00U +/* Section 2: PHY configuration section */ +#if !defined (LAN8742A_PHY_ADDRESS) + /* KH, LAN8742A PHY Address*/ + #define LAN8742A_PHY_ADDRESS 0x00U +#endif +//////////////////////////////// +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x00000FFFU +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY 0x00000FFFU + +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x00U) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x01U) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ + +#define PHY_SR ((uint16_t)0x1FU) /*!< PHY special control/ status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0004U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0010U) /*!< PHY Duplex mask */ + + +#define PHY_ISFR ((uint16_t)0x01DU) /*!< PHY Interrupt Source Flag register Offset */ +#define PHY_IMR ((uint16_t)0x001E) /*!< PHY Interrupt Mask register Offset */ +#define PHY_ISFR_INT4 ((uint16_t)0x0010U) /*!< PHY Link down inturrupt */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ +#if !defined (USE_SPI_CRC) +#define USE_SPI_CRC 0U +#endif + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED +#include "stm32f7xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED +#include "stm32f7xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED +#include "stm32f7xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED +#include "stm32f7xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED +#include "stm32f7xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED +#include "stm32f7xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED +#include "stm32f7xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED +#include "stm32f7xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED +#include "stm32f7xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED +#include "stm32f7xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED +#include "stm32f7xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED +#include "stm32f7xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED +#include "stm32f7xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED +#include "stm32f7xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED +#include "stm32f7xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED +#include "stm32f7xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED +#include "stm32f7xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED +#include "stm32f7xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED +#include "stm32f7xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED +#include "stm32f7xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED +#include "stm32f7xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED +#include "stm32f7xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED +#include "stm32f7xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED +#include "stm32f7xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32f7xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED +#include "stm32f7xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED +#include "stm32f7xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED +#include "stm32f7xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED +#include "stm32f7xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED +#include "stm32f7xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED +#include "stm32f7xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED +#include "stm32f7xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED +#include "stm32f7xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED +#include "stm32f7xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED +#include "stm32f7xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED +#include "stm32f7xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED +#include "stm32f7xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED +#include "stm32f7xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED +#include "stm32f7xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED +#include "stm32f7xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED +#include "stm32f7xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED +#include "stm32f7xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED +#include "stm32f7xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED +#include "stm32f7xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_JPEG_MODULE_ENABLED +#include "stm32f7xx_hal_jpeg.h" +#endif /* HAL_JPEG_MODULE_ENABLED */ + +#ifdef HAL_MDIOS_MODULE_ENABLED +#include "stm32f7xx_hal_mdios.h" +#endif /* HAL_MDIOS_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED +#include "stm32f7xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED +#include "stm32f7xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else +#define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F7xx_HAL_CONF_DEFAULT_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.2.0/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/variant_NUCLEO_F767ZI.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.2.0/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/variant_NUCLEO_F767ZI.h new file mode 100644 index 0000000..e8eaf79 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.2.0/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/variant_NUCLEO_F767ZI.h @@ -0,0 +1,274 @@ +/* + ******************************************************************************* + * Copyright (c) 2020-2021, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* +*/ +#pragma once + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +#define PG9 0 +#define PG14 1 +#define PF15 2 +#define PE13 3 +#define PF14 4 +#define PE11 5 +#define PE9 6 +#define PF13 7 +#define PF12 8 +#define PD15 9 +#define PD14 10 +#define PA7 PIN_A10 +#define PA6 PIN_A11 +#define PA5 PIN_A12 +#define PB9 14 +#define PB8 15 +#define PC6 16 +#define PB15 17 +#define PB13 18 +#define PB12 19 +#define PA15 20 +#define PC7 21 +#define PB5 22 +#define PB3 23 +#define PA4 PIN_A13 +#define PB4 25 +#define PB6 26 +#define PB2 27 +#define PD13 28 +#define PD12 29 +#define PD11 30 +#define PE2 31 +#define PA0 PIN_A14 +#define PB0 PIN_A23 // LED_GREEN +#define PE0 34 +#define PB11 35 +#define PB10 36 +#define PE15 37 +#define PE14 38 +#define PE12 39 +#define PE10 40 +#define PE7 41 +#define PE8 42 +#define PC8 43 +#define PC9 44 +#define PC10 45 +#define PC11 46 +#define PC12 47 +#define PD2 48 +#define PG2 49 +#define PG3 50 +#define PD7 51 +#define PD6 52 +#define PD5 53 +#define PD4 54 +#define PD3 55 +// 56 is PE2 (31) +#define PE4 57 +#define PE5 58 +#define PE6 59 +#define PE3 60 +#define PF8 PIN_A15 +#define PF7 PIN_A16 +#define PF9 PIN_A17 +#define PG1 64 +#define PG0 65 +#define PD1 66 +#define PD0 67 +#define PF0 68 +#define PF1 69 +#define PF2 70 +// 71 is PA7 (11) +// 72 is NC +#define PB7 73 // LED_BLUE +#define PB14 74 // LED_RED +#define PC13 75 // USER_BTN +#define PD9 76 // Serial Rx +#define PD8 77 // Serial Tx +#define PA3 PIN_A0 +#define PC0 PIN_A1 +#define PC3 PIN_A2 +#define PF3 PIN_A3 +#define PF5 PIN_A4 +#define PF10 PIN_A5 +#define PB1 PIN_A6 +#define PC2 PIN_A7 +#define PF4 PIN_A8 +#define PF6 PIN_A9 +// ST Morpho +#define PA1 PIN_A18 +#define PA2 PIN_A19 +#define PA8 90 +#define PA9 91 +#define PA10 92 +#define PA11 93 +#define PA12 94 +#define PA13 95 // SWD +#define PA14 96 // SWD +#define PC1 PIN_A20 +#define PC4 PIN_A21 +#define PC5 PIN_A22 +#define PC14 100 +#define PC15 101 +#define PD10 102 +#define PE1 103 +#define PF11 104 +#define PG4 105 +#define PG5 106 +#define PG6 107 +#define PG7 108 +#define PG8 109 +#define PG10 110 +#define PG11 111 +#define PG12 112 +#define PG13 113 +#define PG15 114 +#define PH0 115 // MCO +#define PH1 116 + +// Alternate pins number +#define PA0_ALT1 (PA0 | ALT1) +#define PA0_ALT2 (PA0 | ALT2) +#define PA1_ALT1 (PA1 | ALT1) +#define PA1_ALT2 (PA1 | ALT2) +#define PA2_ALT1 (PA2 | ALT1) +#define PA2_ALT2 (PA2 | ALT2) +#define PA3_ALT1 (PA3 | ALT1) +#define PA3_ALT2 (PA3 | ALT2) +#define PA4_ALT1 (PA4 | ALT1) +#define PA5_ALT1 (PA5 | ALT1) +#define PA6_ALT1 (PA6 | ALT1) +#define PA7_ALT1 (PA7 | ALT1) +#define PA7_ALT2 (PA7 | ALT2) +#define PA7_ALT3 (PA7 | ALT3) +#define PA15_ALT1 (PA15 | ALT1) +#define PB0_ALT1 (PB0 | ALT1) +#define PB0_ALT2 (PB0 | ALT2) +#define PB1_ALT1 (PB1 | ALT1) +#define PB1_ALT2 (PB1 | ALT2) +#define PB3_ALT1 (PB3 | ALT1) +#define PB4_ALT1 (PB4 | ALT1) +#define PB5_ALT1 (PB5 | ALT1) +#define PB8_ALT1 (PB8 | ALT1) +#define PB9_ALT1 (PB9 | ALT1) +#define PB14_ALT1 (PB14 | ALT1) +#define PB14_ALT2 (PB14 | ALT2) +#define PB15_ALT1 (PB15 | ALT1) +#define PB15_ALT2 (PB15 | ALT2) +#define PC0_ALT1 (PC0 | ALT1) +#define PC0_ALT2 (PC0 | ALT2) +#define PC1_ALT1 (PC1 | ALT1) +#define PC1_ALT2 (PC1 | ALT2) +#define PC2_ALT1 (PC2 | ALT1) +#define PC2_ALT2 (PC2 | ALT2) +#define PC3_ALT1 (PC3 | ALT1) +#define PC3_ALT2 (PC3 | ALT2) +#define PC4_ALT1 (PC4 | ALT1) +#define PC5_ALT1 (PC5 | ALT1) +#define PC6_ALT1 (PC6 | ALT1) +#define PC7_ALT1 (PC7 | ALT1) +#define PC8_ALT1 (PC8 | ALT1) +#define PC9_ALT1 (PC9 | ALT1) +#define PC10_ALT1 (PC10 | ALT1) +#define PC11_ALT1 (PC11 | ALT1) + +// This must be a literal +#define NUM_DIGITAL_PINS 117 +// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 24 + +// On-board LED pin number +#ifndef LED_BUILTIN + #define LED_BUILTIN PB0 +#endif +#define LED_GREEN LED_BUILTIN +#define LED_BLUE PB7 +#define LED_RED PB14 + +// On-board user button +#ifndef USER_BTN + #define USER_BTN PC13 +#endif + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifndef TIMER_TONE + #define TIMER_TONE TIM6 +#endif +#ifndef TIMER_SERVO + #define TIMER_SERVO TIM7 +#endif + +// UART Definitions +#ifndef SERIAL_UART_INSTANCE + #define SERIAL_UART_INSTANCE 3 //Connected to ST-Link +#endif +// Serial pin used for console (ex: stlink) +// Rerquired by Firmata +#ifndef PIN_SERIAL_RX + #define PIN_SERIAL_RX PD9 +#endif +#ifndef PIN_SERIAL_TX + #define PIN_SERIAL_TX PD8 +#endif + +// Value of the External oscillator in Hz +#define HSE_VALUE 8000000U + +/* Extra HAL modules */ +#if !defined(HAL_DAC_MODULE_DISABLED) + #define HAL_DAC_MODULE_ENABLED +#endif +#if !defined(HAL_ETH_MODULE_DISABLED) + #define HAL_ETH_MODULE_ENABLED +#endif +#if !defined(HAL_QSPI_MODULE_DISABLED) + #define HAL_QSPI_MODULE_ENABLED +#endif +#if !defined(HAL_SD_MODULE_DISABLED) + #define HAL_SD_MODULE_ENABLED +#endif + +// Last Flash sector used for EEPROM emulation, address/sector depends on single/dual bank configuration. +// By default 2MB single bank +#define FLASH_BASE_ADDRESS 0x081C0000 +#define FLASH_DATA_SECTOR 11 + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + // These serial port names are intended to allow libraries and architecture-neutral + // sketches to automatically default to the correct port name for a particular type + // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, + // the first hardware serial port whose RX/TX pins are not dedicated to another use. + // + // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor + // + // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial + // + // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library + // + // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. + // + // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX + // pins are NOT connected to anything by default. + #ifndef SERIAL_PORT_MONITOR + #define SERIAL_PORT_MONITOR Serial + #endif + #ifndef SERIAL_PORT_HARDWARE + // KH mod to add Serial1, for ESP-AT + //#define SERIAL_PORT_HARDWARE Serial + #define SERIAL_PORT_HARDWARE Serial1 + #endif +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.2.0/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/variant_generic.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.2.0/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/variant_generic.h new file mode 100644 index 0000000..43ba241 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/STM32/hardware/stm32/2.2.0/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/variant_generic.h @@ -0,0 +1,173 @@ +/* + ******************************************************************************* + * Copyright (c) 2020-2021, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* + */ +#pragma once + +/*---------------------------------------------------------------------------- + * STM32 pins number + *----------------------------------------------------------------------------*/ +#define PA0 PIN_A0 +#define PA1 PIN_A1 +#define PA2 PIN_A2 +#define PA3 PIN_A3 +#define PA4 PIN_A4 +#define PA5 PIN_A5 +#define PA6 PIN_A6 +#define PA7 PIN_A7 +#define PA8 8 +#define PA9 9 +#define PA10 10 +#define PA11 11 +#define PA12 12 +#define PA13 13 +#define PA14 14 +#define PA15 15 +#define PB0 PIN_A8 +#define PB1 PIN_A9 +#define PB2 18 +#define PB3 19 +#define PB4 20 +#define PB5 21 +#define PB6 22 +#define PB7 23 +#define PB8 24 +#define PB9 25 +#define PB10 26 +#define PB11 27 +#define PB12 28 +#define PB13 29 +#define PB14 30 +#define PB15 31 +#define PC0 PIN_A10 +#define PC1 PIN_A11 +#define PC2 PIN_A12 +#define PC4 PIN_A13 +#define PC5 PIN_A14 +#define PC6 37 +#define PC7 38 +#define PC8 39 +#define PC9 40 +#define PC10 41 +#define PC11 42 +#define PC12 43 +#define PC13 44 +#define PC14 45 +#define PC15 46 +#define PD2 47 +#define PH0 48 +#define PH1 49 + +// Alternate pins number +#define PA2_ALT1 (PA2 | ALT1) +#define PA3_ALT1 (PA3 | ALT1) + +#define NUM_DIGITAL_PINS 50 +#define NUM_ANALOG_INPUTS 15 + +// On-board LED pin number +#ifndef LED_BUILTIN + #define LED_BUILTIN PNUM_NOT_DEFINED +#endif + +// On-board user button +#ifndef USER_BTN + #define USER_BTN PNUM_NOT_DEFINED +#endif + +// SPI definitions +#ifndef PIN_SPI_SS + #define PIN_SPI_SS PA4 +#endif +#ifndef PIN_SPI_SS1 + #define PIN_SPI_SS1 PA15 +#endif +#ifndef PIN_SPI_SS2 + #define PIN_SPI_SS2 PNUM_NOT_DEFINED +#endif +#ifndef PIN_SPI_SS3 + #define PIN_SPI_SS3 PNUM_NOT_DEFINED +#endif +#ifndef PIN_SPI_MOSI + #define PIN_SPI_MOSI PA7 +#endif +#ifndef PIN_SPI_MISO + #define PIN_SPI_MISO PA6 +#endif +#ifndef PIN_SPI_SCK + #define PIN_SPI_SCK PA5 +#endif + +// I2C definitions +#ifndef PIN_WIRE_SDA + #define PIN_WIRE_SDA PB7 +#endif +#ifndef PIN_WIRE_SCL + #define PIN_WIRE_SCL PB6 +#endif + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifndef TIMER_TONE + #define TIMER_TONE TIM6 +#endif +#ifndef TIMER_SERVO + #define TIMER_SERVO TIM21 +#endif + +// UART Definitions +#ifndef SERIAL_UART_INSTANCE + #define SERIAL_UART_INSTANCE 2 +#endif + +// Default pin used for generic 'Serial' instance +// Mandatory for Firmata +#ifndef PIN_SERIAL_RX + #define PIN_SERIAL_RX PA3 +#endif +#ifndef PIN_SERIAL_TX + #define PIN_SERIAL_TX PA2 +#endif + +// Extra HAL modules +#if !defined(HAL_DAC_MODULE_DISABLED) + #define HAL_DAC_MODULE_ENABLED +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + // These serial port names are intended to allow libraries and architecture-neutral + // sketches to automatically default to the correct port name for a particular type + // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, + // the first hardware serial port whose RX/TX pins are not dedicated to another use. + // + // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor + // + // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial + // + // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library + // + // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. + // + // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX + // pins are NOT connected to anything by default. + #ifndef SERIAL_PORT_MONITOR + #define SERIAL_PORT_MONITOR Serial + #endif + #ifndef SERIAL_PORT_HARDWARE + // KH mod to add Serial1, for ESP-AT + //#define SERIAL_PORT_HARDWARE Serial + #define SERIAL_PORT_HARDWARE Serial1 + #endif +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/rp2040/1.9.3/variants/rpipico/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/rp2040/1.9.3/variants/rpipico/pins_arduino.h new file mode 100644 index 0000000..603700f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/rp2040/1.9.3/variants/rpipico/pins_arduino.h @@ -0,0 +1,81 @@ +#pragma once + +// Pin definitions taken from: +// https://datasheets.raspberrypi.org/pico/pico-datasheet.pdf + +//KH +// Pin count +// ---- +#define PINS_COUNT (30u) +#define NUM_DIGITAL_PINS (30u) +#define NUM_ANALOG_INPUTS (4u) +#define NUM_ANALOG_OUTPUTS (0u) +////// + +// LEDs +#define PIN_LED (25u) +#define PIN_LED_0 (16u) +#define PIN_LED_1 (17u) +#define PIN_LED_2 (18u) +// Serial +#define PIN_SERIAL1_TX (0u) +#define PIN_SERIAL1_RX (1u) + +#define PIN_SERIAL2_TX (31u) +#define PIN_SERIAL2_RX (31u) + + +// SPI +#define PIN_SPI0_MISO (4u) +#define PIN_SPI0_MOSI (3u) +#define PIN_SPI0_SCK (2u) +#define PIN_SPI0_SS (5u) + +// static const int SS = PIN_SPI0_SS; // SPI Slave SS not used. Set here only for reference. +// static const int MOSI = PIN_SPI0_MOSI; +// static const int MISO = PIN_SPI0_MISO; +// static const int SCK = PIN_SPI0_SCK; + +#define PIN_SPI1_MISO (12u) +#define PIN_SPI1_MOSI (31u) +#define PIN_SPI1_SCK (31u) +#define PIN_SPI1_SS (31u) +// static const int MISO_1 = PIN_SPI1_MISO; + +#define PIN_A0 (26u) +#define PIN_A1 (27u) +#define PIN_A2 (28u) +#define PIN_A3 (29u) + +static const int A0 = PIN_A0; +static const int A1 = PIN_A1; +static const int A2 = PIN_A2; +static const int A3 = PIN_A3; + +// D0 - D10 +#define D26 (26u) +#define D1 (27u) +#define D2 (28u) +#define D3 (29u) +#define D4 (6u) +#define D5 (7u) +#define D0 (0u) +#define D7 (1u) +#define D8 (2u) +#define D9 (4u) +#define D10 (3u) + +// static const int 0 = D0; + +// Wire +#define PIN_WIRE0_SDA (6u) +#define PIN_WIRE0_SCL (7u) + +#define PIN_WIRE1_SDA (26u) +#define PIN_WIRE1_SCL (27u) + +// #define SERIAL_HOWMANY (3u) +// #define SPI_HOWMANY (2u) +// #define WIRE_HOWMANY (2u) + +// #include "../generic/common.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/rp2040/2.7.2/boards.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/rp2040/2.7.2/boards.txt new file mode 100644 index 0000000..6ac0f09 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/rp2040/2.7.2/boards.txt @@ -0,0 +1,84 @@ +menu.split=Flash split +Seeed_XIAO_RP2040.name=SEEED XIAO RP2040 +Seeed_XIAO_RP2040.build.core=arduino +Seeed_XIAO_RP2040.build.crossprefix=arm-none-eabi- +Seeed_XIAO_RP2040.build.compiler_path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ + +# KH fix for Linux case-sensitive path +#Seeed_XIAO_RP2040.build.variant=SEEED_XIAO_RP2040 +Seeed_XIAO_RP2040.build.variant=Seeed_XIAO_RP2040 +###### + +Seeed_XIAO_RP2040.build.mcu=cortex-m0plus +Seeed_XIAO_RP2040.build.extra_flags= +Seeed_XIAO_RP2040.build.fpu= +Seeed_XIAO_RP2040.build.float-abi= +Seeed_XIAO_RP2040.build.architecture=cortex-m0plus +Seeed_XIAO_RP2040.build.board=SEEED_XIAO_RP2040 +Seeed_XIAO_RP2040.build.ldscript=linker_script.ld +Seeed_XIAO_RP2040.compiler.mbed.arch.define=-DARDUINO_ARCH_RP2040 +Seeed_XIAO_RP2040.compiler.mbed.defines={build.variant.path}/defines.txt +Seeed_XIAO_RP2040.compiler.mbed.ldflags={build.variant.path}/ldflags.txt +Seeed_XIAO_RP2040.compiler.mbed.cflags={build.variant.path}/cflags.txt +Seeed_XIAO_RP2040.compiler.mbed.cxxflags={build.variant.path}/cxxflags.txt +Seeed_XIAO_RP2040.compiler.mbed.includes={build.variant.path}/includes.txt +Seeed_XIAO_RP2040.compiler.mbed.extra_ldflags=-lstdc++ -lsupc++ -lm -lc -lgcc -lnosys +Seeed_XIAO_RP2040.compiler.mbed="{build.variant.path}/libs/libmbed.a" +Seeed_XIAO_RP2040.vid.0=0x2886 +Seeed_XIAO_RP2040.pid.0=0x8042 +Seeed_XIAO_RP2040.upload_port.0.vid=0x2886 +Seeed_XIAO_RP2040.upload_port.0.pid=0x8042 +Seeed_XIAO_RP2040.upload.tool=picotool +Seeed_XIAO_RP2040.upload.tool.default=picotool +Seeed_XIAO_RP2040.upload.protocol= +Seeed_XIAO_RP2040.upload.transport= +Seeed_XIAO_RP2040.upload.use_1200bps_touch=true +Seeed_XIAO_RP2040.upload.wait_for_upload_port=false +Seeed_XIAO_RP2040.upload.native_usb=true +Seeed_XIAO_RP2040.upload.maximum_size=16777216 +Seeed_XIAO_RP2040.upload.maximum_data_size=270336 +Seeed_XIAO_RP2040.bootloader.tool=openocd +Seeed_XIAO_RP2040.bootloader.tool.default=openocd +Seeed_XIAO_RP2040.bootloader.config=-f target/rp2040.cfg +Seeed_XIAO_RP2040.bootloader.programmer=-f interface/cmsis-dap.cfg + +############################################################## + +menu.split=Flash split +WIO_RP2040_MINI_DEV_BOARD.name=Wio RP2040 Mini Dev Board +WIO_RP2040_MINI_DEV_BOARD.build.core=arduino +WIO_RP2040_MINI_DEV_BOARD.build.crossprefix=arm-none-eabi- +WIO_RP2040_MINI_DEV_BOARD.build.compiler_path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +WIO_RP2040_MINI_DEV_BOARD.build.variant=WIO_RP2040_MINI_DEV_BOARD +WIO_RP2040_MINI_DEV_BOARD.build.mcu=cortex-m0plus +WIO_RP2040_MINI_DEV_BOARD.build.extra_flags= +WIO_RP2040_MINI_DEV_BOARD.build.fpu= +WIO_RP2040_MINI_DEV_BOARD.build.float-abi= +WIO_RP2040_MINI_DEV_BOARD.build.architecture=cortex-m0plus +WIO_RP2040_MINI_DEV_BOARD.build.board=WIO_RP2040_MINI_DEV_BOARD +WIO_RP2040_MINI_DEV_BOARD.build.ldscript=linker_script.ld +WIO_RP2040_MINI_DEV_BOARD.compiler.mbed.arch.define=-DARDUINO_ARCH_RP2040 +WIO_RP2040_MINI_DEV_BOARD.compiler.mbed.defines={build.variant.path}/defines.txt +WIO_RP2040_MINI_DEV_BOARD.compiler.mbed.ldflags={build.variant.path}/ldflags.txt +WIO_RP2040_MINI_DEV_BOARD.compiler.mbed.cflags={build.variant.path}/cflags.txt +WIO_RP2040_MINI_DEV_BOARD.compiler.mbed.cxxflags={build.variant.path}/cxxflags.txt +WIO_RP2040_MINI_DEV_BOARD.compiler.mbed.includes={build.variant.path}/includes.txt +WIO_RP2040_MINI_DEV_BOARD.compiler.mbed.extra_ldflags=-lstdc++ -lsupc++ -lm -lc -lgcc -lnosys +WIO_RP2040_MINI_DEV_BOARD.compiler.mbed="{build.variant.path}/libs/libmbed.a" +WIO_RP2040_MINI_DEV_BOARD.vid.0=0x2886 +WIO_RP2040_MINI_DEV_BOARD.pid.0=0x8043 +WIO_RP2040_MINI_DEV_BOARD.upload_port.0.vid=0x2886 +WIO_RP2040_MINI_DEV_BOARD.upload_port.0.pid=0x8043 +WIO_RP2040_MINI_DEV_BOARD.upload.tool=picotool +WIO_RP2040_MINI_DEV_BOARD.upload.tool.default=picotool +WIO_RP2040_MINI_DEV_BOARD.upload.protocol= +WIO_RP2040_MINI_DEV_BOARD.upload.transport= +WIO_RP2040_MINI_DEV_BOARD.upload.use_1200bps_touch=true +WIO_RP2040_MINI_DEV_BOARD.upload.wait_for_upload_port=false +WIO_RP2040_MINI_DEV_BOARD.upload.native_usb=true +WIO_RP2040_MINI_DEV_BOARD.upload.maximum_size=16777216 +WIO_RP2040_MINI_DEV_BOARD.upload.maximum_data_size=270336 +WIO_RP2040_MINI_DEV_BOARD.bootloader.tool=openocd +WIO_RP2040_MINI_DEV_BOARD.bootloader.tool.default=openocd +WIO_RP2040_MINI_DEV_BOARD.bootloader.config=-f target/rp2040.cfg +WIO_RP2040_MINI_DEV_BOARD.bootloader.programmer=-f interface/cmsis-dap.cfg diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/rp2040/2.7.2/variants/Seeed_XIAO_RP2040/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/rp2040/2.7.2/variants/Seeed_XIAO_RP2040/pins_arduino.h new file mode 100644 index 0000000..d51c54c --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/rp2040/2.7.2/variants/Seeed_XIAO_RP2040/pins_arduino.h @@ -0,0 +1,123 @@ +#pragma once +#include +#include + +#ifndef __PINS_ARDUINO__ +#define __PINS_ARDUINO__ + +#ifdef __cplusplus +extern "C" unsigned int PINCOUNT_fn(); +#endif + +// Pin count +// ---- +#define PINS_COUNT (PINCOUNT_fn()) +#define NUM_DIGITAL_PINS (30u) +#define NUM_ANALOG_INPUTS (4u) +#define NUM_ANALOG_OUTPUTS (0u) + +extern PinName digitalPinToPinName(pin_size_t P); + +// LEDs +// ---- +#define PIN_LED (25u) +#define LED_BUILTIN PIN_LED + +// Digital pins +// ---- +#define PIN_D0 (26u) +#define PIN_D1 (27u) +#define PIN_D2 (28u) +#define PIN_D3 (29u) +#define PIN_D4 (6u) +#define PIN_D5 (7u) +#define PIN_D6 (0u) +#define PIN_D7 (1u) +#define PIN_D8 (2u) +#define PIN_D9 (4u) +#define PIN_D10 (3u) + +static const uint8_t D0 = PIN_D0; +static const uint8_t D1 = PIN_D1; +static const uint8_t D2 = PIN_D2; +static const uint8_t D3 = PIN_D3; +static const uint8_t D4 = PIN_D4; +static const uint8_t D5 = PIN_D5; +static const uint8_t D6 = PIN_D6; +static const uint8_t D7 = PIN_D7; +static const uint8_t D8 = PIN_D8; +static const uint8_t D9 = PIN_D9; +static const uint8_t D10 = PIN_D10; + + +// Analog pins +// ----------- +#define PIN_A0 (26u) +#define PIN_A1 (27u) +#define PIN_A2 (28u) +#define PIN_A3 (29u) + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; +static const uint8_t A3 = PIN_A3; + +#define ADC_RESOLUTION 12 + +// Serial +#define PIN_SERIAL_TX (0ul) +#define PIN_SERIAL_RX (1ul) + +// SPI +//#define PIN_SPI_MISO (16u) +//#define PIN_SPI_MOSI (19u) +//#define PIN_SPI_SCK (18u) +//#define PIN_SPI_SS (17u) +// KH fix wrong pin +#define PIN_SPI_MISO (D9) +#define PIN_SPI_MOSI (D10) +#define PIN_SPI_SCK (D8) +#define PIN_SPI_SS (D7) +////// + +static const uint8_t SS = PIN_SPI_SS; // SPI Slave SS not used. Set here only for reference. +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +// Wire +#define SDA (6u) +#define SCL (7u) + +#define SERIAL_HOWMANY 1 +#define SERIAL1_TX (digitalPinToPinName(PIN_SERIAL_TX)) +#define SERIAL1_RX (digitalPinToPinName(PIN_SERIAL_RX)) + +#define SERIAL_CDC 1 +#define HAS_UNIQUE_ISERIAL_DESCRIPTOR +#define BOARD_VENDORID 0x2886 +#define BOARD_PRODUCTID 0x8042 +#define BOARD_NAME "RaspberryPi Pico" + +uint8_t getUniqueSerialNumber(uint8_t* name); +void _ontouch1200bps_(); + +#define SPI_HOWMANY (1) +#define SPI_MISO (digitalPinToPinName(PIN_SPI_MISO)) +#define SPI_MOSI (digitalPinToPinName(PIN_SPI_MOSI)) +#define SPI_SCK (digitalPinToPinName(PIN_SPI_SCK)) + +#define WIRE_HOWMANY (1) +#define I2C_SDA (digitalPinToPinName(SDA)) +#define I2C_SCL (digitalPinToPinName(SCL)) + +#define digitalPinToPort(P) (digitalPinToPinName(P)/32) + +#define SERIAL_PORT_USBVIRTUAL SerialUSB +#define SERIAL_PORT_MONITOR SerialUSB +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 + +#define USB_MAX_POWER (500) + +#endif //__PINS_ARDUINO__ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.7/cores/arduino/Arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.7/cores/arduino/Arduino.h new file mode 100644 index 0000000..ca6ec0d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.7/cores/arduino/Arduino.h @@ -0,0 +1,181 @@ +/* + Arduino.h - Main include file for the Arduino SDK + Copyright (c) 2014 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef Arduino_h +#define Arduino_h + +#include +#include +#include +#include +#include + +#define CORE_HAS_LIBB64 + +typedef bool boolean; +typedef uint8_t byte; +typedef uint16_t word; + +// some libraries and sketches depend on this AVR stuff, +// assuming Arduino.h or WProgram.h automatically includes it... +// +#include "avr/pgmspace.h" +#include "avr/interrupt.h" +#include "avr/dtostrf.h" +#include "avr/io.h" + +#include "binary.h" +#include "itoa.h" + +#ifdef __cplusplus +extern "C"{ +#endif // __cplusplus + +// Include Atmel headers +#include "sam.h" + +#include "wiring_constants.h" + +#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L ) +#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) ) +#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) ) + +void yield( void ) ; + +/* system functions */ +int main( void ); +void init( void ); + +/* sketch */ +void setup( void ) ; +void loop( void ) ; + +int __debug_buf(const char* head, char* buf, int len); + +#include "WVariant.h" + +#ifdef __cplusplus +} // extern "C" +#endif + +// The following headers are for C++ only compilation +#ifdef __cplusplus + #include "WCharacter.h" + #include "WString.h" + #include "Tone.h" + #include "WMath.h" + #include "HardwareSerial.h" + #include "pulse.h" +#endif +#include "delay.h" +#ifdef __cplusplus + #include "Uart.h" +#endif + +// Include board variant +#include "variant.h" + +#include "wiring.h" +#include "wiring_digital.h" +#include "wiring_analog.h" +#include "wiring_shift.h" +#include "wiring_pwm.h" +#include "WInterrupts.h" + +// undefine stdlib's abs if encountered +#ifdef abs +#undef abs +#endif // abs +// undefine stdlib's abs if encountered +#ifdef abs +#undef abs +#endif // abs + +#ifdef __cplusplus + template + auto min(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (b < a) ? b : a; + } + + template + auto max(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (a < b) ? b : a; + } +#else +#ifndef min +#define min(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a < _b ? _a : _b; }) +#endif +#ifndef max +#define max(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a > _b ? _a : _b; }) +#endif +#endif + +#define abs(x) ((x)>0?(x):-(x)) +#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) +#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) +#define radians(deg) ((deg)*DEG_TO_RAD) +#define degrees(rad) ((rad)*RAD_TO_DEG) +#define sq(x) ((x)*(x)) + +#define interrupts() __enable_irq() +#define noInterrupts() __disable_irq() +#ifndef interruptsStatus +static inline unsigned char __interruptsStatus(void) __attribute__((always_inline, unused)); +static inline unsigned char __interruptsStatus(void) +{ + // See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0497a/CHDBIBGJ.html + return (__get_PRIMASK() ? 0 : 1); +} +#define interruptsStatus() __interruptsStatus() +#endif + +#define lowByte(w) ((uint8_t) ((w) & 0xff)) +#define highByte(w) ((uint8_t) ((w) >> 8)) + +#define bitRead(value, bit) (((value) >> (bit)) & 0x01) +#define bitSet(value, bit) ((value) |= (1UL << (bit))) +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) +#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) + +#define bit(b) (1UL << (b)) + +#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606) +// Interrupts +#define digitalPinToInterrupt(P) ( P ) +#endif + +// USB +#ifdef USE_TINYUSB +#include "Adafruit_TinyUSB_Core.h" +#else +#include "USB/USBDesc.h" +#include "USB/USBCore.h" +#include "USB/USBAPI.h" +#include "USB/USB_host.h" +#endif + +#endif // Arduino_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.7/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.7/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.7/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.7/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.7/cores/arduino/Print.h new file mode 100644 index 0000000..48353c4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.7/cores/arduino/Print.h @@ -0,0 +1,108 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t +#include // for printf + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.7/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.7/platform.txt new file mode 100644 index 0000000..7b6c33c --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.7/platform.txt @@ -0,0 +1,234 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Seeed SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.7.7 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++14 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -u _printf_float -u _scanf_float -Wl,--wrap,_write -u __wrap__write +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.project_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.1.path}/CMSIS-Atmel/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {build.project_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {build.project_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.8/cores/arduino/Arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.8/cores/arduino/Arduino.h new file mode 100644 index 0000000..ca6ec0d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.8/cores/arduino/Arduino.h @@ -0,0 +1,181 @@ +/* + Arduino.h - Main include file for the Arduino SDK + Copyright (c) 2014 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef Arduino_h +#define Arduino_h + +#include +#include +#include +#include +#include + +#define CORE_HAS_LIBB64 + +typedef bool boolean; +typedef uint8_t byte; +typedef uint16_t word; + +// some libraries and sketches depend on this AVR stuff, +// assuming Arduino.h or WProgram.h automatically includes it... +// +#include "avr/pgmspace.h" +#include "avr/interrupt.h" +#include "avr/dtostrf.h" +#include "avr/io.h" + +#include "binary.h" +#include "itoa.h" + +#ifdef __cplusplus +extern "C"{ +#endif // __cplusplus + +// Include Atmel headers +#include "sam.h" + +#include "wiring_constants.h" + +#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L ) +#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) ) +#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) ) + +void yield( void ) ; + +/* system functions */ +int main( void ); +void init( void ); + +/* sketch */ +void setup( void ) ; +void loop( void ) ; + +int __debug_buf(const char* head, char* buf, int len); + +#include "WVariant.h" + +#ifdef __cplusplus +} // extern "C" +#endif + +// The following headers are for C++ only compilation +#ifdef __cplusplus + #include "WCharacter.h" + #include "WString.h" + #include "Tone.h" + #include "WMath.h" + #include "HardwareSerial.h" + #include "pulse.h" +#endif +#include "delay.h" +#ifdef __cplusplus + #include "Uart.h" +#endif + +// Include board variant +#include "variant.h" + +#include "wiring.h" +#include "wiring_digital.h" +#include "wiring_analog.h" +#include "wiring_shift.h" +#include "wiring_pwm.h" +#include "WInterrupts.h" + +// undefine stdlib's abs if encountered +#ifdef abs +#undef abs +#endif // abs +// undefine stdlib's abs if encountered +#ifdef abs +#undef abs +#endif // abs + +#ifdef __cplusplus + template + auto min(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (b < a) ? b : a; + } + + template + auto max(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (a < b) ? b : a; + } +#else +#ifndef min +#define min(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a < _b ? _a : _b; }) +#endif +#ifndef max +#define max(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a > _b ? _a : _b; }) +#endif +#endif + +#define abs(x) ((x)>0?(x):-(x)) +#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) +#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) +#define radians(deg) ((deg)*DEG_TO_RAD) +#define degrees(rad) ((rad)*RAD_TO_DEG) +#define sq(x) ((x)*(x)) + +#define interrupts() __enable_irq() +#define noInterrupts() __disable_irq() +#ifndef interruptsStatus +static inline unsigned char __interruptsStatus(void) __attribute__((always_inline, unused)); +static inline unsigned char __interruptsStatus(void) +{ + // See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0497a/CHDBIBGJ.html + return (__get_PRIMASK() ? 0 : 1); +} +#define interruptsStatus() __interruptsStatus() +#endif + +#define lowByte(w) ((uint8_t) ((w) & 0xff)) +#define highByte(w) ((uint8_t) ((w) >> 8)) + +#define bitRead(value, bit) (((value) >> (bit)) & 0x01) +#define bitSet(value, bit) ((value) |= (1UL << (bit))) +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) +#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) + +#define bit(b) (1UL << (b)) + +#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606) +// Interrupts +#define digitalPinToInterrupt(P) ( P ) +#endif + +// USB +#ifdef USE_TINYUSB +#include "Adafruit_TinyUSB_Core.h" +#else +#include "USB/USBDesc.h" +#include "USB/USBCore.h" +#include "USB/USBAPI.h" +#include "USB/USB_host.h" +#endif + +#endif // Arduino_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.8/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.8/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.8/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.8/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.8/cores/arduino/Print.h new file mode 100644 index 0000000..48353c4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.8/cores/arduino/Print.h @@ -0,0 +1,108 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t +#include // for printf + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.8/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.8/platform.txt new file mode 100644 index 0000000..0ca1ffd --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.8/platform.txt @@ -0,0 +1,230 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Seeed SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.7.8 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++14 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -u _printf_float -u _scanf_float -Wl,--wrap,_write -u __wrap__write +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.project_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.1.path}/CMSIS-Atmel/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" +##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {build.project_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" +##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {build.project_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" +##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.9/cores/arduino/Arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.9/cores/arduino/Arduino.h new file mode 100644 index 0000000..ca6ec0d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.9/cores/arduino/Arduino.h @@ -0,0 +1,181 @@ +/* + Arduino.h - Main include file for the Arduino SDK + Copyright (c) 2014 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef Arduino_h +#define Arduino_h + +#include +#include +#include +#include +#include + +#define CORE_HAS_LIBB64 + +typedef bool boolean; +typedef uint8_t byte; +typedef uint16_t word; + +// some libraries and sketches depend on this AVR stuff, +// assuming Arduino.h or WProgram.h automatically includes it... +// +#include "avr/pgmspace.h" +#include "avr/interrupt.h" +#include "avr/dtostrf.h" +#include "avr/io.h" + +#include "binary.h" +#include "itoa.h" + +#ifdef __cplusplus +extern "C"{ +#endif // __cplusplus + +// Include Atmel headers +#include "sam.h" + +#include "wiring_constants.h" + +#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L ) +#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) ) +#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) ) + +void yield( void ) ; + +/* system functions */ +int main( void ); +void init( void ); + +/* sketch */ +void setup( void ) ; +void loop( void ) ; + +int __debug_buf(const char* head, char* buf, int len); + +#include "WVariant.h" + +#ifdef __cplusplus +} // extern "C" +#endif + +// The following headers are for C++ only compilation +#ifdef __cplusplus + #include "WCharacter.h" + #include "WString.h" + #include "Tone.h" + #include "WMath.h" + #include "HardwareSerial.h" + #include "pulse.h" +#endif +#include "delay.h" +#ifdef __cplusplus + #include "Uart.h" +#endif + +// Include board variant +#include "variant.h" + +#include "wiring.h" +#include "wiring_digital.h" +#include "wiring_analog.h" +#include "wiring_shift.h" +#include "wiring_pwm.h" +#include "WInterrupts.h" + +// undefine stdlib's abs if encountered +#ifdef abs +#undef abs +#endif // abs +// undefine stdlib's abs if encountered +#ifdef abs +#undef abs +#endif // abs + +#ifdef __cplusplus + template + auto min(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (b < a) ? b : a; + } + + template + auto max(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (a < b) ? b : a; + } +#else +#ifndef min +#define min(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a < _b ? _a : _b; }) +#endif +#ifndef max +#define max(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a > _b ? _a : _b; }) +#endif +#endif + +#define abs(x) ((x)>0?(x):-(x)) +#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) +#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) +#define radians(deg) ((deg)*DEG_TO_RAD) +#define degrees(rad) ((rad)*RAD_TO_DEG) +#define sq(x) ((x)*(x)) + +#define interrupts() __enable_irq() +#define noInterrupts() __disable_irq() +#ifndef interruptsStatus +static inline unsigned char __interruptsStatus(void) __attribute__((always_inline, unused)); +static inline unsigned char __interruptsStatus(void) +{ + // See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0497a/CHDBIBGJ.html + return (__get_PRIMASK() ? 0 : 1); +} +#define interruptsStatus() __interruptsStatus() +#endif + +#define lowByte(w) ((uint8_t) ((w) & 0xff)) +#define highByte(w) ((uint8_t) ((w) >> 8)) + +#define bitRead(value, bit) (((value) >> (bit)) & 0x01) +#define bitSet(value, bit) ((value) |= (1UL << (bit))) +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) +#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) + +#define bit(b) (1UL << (b)) + +#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606) +// Interrupts +#define digitalPinToInterrupt(P) ( P ) +#endif + +// USB +#ifdef USE_TINYUSB +#include "Adafruit_TinyUSB_Core.h" +#else +#include "USB/USBDesc.h" +#include "USB/USBCore.h" +#include "USB/USBAPI.h" +#include "USB/USB_host.h" +#endif + +#endif // Arduino_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.9/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.9/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.9/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.9/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.9/cores/arduino/Print.h new file mode 100644 index 0000000..48353c4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.9/cores/arduino/Print.h @@ -0,0 +1,108 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t +#include // for printf + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.9/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.9/platform.txt new file mode 100644 index 0000000..986663b --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.7.9/platform.txt @@ -0,0 +1,227 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Seeed SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.7.9 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++14 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -u _printf_float -u _scanf_float -Wl,--wrap,_write -u __wrap__write +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.project_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.1.path}/CMSIS-Atmel/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {build.project_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.1/cores/arduino/Arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.1/cores/arduino/Arduino.h new file mode 100644 index 0000000..ca6ec0d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.1/cores/arduino/Arduino.h @@ -0,0 +1,181 @@ +/* + Arduino.h - Main include file for the Arduino SDK + Copyright (c) 2014 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef Arduino_h +#define Arduino_h + +#include +#include +#include +#include +#include + +#define CORE_HAS_LIBB64 + +typedef bool boolean; +typedef uint8_t byte; +typedef uint16_t word; + +// some libraries and sketches depend on this AVR stuff, +// assuming Arduino.h or WProgram.h automatically includes it... +// +#include "avr/pgmspace.h" +#include "avr/interrupt.h" +#include "avr/dtostrf.h" +#include "avr/io.h" + +#include "binary.h" +#include "itoa.h" + +#ifdef __cplusplus +extern "C"{ +#endif // __cplusplus + +// Include Atmel headers +#include "sam.h" + +#include "wiring_constants.h" + +#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L ) +#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) ) +#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) ) + +void yield( void ) ; + +/* system functions */ +int main( void ); +void init( void ); + +/* sketch */ +void setup( void ) ; +void loop( void ) ; + +int __debug_buf(const char* head, char* buf, int len); + +#include "WVariant.h" + +#ifdef __cplusplus +} // extern "C" +#endif + +// The following headers are for C++ only compilation +#ifdef __cplusplus + #include "WCharacter.h" + #include "WString.h" + #include "Tone.h" + #include "WMath.h" + #include "HardwareSerial.h" + #include "pulse.h" +#endif +#include "delay.h" +#ifdef __cplusplus + #include "Uart.h" +#endif + +// Include board variant +#include "variant.h" + +#include "wiring.h" +#include "wiring_digital.h" +#include "wiring_analog.h" +#include "wiring_shift.h" +#include "wiring_pwm.h" +#include "WInterrupts.h" + +// undefine stdlib's abs if encountered +#ifdef abs +#undef abs +#endif // abs +// undefine stdlib's abs if encountered +#ifdef abs +#undef abs +#endif // abs + +#ifdef __cplusplus + template + auto min(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (b < a) ? b : a; + } + + template + auto max(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (a < b) ? b : a; + } +#else +#ifndef min +#define min(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a < _b ? _a : _b; }) +#endif +#ifndef max +#define max(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a > _b ? _a : _b; }) +#endif +#endif + +#define abs(x) ((x)>0?(x):-(x)) +#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) +#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) +#define radians(deg) ((deg)*DEG_TO_RAD) +#define degrees(rad) ((rad)*RAD_TO_DEG) +#define sq(x) ((x)*(x)) + +#define interrupts() __enable_irq() +#define noInterrupts() __disable_irq() +#ifndef interruptsStatus +static inline unsigned char __interruptsStatus(void) __attribute__((always_inline, unused)); +static inline unsigned char __interruptsStatus(void) +{ + // See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0497a/CHDBIBGJ.html + return (__get_PRIMASK() ? 0 : 1); +} +#define interruptsStatus() __interruptsStatus() +#endif + +#define lowByte(w) ((uint8_t) ((w) & 0xff)) +#define highByte(w) ((uint8_t) ((w) >> 8)) + +#define bitRead(value, bit) (((value) >> (bit)) & 0x01) +#define bitSet(value, bit) ((value) |= (1UL << (bit))) +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) +#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) + +#define bit(b) (1UL << (b)) + +#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606) +// Interrupts +#define digitalPinToInterrupt(P) ( P ) +#endif + +// USB +#ifdef USE_TINYUSB +#include "Adafruit_TinyUSB_Core.h" +#else +#include "USB/USBDesc.h" +#include "USB/USBCore.h" +#include "USB/USBAPI.h" +#include "USB/USB_host.h" +#endif + +#endif // Arduino_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.1/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.1/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.1/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.1/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.1/cores/arduino/Print.h new file mode 100644 index 0000000..48353c4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.1/cores/arduino/Print.h @@ -0,0 +1,108 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t +#include // for printf + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.1/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.1/platform.txt new file mode 100644 index 0000000..b215d74 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.1/platform.txt @@ -0,0 +1,204 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Seeed SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.8.1 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++14 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -u _printf_float -u _scanf_float -Wl,--wrap,_write -u __wrap__write +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.project_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= +build.flags.txrxled= +build.flags.role= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.1.path}/CMSIS-Atmel/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} {build.flags.role} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.txrxled} {build.flags.role} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.txrxled} {build.flags.role} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {build.project_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b +# v1.8.0 +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b +# +# OpenOCD sketch upload +# +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.2/cores/arduino/Arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.2/cores/arduino/Arduino.h new file mode 100644 index 0000000..ca6ec0d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.2/cores/arduino/Arduino.h @@ -0,0 +1,181 @@ +/* + Arduino.h - Main include file for the Arduino SDK + Copyright (c) 2014 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef Arduino_h +#define Arduino_h + +#include +#include +#include +#include +#include + +#define CORE_HAS_LIBB64 + +typedef bool boolean; +typedef uint8_t byte; +typedef uint16_t word; + +// some libraries and sketches depend on this AVR stuff, +// assuming Arduino.h or WProgram.h automatically includes it... +// +#include "avr/pgmspace.h" +#include "avr/interrupt.h" +#include "avr/dtostrf.h" +#include "avr/io.h" + +#include "binary.h" +#include "itoa.h" + +#ifdef __cplusplus +extern "C"{ +#endif // __cplusplus + +// Include Atmel headers +#include "sam.h" + +#include "wiring_constants.h" + +#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L ) +#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) ) +#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) ) + +void yield( void ) ; + +/* system functions */ +int main( void ); +void init( void ); + +/* sketch */ +void setup( void ) ; +void loop( void ) ; + +int __debug_buf(const char* head, char* buf, int len); + +#include "WVariant.h" + +#ifdef __cplusplus +} // extern "C" +#endif + +// The following headers are for C++ only compilation +#ifdef __cplusplus + #include "WCharacter.h" + #include "WString.h" + #include "Tone.h" + #include "WMath.h" + #include "HardwareSerial.h" + #include "pulse.h" +#endif +#include "delay.h" +#ifdef __cplusplus + #include "Uart.h" +#endif + +// Include board variant +#include "variant.h" + +#include "wiring.h" +#include "wiring_digital.h" +#include "wiring_analog.h" +#include "wiring_shift.h" +#include "wiring_pwm.h" +#include "WInterrupts.h" + +// undefine stdlib's abs if encountered +#ifdef abs +#undef abs +#endif // abs +// undefine stdlib's abs if encountered +#ifdef abs +#undef abs +#endif // abs + +#ifdef __cplusplus + template + auto min(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (b < a) ? b : a; + } + + template + auto max(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (a < b) ? b : a; + } +#else +#ifndef min +#define min(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a < _b ? _a : _b; }) +#endif +#ifndef max +#define max(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a > _b ? _a : _b; }) +#endif +#endif + +#define abs(x) ((x)>0?(x):-(x)) +#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) +#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) +#define radians(deg) ((deg)*DEG_TO_RAD) +#define degrees(rad) ((rad)*RAD_TO_DEG) +#define sq(x) ((x)*(x)) + +#define interrupts() __enable_irq() +#define noInterrupts() __disable_irq() +#ifndef interruptsStatus +static inline unsigned char __interruptsStatus(void) __attribute__((always_inline, unused)); +static inline unsigned char __interruptsStatus(void) +{ + // See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0497a/CHDBIBGJ.html + return (__get_PRIMASK() ? 0 : 1); +} +#define interruptsStatus() __interruptsStatus() +#endif + +#define lowByte(w) ((uint8_t) ((w) & 0xff)) +#define highByte(w) ((uint8_t) ((w) >> 8)) + +#define bitRead(value, bit) (((value) >> (bit)) & 0x01) +#define bitSet(value, bit) ((value) |= (1UL << (bit))) +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) +#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) + +#define bit(b) (1UL << (b)) + +#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606) +// Interrupts +#define digitalPinToInterrupt(P) ( P ) +#endif + +// USB +#ifdef USE_TINYUSB +#include "Adafruit_TinyUSB_Core.h" +#else +#include "USB/USBDesc.h" +#include "USB/USBCore.h" +#include "USB/USBAPI.h" +#include "USB/USB_host.h" +#endif + +#endif // Arduino_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.2/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.2/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.2/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.2/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.2/cores/arduino/Print.h new file mode 100644 index 0000000..48353c4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.2/cores/arduino/Print.h @@ -0,0 +1,108 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t +#include // for printf + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.2/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.2/platform.txt new file mode 100644 index 0000000..2cbc192 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/Seeeduino/hardware/samd/1.8.2/platform.txt @@ -0,0 +1,204 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Seeed SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.8.2 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++14 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -u _printf_float -u _scanf_float -Wl,--wrap,_write -u __wrap__write +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.project_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= +build.flags.role= +build.flags.txrxled= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.7.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.7.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.1.path}/CMSIS-Atmel/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.7.0.path}/CMSIS/DSP/Lib/GCC/" -larm_cortexM0l_math -lm + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} {build.flags.role} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.txrxled} {build.flags.role} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.txrxled} {build.flags.role} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {build.project_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b +# v1.8.0 +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b +# +# OpenOCD sketch upload +# +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/SparkFun/hardware/samd/1.8.3/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/SparkFun/hardware/samd/1.8.3/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/SparkFun/hardware/samd/1.8.3/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/SparkFun/hardware/samd/1.8.3/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/SparkFun/hardware/samd/1.8.3/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/SparkFun/hardware/samd/1.8.3/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/SparkFun/hardware/samd/1.8.3/cores/arduino51/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/SparkFun/hardware/samd/1.8.3/cores/arduino51/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/SparkFun/hardware/samd/1.8.3/cores/arduino51/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/SparkFun/hardware/samd/1.8.3/cores/arduino51/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/SparkFun/hardware/samd/1.8.3/cores/arduino51/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/SparkFun/hardware/samd/1.8.3/cores/arduino51/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/boards.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/boards.txt new file mode 100644 index 0000000..bbe9f9e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/boards.txt @@ -0,0 +1,649 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +menu.softdevice=Bootloader +menu.debug=Debug + +# ---------------------------------- +# Bluefruit Feather nRF52832 +# ---------------------------------- +feather52832.name=Adafruit Feather nRF52832 +feather52832.bootloader.tool=bootburn + +# Upload +feather52832.upload.tool=nrfutil +feather52832.upload.protocol=nrfutil +feather52832.upload.use_1200bps_touch=false +feather52832.upload.wait_for_upload_port=false +feather52832.upload.native_usb=false +feather52832.upload.maximum_size=290816 +feather52832.upload.maximum_data_size=52224 + +# Build +feather52832.build.mcu=cortex-m4 +feather52832.build.f_cpu=64000000 +feather52832.build.board=NRF52832_FEATHER +feather52832.build.core=nRF5 +feather52832.build.variant=feather_nrf52832 +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52832" +feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52832_FEATHER -DNRF52 +feather52832.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +feather52832.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_name=s132 +feather52832.menu.softdevice.s132v6.build.sd_version=6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +feather52832.menu.debug.l0=Level 0 (Release) +feather52832.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52832.menu.debug.l1=Level 1 (Error Message) +feather52832.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52832.menu.debug.l2=Level 2 (Full Debug) +feather52832.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52832.menu.debug.l3=Level 3 (Segger SystemView) +feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52832.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Bluefruit Feather nRF52840 Express +# ---------------------------------- +feather52840.name=Adafruit Feather nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840.vid.0=0x239A +feather52840.pid.0=0x8029 +feather52840.vid.1=0x239A +feather52840.pid.1=0x0029 +feather52840.vid.2=0x239A +feather52840.pid.2=0x002A +feather52840.vid.3=0x239A +feather52840.pid.3=0x802A + +# Upload +feather52840.bootloader.tool=bootburn +feather52840.upload.tool=nrfutil +feather52840.upload.protocol=nrfutil +feather52840.upload.use_1200bps_touch=true +feather52840.upload.wait_for_upload_port=true +feather52840.upload.maximum_size=815104 +feather52840.upload.maximum_data_size=237568 + +# Build +feather52840.build.mcu=cortex-m4 +feather52840.build.f_cpu=64000000 +feather52840.build.board=NRF52840_FEATHER +feather52840.build.core=nRF5 +feather52840.build.variant=feather_nrf52840_express +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52840 Express" +feather52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_FEATHER {build.flags.usb} +feather52840.build.ldscript=nrf52840_s140_v6.ld +feather52840.build.vid=0x239A +feather52840.build.pid=0x8029 + +# SofDevice Menu +feather52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_name=s140 +feather52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840.menu.debug.l0=Level 0 (Release) +feather52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840.menu.debug.l1=Level 1 (Error Message) +feather52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840.menu.debug.l2=Level 2 (Full Debug) +feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840.menu.debug.l3=Level 3 (Segger SystemView) +feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# ---------------------------------- +# Feather Bluefruit sense +# ---------------------------------- +feather52840sense.name=Adafruit Feather Bluefruit Sense + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840sense.vid.0=0x239A +feather52840sense.pid.0=0x8087 +feather52840sense.vid.1=0x239A +feather52840sense.pid.1=0x0087 +feather52840sense.vid.2=0x239A +feather52840sense.pid.2=0x0088 +feather52840sense.vid.3=0x239A +feather52840sense.pid.3=0x8088 + +# Upload +feather52840sense.bootloader.tool=bootburn +feather52840sense.upload.tool=nrfutil +feather52840sense.upload.protocol=nrfutil +feather52840sense.upload.use_1200bps_touch=true +feather52840sense.upload.wait_for_upload_port=true +feather52840sense.upload.maximum_size=815104 +feather52840sense.upload.maximum_data_size=237568 + +# Build +feather52840sense.build.mcu=cortex-m4 +feather52840sense.build.f_cpu=64000000 +feather52840sense.build.board=NRF52840_FEATHER_SENSE +feather52840sense.build.core=nRF5 +feather52840sense.build.variant=feather_nrf52840_sense +feather52840sense.build.usb_manufacturer="Adafruit LLC" +feather52840sense.build.usb_product="Feather nRF52840 Sense" +feather52840sense.build.extra_flags=-DNRF52840_XXAA -DNRF52840_FEATHER_SENSE {build.flags.usb} +feather52840sense.build.ldscript=nrf52840_s140_v6.ld +feather52840sense.build.vid=0x239A +feather52840sense.build.pid=0x8087 + +# SofDevice Menu +feather52840sense.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_name=s140 +feather52840sense.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840sense.menu.debug.l0=Level 0 (Release) +feather52840sense.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840sense.menu.debug.l1=Level 1 (Error Message) +feather52840sense.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840sense.menu.debug.l2=Level 2 (Full Debug) +feather52840sense.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840sense.menu.debug.l3=Level 3 (Segger SystemView) +feather52840sense.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840sense.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Bluefruit ItsyBitsy nRF52840 Express +# --------------------------------------------- +itsybitsy52840.name=Adafruit ItsyBitsy nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +itsybitsy52840.vid.0=0x239A +itsybitsy52840.pid.0=0x8051 +itsybitsy52840.vid.1=0x239A +itsybitsy52840.pid.1=0x0051 +itsybitsy52840.vid.2=0x239A +itsybitsy52840.pid.2=0x0052 +itsybitsy52840.vid.3=0x239A +itsybitsy52840.pid.3=0x8052 + +# Upload +itsybitsy52840.bootloader.tool=bootburn +itsybitsy52840.upload.tool=nrfutil +itsybitsy52840.upload.protocol=nrfutil +itsybitsy52840.upload.use_1200bps_touch=true +itsybitsy52840.upload.wait_for_upload_port=true +itsybitsy52840.upload.maximum_size=815104 +itsybitsy52840.upload.maximum_data_size=237568 + +# Build +itsybitsy52840.build.mcu=cortex-m4 +itsybitsy52840.build.f_cpu=64000000 +itsybitsy52840.build.board=NRF52840_ITSYBITSY +itsybitsy52840.build.core=nRF5 +itsybitsy52840.build.variant=itsybitsy_nrf52840_express +itsybitsy52840.build.usb_manufacturer="Adafruit LLC" +itsybitsy52840.build.usb_product="ItsyBitsy nRF52840 Express" +itsybitsy52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_ITSYBITSY -DARDUINO_NRF52_ITSYBITSY {build.flags.usb} +itsybitsy52840.build.ldscript=nrf52840_s140_v6.ld +itsybitsy52840.build.vid=0x239A +itsybitsy52840.build.pid=0x8051 + +# SofDevice Menu +itsybitsy52840.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_name=s140 +itsybitsy52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +itsybitsy52840.menu.debug.l0=Level 0 (Release) +itsybitsy52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +itsybitsy52840.menu.debug.l1=Level 1 (Error Message) +itsybitsy52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +itsybitsy52840.menu.debug.l2=Level 2 (Full Debug) +itsybitsy52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +itsybitsy52840.menu.debug.l3=Level 3 (Segger SystemView) +itsybitsy52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +itsybitsy52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# --------------------------------------------- +# Bluefruit Circuit Playground nRF52840 Express +# --------------------------------------------- +cplaynrf52840.name=Adafruit Circuit Playground Bluefruit + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cplaynrf52840.vid.0=0x239A +cplaynrf52840.pid.0=0x8045 +cplaynrf52840.vid.1=0x239A +cplaynrf52840.pid.1=0x0045 +cplaynrf52840.vid.2=0x239A +cplaynrf52840.pid.2=0x0046 +cplaynrf52840.vid.3=0x239A +cplaynrf52840.pid.3=0x8046 + +# Upload +cplaynrf52840.bootloader.tool=bootburn +cplaynrf52840.upload.tool=nrfutil +cplaynrf52840.upload.protocol=nrfutil +cplaynrf52840.upload.use_1200bps_touch=true +cplaynrf52840.upload.wait_for_upload_port=true +cplaynrf52840.upload.maximum_size=815104 +cplaynrf52840.upload.maximum_data_size=237568 + +# Build +cplaynrf52840.build.mcu=cortex-m4 +cplaynrf52840.build.f_cpu=64000000 +cplaynrf52840.build.board=NRF52840_CIRCUITPLAY +cplaynrf52840.build.core=nRF5 +cplaynrf52840.build.variant=circuitplayground_nrf52840 +cplaynrf52840.build.usb_manufacturer="Adafruit LLC" +cplaynrf52840.build.usb_product="Circuit Playground Bluefruit" +cplaynrf52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_CIRCUITPLAY {build.flags.usb} +cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld +cplaynrf52840.build.vid=0x239A +cplaynrf52840.build.pid=0x8045 + +# SofDevice Menu +cplaynrf52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cplaynrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cplaynrf52840.menu.debug.l0=Level 0 (Release) +cplaynrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cplaynrf52840.menu.debug.l1=Level 1 (Error Message) +cplaynrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cplaynrf52840.menu.debug.l2=Level 2 (Full Debug) +cplaynrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cplaynrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cplaynrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Clue nRF52840 +# --------------------------------------------- +cluenrf52840.name=Adafruit CLUE + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cluenrf52840.vid.0=0x239A +cluenrf52840.pid.0=0x8072 +cluenrf52840.vid.1=0x239A +cluenrf52840.pid.1=0x0072 +cluenrf52840.vid.2=0x239A +cluenrf52840.pid.2=0x0071 +cluenrf52840.vid.3=0x239A +cluenrf52840.pid.3=0x8071 + +# Upload +cluenrf52840.bootloader.tool=bootburn +cluenrf52840.upload.tool=nrfutil +cluenrf52840.upload.protocol=nrfutil +cluenrf52840.upload.use_1200bps_touch=true +cluenrf52840.upload.wait_for_upload_port=true +cluenrf52840.upload.maximum_size=815104 +cluenrf52840.upload.maximum_data_size=237568 + +# Build +cluenrf52840.build.mcu=cortex-m4 +cluenrf52840.build.f_cpu=64000000 +cluenrf52840.build.board=NRF52840_CLUE +cluenrf52840.build.core=nRF5 +cluenrf52840.build.variant=clue_nrf52840 +cluenrf52840.build.usb_manufacturer="Adafruit LLC" +cluenrf52840.build.usb_product="CLUE" +cluenrf52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_CLUE {build.flags.usb} +cluenrf52840.build.ldscript=nrf52840_s140_v6.ld +cluenrf52840.build.vid=0x239A +cluenrf52840.build.pid=0x8071 + +# SofDevice Menu +cluenrf52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cluenrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cluenrf52840.menu.debug.l0=Level 0 (Release) +cluenrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cluenrf52840.menu.debug.l1=Level 1 (Error Message) +cluenrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cluenrf52840.menu.debug.l2=Level 2 (Full Debug) +cluenrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cluenrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cluenrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cluenrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Bluefruit Metro nRF52840 Express +# ---------------------------------- +metro52840.name=Adafruit Bluefruit Metro nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +metro52840.vid.0=0x239A +metro52840.pid.0=0x803F +metro52840.vid.1=0x239A +metro52840.pid.1=0x003F +metro52840.vid.2=0x239A +metro52840.pid.2=0x0040 +metro52840.vid.3=0x239A +metro52840.pid.3=0x8040 + +# Upload +metro52840.bootloader.tool=bootburn +metro52840.upload.tool=nrfutil +metro52840.upload.protocol=nrfutil +metro52840.upload.use_1200bps_touch=true +metro52840.upload.wait_for_upload_port=true +metro52840.upload.maximum_size=815104 +metro52840.upload.maximum_data_size=237568 + +# Build +metro52840.build.mcu=cortex-m4 +metro52840.build.f_cpu=64000000 +metro52840.build.board=NRF52840_METRO +metro52840.build.core=nRF5 +metro52840.build.variant=metro_nrf52840_express +metro52840.build.usb_manufacturer="Adafruit LLC" +metro52840.build.usb_product="Metro nRF52840 Express" +metro52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_METRO {build.flags.usb} +metro52840.build.ldscript=nrf52840_s140_v6.ld +metro52840.build.vid=0x239A +metro52840.build.pid=0x803F + +# SofDevice Menu +metro52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_name=s140 +metro52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +metro52840.menu.debug.l0=Level 0 (Release) +metro52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +metro52840.menu.debug.l1=Level 1 (Error Message) +metro52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +metro52840.menu.debug.l2=Level 2 (Full Debug) +metro52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +metro52840.menu.debug.l3=Level 3 (Segger SystemView) +metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +metro52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + + + +# ------------------------------------------------------- +# +# Boards that aren't made by Adafruit +# +# ------------------------------------------------------- + + +# ---------------------------------- +# Nordic nRF52840DK (PCA10056) +# ---------------------------------- +pca10056.name=Nordic nRF52840DK (PCA10056) +pca10056.bootloader.tool=bootburn + +# Upload +pca10056.upload.tool=nrfutil +pca10056.upload.protocol=nrfutil +pca10056.upload.use_1200bps_touch=true +pca10056.upload.wait_for_upload_port=true +pca10056.upload.maximum_size=815104 +pca10056.upload.maximum_data_size=237568 + +# Build +pca10056.build.mcu=cortex-m4 +pca10056.build.f_cpu=64000000 +pca10056.build.board=NRF52840_PCA10056 +pca10056.build.core=nRF5 +pca10056.build.variant=pca10056 +pca10056.build.usb_manufacturer="Nordic" +pca10056.build.usb_product="nRF52840 DK" +pca10056.build.extra_flags=-DNRF52840_XXAA -DNRF52840_PCA10056 {build.flags.usb} +pca10056.build.ldscript=nrf52840_s140_v6.ld +pca10056.build.vid=0x239A +pca10056.build.pid=0x8029 + +# SofDevice Menu +pca10056.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_name=s140 +pca10056.menu.softdevice.s140v6.build.sd_version=6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +pca10056.menu.debug.l0=Level 0 (Release) +pca10056.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +pca10056.menu.debug.l1=Level 1 (Error Message) +pca10056.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +pca10056.menu.debug.l2=Level 2 (Full Debug) +pca10056.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +pca10056.menu.debug.l3=Level 3 (Segger SystemView) +pca10056.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +pca10056.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Particle Xenon +# ---------------------------------- +particle_xenon.name=Particle Xenon + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +particle_xenon.vid.0=0x239A +particle_xenon.pid.0=0x8029 +particle_xenon.vid.1=0x239A +particle_xenon.pid.1=0x0029 +particle_xenon.vid.2=0x239A +particle_xenon.pid.2=0x002A +particle_xenon.vid.3=0x239A +particle_xenon.pid.3=0x802A + +# Upload +particle_xenon.bootloader.tool=bootburn +particle_xenon.upload.tool=nrfutil +particle_xenon.upload.protocol=nrfutil +particle_xenon.upload.use_1200bps_touch=true +particle_xenon.upload.wait_for_upload_port=true +particle_xenon.upload.maximum_size=815104 +particle_xenon.upload.maximum_data_size=237568 + +# Build +particle_xenon.build.mcu=cortex-m4 +particle_xenon.build.f_cpu=64000000 +particle_xenon.build.board=PARTICLE_XENON +particle_xenon.build.core=nRF5 +particle_xenon.build.variant=particle_xenon +particle_xenon.build.usb_manufacturer="Particle Industries" +particle_xenon.build.usb_product="Particle Xenon" +particle_xenon.build.extra_flags=-DNRF52840_XXAA -DPARTICLE_XENON {build.flags.usb} +particle_xenon.build.ldscript=nrf52840_s140_v6.ld +particle_xenon.build.vid=0x239A +particle_xenon.build.pid=0x8029 + +# SofDevice Menu +particle_xenon.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_name=s140 +particle_xenon.menu.softdevice.s140v6.build.sd_version=6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +particle_xenon.menu.debug.l0=Level 0 (Release) +particle_xenon.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +particle_xenon.menu.debug.l1=Level 1 (Error Message) +particle_xenon.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +particle_xenon.menu.debug.l2=Level 2 (Full Debug) +particle_xenon.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +particle_xenon.menu.debug.l3=Level 3 (Segger SystemView) +particle_xenon.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +particle_xenon.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Raytac MDBT50Q - RX +# ---------------------------------- +mdbt50qrx.name=Raytac MDBT50Q-RX Dongle + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +mdbt50qrx.vid.0=0x239A +mdbt50qrx.pid.0=0x8029 +mdbt50qrx.vid.1=0x239A +mdbt50qrx.pid.1=0x0029 +mdbt50qrx.vid.2=0x239A +mdbt50qrx.pid.2=0x002A +mdbt50qrx.vid.3=0x239A +mdbt50qrx.pid.3=0x802A + +# Upload +mdbt50qrx.bootloader.tool=bootburn +mdbt50qrx.upload.tool=nrfutil +mdbt50qrx.upload.protocol=nrfutil +mdbt50qrx.upload.use_1200bps_touch=true +mdbt50qrx.upload.wait_for_upload_port=true +mdbt50qrx.upload.maximum_size=815104 +mdbt50qrx.upload.maximum_data_size=237568 + +# Build +mdbt50qrx.build.mcu=cortex-m4 +mdbt50qrx.build.f_cpu=64000000 +mdbt50qrx.build.board=MDBT50Q_RX +mdbt50qrx.build.core=nRF5 +mdbt50qrx.build.variant=raytac_mdbt50q_rx +mdbt50qrx.build.usb_manufacturer="Raytac Corporation" +mdbt50qrx.build.usb_product="Raytac MDBT50Q - RX" +mdbt50qrx.build.extra_flags=-DNRF52840_XXAA -DMDBT50Q_RX {build.flags.usb} +mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld +mdbt50qrx.build.vid=0x239A +mdbt50qrx.build.pid=0x8029 + +# SofDevice Menu +mdbt50qrx.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_name=s140 +mdbt50qrx.menu.softdevice.s140v6.build.sd_version=6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +mdbt50qrx.menu.debug.l0=Level 0 (Release) +mdbt50qrx.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +mdbt50qrx.menu.debug.l1=Level 1 (Error Message) +mdbt50qrx.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +mdbt50qrx.menu.debug.l2=Level 2 (Full Debug) +mdbt50qrx.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +mdbt50qrx.menu.debug.l3=Level 3 (Segger SystemView) +mdbt50qrx.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +mdbt50qrx.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# NINA B302 +# ---------------------------------- +ninab302.name=NINA B302 ublox + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +ninab302.vid.0=0x239A +ninab302.pid.0=0x8029 +ninab302.vid.1=0x239A +ninab302.pid.1=0x0029 +ninab302.vid.2=0x7239A +ninab302.pid.2=0x002A +ninab302.vid.3=0x239A +ninab302.pid.3=0x802A + +# Upload +ninab302.bootloader.tool=bootburn +ninab302.upload.tool=nrfutil +ninab302.upload.protocol=nrfutil +ninab302.upload.use_1200bps_touch=true +ninab302.upload.wait_for_upload_port=true +ninab302.upload.maximum_size=815104 +ninab302.upload.maximum_data_size=237568 + +# Build +ninab302.build.mcu=cortex-m4 +ninab302.build.f_cpu=64000000 +ninab302.build.board=NINA_B302_ublox +ninab302.build.core=nRF5 +ninab302.build.variant=NINA_B302_ublox +ninab302.build.usb_manufacturer="Nordic" +ninab302.build.usb_product="NINA B302 ublox" +ninab302.build.extra_flags=-DNRF52840_XXAA -DNINA_B302_ublox {build.flags.usb} +ninab302.build.ldscript=nrf52840_s140_v6.ld +ninab302.build.vid=0x239A +ninab302.build.pid=0x8029 + +# SofDevice Menu +ninab302.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_name=s140 +ninab302.menu.softdevice.s140v6.build.sd_version=6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +ninab302.menu.debug.l0=Level 0 (Release) +ninab302.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab302.menu.debug.l1=Level 1 (Error Message) +ninab302.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab302.menu.debug.l2=Level 2 (Full Debug) +ninab302.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab302.menu.debug.l3=Level 3 (Segger SystemView) +ninab302.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab302.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# NINA B112 +# ---------------------------------- +ninab112.name=NINA B112 ublox +ninab112.bootloader.tool=bootburn + +# Upload +ninab112.upload.tool=nrfutil +ninab112.upload.protocol=nrfutil +ninab112.upload.use_1200bps_touch=false +ninab112.upload.wait_for_upload_port=false +ninab112.upload.native_usb=false +ninab112.upload.maximum_size=290816 +ninab112.upload.maximum_data_size=52224 + +# Build +ninab112.build.mcu=cortex-m4 +ninab112.build.f_cpu=64000000 +ninab112.build.board=NINA_B112_ublox +ninab112.build.core=nRF5 +ninab112.build.variant=NINA_B112_ublox +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52832" +ninab112.build.extra_flags=-DNRF52832_XXAA -DNINA_B112_ublox -DNRF52 +ninab112.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +ninab112.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_name=s132 +ninab112.menu.softdevice.s132v6.build.sd_version=6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +ninab112.menu.debug.l0=Level 0 (Release) +ninab112.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab112.menu.debug.l1=Level 1 (Error Message) +ninab112.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab112.menu.debug.l2=Level 2 (Full Debug) +ninab112.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab112.menu.debug.l3=Level 3 (Segger SystemView) +ninab112.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab112.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/cores/nRF5/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/cores/nRF5/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/cores/nRF5/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/cores/nRF5/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/cores/nRF5/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/cores/nRF5/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/cores/nRF5/Udp.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/cores/nRF5/Udp.h new file mode 100644 index 0000000..016042a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/cores/nRF5/Udp.h @@ -0,0 +1,92 @@ +/* + * Udp.cpp: Library to send/receive UDP packets. + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + */ + +#ifndef udp_h +#define udp_h + +#include +#include + +class UDP : public Stream { + +public: + virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + + // KH, add virtual function to support Multicast, necessary for many services (MDNS, etc.) + virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + + virtual void stop() =0; // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port) =0; + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port) =0; + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket() =0; + // Write a single byte into the packet + virtual size_t write(uint8_t) =0; + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size) =0; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket() =0; + // Number of bytes remaining in the current packet + virtual int available() =0; + // Read a single byte from the current packet + virtual int read() =0; + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len) =0; + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) =0; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek() =0; + virtual void flush() =0; // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() =0; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() =0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/platform.txt new file mode 100644 index 0000000..6c7ed43 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/platform.txt @@ -0,0 +1,164 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All rights reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +name=Adafruit nRF52 Boards +version=0.20.5 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-pointer-arith + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD +# KH, Error here to use gcc, mjust use g++ +#compiler.c.elf.cmd=arm-none-eabi-gcc +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Ofast -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2bin.flags=-O binary +compiler.elf2bin.cmd=arm-none-eabi-objcopy +compiler.elf2hex.flags=-O ihex +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb {build.float_flags} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align --specs=nano.specs --specs=nosys.specs +compiler.size.cmd=arm-none-eabi-size + +# this can be overriden in boards.txt +build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float +build.debug_flags=-DCFG_DEBUG=0 +build.logger_flags=-DCFG_LOGGER=1 +build.sysview_flags=-DCFG_SYSVIEW=0 + +# common compiler for nrf +rtos.path={build.core.path}/freertos +nordic.path={build.core.path}/nordic + +# build.logger_flags and build.sysview_flags and intentionally empty, +# to allow modification via a user's own boards.local.txt or platform.local.txt files. +build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DLFS_NAME_MAX=64 -Ofast {build.debug_flags} {build.logger_flags} {build.sysview_flags} "-I{build.core.path}/cmsis/Core/Include" "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" + +# usb flags +build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2bin.extra_flags= +compiler.elf2hex.extra_flags= + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Create archives +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-L{build.core.path}/linker" "-T{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} -Wl,--start-group -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +#recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2bin.cmd}" {compiler.elf2bin.flags} {compiler.elf2bin.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +## Create dfu package zip file +recipe.objcopy.zip.pattern="{tools.nrfutil.cmd}" dfu genpkg --dev-type 0x0052 --sd-req {build.sd_fwid} --application "{build.path}/{build.project_name}.hex" "{build.path}/{build.project_name}.zip" + +## Create uf2 file +#recipe.objcopy.uf2.pattern=python "{runtime.platform.path}/tools/uf2conv/uf2conv.py" -f 0xADA52840 -c -o "{build.path}/{build.project_name}.uf2" "{build.path}/{build.project_name}.hex" + +## Save bin +recipe.output.tmp_file_bin={build.project_name}.bin +recipe.output.save_file_bin={build.project_name}.save.bin + +## Save hex +recipe.output.tmp_file_hex={build.project_name}.hex +recipe.output.save_file_hexu={build.project_name}.save.hex + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + +## Export Compiled Binary +recipe.output.tmp_file={build.project_name}.hex +recipe.output.save_file={build.project_name}.{build.variant}.hex + +#*************************************************** +# adafruit-nrfutil for uploading +# https://github.com/adafruit/Adafruit_nRF52_nrfutil +# pre-built binaries are provided for macos and windows +#*************************************************** +tools.nrfutil.cmd=adafruit-nrfutil +tools.nrfutil.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe +tools.nrfutil.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil + +tools.nrfutil.upload.params.verbose=--verbose +tools.nrfutil.upload.params.quiet= +tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.path}/{build.project_name}.zip" -p {serial.port} -b 115200 --singlebank + +#*************************************************** +# Burning bootloader with either jlink or nrfutil +#*************************************************** + +# Bootloader version +tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.3.2_{build.sd_name}_{build.sd_version} + +tools.bootburn.bootloader.params.verbose= +tools.bootburn.bootloader.params.quiet= +tools.bootburn.bootloader.pattern={program.burn_pattern} + +# erase flash page while programming +tools.bootburn.erase.params.verbose= +tools.bootburn.erase.params.quiet= +tools.bootburn.erase.pattern= + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/variants/NINA_B112_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/variants/NINA_B112_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/variants/NINA_B112_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/variants/NINA_B112_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/variants/NINA_B112_ublox/variant.cpp new file mode 100644 index 0000000..f43f3a4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/variants/NINA_B112_ublox/variant.cpp @@ -0,0 +1,59 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" + +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +const uint32_t g_ADigitalPinMap[] = { + // D0 .. D13 + 5, // D0 is P0.05 (UART RX) + 6, // D1 is P0.06 (UART TX) + 7, // D2 is P0.07 + 31, // D3 is P0.31 + 18, // D4 is P0.18 (LED Blue) + 99, // D5 (NC) + 9, // D6 is P0.09 NFC1 + 10, // D7 is P0.10 (Button) NFC2 + 99, // D8 (NC) + 8, // D9 is P0.08 + 11, // D10 is P0.11 CS + 13, // D11 is P0.13 MOSI + 12, // D12 is P0.12 MISO + 14, // D13 is P0.14 SCK + //I2C + 2, // D14 is P0.2 (SDA) + 3, // D15 is P0.3 (SCL) + // D16 .. D21 (aka A0 .. A5) + 3, // D16 is P0.03 (A0) + 2, // D17 is P0.02 (A1) + 4, // D18 is P0.04 (A2) + 30, // D19 is P0.30 (A3) SW2 + 29, // D20 is P0.29 (A4) + 28, // D21 is P0.28 (A5) + 9, // P0.09 NFC + 10, // P0.10 NFC + 16, // SW1 (LED Green) +}; \ No newline at end of file diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/variants/NINA_B112_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/variants/NINA_B112_ublox/variant.h new file mode 100644 index 0000000..833cbf6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/variants/NINA_B112_ublox/variant.h @@ -0,0 +1,172 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +#ifndef _VARIANT_NINA_B112_UBLOX_ +#define _VARIANT_NINA_B112_UBLOX_ + +#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \ + .rc_ctiv = 0, \ +.rc_temp_ctiv = 0, \ +.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM} + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (32u) +#define NUM_DIGITAL_PINS (32u) +#define NUM_ANALOG_INPUTS (6u) +#define NUM_ANALOG_OUTPUTS (0u) + +// LEDs +#define PIN_LED LED1 +#define LED_BUILTIN PIN_LED + +//LEDs onboard +#define LED1 (0) // Red +#define LED2 (24) // Green/SW1 +#define LED3 (4) // Blue + +#define LED_STATE_ON 1 // State when LED is litted + +//Switch +#define SW1 (24) +#define SW2 (19) + +// NFC +#define PIN_NFC_1 (6) // P0.9 +#define PIN_NFC_2 (7) // P0.10 + +/* + * Analog pins + */ +#define PIN_A0 (16) // P0.03 +#define PIN_A1 (17) // P0.02 +#define PIN_A2 (18) // P0.04 +#define PIN_A3 (19) // P0.30 +#define PIN_A4 (20) // P0.29 +#define PIN_A5 (21) // P0.28 + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_D0 (0) // P0.05 +#define PIN_D1 (1) // P0.06 +#define PIN_D2 (2) // P0.07 +#define PIN_D3 (4) // P0.31 +#define PIN_D4 (5) // P0.18 +#define PIN_D6 (6) // P0.09 +#define PIN_D7 (7) // P0.10 +#define PIN_D9 (9) // P0.08 +#define PIN_D10 (11) // P0.11 +#define PIN_D11 (13) // P0.13 +#define PIN_D12 (12) // P0.12 +#define PIN_D13 (14) // P0.14 +#define PIN_D14 (2) // P0.02 +#define PIN_D15 (3) // P0.03 + +static const uint8_t D0 = PIN_D0 ; +static const uint8_t D1 = PIN_D1 ; +static const uint8_t D2 = PIN_D2 ; +static const uint8_t D3 = PIN_D3 ; +static const uint8_t D4 = PIN_D4 ; +static const uint8_t D6 = PIN_D6 ; +static const uint8_t D7 = PIN_D7 ; +static const uint8_t D9 = PIN_D9 ; +static const uint8_t D10 = PIN_D10 ; +static const uint8_t D11 = PIN_D11 ; +static const uint8_t D12 = PIN_D12 ; +static const uint8_t D13 = PIN_D13 ; +static const uint8_t D14 = PIN_D14 ; +static const uint8_t D15 = PIN_D15 ; + +// Other pins +//static const uint8_t AREF = PIN_AREF; + +//#define PIN_AREF (24) +//#define PIN_VBAT PIN_A7 + +/* + * Serial interfaces + */ +#define PIN_SERIAL_RX (0) // P0.05 +#define PIN_SERIAL_TX (1) // P0.06 +#define PIN_SERIAL_CTS (2) // P0.07 +#define PIN_SERIAL_RTS (3) // P0.31 +#define PIN_SERIAL_DTR (28) // P0.28 +#define PIN_SERIAL_DSR (29) // P0.29 + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (12) // P0.12 +#define PIN_SPI_MOSI (11) // P0.13 +#define PIN_SPI_SCK (13) // P0.14 + +static const uint8_t SS = 10 ; // P0.11 +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (14) // P0.02 +#define PIN_WIRE_SCL (15) // P0.03 + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + + +#endif //_VARIANT_NINA_B112_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/variants/NINA_B302_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/variants/NINA_B302_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/variants/NINA_B302_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/variants/NINA_B302_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/variants/NINA_B302_ublox/variant.cpp new file mode 100644 index 0000000..8b4df2e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/variants/NINA_B302_ublox/variant.cpp @@ -0,0 +1,87 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 + 29, // D0 is P0.29 (UART RX) + 45, // D1 is P1.13 (UART TX) + 44, // D2 is P1.12 (NFC2) + 31, // D3 is P0.31 (LED1) + 13, // D4 is P0.13 (LED2) + 11, // D5 is P0.11 + 9, // D6 is P0.09 + 10, // D7 is P0.10 (Button) + 41, // D8 is P1.09 + 12, // D9 is P0.12 + 14, // D10 is P0.14 + 15, // D11 is P0.15 + 32, // D12 is P1.00 + 7, // D13 is P0.07 + + // D14 .. D21 (aka A0 .. A5) + 4, // D14 is P0.04 (A0) + 30, // D15 is P0.30 (A1) + 5, // D16 is P0.05 (A2) + 2, // D17 is P0.02 (A3) + 28, // D18 is P0.28 (A4) + 3, // D19 is P0.03 (A5) + + // D20 .. D21 (aka I2C pins) + 16, // D20 is P0.16 (SDA) + 24, // D21 is P0.24 (SCL) + + // QSPI pins (not exposed via any header / test point) + 19, // D22 is P0.19 (QSPI CLK) + 17, // D23 is P0.17 (QSPI CS) + 20, // D24 is P0.20 (QSPI Data 0) + 21, // D25 is P0.21 (QSPI Data 1) + 22, // D26 is P0.22 (QSPI Data 2) + 26, // D27 is P0.23 (QSPI Data 3) + + 40, // D28 is P1.08 - IO34 + 41, // D29 is P1.01 - IO35 + 44, // D30 is P1.02 - IO36 + 45, // D31 is P1.03 - IO37 + 42, // D32 is P1.10 - IO38 + 43, // D33 is P1.11 - IO39 + 47, // D34 is P1.15 - IO40 + 46, // D35 is P1.14 - IO41 + 26, // D36 is P0.26 - IO42 + 6, // D37 is P0.6 - IO43 + 27, // D38 is P0.27 - IO44 +}; + +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/variants/NINA_B302_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/variants/NINA_B302_ublox/variant.h new file mode 100644 index 0000000..a69575f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.19.0/variants/NINA_B302_ublox/variant.h @@ -0,0 +1,149 @@ + /* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#ifndef _VARIANT_NINA_B302_UBLOX_ +#define _VARIANT_NINA_B302_UBLOX_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus +// Number of pins defined in PinDescription array +#define PINS_COUNT (40) +#define NUM_DIGITAL_PINS (34) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (3) +#define PIN_LED2 (4) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_RED PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +/* + * Buttons + */ +#define PIN_BUTTON1 (7) + +/* + * Analog pins + */ +#define PIN_A0 (14) +#define PIN_A1 (15) +#define PIN_A2 (16) +#define PIN_A3 (17) +#define PIN_A4 (18) +#define PIN_A5 (19) + +#define D0 (0) +#define D1 (1) +#define D2 (2) +#define D3 (3) +#define D4 (4) +#define D5 (5) +#define D6 (6) +#define D7 (7) +#define D8 (8) +#define D9 (9) +#define D10 (10) +#define D11 (11) +#define D12 (12) +#define D13 (13) + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_NFC1 (31) +#define PIN_NFC2 (2) + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (0) +#define PIN_SERIAL1_TX (1) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (22) //24 original +#define PIN_SPI_MOSI (23) //25 original +#define PIN_SPI_SCK (24) //26 original + +static const uint8_t SS = (13); +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (20) +#define PIN_WIRE_SCL (21) + +// QSPI Pins +#define PIN_QSPI_SCK 22 +#define PIN_QSPI_CS 23 +#define PIN_QSPI_IO0 24 +#define PIN_QSPI_IO1 25 +#define PIN_QSPI_IO2 26 +#define PIN_QSPI_IO3 27 + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES GD25Q16C +#define EXTERNAL_FLASH_USE_QSPI + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif //_VARIANT_NINA_B302_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/boards.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/boards.txt new file mode 100644 index 0000000..bbe9f9e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/boards.txt @@ -0,0 +1,649 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +menu.softdevice=Bootloader +menu.debug=Debug + +# ---------------------------------- +# Bluefruit Feather nRF52832 +# ---------------------------------- +feather52832.name=Adafruit Feather nRF52832 +feather52832.bootloader.tool=bootburn + +# Upload +feather52832.upload.tool=nrfutil +feather52832.upload.protocol=nrfutil +feather52832.upload.use_1200bps_touch=false +feather52832.upload.wait_for_upload_port=false +feather52832.upload.native_usb=false +feather52832.upload.maximum_size=290816 +feather52832.upload.maximum_data_size=52224 + +# Build +feather52832.build.mcu=cortex-m4 +feather52832.build.f_cpu=64000000 +feather52832.build.board=NRF52832_FEATHER +feather52832.build.core=nRF5 +feather52832.build.variant=feather_nrf52832 +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52832" +feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52832_FEATHER -DNRF52 +feather52832.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +feather52832.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_name=s132 +feather52832.menu.softdevice.s132v6.build.sd_version=6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +feather52832.menu.debug.l0=Level 0 (Release) +feather52832.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52832.menu.debug.l1=Level 1 (Error Message) +feather52832.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52832.menu.debug.l2=Level 2 (Full Debug) +feather52832.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52832.menu.debug.l3=Level 3 (Segger SystemView) +feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52832.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Bluefruit Feather nRF52840 Express +# ---------------------------------- +feather52840.name=Adafruit Feather nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840.vid.0=0x239A +feather52840.pid.0=0x8029 +feather52840.vid.1=0x239A +feather52840.pid.1=0x0029 +feather52840.vid.2=0x239A +feather52840.pid.2=0x002A +feather52840.vid.3=0x239A +feather52840.pid.3=0x802A + +# Upload +feather52840.bootloader.tool=bootburn +feather52840.upload.tool=nrfutil +feather52840.upload.protocol=nrfutil +feather52840.upload.use_1200bps_touch=true +feather52840.upload.wait_for_upload_port=true +feather52840.upload.maximum_size=815104 +feather52840.upload.maximum_data_size=237568 + +# Build +feather52840.build.mcu=cortex-m4 +feather52840.build.f_cpu=64000000 +feather52840.build.board=NRF52840_FEATHER +feather52840.build.core=nRF5 +feather52840.build.variant=feather_nrf52840_express +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52840 Express" +feather52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_FEATHER {build.flags.usb} +feather52840.build.ldscript=nrf52840_s140_v6.ld +feather52840.build.vid=0x239A +feather52840.build.pid=0x8029 + +# SofDevice Menu +feather52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_name=s140 +feather52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840.menu.debug.l0=Level 0 (Release) +feather52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840.menu.debug.l1=Level 1 (Error Message) +feather52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840.menu.debug.l2=Level 2 (Full Debug) +feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840.menu.debug.l3=Level 3 (Segger SystemView) +feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# ---------------------------------- +# Feather Bluefruit sense +# ---------------------------------- +feather52840sense.name=Adafruit Feather Bluefruit Sense + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840sense.vid.0=0x239A +feather52840sense.pid.0=0x8087 +feather52840sense.vid.1=0x239A +feather52840sense.pid.1=0x0087 +feather52840sense.vid.2=0x239A +feather52840sense.pid.2=0x0088 +feather52840sense.vid.3=0x239A +feather52840sense.pid.3=0x8088 + +# Upload +feather52840sense.bootloader.tool=bootburn +feather52840sense.upload.tool=nrfutil +feather52840sense.upload.protocol=nrfutil +feather52840sense.upload.use_1200bps_touch=true +feather52840sense.upload.wait_for_upload_port=true +feather52840sense.upload.maximum_size=815104 +feather52840sense.upload.maximum_data_size=237568 + +# Build +feather52840sense.build.mcu=cortex-m4 +feather52840sense.build.f_cpu=64000000 +feather52840sense.build.board=NRF52840_FEATHER_SENSE +feather52840sense.build.core=nRF5 +feather52840sense.build.variant=feather_nrf52840_sense +feather52840sense.build.usb_manufacturer="Adafruit LLC" +feather52840sense.build.usb_product="Feather nRF52840 Sense" +feather52840sense.build.extra_flags=-DNRF52840_XXAA -DNRF52840_FEATHER_SENSE {build.flags.usb} +feather52840sense.build.ldscript=nrf52840_s140_v6.ld +feather52840sense.build.vid=0x239A +feather52840sense.build.pid=0x8087 + +# SofDevice Menu +feather52840sense.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_name=s140 +feather52840sense.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840sense.menu.debug.l0=Level 0 (Release) +feather52840sense.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840sense.menu.debug.l1=Level 1 (Error Message) +feather52840sense.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840sense.menu.debug.l2=Level 2 (Full Debug) +feather52840sense.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840sense.menu.debug.l3=Level 3 (Segger SystemView) +feather52840sense.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840sense.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Bluefruit ItsyBitsy nRF52840 Express +# --------------------------------------------- +itsybitsy52840.name=Adafruit ItsyBitsy nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +itsybitsy52840.vid.0=0x239A +itsybitsy52840.pid.0=0x8051 +itsybitsy52840.vid.1=0x239A +itsybitsy52840.pid.1=0x0051 +itsybitsy52840.vid.2=0x239A +itsybitsy52840.pid.2=0x0052 +itsybitsy52840.vid.3=0x239A +itsybitsy52840.pid.3=0x8052 + +# Upload +itsybitsy52840.bootloader.tool=bootburn +itsybitsy52840.upload.tool=nrfutil +itsybitsy52840.upload.protocol=nrfutil +itsybitsy52840.upload.use_1200bps_touch=true +itsybitsy52840.upload.wait_for_upload_port=true +itsybitsy52840.upload.maximum_size=815104 +itsybitsy52840.upload.maximum_data_size=237568 + +# Build +itsybitsy52840.build.mcu=cortex-m4 +itsybitsy52840.build.f_cpu=64000000 +itsybitsy52840.build.board=NRF52840_ITSYBITSY +itsybitsy52840.build.core=nRF5 +itsybitsy52840.build.variant=itsybitsy_nrf52840_express +itsybitsy52840.build.usb_manufacturer="Adafruit LLC" +itsybitsy52840.build.usb_product="ItsyBitsy nRF52840 Express" +itsybitsy52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_ITSYBITSY -DARDUINO_NRF52_ITSYBITSY {build.flags.usb} +itsybitsy52840.build.ldscript=nrf52840_s140_v6.ld +itsybitsy52840.build.vid=0x239A +itsybitsy52840.build.pid=0x8051 + +# SofDevice Menu +itsybitsy52840.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_name=s140 +itsybitsy52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +itsybitsy52840.menu.debug.l0=Level 0 (Release) +itsybitsy52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +itsybitsy52840.menu.debug.l1=Level 1 (Error Message) +itsybitsy52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +itsybitsy52840.menu.debug.l2=Level 2 (Full Debug) +itsybitsy52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +itsybitsy52840.menu.debug.l3=Level 3 (Segger SystemView) +itsybitsy52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +itsybitsy52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# --------------------------------------------- +# Bluefruit Circuit Playground nRF52840 Express +# --------------------------------------------- +cplaynrf52840.name=Adafruit Circuit Playground Bluefruit + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cplaynrf52840.vid.0=0x239A +cplaynrf52840.pid.0=0x8045 +cplaynrf52840.vid.1=0x239A +cplaynrf52840.pid.1=0x0045 +cplaynrf52840.vid.2=0x239A +cplaynrf52840.pid.2=0x0046 +cplaynrf52840.vid.3=0x239A +cplaynrf52840.pid.3=0x8046 + +# Upload +cplaynrf52840.bootloader.tool=bootburn +cplaynrf52840.upload.tool=nrfutil +cplaynrf52840.upload.protocol=nrfutil +cplaynrf52840.upload.use_1200bps_touch=true +cplaynrf52840.upload.wait_for_upload_port=true +cplaynrf52840.upload.maximum_size=815104 +cplaynrf52840.upload.maximum_data_size=237568 + +# Build +cplaynrf52840.build.mcu=cortex-m4 +cplaynrf52840.build.f_cpu=64000000 +cplaynrf52840.build.board=NRF52840_CIRCUITPLAY +cplaynrf52840.build.core=nRF5 +cplaynrf52840.build.variant=circuitplayground_nrf52840 +cplaynrf52840.build.usb_manufacturer="Adafruit LLC" +cplaynrf52840.build.usb_product="Circuit Playground Bluefruit" +cplaynrf52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_CIRCUITPLAY {build.flags.usb} +cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld +cplaynrf52840.build.vid=0x239A +cplaynrf52840.build.pid=0x8045 + +# SofDevice Menu +cplaynrf52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cplaynrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cplaynrf52840.menu.debug.l0=Level 0 (Release) +cplaynrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cplaynrf52840.menu.debug.l1=Level 1 (Error Message) +cplaynrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cplaynrf52840.menu.debug.l2=Level 2 (Full Debug) +cplaynrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cplaynrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cplaynrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Clue nRF52840 +# --------------------------------------------- +cluenrf52840.name=Adafruit CLUE + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cluenrf52840.vid.0=0x239A +cluenrf52840.pid.0=0x8072 +cluenrf52840.vid.1=0x239A +cluenrf52840.pid.1=0x0072 +cluenrf52840.vid.2=0x239A +cluenrf52840.pid.2=0x0071 +cluenrf52840.vid.3=0x239A +cluenrf52840.pid.3=0x8071 + +# Upload +cluenrf52840.bootloader.tool=bootburn +cluenrf52840.upload.tool=nrfutil +cluenrf52840.upload.protocol=nrfutil +cluenrf52840.upload.use_1200bps_touch=true +cluenrf52840.upload.wait_for_upload_port=true +cluenrf52840.upload.maximum_size=815104 +cluenrf52840.upload.maximum_data_size=237568 + +# Build +cluenrf52840.build.mcu=cortex-m4 +cluenrf52840.build.f_cpu=64000000 +cluenrf52840.build.board=NRF52840_CLUE +cluenrf52840.build.core=nRF5 +cluenrf52840.build.variant=clue_nrf52840 +cluenrf52840.build.usb_manufacturer="Adafruit LLC" +cluenrf52840.build.usb_product="CLUE" +cluenrf52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_CLUE {build.flags.usb} +cluenrf52840.build.ldscript=nrf52840_s140_v6.ld +cluenrf52840.build.vid=0x239A +cluenrf52840.build.pid=0x8071 + +# SofDevice Menu +cluenrf52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cluenrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cluenrf52840.menu.debug.l0=Level 0 (Release) +cluenrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cluenrf52840.menu.debug.l1=Level 1 (Error Message) +cluenrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cluenrf52840.menu.debug.l2=Level 2 (Full Debug) +cluenrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cluenrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cluenrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cluenrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Bluefruit Metro nRF52840 Express +# ---------------------------------- +metro52840.name=Adafruit Bluefruit Metro nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +metro52840.vid.0=0x239A +metro52840.pid.0=0x803F +metro52840.vid.1=0x239A +metro52840.pid.1=0x003F +metro52840.vid.2=0x239A +metro52840.pid.2=0x0040 +metro52840.vid.3=0x239A +metro52840.pid.3=0x8040 + +# Upload +metro52840.bootloader.tool=bootburn +metro52840.upload.tool=nrfutil +metro52840.upload.protocol=nrfutil +metro52840.upload.use_1200bps_touch=true +metro52840.upload.wait_for_upload_port=true +metro52840.upload.maximum_size=815104 +metro52840.upload.maximum_data_size=237568 + +# Build +metro52840.build.mcu=cortex-m4 +metro52840.build.f_cpu=64000000 +metro52840.build.board=NRF52840_METRO +metro52840.build.core=nRF5 +metro52840.build.variant=metro_nrf52840_express +metro52840.build.usb_manufacturer="Adafruit LLC" +metro52840.build.usb_product="Metro nRF52840 Express" +metro52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_METRO {build.flags.usb} +metro52840.build.ldscript=nrf52840_s140_v6.ld +metro52840.build.vid=0x239A +metro52840.build.pid=0x803F + +# SofDevice Menu +metro52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_name=s140 +metro52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +metro52840.menu.debug.l0=Level 0 (Release) +metro52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +metro52840.menu.debug.l1=Level 1 (Error Message) +metro52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +metro52840.menu.debug.l2=Level 2 (Full Debug) +metro52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +metro52840.menu.debug.l3=Level 3 (Segger SystemView) +metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +metro52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + + + +# ------------------------------------------------------- +# +# Boards that aren't made by Adafruit +# +# ------------------------------------------------------- + + +# ---------------------------------- +# Nordic nRF52840DK (PCA10056) +# ---------------------------------- +pca10056.name=Nordic nRF52840DK (PCA10056) +pca10056.bootloader.tool=bootburn + +# Upload +pca10056.upload.tool=nrfutil +pca10056.upload.protocol=nrfutil +pca10056.upload.use_1200bps_touch=true +pca10056.upload.wait_for_upload_port=true +pca10056.upload.maximum_size=815104 +pca10056.upload.maximum_data_size=237568 + +# Build +pca10056.build.mcu=cortex-m4 +pca10056.build.f_cpu=64000000 +pca10056.build.board=NRF52840_PCA10056 +pca10056.build.core=nRF5 +pca10056.build.variant=pca10056 +pca10056.build.usb_manufacturer="Nordic" +pca10056.build.usb_product="nRF52840 DK" +pca10056.build.extra_flags=-DNRF52840_XXAA -DNRF52840_PCA10056 {build.flags.usb} +pca10056.build.ldscript=nrf52840_s140_v6.ld +pca10056.build.vid=0x239A +pca10056.build.pid=0x8029 + +# SofDevice Menu +pca10056.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_name=s140 +pca10056.menu.softdevice.s140v6.build.sd_version=6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +pca10056.menu.debug.l0=Level 0 (Release) +pca10056.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +pca10056.menu.debug.l1=Level 1 (Error Message) +pca10056.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +pca10056.menu.debug.l2=Level 2 (Full Debug) +pca10056.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +pca10056.menu.debug.l3=Level 3 (Segger SystemView) +pca10056.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +pca10056.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Particle Xenon +# ---------------------------------- +particle_xenon.name=Particle Xenon + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +particle_xenon.vid.0=0x239A +particle_xenon.pid.0=0x8029 +particle_xenon.vid.1=0x239A +particle_xenon.pid.1=0x0029 +particle_xenon.vid.2=0x239A +particle_xenon.pid.2=0x002A +particle_xenon.vid.3=0x239A +particle_xenon.pid.3=0x802A + +# Upload +particle_xenon.bootloader.tool=bootburn +particle_xenon.upload.tool=nrfutil +particle_xenon.upload.protocol=nrfutil +particle_xenon.upload.use_1200bps_touch=true +particle_xenon.upload.wait_for_upload_port=true +particle_xenon.upload.maximum_size=815104 +particle_xenon.upload.maximum_data_size=237568 + +# Build +particle_xenon.build.mcu=cortex-m4 +particle_xenon.build.f_cpu=64000000 +particle_xenon.build.board=PARTICLE_XENON +particle_xenon.build.core=nRF5 +particle_xenon.build.variant=particle_xenon +particle_xenon.build.usb_manufacturer="Particle Industries" +particle_xenon.build.usb_product="Particle Xenon" +particle_xenon.build.extra_flags=-DNRF52840_XXAA -DPARTICLE_XENON {build.flags.usb} +particle_xenon.build.ldscript=nrf52840_s140_v6.ld +particle_xenon.build.vid=0x239A +particle_xenon.build.pid=0x8029 + +# SofDevice Menu +particle_xenon.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_name=s140 +particle_xenon.menu.softdevice.s140v6.build.sd_version=6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +particle_xenon.menu.debug.l0=Level 0 (Release) +particle_xenon.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +particle_xenon.menu.debug.l1=Level 1 (Error Message) +particle_xenon.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +particle_xenon.menu.debug.l2=Level 2 (Full Debug) +particle_xenon.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +particle_xenon.menu.debug.l3=Level 3 (Segger SystemView) +particle_xenon.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +particle_xenon.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Raytac MDBT50Q - RX +# ---------------------------------- +mdbt50qrx.name=Raytac MDBT50Q-RX Dongle + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +mdbt50qrx.vid.0=0x239A +mdbt50qrx.pid.0=0x8029 +mdbt50qrx.vid.1=0x239A +mdbt50qrx.pid.1=0x0029 +mdbt50qrx.vid.2=0x239A +mdbt50qrx.pid.2=0x002A +mdbt50qrx.vid.3=0x239A +mdbt50qrx.pid.3=0x802A + +# Upload +mdbt50qrx.bootloader.tool=bootburn +mdbt50qrx.upload.tool=nrfutil +mdbt50qrx.upload.protocol=nrfutil +mdbt50qrx.upload.use_1200bps_touch=true +mdbt50qrx.upload.wait_for_upload_port=true +mdbt50qrx.upload.maximum_size=815104 +mdbt50qrx.upload.maximum_data_size=237568 + +# Build +mdbt50qrx.build.mcu=cortex-m4 +mdbt50qrx.build.f_cpu=64000000 +mdbt50qrx.build.board=MDBT50Q_RX +mdbt50qrx.build.core=nRF5 +mdbt50qrx.build.variant=raytac_mdbt50q_rx +mdbt50qrx.build.usb_manufacturer="Raytac Corporation" +mdbt50qrx.build.usb_product="Raytac MDBT50Q - RX" +mdbt50qrx.build.extra_flags=-DNRF52840_XXAA -DMDBT50Q_RX {build.flags.usb} +mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld +mdbt50qrx.build.vid=0x239A +mdbt50qrx.build.pid=0x8029 + +# SofDevice Menu +mdbt50qrx.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_name=s140 +mdbt50qrx.menu.softdevice.s140v6.build.sd_version=6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +mdbt50qrx.menu.debug.l0=Level 0 (Release) +mdbt50qrx.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +mdbt50qrx.menu.debug.l1=Level 1 (Error Message) +mdbt50qrx.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +mdbt50qrx.menu.debug.l2=Level 2 (Full Debug) +mdbt50qrx.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +mdbt50qrx.menu.debug.l3=Level 3 (Segger SystemView) +mdbt50qrx.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +mdbt50qrx.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# NINA B302 +# ---------------------------------- +ninab302.name=NINA B302 ublox + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +ninab302.vid.0=0x239A +ninab302.pid.0=0x8029 +ninab302.vid.1=0x239A +ninab302.pid.1=0x0029 +ninab302.vid.2=0x7239A +ninab302.pid.2=0x002A +ninab302.vid.3=0x239A +ninab302.pid.3=0x802A + +# Upload +ninab302.bootloader.tool=bootburn +ninab302.upload.tool=nrfutil +ninab302.upload.protocol=nrfutil +ninab302.upload.use_1200bps_touch=true +ninab302.upload.wait_for_upload_port=true +ninab302.upload.maximum_size=815104 +ninab302.upload.maximum_data_size=237568 + +# Build +ninab302.build.mcu=cortex-m4 +ninab302.build.f_cpu=64000000 +ninab302.build.board=NINA_B302_ublox +ninab302.build.core=nRF5 +ninab302.build.variant=NINA_B302_ublox +ninab302.build.usb_manufacturer="Nordic" +ninab302.build.usb_product="NINA B302 ublox" +ninab302.build.extra_flags=-DNRF52840_XXAA -DNINA_B302_ublox {build.flags.usb} +ninab302.build.ldscript=nrf52840_s140_v6.ld +ninab302.build.vid=0x239A +ninab302.build.pid=0x8029 + +# SofDevice Menu +ninab302.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_name=s140 +ninab302.menu.softdevice.s140v6.build.sd_version=6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +ninab302.menu.debug.l0=Level 0 (Release) +ninab302.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab302.menu.debug.l1=Level 1 (Error Message) +ninab302.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab302.menu.debug.l2=Level 2 (Full Debug) +ninab302.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab302.menu.debug.l3=Level 3 (Segger SystemView) +ninab302.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab302.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# NINA B112 +# ---------------------------------- +ninab112.name=NINA B112 ublox +ninab112.bootloader.tool=bootburn + +# Upload +ninab112.upload.tool=nrfutil +ninab112.upload.protocol=nrfutil +ninab112.upload.use_1200bps_touch=false +ninab112.upload.wait_for_upload_port=false +ninab112.upload.native_usb=false +ninab112.upload.maximum_size=290816 +ninab112.upload.maximum_data_size=52224 + +# Build +ninab112.build.mcu=cortex-m4 +ninab112.build.f_cpu=64000000 +ninab112.build.board=NINA_B112_ublox +ninab112.build.core=nRF5 +ninab112.build.variant=NINA_B112_ublox +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52832" +ninab112.build.extra_flags=-DNRF52832_XXAA -DNINA_B112_ublox -DNRF52 +ninab112.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +ninab112.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_name=s132 +ninab112.menu.softdevice.s132v6.build.sd_version=6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +ninab112.menu.debug.l0=Level 0 (Release) +ninab112.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab112.menu.debug.l1=Level 1 (Error Message) +ninab112.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab112.menu.debug.l2=Level 2 (Full Debug) +ninab112.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab112.menu.debug.l3=Level 3 (Segger SystemView) +ninab112.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab112.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/cores/nRF5/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/cores/nRF5/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/cores/nRF5/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/cores/nRF5/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/cores/nRF5/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/cores/nRF5/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/cores/nRF5/Udp.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/cores/nRF5/Udp.h new file mode 100644 index 0000000..016042a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/cores/nRF5/Udp.h @@ -0,0 +1,92 @@ +/* + * Udp.cpp: Library to send/receive UDP packets. + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + */ + +#ifndef udp_h +#define udp_h + +#include +#include + +class UDP : public Stream { + +public: + virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + + // KH, add virtual function to support Multicast, necessary for many services (MDNS, etc.) + virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + + virtual void stop() =0; // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port) =0; + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port) =0; + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket() =0; + // Write a single byte into the packet + virtual size_t write(uint8_t) =0; + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size) =0; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket() =0; + // Number of bytes remaining in the current packet + virtual int available() =0; + // Read a single byte from the current packet + virtual int read() =0; + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len) =0; + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) =0; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek() =0; + virtual void flush() =0; // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() =0; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() =0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/platform.txt new file mode 100644 index 0000000..6c7ed43 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/platform.txt @@ -0,0 +1,164 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All rights reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +name=Adafruit nRF52 Boards +version=0.20.5 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-pointer-arith + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD +# KH, Error here to use gcc, mjust use g++ +#compiler.c.elf.cmd=arm-none-eabi-gcc +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Ofast -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2bin.flags=-O binary +compiler.elf2bin.cmd=arm-none-eabi-objcopy +compiler.elf2hex.flags=-O ihex +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb {build.float_flags} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align --specs=nano.specs --specs=nosys.specs +compiler.size.cmd=arm-none-eabi-size + +# this can be overriden in boards.txt +build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float +build.debug_flags=-DCFG_DEBUG=0 +build.logger_flags=-DCFG_LOGGER=1 +build.sysview_flags=-DCFG_SYSVIEW=0 + +# common compiler for nrf +rtos.path={build.core.path}/freertos +nordic.path={build.core.path}/nordic + +# build.logger_flags and build.sysview_flags and intentionally empty, +# to allow modification via a user's own boards.local.txt or platform.local.txt files. +build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DLFS_NAME_MAX=64 -Ofast {build.debug_flags} {build.logger_flags} {build.sysview_flags} "-I{build.core.path}/cmsis/Core/Include" "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" + +# usb flags +build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2bin.extra_flags= +compiler.elf2hex.extra_flags= + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Create archives +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-L{build.core.path}/linker" "-T{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} -Wl,--start-group -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +#recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2bin.cmd}" {compiler.elf2bin.flags} {compiler.elf2bin.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +## Create dfu package zip file +recipe.objcopy.zip.pattern="{tools.nrfutil.cmd}" dfu genpkg --dev-type 0x0052 --sd-req {build.sd_fwid} --application "{build.path}/{build.project_name}.hex" "{build.path}/{build.project_name}.zip" + +## Create uf2 file +#recipe.objcopy.uf2.pattern=python "{runtime.platform.path}/tools/uf2conv/uf2conv.py" -f 0xADA52840 -c -o "{build.path}/{build.project_name}.uf2" "{build.path}/{build.project_name}.hex" + +## Save bin +recipe.output.tmp_file_bin={build.project_name}.bin +recipe.output.save_file_bin={build.project_name}.save.bin + +## Save hex +recipe.output.tmp_file_hex={build.project_name}.hex +recipe.output.save_file_hexu={build.project_name}.save.hex + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + +## Export Compiled Binary +recipe.output.tmp_file={build.project_name}.hex +recipe.output.save_file={build.project_name}.{build.variant}.hex + +#*************************************************** +# adafruit-nrfutil for uploading +# https://github.com/adafruit/Adafruit_nRF52_nrfutil +# pre-built binaries are provided for macos and windows +#*************************************************** +tools.nrfutil.cmd=adafruit-nrfutil +tools.nrfutil.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe +tools.nrfutil.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil + +tools.nrfutil.upload.params.verbose=--verbose +tools.nrfutil.upload.params.quiet= +tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.path}/{build.project_name}.zip" -p {serial.port} -b 115200 --singlebank + +#*************************************************** +# Burning bootloader with either jlink or nrfutil +#*************************************************** + +# Bootloader version +tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.3.2_{build.sd_name}_{build.sd_version} + +tools.bootburn.bootloader.params.verbose= +tools.bootburn.bootloader.params.quiet= +tools.bootburn.bootloader.pattern={program.burn_pattern} + +# erase flash page while programming +tools.bootburn.erase.params.verbose= +tools.bootburn.erase.params.quiet= +tools.bootburn.erase.pattern= + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/variants/NINA_B112_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/variants/NINA_B112_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/variants/NINA_B112_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/variants/NINA_B112_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/variants/NINA_B112_ublox/variant.cpp new file mode 100644 index 0000000..f43f3a4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/variants/NINA_B112_ublox/variant.cpp @@ -0,0 +1,59 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" + +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +const uint32_t g_ADigitalPinMap[] = { + // D0 .. D13 + 5, // D0 is P0.05 (UART RX) + 6, // D1 is P0.06 (UART TX) + 7, // D2 is P0.07 + 31, // D3 is P0.31 + 18, // D4 is P0.18 (LED Blue) + 99, // D5 (NC) + 9, // D6 is P0.09 NFC1 + 10, // D7 is P0.10 (Button) NFC2 + 99, // D8 (NC) + 8, // D9 is P0.08 + 11, // D10 is P0.11 CS + 13, // D11 is P0.13 MOSI + 12, // D12 is P0.12 MISO + 14, // D13 is P0.14 SCK + //I2C + 2, // D14 is P0.2 (SDA) + 3, // D15 is P0.3 (SCL) + // D16 .. D21 (aka A0 .. A5) + 3, // D16 is P0.03 (A0) + 2, // D17 is P0.02 (A1) + 4, // D18 is P0.04 (A2) + 30, // D19 is P0.30 (A3) SW2 + 29, // D20 is P0.29 (A4) + 28, // D21 is P0.28 (A5) + 9, // P0.09 NFC + 10, // P0.10 NFC + 16, // SW1 (LED Green) +}; \ No newline at end of file diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/variants/NINA_B112_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/variants/NINA_B112_ublox/variant.h new file mode 100644 index 0000000..833cbf6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/variants/NINA_B112_ublox/variant.h @@ -0,0 +1,172 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +#ifndef _VARIANT_NINA_B112_UBLOX_ +#define _VARIANT_NINA_B112_UBLOX_ + +#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \ + .rc_ctiv = 0, \ +.rc_temp_ctiv = 0, \ +.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM} + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (32u) +#define NUM_DIGITAL_PINS (32u) +#define NUM_ANALOG_INPUTS (6u) +#define NUM_ANALOG_OUTPUTS (0u) + +// LEDs +#define PIN_LED LED1 +#define LED_BUILTIN PIN_LED + +//LEDs onboard +#define LED1 (0) // Red +#define LED2 (24) // Green/SW1 +#define LED3 (4) // Blue + +#define LED_STATE_ON 1 // State when LED is litted + +//Switch +#define SW1 (24) +#define SW2 (19) + +// NFC +#define PIN_NFC_1 (6) // P0.9 +#define PIN_NFC_2 (7) // P0.10 + +/* + * Analog pins + */ +#define PIN_A0 (16) // P0.03 +#define PIN_A1 (17) // P0.02 +#define PIN_A2 (18) // P0.04 +#define PIN_A3 (19) // P0.30 +#define PIN_A4 (20) // P0.29 +#define PIN_A5 (21) // P0.28 + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_D0 (0) // P0.05 +#define PIN_D1 (1) // P0.06 +#define PIN_D2 (2) // P0.07 +#define PIN_D3 (4) // P0.31 +#define PIN_D4 (5) // P0.18 +#define PIN_D6 (6) // P0.09 +#define PIN_D7 (7) // P0.10 +#define PIN_D9 (9) // P0.08 +#define PIN_D10 (11) // P0.11 +#define PIN_D11 (13) // P0.13 +#define PIN_D12 (12) // P0.12 +#define PIN_D13 (14) // P0.14 +#define PIN_D14 (2) // P0.02 +#define PIN_D15 (3) // P0.03 + +static const uint8_t D0 = PIN_D0 ; +static const uint8_t D1 = PIN_D1 ; +static const uint8_t D2 = PIN_D2 ; +static const uint8_t D3 = PIN_D3 ; +static const uint8_t D4 = PIN_D4 ; +static const uint8_t D6 = PIN_D6 ; +static const uint8_t D7 = PIN_D7 ; +static const uint8_t D9 = PIN_D9 ; +static const uint8_t D10 = PIN_D10 ; +static const uint8_t D11 = PIN_D11 ; +static const uint8_t D12 = PIN_D12 ; +static const uint8_t D13 = PIN_D13 ; +static const uint8_t D14 = PIN_D14 ; +static const uint8_t D15 = PIN_D15 ; + +// Other pins +//static const uint8_t AREF = PIN_AREF; + +//#define PIN_AREF (24) +//#define PIN_VBAT PIN_A7 + +/* + * Serial interfaces + */ +#define PIN_SERIAL_RX (0) // P0.05 +#define PIN_SERIAL_TX (1) // P0.06 +#define PIN_SERIAL_CTS (2) // P0.07 +#define PIN_SERIAL_RTS (3) // P0.31 +#define PIN_SERIAL_DTR (28) // P0.28 +#define PIN_SERIAL_DSR (29) // P0.29 + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (12) // P0.12 +#define PIN_SPI_MOSI (11) // P0.13 +#define PIN_SPI_SCK (13) // P0.14 + +static const uint8_t SS = 10 ; // P0.11 +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (14) // P0.02 +#define PIN_WIRE_SCL (15) // P0.03 + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + + +#endif //_VARIANT_NINA_B112_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/variants/NINA_B302_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/variants/NINA_B302_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/variants/NINA_B302_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/variants/NINA_B302_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/variants/NINA_B302_ublox/variant.cpp new file mode 100644 index 0000000..8b4df2e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/variants/NINA_B302_ublox/variant.cpp @@ -0,0 +1,87 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 + 29, // D0 is P0.29 (UART RX) + 45, // D1 is P1.13 (UART TX) + 44, // D2 is P1.12 (NFC2) + 31, // D3 is P0.31 (LED1) + 13, // D4 is P0.13 (LED2) + 11, // D5 is P0.11 + 9, // D6 is P0.09 + 10, // D7 is P0.10 (Button) + 41, // D8 is P1.09 + 12, // D9 is P0.12 + 14, // D10 is P0.14 + 15, // D11 is P0.15 + 32, // D12 is P1.00 + 7, // D13 is P0.07 + + // D14 .. D21 (aka A0 .. A5) + 4, // D14 is P0.04 (A0) + 30, // D15 is P0.30 (A1) + 5, // D16 is P0.05 (A2) + 2, // D17 is P0.02 (A3) + 28, // D18 is P0.28 (A4) + 3, // D19 is P0.03 (A5) + + // D20 .. D21 (aka I2C pins) + 16, // D20 is P0.16 (SDA) + 24, // D21 is P0.24 (SCL) + + // QSPI pins (not exposed via any header / test point) + 19, // D22 is P0.19 (QSPI CLK) + 17, // D23 is P0.17 (QSPI CS) + 20, // D24 is P0.20 (QSPI Data 0) + 21, // D25 is P0.21 (QSPI Data 1) + 22, // D26 is P0.22 (QSPI Data 2) + 26, // D27 is P0.23 (QSPI Data 3) + + 40, // D28 is P1.08 - IO34 + 41, // D29 is P1.01 - IO35 + 44, // D30 is P1.02 - IO36 + 45, // D31 is P1.03 - IO37 + 42, // D32 is P1.10 - IO38 + 43, // D33 is P1.11 - IO39 + 47, // D34 is P1.15 - IO40 + 46, // D35 is P1.14 - IO41 + 26, // D36 is P0.26 - IO42 + 6, // D37 is P0.6 - IO43 + 27, // D38 is P0.27 - IO44 +}; + +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/variants/NINA_B302_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/variants/NINA_B302_ublox/variant.h new file mode 100644 index 0000000..a69575f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.1/variants/NINA_B302_ublox/variant.h @@ -0,0 +1,149 @@ + /* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#ifndef _VARIANT_NINA_B302_UBLOX_ +#define _VARIANT_NINA_B302_UBLOX_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus +// Number of pins defined in PinDescription array +#define PINS_COUNT (40) +#define NUM_DIGITAL_PINS (34) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (3) +#define PIN_LED2 (4) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_RED PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +/* + * Buttons + */ +#define PIN_BUTTON1 (7) + +/* + * Analog pins + */ +#define PIN_A0 (14) +#define PIN_A1 (15) +#define PIN_A2 (16) +#define PIN_A3 (17) +#define PIN_A4 (18) +#define PIN_A5 (19) + +#define D0 (0) +#define D1 (1) +#define D2 (2) +#define D3 (3) +#define D4 (4) +#define D5 (5) +#define D6 (6) +#define D7 (7) +#define D8 (8) +#define D9 (9) +#define D10 (10) +#define D11 (11) +#define D12 (12) +#define D13 (13) + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_NFC1 (31) +#define PIN_NFC2 (2) + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (0) +#define PIN_SERIAL1_TX (1) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (22) //24 original +#define PIN_SPI_MOSI (23) //25 original +#define PIN_SPI_SCK (24) //26 original + +static const uint8_t SS = (13); +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (20) +#define PIN_WIRE_SCL (21) + +// QSPI Pins +#define PIN_QSPI_SCK 22 +#define PIN_QSPI_CS 23 +#define PIN_QSPI_IO0 24 +#define PIN_QSPI_IO1 25 +#define PIN_QSPI_IO2 26 +#define PIN_QSPI_IO3 27 + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES GD25Q16C +#define EXTERNAL_FLASH_USE_QSPI + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif //_VARIANT_NINA_B302_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/boards.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/boards.txt new file mode 100644 index 0000000..5aee8ca --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/boards.txt @@ -0,0 +1,649 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +menu.softdevice=Bootloader +menu.debug=Debug + +# ---------------------------------- +# Bluefruit Feather nRF52832 +# ---------------------------------- +feather52832.name=Adafruit Feather nRF52832 +feather52832.bootloader.tool=bootburn + +# Upload +feather52832.upload.tool=nrfutil +feather52832.upload.protocol=nrfutil +feather52832.upload.use_1200bps_touch=false +feather52832.upload.wait_for_upload_port=false +feather52832.upload.native_usb=false +feather52832.upload.maximum_size=290816 +feather52832.upload.maximum_data_size=52224 + +# Build +feather52832.build.mcu=cortex-m4 +feather52832.build.f_cpu=64000000 +feather52832.build.board=NRF52832_FEATHER +feather52832.build.core=nRF5 +feather52832.build.variant=feather_nrf52832 +feather52832.build.usb_manufacturer="Adafruit LLC" +feather52832.build.usb_product="Feather nRF52832" +feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52832_FEATHER -DNRF52 +feather52832.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +feather52832.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_name=s132 +feather52832.menu.softdevice.s132v6.build.sd_version=6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +feather52832.menu.debug.l0=Level 0 (Release) +feather52832.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52832.menu.debug.l1=Level 1 (Error Message) +feather52832.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52832.menu.debug.l2=Level 2 (Full Debug) +feather52832.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52832.menu.debug.l3=Level 3 (Segger SystemView) +feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52832.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Bluefruit Feather nRF52840 Express +# ---------------------------------- +feather52840.name=Adafruit Feather nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840.vid.0=0x239A +feather52840.pid.0=0x8029 +feather52840.vid.1=0x239A +feather52840.pid.1=0x0029 +feather52840.vid.2=0x239A +feather52840.pid.2=0x002A +feather52840.vid.3=0x239A +feather52840.pid.3=0x802A + +# Upload +feather52840.bootloader.tool=bootburn +feather52840.upload.tool=nrfutil +feather52840.upload.protocol=nrfutil +feather52840.upload.use_1200bps_touch=true +feather52840.upload.wait_for_upload_port=true +feather52840.upload.maximum_size=815104 +feather52840.upload.maximum_data_size=237568 + +# Build +feather52840.build.mcu=cortex-m4 +feather52840.build.f_cpu=64000000 +feather52840.build.board=NRF52840_FEATHER +feather52840.build.core=nRF5 +feather52840.build.variant=feather_nrf52840_express +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52840 Express" +feather52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_FEATHER {build.flags.usb} +feather52840.build.ldscript=nrf52840_s140_v6.ld +feather52840.build.vid=0x239A +feather52840.build.pid=0x8029 + +# SofDevice Menu +feather52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_name=s140 +feather52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840.menu.debug.l0=Level 0 (Release) +feather52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840.menu.debug.l1=Level 1 (Error Message) +feather52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840.menu.debug.l2=Level 2 (Full Debug) +feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840.menu.debug.l3=Level 3 (Segger SystemView) +feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# ---------------------------------- +# Feather Bluefruit sense +# ---------------------------------- +feather52840sense.name=Adafruit Feather Bluefruit Sense + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840sense.vid.0=0x239A +feather52840sense.pid.0=0x8087 +feather52840sense.vid.1=0x239A +feather52840sense.pid.1=0x0087 +feather52840sense.vid.2=0x239A +feather52840sense.pid.2=0x0088 +feather52840sense.vid.3=0x239A +feather52840sense.pid.3=0x8088 + +# Upload +feather52840sense.bootloader.tool=bootburn +feather52840sense.upload.tool=nrfutil +feather52840sense.upload.protocol=nrfutil +feather52840sense.upload.use_1200bps_touch=true +feather52840sense.upload.wait_for_upload_port=true +feather52840sense.upload.maximum_size=815104 +feather52840sense.upload.maximum_data_size=237568 + +# Build +feather52840sense.build.mcu=cortex-m4 +feather52840sense.build.f_cpu=64000000 +feather52840sense.build.board=NRF52840_FEATHER_SENSE +feather52840sense.build.core=nRF5 +feather52840sense.build.variant=feather_nrf52840_sense +feather52840sense.build.usb_manufacturer="Adafruit LLC" +feather52840sense.build.usb_product="Feather nRF52840 Sense" +feather52840sense.build.extra_flags=-DNRF52840_XXAA -DNRF52840_FEATHER_SENSE {build.flags.usb} +feather52840sense.build.ldscript=nrf52840_s140_v6.ld +feather52840sense.build.vid=0x239A +feather52840sense.build.pid=0x8087 + +# SofDevice Menu +feather52840sense.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_name=s140 +feather52840sense.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840sense.menu.debug.l0=Level 0 (Release) +feather52840sense.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840sense.menu.debug.l1=Level 1 (Error Message) +feather52840sense.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840sense.menu.debug.l2=Level 2 (Full Debug) +feather52840sense.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840sense.menu.debug.l3=Level 3 (Segger SystemView) +feather52840sense.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840sense.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Bluefruit ItsyBitsy nRF52840 Express +# --------------------------------------------- +itsybitsy52840.name=Adafruit ItsyBitsy nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +itsybitsy52840.vid.0=0x239A +itsybitsy52840.pid.0=0x8051 +itsybitsy52840.vid.1=0x239A +itsybitsy52840.pid.1=0x0051 +itsybitsy52840.vid.2=0x239A +itsybitsy52840.pid.2=0x0052 +itsybitsy52840.vid.3=0x239A +itsybitsy52840.pid.3=0x8052 + +# Upload +itsybitsy52840.bootloader.tool=bootburn +itsybitsy52840.upload.tool=nrfutil +itsybitsy52840.upload.protocol=nrfutil +itsybitsy52840.upload.use_1200bps_touch=true +itsybitsy52840.upload.wait_for_upload_port=true +itsybitsy52840.upload.maximum_size=815104 +itsybitsy52840.upload.maximum_data_size=237568 + +# Build +itsybitsy52840.build.mcu=cortex-m4 +itsybitsy52840.build.f_cpu=64000000 +itsybitsy52840.build.board=NRF52840_ITSYBITSY +itsybitsy52840.build.core=nRF5 +itsybitsy52840.build.variant=itsybitsy_nrf52840_express +itsybitsy52840.build.usb_manufacturer="Adafruit LLC" +itsybitsy52840.build.usb_product="ItsyBitsy nRF52840 Express" +itsybitsy52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_ITSYBITSY -DARDUINO_NRF52_ITSYBITSY {build.flags.usb} +itsybitsy52840.build.ldscript=nrf52840_s140_v6.ld +itsybitsy52840.build.vid=0x239A +itsybitsy52840.build.pid=0x8051 + +# SofDevice Menu +itsybitsy52840.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_name=s140 +itsybitsy52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +itsybitsy52840.menu.debug.l0=Level 0 (Release) +itsybitsy52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +itsybitsy52840.menu.debug.l1=Level 1 (Error Message) +itsybitsy52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +itsybitsy52840.menu.debug.l2=Level 2 (Full Debug) +itsybitsy52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +itsybitsy52840.menu.debug.l3=Level 3 (Segger SystemView) +itsybitsy52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +itsybitsy52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# --------------------------------------------- +# Bluefruit Circuit Playground nRF52840 Express +# --------------------------------------------- +cplaynrf52840.name=Adafruit Circuit Playground Bluefruit + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cplaynrf52840.vid.0=0x239A +cplaynrf52840.pid.0=0x8045 +cplaynrf52840.vid.1=0x239A +cplaynrf52840.pid.1=0x0045 +cplaynrf52840.vid.2=0x239A +cplaynrf52840.pid.2=0x0046 +cplaynrf52840.vid.3=0x239A +cplaynrf52840.pid.3=0x8046 + +# Upload +cplaynrf52840.bootloader.tool=bootburn +cplaynrf52840.upload.tool=nrfutil +cplaynrf52840.upload.protocol=nrfutil +cplaynrf52840.upload.use_1200bps_touch=true +cplaynrf52840.upload.wait_for_upload_port=true +cplaynrf52840.upload.maximum_size=815104 +cplaynrf52840.upload.maximum_data_size=237568 + +# Build +cplaynrf52840.build.mcu=cortex-m4 +cplaynrf52840.build.f_cpu=64000000 +cplaynrf52840.build.board=NRF52840_CIRCUITPLAY +cplaynrf52840.build.core=nRF5 +cplaynrf52840.build.variant=circuitplayground_nrf52840 +cplaynrf52840.build.usb_manufacturer="Adafruit LLC" +cplaynrf52840.build.usb_product="Circuit Playground Bluefruit" +cplaynrf52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_CIRCUITPLAY {build.flags.usb} +cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld +cplaynrf52840.build.vid=0x239A +cplaynrf52840.build.pid=0x8045 + +# SofDevice Menu +cplaynrf52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cplaynrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cplaynrf52840.menu.debug.l0=Level 0 (Release) +cplaynrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cplaynrf52840.menu.debug.l1=Level 1 (Error Message) +cplaynrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cplaynrf52840.menu.debug.l2=Level 2 (Full Debug) +cplaynrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cplaynrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cplaynrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Clue nRF52840 +# --------------------------------------------- +cluenrf52840.name=Adafruit CLUE + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cluenrf52840.vid.0=0x239A +cluenrf52840.pid.0=0x8072 +cluenrf52840.vid.1=0x239A +cluenrf52840.pid.1=0x0072 +cluenrf52840.vid.2=0x239A +cluenrf52840.pid.2=0x0071 +cluenrf52840.vid.3=0x239A +cluenrf52840.pid.3=0x8071 + +# Upload +cluenrf52840.bootloader.tool=bootburn +cluenrf52840.upload.tool=nrfutil +cluenrf52840.upload.protocol=nrfutil +cluenrf52840.upload.use_1200bps_touch=true +cluenrf52840.upload.wait_for_upload_port=true +cluenrf52840.upload.maximum_size=815104 +cluenrf52840.upload.maximum_data_size=237568 + +# Build +cluenrf52840.build.mcu=cortex-m4 +cluenrf52840.build.f_cpu=64000000 +cluenrf52840.build.board=NRF52840_CLUE +cluenrf52840.build.core=nRF5 +cluenrf52840.build.variant=clue_nrf52840 +cluenrf52840.build.usb_manufacturer="Adafruit LLC" +cluenrf52840.build.usb_product="CLUE" +cluenrf52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_CLUE {build.flags.usb} +cluenrf52840.build.ldscript=nrf52840_s140_v6.ld +cluenrf52840.build.vid=0x239A +cluenrf52840.build.pid=0x8071 + +# SofDevice Menu +cluenrf52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cluenrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cluenrf52840.menu.debug.l0=Level 0 (Release) +cluenrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cluenrf52840.menu.debug.l1=Level 1 (Error Message) +cluenrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cluenrf52840.menu.debug.l2=Level 2 (Full Debug) +cluenrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cluenrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cluenrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cluenrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Bluefruit Metro nRF52840 Express +# ---------------------------------- +metro52840.name=Adafruit Bluefruit Metro nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +metro52840.vid.0=0x239A +metro52840.pid.0=0x803F +metro52840.vid.1=0x239A +metro52840.pid.1=0x003F +metro52840.vid.2=0x239A +metro52840.pid.2=0x0040 +metro52840.vid.3=0x239A +metro52840.pid.3=0x8040 + +# Upload +metro52840.bootloader.tool=bootburn +metro52840.upload.tool=nrfutil +metro52840.upload.protocol=nrfutil +metro52840.upload.use_1200bps_touch=true +metro52840.upload.wait_for_upload_port=true +metro52840.upload.maximum_size=815104 +metro52840.upload.maximum_data_size=237568 + +# Build +metro52840.build.mcu=cortex-m4 +metro52840.build.f_cpu=64000000 +metro52840.build.board=NRF52840_METRO +metro52840.build.core=nRF5 +metro52840.build.variant=metro_nrf52840_express +metro52840.build.usb_manufacturer="Adafruit LLC" +metro52840.build.usb_product="Metro nRF52840 Express" +metro52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_METRO {build.flags.usb} +metro52840.build.ldscript=nrf52840_s140_v6.ld +metro52840.build.vid=0x239A +metro52840.build.pid=0x803F + +# SofDevice Menu +metro52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_name=s140 +metro52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +metro52840.menu.debug.l0=Level 0 (Release) +metro52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +metro52840.menu.debug.l1=Level 1 (Error Message) +metro52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +metro52840.menu.debug.l2=Level 2 (Full Debug) +metro52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +metro52840.menu.debug.l3=Level 3 (Segger SystemView) +metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +metro52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + + + +# ------------------------------------------------------- +# +# Boards that aren't made by Adafruit +# +# ------------------------------------------------------- + + +# ---------------------------------- +# Nordic nRF52840DK (PCA10056) +# ---------------------------------- +pca10056.name=Nordic nRF52840DK (PCA10056) +pca10056.bootloader.tool=bootburn + +# Upload +pca10056.upload.tool=nrfutil +pca10056.upload.protocol=nrfutil +pca10056.upload.use_1200bps_touch=true +pca10056.upload.wait_for_upload_port=true +pca10056.upload.maximum_size=815104 +pca10056.upload.maximum_data_size=237568 + +# Build +pca10056.build.mcu=cortex-m4 +pca10056.build.f_cpu=64000000 +pca10056.build.board=NRF52840_PCA10056 +pca10056.build.core=nRF5 +pca10056.build.variant=pca10056 +pca10056.build.usb_manufacturer="Nordic" +pca10056.build.usb_product="nRF52840 DK" +pca10056.build.extra_flags=-DNRF52840_XXAA -DNRF52840_PCA10056 {build.flags.usb} +pca10056.build.ldscript=nrf52840_s140_v6.ld +pca10056.build.vid=0x239A +pca10056.build.pid=0x8029 + +# SofDevice Menu +pca10056.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_name=s140 +pca10056.menu.softdevice.s140v6.build.sd_version=6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +pca10056.menu.debug.l0=Level 0 (Release) +pca10056.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +pca10056.menu.debug.l1=Level 1 (Error Message) +pca10056.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +pca10056.menu.debug.l2=Level 2 (Full Debug) +pca10056.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +pca10056.menu.debug.l3=Level 3 (Segger SystemView) +pca10056.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +pca10056.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Particle Xenon +# ---------------------------------- +particle_xenon.name=Particle Xenon + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +particle_xenon.vid.0=0x239A +particle_xenon.pid.0=0x8029 +particle_xenon.vid.1=0x239A +particle_xenon.pid.1=0x0029 +particle_xenon.vid.2=0x239A +particle_xenon.pid.2=0x002A +particle_xenon.vid.3=0x239A +particle_xenon.pid.3=0x802A + +# Upload +particle_xenon.bootloader.tool=bootburn +particle_xenon.upload.tool=nrfutil +particle_xenon.upload.protocol=nrfutil +particle_xenon.upload.use_1200bps_touch=true +particle_xenon.upload.wait_for_upload_port=true +particle_xenon.upload.maximum_size=815104 +particle_xenon.upload.maximum_data_size=237568 + +# Build +particle_xenon.build.mcu=cortex-m4 +particle_xenon.build.f_cpu=64000000 +particle_xenon.build.board=PARTICLE_XENON +particle_xenon.build.core=nRF5 +particle_xenon.build.variant=particle_xenon +particle_xenon.build.usb_manufacturer="Particle Industries" +particle_xenon.build.usb_product="Particle Xenon" +particle_xenon.build.extra_flags=-DNRF52840_XXAA -DPARTICLE_XENON {build.flags.usb} +particle_xenon.build.ldscript=nrf52840_s140_v6.ld +particle_xenon.build.vid=0x239A +particle_xenon.build.pid=0x8029 + +# SofDevice Menu +particle_xenon.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_name=s140 +particle_xenon.menu.softdevice.s140v6.build.sd_version=6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +particle_xenon.menu.debug.l0=Level 0 (Release) +particle_xenon.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +particle_xenon.menu.debug.l1=Level 1 (Error Message) +particle_xenon.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +particle_xenon.menu.debug.l2=Level 2 (Full Debug) +particle_xenon.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +particle_xenon.menu.debug.l3=Level 3 (Segger SystemView) +particle_xenon.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +particle_xenon.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Raytac MDBT50Q - RX +# ---------------------------------- +mdbt50qrx.name=Raytac MDBT50Q-RX Dongle + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +mdbt50qrx.vid.0=0x239A +mdbt50qrx.pid.0=0x8029 +mdbt50qrx.vid.1=0x239A +mdbt50qrx.pid.1=0x0029 +mdbt50qrx.vid.2=0x239A +mdbt50qrx.pid.2=0x002A +mdbt50qrx.vid.3=0x239A +mdbt50qrx.pid.3=0x802A + +# Upload +mdbt50qrx.bootloader.tool=bootburn +mdbt50qrx.upload.tool=nrfutil +mdbt50qrx.upload.protocol=nrfutil +mdbt50qrx.upload.use_1200bps_touch=true +mdbt50qrx.upload.wait_for_upload_port=true +mdbt50qrx.upload.maximum_size=815104 +mdbt50qrx.upload.maximum_data_size=237568 + +# Build +mdbt50qrx.build.mcu=cortex-m4 +mdbt50qrx.build.f_cpu=64000000 +mdbt50qrx.build.board=MDBT50Q_RX +mdbt50qrx.build.core=nRF5 +mdbt50qrx.build.variant=raytac_mdbt50q_rx +mdbt50qrx.build.usb_manufacturer="Raytac Corporation" +mdbt50qrx.build.usb_product="Raytac MDBT50Q - RX" +mdbt50qrx.build.extra_flags=-DNRF52840_XXAA -DMDBT50Q_RX {build.flags.usb} +mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld +mdbt50qrx.build.vid=0x239A +mdbt50qrx.build.pid=0x8029 + +# SofDevice Menu +mdbt50qrx.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_name=s140 +mdbt50qrx.menu.softdevice.s140v6.build.sd_version=6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +mdbt50qrx.menu.debug.l0=Level 0 (Release) +mdbt50qrx.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +mdbt50qrx.menu.debug.l1=Level 1 (Error Message) +mdbt50qrx.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +mdbt50qrx.menu.debug.l2=Level 2 (Full Debug) +mdbt50qrx.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +mdbt50qrx.menu.debug.l3=Level 3 (Segger SystemView) +mdbt50qrx.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +mdbt50qrx.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# NINA B302 +# ---------------------------------- +ninab302.name=NINA B302 ublox + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +ninab302.vid.0=0x239A +ninab302.pid.0=0x8029 +ninab302.vid.1=0x239A +ninab302.pid.1=0x0029 +ninab302.vid.2=0x7239A +ninab302.pid.2=0x002A +ninab302.vid.3=0x239A +ninab302.pid.3=0x802A + +# Upload +ninab302.bootloader.tool=bootburn +ninab302.upload.tool=nrfutil +ninab302.upload.protocol=nrfutil +ninab302.upload.use_1200bps_touch=true +ninab302.upload.wait_for_upload_port=true +ninab302.upload.maximum_size=815104 +ninab302.upload.maximum_data_size=237568 + +# Build +ninab302.build.mcu=cortex-m4 +ninab302.build.f_cpu=64000000 +ninab302.build.board=NINA_B302_ublox +ninab302.build.core=nRF5 +ninab302.build.variant=NINA_B302_ublox +ninab302.build.usb_manufacturer="Nordic" +ninab302.build.usb_product="NINA B302 ublox" +ninab302.build.extra_flags=-DNRF52840_XXAA -DNINA_B302_ublox {build.flags.usb} +ninab302.build.ldscript=nrf52840_s140_v6.ld +ninab302.build.vid=0x239A +ninab302.build.pid=0x8029 + +# SofDevice Menu +ninab302.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_name=s140 +ninab302.menu.softdevice.s140v6.build.sd_version=6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +ninab302.menu.debug.l0=Level 0 (Release) +ninab302.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab302.menu.debug.l1=Level 1 (Error Message) +ninab302.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab302.menu.debug.l2=Level 2 (Full Debug) +ninab302.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab302.menu.debug.l3=Level 3 (Segger SystemView) +ninab302.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab302.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# NINA B112 +# ---------------------------------- +ninab112.name=NINA B112 ublox +ninab112.bootloader.tool=bootburn + +# Upload +ninab112.upload.tool=nrfutil +ninab112.upload.protocol=nrfutil +ninab112.upload.use_1200bps_touch=false +ninab112.upload.wait_for_upload_port=false +ninab112.upload.native_usb=false +ninab112.upload.maximum_size=290816 +ninab112.upload.maximum_data_size=52224 + +# Build +ninab112.build.mcu=cortex-m4 +ninab112.build.f_cpu=64000000 +ninab112.build.board=NINA_B112_ublox +ninab112.build.core=nRF5 +ninab112.build.variant=NINA_B112_ublox +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52832" +ninab112.build.extra_flags=-DNRF52832_XXAA -DNINA_B112_ublox -DNRF52 +ninab112.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +ninab112.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_name=s132 +ninab112.menu.softdevice.s132v6.build.sd_version=6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +ninab112.menu.debug.l0=Level 0 (Release) +ninab112.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab112.menu.debug.l1=Level 1 (Error Message) +ninab112.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab112.menu.debug.l2=Level 2 (Full Debug) +ninab112.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab112.menu.debug.l3=Level 3 (Segger SystemView) +ninab112.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab112.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/cores/nRF5/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/cores/nRF5/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/cores/nRF5/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/cores/nRF5/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/cores/nRF5/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/cores/nRF5/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/cores/nRF5/Udp.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/cores/nRF5/Udp.h new file mode 100644 index 0000000..016042a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/cores/nRF5/Udp.h @@ -0,0 +1,92 @@ +/* + * Udp.cpp: Library to send/receive UDP packets. + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + */ + +#ifndef udp_h +#define udp_h + +#include +#include + +class UDP : public Stream { + +public: + virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + + // KH, add virtual function to support Multicast, necessary for many services (MDNS, etc.) + virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + + virtual void stop() =0; // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port) =0; + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port) =0; + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket() =0; + // Write a single byte into the packet + virtual size_t write(uint8_t) =0; + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size) =0; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket() =0; + // Number of bytes remaining in the current packet + virtual int available() =0; + // Read a single byte from the current packet + virtual int read() =0; + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len) =0; + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) =0; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek() =0; + virtual void flush() =0; // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() =0; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() =0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/platform.txt new file mode 100644 index 0000000..6c7ed43 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/platform.txt @@ -0,0 +1,164 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All rights reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +name=Adafruit nRF52 Boards +version=0.20.5 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-pointer-arith + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD +# KH, Error here to use gcc, mjust use g++ +#compiler.c.elf.cmd=arm-none-eabi-gcc +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Ofast -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2bin.flags=-O binary +compiler.elf2bin.cmd=arm-none-eabi-objcopy +compiler.elf2hex.flags=-O ihex +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb {build.float_flags} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align --specs=nano.specs --specs=nosys.specs +compiler.size.cmd=arm-none-eabi-size + +# this can be overriden in boards.txt +build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float +build.debug_flags=-DCFG_DEBUG=0 +build.logger_flags=-DCFG_LOGGER=1 +build.sysview_flags=-DCFG_SYSVIEW=0 + +# common compiler for nrf +rtos.path={build.core.path}/freertos +nordic.path={build.core.path}/nordic + +# build.logger_flags and build.sysview_flags and intentionally empty, +# to allow modification via a user's own boards.local.txt or platform.local.txt files. +build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DLFS_NAME_MAX=64 -Ofast {build.debug_flags} {build.logger_flags} {build.sysview_flags} "-I{build.core.path}/cmsis/Core/Include" "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" + +# usb flags +build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2bin.extra_flags= +compiler.elf2hex.extra_flags= + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Create archives +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-L{build.core.path}/linker" "-T{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} -Wl,--start-group -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +#recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2bin.cmd}" {compiler.elf2bin.flags} {compiler.elf2bin.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +## Create dfu package zip file +recipe.objcopy.zip.pattern="{tools.nrfutil.cmd}" dfu genpkg --dev-type 0x0052 --sd-req {build.sd_fwid} --application "{build.path}/{build.project_name}.hex" "{build.path}/{build.project_name}.zip" + +## Create uf2 file +#recipe.objcopy.uf2.pattern=python "{runtime.platform.path}/tools/uf2conv/uf2conv.py" -f 0xADA52840 -c -o "{build.path}/{build.project_name}.uf2" "{build.path}/{build.project_name}.hex" + +## Save bin +recipe.output.tmp_file_bin={build.project_name}.bin +recipe.output.save_file_bin={build.project_name}.save.bin + +## Save hex +recipe.output.tmp_file_hex={build.project_name}.hex +recipe.output.save_file_hexu={build.project_name}.save.hex + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + +## Export Compiled Binary +recipe.output.tmp_file={build.project_name}.hex +recipe.output.save_file={build.project_name}.{build.variant}.hex + +#*************************************************** +# adafruit-nrfutil for uploading +# https://github.com/adafruit/Adafruit_nRF52_nrfutil +# pre-built binaries are provided for macos and windows +#*************************************************** +tools.nrfutil.cmd=adafruit-nrfutil +tools.nrfutil.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe +tools.nrfutil.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil + +tools.nrfutil.upload.params.verbose=--verbose +tools.nrfutil.upload.params.quiet= +tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.path}/{build.project_name}.zip" -p {serial.port} -b 115200 --singlebank + +#*************************************************** +# Burning bootloader with either jlink or nrfutil +#*************************************************** + +# Bootloader version +tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.3.2_{build.sd_name}_{build.sd_version} + +tools.bootburn.bootloader.params.verbose= +tools.bootburn.bootloader.params.quiet= +tools.bootburn.bootloader.pattern={program.burn_pattern} + +# erase flash page while programming +tools.bootburn.erase.params.verbose= +tools.bootburn.erase.params.quiet= +tools.bootburn.erase.pattern= + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/variants/NINA_B112_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/variants/NINA_B112_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/variants/NINA_B112_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/variants/NINA_B112_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/variants/NINA_B112_ublox/variant.cpp new file mode 100644 index 0000000..f43f3a4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/variants/NINA_B112_ublox/variant.cpp @@ -0,0 +1,59 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" + +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +const uint32_t g_ADigitalPinMap[] = { + // D0 .. D13 + 5, // D0 is P0.05 (UART RX) + 6, // D1 is P0.06 (UART TX) + 7, // D2 is P0.07 + 31, // D3 is P0.31 + 18, // D4 is P0.18 (LED Blue) + 99, // D5 (NC) + 9, // D6 is P0.09 NFC1 + 10, // D7 is P0.10 (Button) NFC2 + 99, // D8 (NC) + 8, // D9 is P0.08 + 11, // D10 is P0.11 CS + 13, // D11 is P0.13 MOSI + 12, // D12 is P0.12 MISO + 14, // D13 is P0.14 SCK + //I2C + 2, // D14 is P0.2 (SDA) + 3, // D15 is P0.3 (SCL) + // D16 .. D21 (aka A0 .. A5) + 3, // D16 is P0.03 (A0) + 2, // D17 is P0.02 (A1) + 4, // D18 is P0.04 (A2) + 30, // D19 is P0.30 (A3) SW2 + 29, // D20 is P0.29 (A4) + 28, // D21 is P0.28 (A5) + 9, // P0.09 NFC + 10, // P0.10 NFC + 16, // SW1 (LED Green) +}; \ No newline at end of file diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/variants/NINA_B112_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/variants/NINA_B112_ublox/variant.h new file mode 100644 index 0000000..833cbf6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/variants/NINA_B112_ublox/variant.h @@ -0,0 +1,172 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +#ifndef _VARIANT_NINA_B112_UBLOX_ +#define _VARIANT_NINA_B112_UBLOX_ + +#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \ + .rc_ctiv = 0, \ +.rc_temp_ctiv = 0, \ +.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM} + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (32u) +#define NUM_DIGITAL_PINS (32u) +#define NUM_ANALOG_INPUTS (6u) +#define NUM_ANALOG_OUTPUTS (0u) + +// LEDs +#define PIN_LED LED1 +#define LED_BUILTIN PIN_LED + +//LEDs onboard +#define LED1 (0) // Red +#define LED2 (24) // Green/SW1 +#define LED3 (4) // Blue + +#define LED_STATE_ON 1 // State when LED is litted + +//Switch +#define SW1 (24) +#define SW2 (19) + +// NFC +#define PIN_NFC_1 (6) // P0.9 +#define PIN_NFC_2 (7) // P0.10 + +/* + * Analog pins + */ +#define PIN_A0 (16) // P0.03 +#define PIN_A1 (17) // P0.02 +#define PIN_A2 (18) // P0.04 +#define PIN_A3 (19) // P0.30 +#define PIN_A4 (20) // P0.29 +#define PIN_A5 (21) // P0.28 + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_D0 (0) // P0.05 +#define PIN_D1 (1) // P0.06 +#define PIN_D2 (2) // P0.07 +#define PIN_D3 (4) // P0.31 +#define PIN_D4 (5) // P0.18 +#define PIN_D6 (6) // P0.09 +#define PIN_D7 (7) // P0.10 +#define PIN_D9 (9) // P0.08 +#define PIN_D10 (11) // P0.11 +#define PIN_D11 (13) // P0.13 +#define PIN_D12 (12) // P0.12 +#define PIN_D13 (14) // P0.14 +#define PIN_D14 (2) // P0.02 +#define PIN_D15 (3) // P0.03 + +static const uint8_t D0 = PIN_D0 ; +static const uint8_t D1 = PIN_D1 ; +static const uint8_t D2 = PIN_D2 ; +static const uint8_t D3 = PIN_D3 ; +static const uint8_t D4 = PIN_D4 ; +static const uint8_t D6 = PIN_D6 ; +static const uint8_t D7 = PIN_D7 ; +static const uint8_t D9 = PIN_D9 ; +static const uint8_t D10 = PIN_D10 ; +static const uint8_t D11 = PIN_D11 ; +static const uint8_t D12 = PIN_D12 ; +static const uint8_t D13 = PIN_D13 ; +static const uint8_t D14 = PIN_D14 ; +static const uint8_t D15 = PIN_D15 ; + +// Other pins +//static const uint8_t AREF = PIN_AREF; + +//#define PIN_AREF (24) +//#define PIN_VBAT PIN_A7 + +/* + * Serial interfaces + */ +#define PIN_SERIAL_RX (0) // P0.05 +#define PIN_SERIAL_TX (1) // P0.06 +#define PIN_SERIAL_CTS (2) // P0.07 +#define PIN_SERIAL_RTS (3) // P0.31 +#define PIN_SERIAL_DTR (28) // P0.28 +#define PIN_SERIAL_DSR (29) // P0.29 + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (12) // P0.12 +#define PIN_SPI_MOSI (11) // P0.13 +#define PIN_SPI_SCK (13) // P0.14 + +static const uint8_t SS = 10 ; // P0.11 +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (14) // P0.02 +#define PIN_WIRE_SCL (15) // P0.03 + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + + +#endif //_VARIANT_NINA_B112_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/variants/NINA_B302_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/variants/NINA_B302_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/variants/NINA_B302_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/variants/NINA_B302_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/variants/NINA_B302_ublox/variant.cpp new file mode 100644 index 0000000..8b4df2e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/variants/NINA_B302_ublox/variant.cpp @@ -0,0 +1,87 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 + 29, // D0 is P0.29 (UART RX) + 45, // D1 is P1.13 (UART TX) + 44, // D2 is P1.12 (NFC2) + 31, // D3 is P0.31 (LED1) + 13, // D4 is P0.13 (LED2) + 11, // D5 is P0.11 + 9, // D6 is P0.09 + 10, // D7 is P0.10 (Button) + 41, // D8 is P1.09 + 12, // D9 is P0.12 + 14, // D10 is P0.14 + 15, // D11 is P0.15 + 32, // D12 is P1.00 + 7, // D13 is P0.07 + + // D14 .. D21 (aka A0 .. A5) + 4, // D14 is P0.04 (A0) + 30, // D15 is P0.30 (A1) + 5, // D16 is P0.05 (A2) + 2, // D17 is P0.02 (A3) + 28, // D18 is P0.28 (A4) + 3, // D19 is P0.03 (A5) + + // D20 .. D21 (aka I2C pins) + 16, // D20 is P0.16 (SDA) + 24, // D21 is P0.24 (SCL) + + // QSPI pins (not exposed via any header / test point) + 19, // D22 is P0.19 (QSPI CLK) + 17, // D23 is P0.17 (QSPI CS) + 20, // D24 is P0.20 (QSPI Data 0) + 21, // D25 is P0.21 (QSPI Data 1) + 22, // D26 is P0.22 (QSPI Data 2) + 26, // D27 is P0.23 (QSPI Data 3) + + 40, // D28 is P1.08 - IO34 + 41, // D29 is P1.01 - IO35 + 44, // D30 is P1.02 - IO36 + 45, // D31 is P1.03 - IO37 + 42, // D32 is P1.10 - IO38 + 43, // D33 is P1.11 - IO39 + 47, // D34 is P1.15 - IO40 + 46, // D35 is P1.14 - IO41 + 26, // D36 is P0.26 - IO42 + 6, // D37 is P0.6 - IO43 + 27, // D38 is P0.27 - IO44 +}; + +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/variants/NINA_B302_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/variants/NINA_B302_ublox/variant.h new file mode 100644 index 0000000..a69575f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.20.5/variants/NINA_B302_ublox/variant.h @@ -0,0 +1,149 @@ + /* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#ifndef _VARIANT_NINA_B302_UBLOX_ +#define _VARIANT_NINA_B302_UBLOX_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus +// Number of pins defined in PinDescription array +#define PINS_COUNT (40) +#define NUM_DIGITAL_PINS (34) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (3) +#define PIN_LED2 (4) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_RED PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +/* + * Buttons + */ +#define PIN_BUTTON1 (7) + +/* + * Analog pins + */ +#define PIN_A0 (14) +#define PIN_A1 (15) +#define PIN_A2 (16) +#define PIN_A3 (17) +#define PIN_A4 (18) +#define PIN_A5 (19) + +#define D0 (0) +#define D1 (1) +#define D2 (2) +#define D3 (3) +#define D4 (4) +#define D5 (5) +#define D6 (6) +#define D7 (7) +#define D8 (8) +#define D9 (9) +#define D10 (10) +#define D11 (11) +#define D12 (12) +#define D13 (13) + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_NFC1 (31) +#define PIN_NFC2 (2) + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (0) +#define PIN_SERIAL1_TX (1) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (22) //24 original +#define PIN_SPI_MOSI (23) //25 original +#define PIN_SPI_SCK (24) //26 original + +static const uint8_t SS = (13); +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (20) +#define PIN_WIRE_SCL (21) + +// QSPI Pins +#define PIN_QSPI_SCK 22 +#define PIN_QSPI_CS 23 +#define PIN_QSPI_IO0 24 +#define PIN_QSPI_IO1 25 +#define PIN_QSPI_IO2 26 +#define PIN_QSPI_IO3 27 + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES GD25Q16C +#define EXTERNAL_FLASH_USE_QSPI + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif //_VARIANT_NINA_B302_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/boards.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/boards.txt new file mode 100644 index 0000000..762f02f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/boards.txt @@ -0,0 +1,649 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +menu.softdevice=Bootloader +menu.debug=Debug + +# ---------------------------------- +# Bluefruit Feather nRF52832 +# ---------------------------------- +feather52832.name=Adafruit Feather nRF52832 +feather52832.bootloader.tool=bootburn + +# Upload +feather52832.upload.tool=nrfutil +feather52832.upload.protocol=nrfutil +feather52832.upload.use_1200bps_touch=false +feather52832.upload.wait_for_upload_port=false +feather52832.upload.native_usb=false +feather52832.upload.maximum_size=290816 +feather52832.upload.maximum_data_size=52224 + +# Build +feather52832.build.mcu=cortex-m4 +feather52832.build.f_cpu=64000000 +feather52832.build.board=NRF52832_FEATHER +feather52832.build.core=nRF5 +feather52832.build.variant=feather_nrf52832 +feather52832.build.usb_manufacturer="Adafruit LLC" +feather52832.build.usb_product="Feather nRF52832" +feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52 +feather52832.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +feather52832.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_name=s132 +feather52832.menu.softdevice.s132v6.build.sd_version=6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +feather52832.menu.debug.l0=Level 0 (Release) +feather52832.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52832.menu.debug.l1=Level 1 (Error Message) +feather52832.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52832.menu.debug.l2=Level 2 (Full Debug) +feather52832.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52832.menu.debug.l3=Level 3 (Segger SystemView) +feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52832.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Bluefruit Feather nRF52840 Express +# ---------------------------------- +feather52840.name=Adafruit Feather nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840.vid.0=0x239A +feather52840.pid.0=0x8029 +feather52840.vid.1=0x239A +feather52840.pid.1=0x0029 +feather52840.vid.2=0x239A +feather52840.pid.2=0x002A +feather52840.vid.3=0x239A +feather52840.pid.3=0x802A + +# Upload +feather52840.bootloader.tool=bootburn +feather52840.upload.tool=nrfutil +feather52840.upload.protocol=nrfutil +feather52840.upload.use_1200bps_touch=true +feather52840.upload.wait_for_upload_port=true +feather52840.upload.maximum_size=815104 +feather52840.upload.maximum_data_size=237568 + +# Build +feather52840.build.mcu=cortex-m4 +feather52840.build.f_cpu=64000000 +feather52840.build.board=NRF52840_FEATHER +feather52840.build.core=nRF5 +feather52840.build.variant=feather_nrf52840_express +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52840 Express" +feather52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +feather52840.build.ldscript=nrf52840_s140_v6.ld +feather52840.build.vid=0x239A +feather52840.build.pid=0x8029 + +# SofDevice Menu +feather52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_name=s140 +feather52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840.menu.debug.l0=Level 0 (Release) +feather52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840.menu.debug.l1=Level 1 (Error Message) +feather52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840.menu.debug.l2=Level 2 (Full Debug) +feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840.menu.debug.l3=Level 3 (Segger SystemView) +feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# ---------------------------------- +# Feather Bluefruit sense +# ---------------------------------- +feather52840sense.name=Adafruit Feather Bluefruit Sense + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840sense.vid.0=0x239A +feather52840sense.pid.0=0x8087 +feather52840sense.vid.1=0x239A +feather52840sense.pid.1=0x0087 +feather52840sense.vid.2=0x239A +feather52840sense.pid.2=0x0088 +feather52840sense.vid.3=0x239A +feather52840sense.pid.3=0x8088 + +# Upload +feather52840sense.bootloader.tool=bootburn +feather52840sense.upload.tool=nrfutil +feather52840sense.upload.protocol=nrfutil +feather52840sense.upload.use_1200bps_touch=true +feather52840sense.upload.wait_for_upload_port=true +feather52840sense.upload.maximum_size=815104 +feather52840sense.upload.maximum_data_size=237568 + +# Build +feather52840sense.build.mcu=cortex-m4 +feather52840sense.build.f_cpu=64000000 +feather52840sense.build.board=NRF52840_FEATHER_SENSE +feather52840sense.build.core=nRF5 +feather52840sense.build.variant=feather_nrf52840_sense +feather52840sense.build.usb_manufacturer="Adafruit LLC" +feather52840sense.build.usb_product="Feather nRF52840 Sense" +feather52840sense.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +feather52840sense.build.ldscript=nrf52840_s140_v6.ld +feather52840sense.build.vid=0x239A +feather52840sense.build.pid=0x8087 + +# SofDevice Menu +feather52840sense.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_name=s140 +feather52840sense.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840sense.menu.debug.l0=Level 0 (Release) +feather52840sense.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840sense.menu.debug.l1=Level 1 (Error Message) +feather52840sense.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840sense.menu.debug.l2=Level 2 (Full Debug) +feather52840sense.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840sense.menu.debug.l3=Level 3 (Segger SystemView) +feather52840sense.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840sense.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Bluefruit ItsyBitsy nRF52840 Express +# --------------------------------------------- +itsybitsy52840.name=Adafruit ItsyBitsy nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +itsybitsy52840.vid.0=0x239A +itsybitsy52840.pid.0=0x8051 +itsybitsy52840.vid.1=0x239A +itsybitsy52840.pid.1=0x0051 +itsybitsy52840.vid.2=0x239A +itsybitsy52840.pid.2=0x0052 +itsybitsy52840.vid.3=0x239A +itsybitsy52840.pid.3=0x8052 + +# Upload +itsybitsy52840.bootloader.tool=bootburn +itsybitsy52840.upload.tool=nrfutil +itsybitsy52840.upload.protocol=nrfutil +itsybitsy52840.upload.use_1200bps_touch=true +itsybitsy52840.upload.wait_for_upload_port=true +itsybitsy52840.upload.maximum_size=815104 +itsybitsy52840.upload.maximum_data_size=237568 + +# Build +itsybitsy52840.build.mcu=cortex-m4 +itsybitsy52840.build.f_cpu=64000000 +itsybitsy52840.build.board=NRF52840_ITSYBITSY +itsybitsy52840.build.core=nRF5 +itsybitsy52840.build.variant=itsybitsy_nrf52840_express +itsybitsy52840.build.usb_manufacturer="Adafruit LLC" +itsybitsy52840.build.usb_product="ItsyBitsy nRF52840 Express" +itsybitsy52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52_ITSYBITSY {build.flags.usb} +itsybitsy52840.build.ldscript=nrf52840_s140_v6.ld +itsybitsy52840.build.vid=0x239A +itsybitsy52840.build.pid=0x8051 + +# SofDevice Menu +itsybitsy52840.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_name=s140 +itsybitsy52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +itsybitsy52840.menu.debug.l0=Level 0 (Release) +itsybitsy52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +itsybitsy52840.menu.debug.l1=Level 1 (Error Message) +itsybitsy52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +itsybitsy52840.menu.debug.l2=Level 2 (Full Debug) +itsybitsy52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +itsybitsy52840.menu.debug.l3=Level 3 (Segger SystemView) +itsybitsy52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +itsybitsy52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# --------------------------------------------- +# Bluefruit Circuit Playground nRF52840 Express +# --------------------------------------------- +cplaynrf52840.name=Adafruit Circuit Playground Bluefruit + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cplaynrf52840.vid.0=0x239A +cplaynrf52840.pid.0=0x8045 +cplaynrf52840.vid.1=0x239A +cplaynrf52840.pid.1=0x0045 +cplaynrf52840.vid.2=0x239A +cplaynrf52840.pid.2=0x0046 +cplaynrf52840.vid.3=0x239A +cplaynrf52840.pid.3=0x8046 + +# Upload +cplaynrf52840.bootloader.tool=bootburn +cplaynrf52840.upload.tool=nrfutil +cplaynrf52840.upload.protocol=nrfutil +cplaynrf52840.upload.use_1200bps_touch=true +cplaynrf52840.upload.wait_for_upload_port=true +cplaynrf52840.upload.maximum_size=815104 +cplaynrf52840.upload.maximum_data_size=237568 + +# Build +cplaynrf52840.build.mcu=cortex-m4 +cplaynrf52840.build.f_cpu=64000000 +cplaynrf52840.build.board=NRF52840_CIRCUITPLAY +cplaynrf52840.build.core=nRF5 +cplaynrf52840.build.variant=circuitplayground_nrf52840 +cplaynrf52840.build.usb_manufacturer="Adafruit LLC" +cplaynrf52840.build.usb_product="Circuit Playground Bluefruit" +cplaynrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld +cplaynrf52840.build.vid=0x239A +cplaynrf52840.build.pid=0x8045 + +# SofDevice Menu +cplaynrf52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cplaynrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cplaynrf52840.menu.debug.l0=Level 0 (Release) +cplaynrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cplaynrf52840.menu.debug.l1=Level 1 (Error Message) +cplaynrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cplaynrf52840.menu.debug.l2=Level 2 (Full Debug) +cplaynrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cplaynrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cplaynrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Clue nRF52840 +# --------------------------------------------- +cluenrf52840.name=Adafruit CLUE + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cluenrf52840.vid.0=0x239A +cluenrf52840.pid.0=0x8072 +cluenrf52840.vid.1=0x239A +cluenrf52840.pid.1=0x0072 +cluenrf52840.vid.2=0x239A +cluenrf52840.pid.2=0x0071 +cluenrf52840.vid.3=0x239A +cluenrf52840.pid.3=0x8071 + +# Upload +cluenrf52840.bootloader.tool=bootburn +cluenrf52840.upload.tool=nrfutil +cluenrf52840.upload.protocol=nrfutil +cluenrf52840.upload.use_1200bps_touch=true +cluenrf52840.upload.wait_for_upload_port=true +cluenrf52840.upload.maximum_size=815104 +cluenrf52840.upload.maximum_data_size=237568 + +# Build +cluenrf52840.build.mcu=cortex-m4 +cluenrf52840.build.f_cpu=64000000 +cluenrf52840.build.board=NRF52840_CLUE +cluenrf52840.build.core=nRF5 +cluenrf52840.build.variant=clue_nrf52840 +cluenrf52840.build.usb_manufacturer="Adafruit LLC" +cluenrf52840.build.usb_product="CLUE" +cluenrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +cluenrf52840.build.ldscript=nrf52840_s140_v6.ld +cluenrf52840.build.vid=0x239A +cluenrf52840.build.pid=0x8071 + +# SofDevice Menu +cluenrf52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cluenrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cluenrf52840.menu.debug.l0=Level 0 (Release) +cluenrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cluenrf52840.menu.debug.l1=Level 1 (Error Message) +cluenrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cluenrf52840.menu.debug.l2=Level 2 (Full Debug) +cluenrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cluenrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cluenrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cluenrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Bluefruit Metro nRF52840 Express +# ---------------------------------- +metro52840.name=Adafruit Bluefruit Metro nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +metro52840.vid.0=0x239A +metro52840.pid.0=0x803F +metro52840.vid.1=0x239A +metro52840.pid.1=0x003F +metro52840.vid.2=0x239A +metro52840.pid.2=0x0040 +metro52840.vid.3=0x239A +metro52840.pid.3=0x8040 + +# Upload +metro52840.bootloader.tool=bootburn +metro52840.upload.tool=nrfutil +metro52840.upload.protocol=nrfutil +metro52840.upload.use_1200bps_touch=true +metro52840.upload.wait_for_upload_port=true +metro52840.upload.maximum_size=815104 +metro52840.upload.maximum_data_size=237568 + +# Build +metro52840.build.mcu=cortex-m4 +metro52840.build.f_cpu=64000000 +metro52840.build.board=NRF52840_METRO +metro52840.build.core=nRF5 +metro52840.build.variant=metro_nrf52840_express +metro52840.build.usb_manufacturer="Adafruit LLC" +metro52840.build.usb_product="Metro nRF52840 Express" +metro52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +metro52840.build.ldscript=nrf52840_s140_v6.ld +metro52840.build.vid=0x239A +metro52840.build.pid=0x803F + +# SofDevice Menu +metro52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_name=s140 +metro52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +metro52840.menu.debug.l0=Level 0 (Release) +metro52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +metro52840.menu.debug.l1=Level 1 (Error Message) +metro52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +metro52840.menu.debug.l2=Level 2 (Full Debug) +metro52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +metro52840.menu.debug.l3=Level 3 (Segger SystemView) +metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +metro52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + + + +# ------------------------------------------------------- +# +# Boards that aren't made by Adafruit +# +# ------------------------------------------------------- + + +# ---------------------------------- +# Nordic nRF52840DK (PCA10056) +# ---------------------------------- +pca10056.name=Nordic nRF52840DK (PCA10056) +pca10056.bootloader.tool=bootburn + +# Upload +pca10056.upload.tool=nrfutil +pca10056.upload.protocol=nrfutil +pca10056.upload.use_1200bps_touch=true +pca10056.upload.wait_for_upload_port=true +pca10056.upload.maximum_size=815104 +pca10056.upload.maximum_data_size=237568 + +# Build +pca10056.build.mcu=cortex-m4 +pca10056.build.f_cpu=64000000 +pca10056.build.board=NRF52840_PCA10056 +pca10056.build.core=nRF5 +pca10056.build.variant=pca10056 +pca10056.build.usb_manufacturer="Nordic" +pca10056.build.usb_product="nRF52840 DK" +pca10056.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +pca10056.build.ldscript=nrf52840_s140_v6.ld +pca10056.build.vid=0x239A +pca10056.build.pid=0x8029 + +# SofDevice Menu +pca10056.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_name=s140 +pca10056.menu.softdevice.s140v6.build.sd_version=6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +pca10056.menu.debug.l0=Level 0 (Release) +pca10056.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +pca10056.menu.debug.l1=Level 1 (Error Message) +pca10056.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +pca10056.menu.debug.l2=Level 2 (Full Debug) +pca10056.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +pca10056.menu.debug.l3=Level 3 (Segger SystemView) +pca10056.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +pca10056.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Particle Xenon +# ---------------------------------- +particle_xenon.name=Particle Xenon + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +particle_xenon.vid.0=0x239A +particle_xenon.pid.0=0x8029 +particle_xenon.vid.1=0x239A +particle_xenon.pid.1=0x0029 +particle_xenon.vid.2=0x239A +particle_xenon.pid.2=0x002A +particle_xenon.vid.3=0x239A +particle_xenon.pid.3=0x802A + +# Upload +particle_xenon.bootloader.tool=bootburn +particle_xenon.upload.tool=nrfutil +particle_xenon.upload.protocol=nrfutil +particle_xenon.upload.use_1200bps_touch=true +particle_xenon.upload.wait_for_upload_port=true +particle_xenon.upload.maximum_size=815104 +particle_xenon.upload.maximum_data_size=237568 + +# Build +particle_xenon.build.mcu=cortex-m4 +particle_xenon.build.f_cpu=64000000 +particle_xenon.build.board=PARTICLE_XENON +particle_xenon.build.core=nRF5 +particle_xenon.build.variant=particle_xenon +particle_xenon.build.usb_manufacturer="Particle Industries" +particle_xenon.build.usb_product="Particle Xenon" +particle_xenon.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +particle_xenon.build.ldscript=nrf52840_s140_v6.ld +particle_xenon.build.vid=0x239A +particle_xenon.build.pid=0x8029 + +# SofDevice Menu +particle_xenon.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_name=s140 +particle_xenon.menu.softdevice.s140v6.build.sd_version=6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +particle_xenon.menu.debug.l0=Level 0 (Release) +particle_xenon.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +particle_xenon.menu.debug.l1=Level 1 (Error Message) +particle_xenon.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +particle_xenon.menu.debug.l2=Level 2 (Full Debug) +particle_xenon.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +particle_xenon.menu.debug.l3=Level 3 (Segger SystemView) +particle_xenon.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +particle_xenon.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Raytac MDBT50Q - RX +# ---------------------------------- +mdbt50qrx.name=Raytac MDBT50Q-RX Dongle + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +mdbt50qrx.vid.0=0x239A +mdbt50qrx.pid.0=0x8029 +mdbt50qrx.vid.1=0x239A +mdbt50qrx.pid.1=0x0029 +mdbt50qrx.vid.2=0x239A +mdbt50qrx.pid.2=0x002A +mdbt50qrx.vid.3=0x239A +mdbt50qrx.pid.3=0x802A + +# Upload +mdbt50qrx.bootloader.tool=bootburn +mdbt50qrx.upload.tool=nrfutil +mdbt50qrx.upload.protocol=nrfutil +mdbt50qrx.upload.use_1200bps_touch=true +mdbt50qrx.upload.wait_for_upload_port=true +mdbt50qrx.upload.maximum_size=815104 +mdbt50qrx.upload.maximum_data_size=237568 + +# Build +mdbt50qrx.build.mcu=cortex-m4 +mdbt50qrx.build.f_cpu=64000000 +mdbt50qrx.build.board=MDBT50Q_RX +mdbt50qrx.build.core=nRF5 +mdbt50qrx.build.variant=raytac_mdbt50q_rx +mdbt50qrx.build.usb_manufacturer="Raytac Corporation" +mdbt50qrx.build.usb_product="Raytac MDBT50Q - RX" +mdbt50qrx.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld +mdbt50qrx.build.vid=0x239A +mdbt50qrx.build.pid=0x8029 + +# SofDevice Menu +mdbt50qrx.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_name=s140 +mdbt50qrx.menu.softdevice.s140v6.build.sd_version=6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +mdbt50qrx.menu.debug.l0=Level 0 (Release) +mdbt50qrx.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +mdbt50qrx.menu.debug.l1=Level 1 (Error Message) +mdbt50qrx.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +mdbt50qrx.menu.debug.l2=Level 2 (Full Debug) +mdbt50qrx.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +mdbt50qrx.menu.debug.l3=Level 3 (Segger SystemView) +mdbt50qrx.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +mdbt50qrx.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# NINA B302 +# ---------------------------------- +ninab302.name=NINA B302 ublox + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +ninab302.vid.0=0x239A +ninab302.pid.0=0x8029 +ninab302.vid.1=0x239A +ninab302.pid.1=0x0029 +ninab302.vid.2=0x7239A +ninab302.pid.2=0x002A +ninab302.vid.3=0x239A +ninab302.pid.3=0x802A + +# Upload +ninab302.bootloader.tool=bootburn +ninab302.upload.tool=nrfutil +ninab302.upload.protocol=nrfutil +ninab302.upload.use_1200bps_touch=true +ninab302.upload.wait_for_upload_port=true +ninab302.upload.maximum_size=815104 +ninab302.upload.maximum_data_size=237568 + +# Build +ninab302.build.mcu=cortex-m4 +ninab302.build.f_cpu=64000000 +ninab302.build.board=NINA_B302_ublox +ninab302.build.core=nRF5 +ninab302.build.variant=NINA_B302_ublox +ninab302.build.usb_manufacturer="Nordic" +ninab302.build.usb_product="NINA B302 ublox" +ninab302.build.extra_flags=-DNRF52840_XXAA -DNINA_B302_ublox {build.flags.usb} +ninab302.build.ldscript=nrf52840_s140_v6.ld +ninab302.build.vid=0x239A +ninab302.build.pid=0x8029 + +# SofDevice Menu +ninab302.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_name=s140 +ninab302.menu.softdevice.s140v6.build.sd_version=6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +ninab302.menu.debug.l0=Level 0 (Release) +ninab302.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab302.menu.debug.l1=Level 1 (Error Message) +ninab302.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab302.menu.debug.l2=Level 2 (Full Debug) +ninab302.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab302.menu.debug.l3=Level 3 (Segger SystemView) +ninab302.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab302.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# NINA B112 +# ---------------------------------- +ninab112.name=NINA B112 ublox +ninab112.bootloader.tool=bootburn + +# Upload +ninab112.upload.tool=nrfutil +ninab112.upload.protocol=nrfutil +ninab112.upload.use_1200bps_touch=false +ninab112.upload.wait_for_upload_port=false +ninab112.upload.native_usb=false +ninab112.upload.maximum_size=290816 +ninab112.upload.maximum_data_size=52224 + +# Build +ninab112.build.mcu=cortex-m4 +ninab112.build.f_cpu=64000000 +ninab112.build.board=NINA_B112_ublox +ninab112.build.core=nRF5 +ninab112.build.variant=NINA_B112_ublox +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52832" +ninab112.build.extra_flags=-DNRF52832_XXAA -DNINA_B112_ublox -DNRF52 +ninab112.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +ninab112.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_name=s132 +ninab112.menu.softdevice.s132v6.build.sd_version=6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +ninab112.menu.debug.l0=Level 0 (Release) +ninab112.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab112.menu.debug.l1=Level 1 (Error Message) +ninab112.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab112.menu.debug.l2=Level 2 (Full Debug) +ninab112.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab112.menu.debug.l3=Level 3 (Segger SystemView) +ninab112.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab112.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/cores/nRF5/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/cores/nRF5/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/cores/nRF5/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/cores/nRF5/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/cores/nRF5/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/cores/nRF5/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/cores/nRF5/Udp.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/cores/nRF5/Udp.h new file mode 100644 index 0000000..cc814d3 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/cores/nRF5/Udp.h @@ -0,0 +1,92 @@ +/* + * Udp.cpp: Library to send/receive UDP packets. + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + */ + +#ifndef udp_h +#define udp_h + +#include +#include + +class UDP : public Stream { + +public: + virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + + // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) + virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + + virtual void stop() =0; // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port) =0; + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port) =0; + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket() =0; + // Write a single byte into the packet + virtual size_t write(uint8_t) =0; + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size) =0; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket() =0; + // Number of bytes remaining in the current packet + virtual int available() =0; + // Read a single byte from the current packet + virtual int read() =0; + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len) =0; + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) =0; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek() =0; + virtual void flush() =0; // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() =0; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() =0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/platform.txt new file mode 100644 index 0000000..3de4b45 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/platform.txt @@ -0,0 +1,164 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All rights reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +name=Adafruit nRF52 Boards +version=0.21.0 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-pointer-arith + +# Allow changing optimization settings via platform.local.txt / boards.local.txt +compiler.optimization_flag=-Ofast + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD + +# KH, Error here to use gcc, must use g++ +#compiler.c.elf.cmd=arm-none-eabi-gcc +compiler.c.elf.cmd=arm-none-eabi-g++ + +compiler.c.elf.flags={compiler.optimization_flag} -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2bin.flags=-O binary +compiler.elf2bin.cmd=arm-none-eabi-objcopy +compiler.elf2hex.flags=-O ihex +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb {build.float_flags} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align --specs=nano.specs --specs=nosys.specs +compiler.size.cmd=arm-none-eabi-size + +# this can be overriden in boards.txt +build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float +build.debug_flags=-DCFG_DEBUG=0 +build.logger_flags=-DCFG_LOGGER=1 +build.sysview_flags=-DCFG_SYSVIEW=0 + +# common compiler for nrf +rtos.path={build.core.path}/freertos +nordic.path={build.core.path}/nordic + +# build.logger_flags and build.sysview_flags and intentionally empty, +# to allow modification via a user's own boards.local.txt or platform.local.txt files. +build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DLFS_NAME_MAX=64 {compiler.optimization_flag} {build.debug_flags} {build.logger_flags} {build.sysview_flags} "-I{build.core.path}/cmsis/Core/Include" "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include/nrf52" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" + +# usb flags +build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.libraries.ldflags= +compiler.elf2bin.extra_flags= +compiler.elf2hex.extra_flags= + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Create archives +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-L{build.core.path}/linker" "-T{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +#recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2bin.cmd}" {compiler.elf2bin.flags} {compiler.elf2bin.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +## Create dfu package zip file +recipe.objcopy.zip.pattern="{tools.nrfutil.cmd}" dfu genpkg --dev-type 0x0052 --sd-req {build.sd_fwid} --application "{build.path}/{build.project_name}.hex" "{build.path}/{build.project_name}.zip" + +## Create uf2 file +#recipe.objcopy.uf2.pattern=python "{runtime.platform.path}/tools/uf2conv/uf2conv.py" -f 0xADA52840 -c -o "{build.path}/{build.project_name}.uf2" "{build.path}/{build.project_name}.hex" + +## Save bin +recipe.output.tmp_file_bin={build.project_name}.bin +recipe.output.save_file_bin={build.project_name}.save.bin + +## Save hex +recipe.output.tmp_file_hex={build.project_name}.hex +recipe.output.save_file_hexu={build.project_name}.save.hex + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + +## Export Compiled Binary +recipe.output.tmp_file={build.project_name}.hex +recipe.output.save_file={build.project_name}.{build.variant}.hex + +#*************************************************** +# adafruit-nrfutil for uploading +# https://github.com/adafruit/Adafruit_nRF52_nrfutil +# pre-built binaries are provided for macos and windows +#*************************************************** +tools.nrfutil.cmd=adafruit-nrfutil +tools.nrfutil.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe +tools.nrfutil.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil + +tools.nrfutil.upload.params.verbose=--verbose +tools.nrfutil.upload.params.quiet= +tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.path}/{build.project_name}.zip" -p {serial.port} -b 115200 --singlebank + +#*************************************************** +# Burning bootloader with either jlink or nrfutil +#*************************************************** + +# Bootloader version +tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.3.2_{build.sd_name}_{build.sd_version} + +tools.bootburn.bootloader.params.verbose= +tools.bootburn.bootloader.params.quiet= +tools.bootburn.bootloader.pattern={program.burn_pattern} + +# erase flash page while programming +tools.bootburn.erase.params.verbose= +tools.bootburn.erase.params.quiet= +tools.bootburn.erase.pattern= + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/variant.cpp new file mode 100644 index 0000000..f43f3a4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/variant.cpp @@ -0,0 +1,59 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" + +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +const uint32_t g_ADigitalPinMap[] = { + // D0 .. D13 + 5, // D0 is P0.05 (UART RX) + 6, // D1 is P0.06 (UART TX) + 7, // D2 is P0.07 + 31, // D3 is P0.31 + 18, // D4 is P0.18 (LED Blue) + 99, // D5 (NC) + 9, // D6 is P0.09 NFC1 + 10, // D7 is P0.10 (Button) NFC2 + 99, // D8 (NC) + 8, // D9 is P0.08 + 11, // D10 is P0.11 CS + 13, // D11 is P0.13 MOSI + 12, // D12 is P0.12 MISO + 14, // D13 is P0.14 SCK + //I2C + 2, // D14 is P0.2 (SDA) + 3, // D15 is P0.3 (SCL) + // D16 .. D21 (aka A0 .. A5) + 3, // D16 is P0.03 (A0) + 2, // D17 is P0.02 (A1) + 4, // D18 is P0.04 (A2) + 30, // D19 is P0.30 (A3) SW2 + 29, // D20 is P0.29 (A4) + 28, // D21 is P0.28 (A5) + 9, // P0.09 NFC + 10, // P0.10 NFC + 16, // SW1 (LED Green) +}; \ No newline at end of file diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/variant.h new file mode 100644 index 0000000..833cbf6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/variant.h @@ -0,0 +1,172 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +#ifndef _VARIANT_NINA_B112_UBLOX_ +#define _VARIANT_NINA_B112_UBLOX_ + +#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \ + .rc_ctiv = 0, \ +.rc_temp_ctiv = 0, \ +.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM} + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (32u) +#define NUM_DIGITAL_PINS (32u) +#define NUM_ANALOG_INPUTS (6u) +#define NUM_ANALOG_OUTPUTS (0u) + +// LEDs +#define PIN_LED LED1 +#define LED_BUILTIN PIN_LED + +//LEDs onboard +#define LED1 (0) // Red +#define LED2 (24) // Green/SW1 +#define LED3 (4) // Blue + +#define LED_STATE_ON 1 // State when LED is litted + +//Switch +#define SW1 (24) +#define SW2 (19) + +// NFC +#define PIN_NFC_1 (6) // P0.9 +#define PIN_NFC_2 (7) // P0.10 + +/* + * Analog pins + */ +#define PIN_A0 (16) // P0.03 +#define PIN_A1 (17) // P0.02 +#define PIN_A2 (18) // P0.04 +#define PIN_A3 (19) // P0.30 +#define PIN_A4 (20) // P0.29 +#define PIN_A5 (21) // P0.28 + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_D0 (0) // P0.05 +#define PIN_D1 (1) // P0.06 +#define PIN_D2 (2) // P0.07 +#define PIN_D3 (4) // P0.31 +#define PIN_D4 (5) // P0.18 +#define PIN_D6 (6) // P0.09 +#define PIN_D7 (7) // P0.10 +#define PIN_D9 (9) // P0.08 +#define PIN_D10 (11) // P0.11 +#define PIN_D11 (13) // P0.13 +#define PIN_D12 (12) // P0.12 +#define PIN_D13 (14) // P0.14 +#define PIN_D14 (2) // P0.02 +#define PIN_D15 (3) // P0.03 + +static const uint8_t D0 = PIN_D0 ; +static const uint8_t D1 = PIN_D1 ; +static const uint8_t D2 = PIN_D2 ; +static const uint8_t D3 = PIN_D3 ; +static const uint8_t D4 = PIN_D4 ; +static const uint8_t D6 = PIN_D6 ; +static const uint8_t D7 = PIN_D7 ; +static const uint8_t D9 = PIN_D9 ; +static const uint8_t D10 = PIN_D10 ; +static const uint8_t D11 = PIN_D11 ; +static const uint8_t D12 = PIN_D12 ; +static const uint8_t D13 = PIN_D13 ; +static const uint8_t D14 = PIN_D14 ; +static const uint8_t D15 = PIN_D15 ; + +// Other pins +//static const uint8_t AREF = PIN_AREF; + +//#define PIN_AREF (24) +//#define PIN_VBAT PIN_A7 + +/* + * Serial interfaces + */ +#define PIN_SERIAL_RX (0) // P0.05 +#define PIN_SERIAL_TX (1) // P0.06 +#define PIN_SERIAL_CTS (2) // P0.07 +#define PIN_SERIAL_RTS (3) // P0.31 +#define PIN_SERIAL_DTR (28) // P0.28 +#define PIN_SERIAL_DSR (29) // P0.29 + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (12) // P0.12 +#define PIN_SPI_MOSI (11) // P0.13 +#define PIN_SPI_SCK (13) // P0.14 + +static const uint8_t SS = 10 ; // P0.11 +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (14) // P0.02 +#define PIN_WIRE_SCL (15) // P0.03 + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + + +#endif //_VARIANT_NINA_B112_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/variants/NINA_B302_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/variants/NINA_B302_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/variants/NINA_B302_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/variants/NINA_B302_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/variants/NINA_B302_ublox/variant.cpp new file mode 100644 index 0000000..8b4df2e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/variants/NINA_B302_ublox/variant.cpp @@ -0,0 +1,87 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 + 29, // D0 is P0.29 (UART RX) + 45, // D1 is P1.13 (UART TX) + 44, // D2 is P1.12 (NFC2) + 31, // D3 is P0.31 (LED1) + 13, // D4 is P0.13 (LED2) + 11, // D5 is P0.11 + 9, // D6 is P0.09 + 10, // D7 is P0.10 (Button) + 41, // D8 is P1.09 + 12, // D9 is P0.12 + 14, // D10 is P0.14 + 15, // D11 is P0.15 + 32, // D12 is P1.00 + 7, // D13 is P0.07 + + // D14 .. D21 (aka A0 .. A5) + 4, // D14 is P0.04 (A0) + 30, // D15 is P0.30 (A1) + 5, // D16 is P0.05 (A2) + 2, // D17 is P0.02 (A3) + 28, // D18 is P0.28 (A4) + 3, // D19 is P0.03 (A5) + + // D20 .. D21 (aka I2C pins) + 16, // D20 is P0.16 (SDA) + 24, // D21 is P0.24 (SCL) + + // QSPI pins (not exposed via any header / test point) + 19, // D22 is P0.19 (QSPI CLK) + 17, // D23 is P0.17 (QSPI CS) + 20, // D24 is P0.20 (QSPI Data 0) + 21, // D25 is P0.21 (QSPI Data 1) + 22, // D26 is P0.22 (QSPI Data 2) + 26, // D27 is P0.23 (QSPI Data 3) + + 40, // D28 is P1.08 - IO34 + 41, // D29 is P1.01 - IO35 + 44, // D30 is P1.02 - IO36 + 45, // D31 is P1.03 - IO37 + 42, // D32 is P1.10 - IO38 + 43, // D33 is P1.11 - IO39 + 47, // D34 is P1.15 - IO40 + 46, // D35 is P1.14 - IO41 + 26, // D36 is P0.26 - IO42 + 6, // D37 is P0.6 - IO43 + 27, // D38 is P0.27 - IO44 +}; + +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/variants/NINA_B302_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/variants/NINA_B302_ublox/variant.h new file mode 100644 index 0000000..a69575f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.21.0/variants/NINA_B302_ublox/variant.h @@ -0,0 +1,149 @@ + /* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#ifndef _VARIANT_NINA_B302_UBLOX_ +#define _VARIANT_NINA_B302_UBLOX_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus +// Number of pins defined in PinDescription array +#define PINS_COUNT (40) +#define NUM_DIGITAL_PINS (34) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (3) +#define PIN_LED2 (4) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_RED PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +/* + * Buttons + */ +#define PIN_BUTTON1 (7) + +/* + * Analog pins + */ +#define PIN_A0 (14) +#define PIN_A1 (15) +#define PIN_A2 (16) +#define PIN_A3 (17) +#define PIN_A4 (18) +#define PIN_A5 (19) + +#define D0 (0) +#define D1 (1) +#define D2 (2) +#define D3 (3) +#define D4 (4) +#define D5 (5) +#define D6 (6) +#define D7 (7) +#define D8 (8) +#define D9 (9) +#define D10 (10) +#define D11 (11) +#define D12 (12) +#define D13 (13) + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_NFC1 (31) +#define PIN_NFC2 (2) + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (0) +#define PIN_SERIAL1_TX (1) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (22) //24 original +#define PIN_SPI_MOSI (23) //25 original +#define PIN_SPI_SCK (24) //26 original + +static const uint8_t SS = (13); +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (20) +#define PIN_WIRE_SCL (21) + +// QSPI Pins +#define PIN_QSPI_SCK 22 +#define PIN_QSPI_CS 23 +#define PIN_QSPI_IO0 24 +#define PIN_QSPI_IO1 25 +#define PIN_QSPI_IO2 26 +#define PIN_QSPI_IO3 27 + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES GD25Q16C +#define EXTERNAL_FLASH_USE_QSPI + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif //_VARIANT_NINA_B302_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/boards.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/boards.txt new file mode 100644 index 0000000..c03de13 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/boards.txt @@ -0,0 +1,650 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +menu.softdevice=Bootloader +menu.debug=Debug + +# ---------------------------------- +# Bluefruit Feather nRF52832 +# ---------------------------------- +feather52832.name=Adafruit Feather nRF52832 +feather52832.bootloader.tool=bootburn + +# Upload +feather52832.upload.tool=nrfutil +feather52832.upload.protocol=nrfutil +feather52832.upload.use_1200bps_touch=false +feather52832.upload.wait_for_upload_port=false +feather52832.upload.native_usb=false +feather52832.upload.maximum_size=290816 +feather52832.upload.maximum_data_size=52224 + +# Build +feather52832.build.mcu=cortex-m4 +feather52832.build.f_cpu=64000000 +feather52832.build.board=NRF52832_FEATHER +feather52832.build.core=nRF5 +feather52832.build.variant=feather_nrf52832 +feather52832.build.usb_manufacturer="Adafruit LLC" +feather52832.build.usb_product="Feather nRF52832" +feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52 +feather52832.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +feather52832.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_name=s132 +feather52832.menu.softdevice.s132v6.build.sd_version=6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +feather52832.menu.debug.l0=Level 0 (Release) +feather52832.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52832.menu.debug.l1=Level 1 (Error Message) +feather52832.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52832.menu.debug.l2=Level 2 (Full Debug) +feather52832.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52832.menu.debug.l3=Level 3 (Segger SystemView) +feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52832.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Bluefruit Feather nRF52840 Express +# ---------------------------------- +feather52840.name=Adafruit Feather nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840.vid.0=0x239A +feather52840.pid.0=0x8029 +feather52840.vid.1=0x239A +feather52840.pid.1=0x0029 +feather52840.vid.2=0x239A +feather52840.pid.2=0x002A +feather52840.vid.3=0x239A +feather52840.pid.3=0x802A + +# Upload +feather52840.bootloader.tool=bootburn +feather52840.upload.tool=nrfutil +feather52840.upload.protocol=nrfutil +feather52840.upload.use_1200bps_touch=true +feather52840.upload.wait_for_upload_port=true +feather52840.upload.maximum_size=815104 +feather52840.upload.maximum_data_size=237568 + +# Build +feather52840.build.mcu=cortex-m4 +feather52840.build.f_cpu=64000000 +feather52840.build.board=NRF52840_FEATHER +feather52840.build.core=nRF5 +feather52840.build.variant=feather_nrf52840_express +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52840 Express" +feather52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +feather52840.build.ldscript=nrf52840_s140_v6.ld +feather52840.build.vid=0x239A +feather52840.build.pid=0x8029 + +# SofDevice Menu +feather52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_name=s140 +feather52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840.menu.debug.l0=Level 0 (Release) +feather52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840.menu.debug.l1=Level 1 (Error Message) +feather52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840.menu.debug.l2=Level 2 (Full Debug) +feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840.menu.debug.l3=Level 3 (Segger SystemView) +feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# ---------------------------------- +# Feather nRF52840 sense +# ---------------------------------- +feather52840sense.name=Adafruit Feather nRF52840 Sense + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840sense.vid.0=0x239A +feather52840sense.pid.0=0x8087 +feather52840sense.vid.1=0x239A +feather52840sense.pid.1=0x0087 +feather52840sense.vid.2=0x239A +feather52840sense.pid.2=0x0088 +feather52840sense.vid.3=0x239A +feather52840sense.pid.3=0x8088 + +# Upload +feather52840sense.bootloader.tool=bootburn +feather52840sense.upload.tool=nrfutil +feather52840sense.upload.protocol=nrfutil +feather52840sense.upload.use_1200bps_touch=true +feather52840sense.upload.wait_for_upload_port=true +feather52840sense.upload.maximum_size=815104 +feather52840sense.upload.maximum_data_size=237568 + +# Build +feather52840sense.build.mcu=cortex-m4 +feather52840sense.build.f_cpu=64000000 +feather52840sense.build.board=NRF52840_FEATHER_SENSE +feather52840sense.build.core=nRF5 +feather52840sense.build.variant=feather_nrf52840_sense +feather52840sense.build.usb_manufacturer="Adafruit LLC" +feather52840sense.build.usb_product="Feather nRF52840 Sense" +feather52840sense.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +feather52840sense.build.ldscript=nrf52840_s140_v6.ld +feather52840sense.build.vid=0x239A +feather52840sense.build.pid=0x8087 + +# SofDevice Menu +feather52840sense.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_name=s140 +feather52840sense.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840sense.menu.debug.l0=Level 0 (Release) +feather52840sense.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840sense.menu.debug.l1=Level 1 (Error Message) +feather52840sense.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840sense.menu.debug.l2=Level 2 (Full Debug) +feather52840sense.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840sense.menu.debug.l3=Level 3 (Segger SystemView) +feather52840sense.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840sense.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Bluefruit ItsyBitsy nRF52840 Express +# --------------------------------------------- +itsybitsy52840.name=Adafruit ItsyBitsy nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +itsybitsy52840.vid.0=0x239A +itsybitsy52840.pid.0=0x8051 +itsybitsy52840.vid.1=0x239A +itsybitsy52840.pid.1=0x0051 +itsybitsy52840.vid.2=0x239A +itsybitsy52840.pid.2=0x0052 +itsybitsy52840.vid.3=0x239A +itsybitsy52840.pid.3=0x8052 + +# Upload +itsybitsy52840.bootloader.tool=bootburn +itsybitsy52840.upload.tool=nrfutil +itsybitsy52840.upload.protocol=nrfutil +itsybitsy52840.upload.use_1200bps_touch=true +itsybitsy52840.upload.wait_for_upload_port=true +itsybitsy52840.upload.maximum_size=815104 +itsybitsy52840.upload.maximum_data_size=237568 + +# Build +itsybitsy52840.build.mcu=cortex-m4 +itsybitsy52840.build.f_cpu=64000000 +itsybitsy52840.build.board=NRF52840_ITSYBITSY +itsybitsy52840.build.core=nRF5 +itsybitsy52840.build.variant=itsybitsy_nrf52840_express +itsybitsy52840.build.usb_manufacturer="Adafruit LLC" +itsybitsy52840.build.usb_product="ItsyBitsy nRF52840 Express" +itsybitsy52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52_ITSYBITSY {build.flags.usb} +itsybitsy52840.build.ldscript=nrf52840_s140_v6.ld +itsybitsy52840.build.vid=0x239A +itsybitsy52840.build.pid=0x8051 + +# SofDevice Menu +itsybitsy52840.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_name=s140 +itsybitsy52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +itsybitsy52840.menu.debug.l0=Level 0 (Release) +itsybitsy52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +itsybitsy52840.menu.debug.l1=Level 1 (Error Message) +itsybitsy52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +itsybitsy52840.menu.debug.l2=Level 2 (Full Debug) +itsybitsy52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +itsybitsy52840.menu.debug.l3=Level 3 (Segger SystemView) +itsybitsy52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +itsybitsy52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# --------------------------------------------- +# Bluefruit Circuit Playground nRF52840 Express +# --------------------------------------------- +cplaynrf52840.name=Adafruit Circuit Playground Bluefruit + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cplaynrf52840.vid.0=0x239A +cplaynrf52840.pid.0=0x8045 +cplaynrf52840.vid.1=0x239A +cplaynrf52840.pid.1=0x0045 +cplaynrf52840.vid.2=0x239A +cplaynrf52840.pid.2=0x0046 +cplaynrf52840.vid.3=0x239A +cplaynrf52840.pid.3=0x8046 + +# Upload +cplaynrf52840.bootloader.tool=bootburn +cplaynrf52840.upload.tool=nrfutil +cplaynrf52840.upload.protocol=nrfutil +cplaynrf52840.upload.use_1200bps_touch=true +cplaynrf52840.upload.wait_for_upload_port=true +cplaynrf52840.upload.maximum_size=815104 +cplaynrf52840.upload.maximum_data_size=237568 + +# Build +cplaynrf52840.build.mcu=cortex-m4 +cplaynrf52840.build.f_cpu=64000000 +cplaynrf52840.build.board=NRF52840_CIRCUITPLAY +cplaynrf52840.build.core=nRF5 +cplaynrf52840.build.variant=circuitplayground_nrf52840 +cplaynrf52840.build.usb_manufacturer="Adafruit LLC" +cplaynrf52840.build.usb_product="Circuit Playground Bluefruit" +cplaynrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld +cplaynrf52840.build.vid=0x239A +cplaynrf52840.build.pid=0x8045 + +# SofDevice Menu +cplaynrf52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cplaynrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cplaynrf52840.menu.debug.l0=Level 0 (Release) +cplaynrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cplaynrf52840.menu.debug.l1=Level 1 (Error Message) +cplaynrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cplaynrf52840.menu.debug.l2=Level 2 (Full Debug) +cplaynrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cplaynrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cplaynrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Clue nRF52840 +# --------------------------------------------- +cluenrf52840.name=Adafruit CLUE + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cluenrf52840.vid.0=0x239A +cluenrf52840.pid.0=0x8072 +cluenrf52840.vid.1=0x239A +cluenrf52840.pid.1=0x0072 +cluenrf52840.vid.2=0x239A +cluenrf52840.pid.2=0x0071 +cluenrf52840.vid.3=0x239A +cluenrf52840.pid.3=0x8071 + +# Upload +cluenrf52840.bootloader.tool=bootburn +cluenrf52840.upload.tool=nrfutil +cluenrf52840.upload.protocol=nrfutil +cluenrf52840.upload.use_1200bps_touch=true +cluenrf52840.upload.wait_for_upload_port=true +cluenrf52840.upload.maximum_size=815104 +cluenrf52840.upload.maximum_data_size=237568 + +# Build +cluenrf52840.build.mcu=cortex-m4 +cluenrf52840.build.f_cpu=64000000 +cluenrf52840.build.board=NRF52840_CLUE +cluenrf52840.build.core=nRF5 +cluenrf52840.build.variant=clue_nrf52840 +cluenrf52840.build.usb_manufacturer="Adafruit LLC" +cluenrf52840.build.usb_product="CLUE" +cluenrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +cluenrf52840.build.ldscript=nrf52840_s140_v6.ld +cluenrf52840.build.vid=0x239A +cluenrf52840.build.pid=0x8071 + +# SofDevice Menu +cluenrf52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cluenrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cluenrf52840.menu.debug.l0=Level 0 (Release) +cluenrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cluenrf52840.menu.debug.l1=Level 1 (Error Message) +cluenrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cluenrf52840.menu.debug.l2=Level 2 (Full Debug) +cluenrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cluenrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cluenrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cluenrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Metro nRF52840 Express +# ---------------------------------- +metro52840.name=Adafruit Metro nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +metro52840.vid.0=0x239A +metro52840.pid.0=0x803F +metro52840.vid.1=0x239A +metro52840.pid.1=0x003F +metro52840.vid.2=0x239A +metro52840.pid.2=0x0040 +metro52840.vid.3=0x239A +metro52840.pid.3=0x8040 + +# Upload +metro52840.bootloader.tool=bootburn +metro52840.upload.tool=nrfutil +metro52840.upload.protocol=nrfutil +metro52840.upload.use_1200bps_touch=true +metro52840.upload.wait_for_upload_port=true +metro52840.upload.maximum_size=815104 +metro52840.upload.maximum_data_size=237568 + +# Build +metro52840.build.mcu=cortex-m4 +metro52840.build.f_cpu=64000000 +metro52840.build.board=NRF52840_METRO +metro52840.build.core=nRF5 +metro52840.build.variant=metro_nrf52840_express +metro52840.build.usb_manufacturer="Adafruit LLC" +metro52840.build.usb_product="Metro nRF52840 Express" +metro52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +metro52840.build.ldscript=nrf52840_s140_v6.ld +metro52840.build.vid=0x239A +metro52840.build.pid=0x803F + +# SofDevice Menu +metro52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_name=s140 +metro52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +metro52840.menu.debug.l0=Level 0 (Release) +metro52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +metro52840.menu.debug.l1=Level 1 (Error Message) +metro52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +metro52840.menu.debug.l2=Level 2 (Full Debug) +metro52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +metro52840.menu.debug.l3=Level 3 (Segger SystemView) +metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +metro52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + + + +# ------------------------------------------------------- +# +# Boards that aren't made by Adafruit +# +# ------------------------------------------------------- + + +# ---------------------------------- +# Nordic nRF52840DK (PCA10056) +# ---------------------------------- +pca10056.name=Nordic nRF52840DK (PCA10056) +pca10056.bootloader.tool=bootburn + +# Upload +pca10056.upload.tool=nrfutil +pca10056.upload.protocol=nrfutil +pca10056.upload.use_1200bps_touch=true +pca10056.upload.wait_for_upload_port=true +pca10056.upload.maximum_size=815104 +pca10056.upload.maximum_data_size=237568 + +# Build +pca10056.build.mcu=cortex-m4 +pca10056.build.f_cpu=64000000 +pca10056.build.board=NRF52840_PCA10056 +pca10056.build.core=nRF5 +pca10056.build.variant=pca10056 +pca10056.build.usb_manufacturer="Nordic" +pca10056.build.usb_product="nRF52840 DK" +pca10056.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +pca10056.build.ldscript=nrf52840_s140_v6.ld +pca10056.build.vid=0x239A +pca10056.build.pid=0x8029 + +# SofDevice Menu +pca10056.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_name=s140 +pca10056.menu.softdevice.s140v6.build.sd_version=6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +pca10056.menu.debug.l0=Level 0 (Release) +pca10056.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +pca10056.menu.debug.l1=Level 1 (Error Message) +pca10056.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +pca10056.menu.debug.l2=Level 2 (Full Debug) +pca10056.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +pca10056.menu.debug.l3=Level 3 (Segger SystemView) +pca10056.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +pca10056.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Particle Xenon +# ---------------------------------- +particle_xenon.name=Particle Xenon + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +particle_xenon.vid.0=0x239A +particle_xenon.pid.0=0x8029 +particle_xenon.vid.1=0x239A +particle_xenon.pid.1=0x0029 +particle_xenon.vid.2=0x239A +particle_xenon.pid.2=0x002A +particle_xenon.vid.3=0x239A +particle_xenon.pid.3=0x802A + +# Upload +particle_xenon.bootloader.tool=bootburn +particle_xenon.upload.tool=nrfutil +particle_xenon.upload.protocol=nrfutil +particle_xenon.upload.use_1200bps_touch=true +particle_xenon.upload.wait_for_upload_port=true +particle_xenon.upload.maximum_size=815104 +particle_xenon.upload.maximum_data_size=237568 + +# Build +particle_xenon.build.mcu=cortex-m4 +particle_xenon.build.f_cpu=64000000 +particle_xenon.build.board=PARTICLE_XENON +particle_xenon.build.core=nRF5 +particle_xenon.build.variant=particle_xenon +particle_xenon.build.usb_manufacturer="Particle Industries" +particle_xenon.build.usb_product="Particle Xenon" +particle_xenon.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +particle_xenon.build.ldscript=nrf52840_s140_v6.ld +particle_xenon.build.vid=0x239A +particle_xenon.build.pid=0x8029 + +# SofDevice Menu +particle_xenon.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_name=s140 +particle_xenon.menu.softdevice.s140v6.build.sd_version=6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +particle_xenon.menu.debug.l0=Level 0 (Release) +particle_xenon.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +particle_xenon.menu.debug.l1=Level 1 (Error Message) +particle_xenon.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +particle_xenon.menu.debug.l2=Level 2 (Full Debug) +particle_xenon.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +particle_xenon.menu.debug.l3=Level 3 (Segger SystemView) +particle_xenon.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +particle_xenon.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Raytac MDBT50Q - RX +# ---------------------------------- +mdbt50qrx.name=Raytac MDBT50Q-RX Dongle + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +mdbt50qrx.vid.0=0x239A +mdbt50qrx.pid.0=0x8029 +mdbt50qrx.vid.1=0x239A +mdbt50qrx.pid.1=0x0029 +mdbt50qrx.vid.2=0x239A +mdbt50qrx.pid.2=0x002A +mdbt50qrx.vid.3=0x239A +mdbt50qrx.pid.3=0x802A + +# Upload +mdbt50qrx.bootloader.tool=bootburn +mdbt50qrx.upload.tool=nrfutil +mdbt50qrx.upload.protocol=nrfutil +mdbt50qrx.upload.use_1200bps_touch=true +mdbt50qrx.upload.wait_for_upload_port=true +mdbt50qrx.upload.maximum_size=815104 +mdbt50qrx.upload.maximum_data_size=237568 + +# Build +mdbt50qrx.build.mcu=cortex-m4 +mdbt50qrx.build.f_cpu=64000000 +mdbt50qrx.build.board=MDBT50Q_RX +mdbt50qrx.build.core=nRF5 +mdbt50qrx.build.variant=raytac_mdbt50q_rx +mdbt50qrx.build.usb_manufacturer="Raytac Corporation" +mdbt50qrx.build.usb_product="Raytac MDBT50Q - RX" +mdbt50qrx.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld +mdbt50qrx.build.vid=0x239A +mdbt50qrx.build.pid=0x8029 + +# SofDevice Menu +mdbt50qrx.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_name=s140 +mdbt50qrx.menu.softdevice.s140v6.build.sd_version=6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +mdbt50qrx.menu.debug.l0=Level 0 (Release) +mdbt50qrx.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +mdbt50qrx.menu.debug.l1=Level 1 (Error Message) +mdbt50qrx.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +mdbt50qrx.menu.debug.l2=Level 2 (Full Debug) +mdbt50qrx.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +mdbt50qrx.menu.debug.l3=Level 3 (Segger SystemView) +mdbt50qrx.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +mdbt50qrx.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# ---------------------------------- +# NINA B302 +# ---------------------------------- +ninab302.name=NINA B302 ublox + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +ninab302.vid.0=0x239A +ninab302.pid.0=0x8029 +ninab302.vid.1=0x239A +ninab302.pid.1=0x0029 +ninab302.vid.2=0x7239A +ninab302.pid.2=0x002A +ninab302.vid.3=0x239A +ninab302.pid.3=0x802A + +# Upload +ninab302.bootloader.tool=bootburn +ninab302.upload.tool=nrfutil +ninab302.upload.protocol=nrfutil +ninab302.upload.use_1200bps_touch=true +ninab302.upload.wait_for_upload_port=true +ninab302.upload.maximum_size=815104 +ninab302.upload.maximum_data_size=237568 + +# Build +ninab302.build.mcu=cortex-m4 +ninab302.build.f_cpu=64000000 +ninab302.build.board=NINA_B302_ublox +ninab302.build.core=nRF5 +ninab302.build.variant=NINA_B302_ublox +ninab302.build.usb_manufacturer="Nordic" +ninab302.build.usb_product="NINA B302 ublox" +ninab302.build.extra_flags=-DNRF52840_XXAA -DNINA_B302_ublox {build.flags.usb} +ninab302.build.ldscript=nrf52840_s140_v6.ld +ninab302.build.vid=0x239A +ninab302.build.pid=0x8029 + +# SofDevice Menu +ninab302.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_name=s140 +ninab302.menu.softdevice.s140v6.build.sd_version=6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +ninab302.menu.debug.l0=Level 0 (Release) +ninab302.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab302.menu.debug.l1=Level 1 (Error Message) +ninab302.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab302.menu.debug.l2=Level 2 (Full Debug) +ninab302.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab302.menu.debug.l3=Level 3 (Segger SystemView) +ninab302.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab302.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# NINA B112 +# ---------------------------------- +ninab112.name=NINA B112 ublox +ninab112.bootloader.tool=bootburn + +# Upload +ninab112.upload.tool=nrfutil +ninab112.upload.protocol=nrfutil +ninab112.upload.use_1200bps_touch=false +ninab112.upload.wait_for_upload_port=false +ninab112.upload.native_usb=false +ninab112.upload.maximum_size=290816 +ninab112.upload.maximum_data_size=52224 + +# Build +ninab112.build.mcu=cortex-m4 +ninab112.build.f_cpu=64000000 +ninab112.build.board=NINA_B112_ublox +ninab112.build.core=nRF5 +ninab112.build.variant=NINA_B112_ublox +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52832" +ninab112.build.extra_flags=-DNRF52832_XXAA -DNINA_B112_ublox -DNRF52 +ninab112.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +ninab112.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_name=s132 +ninab112.menu.softdevice.s132v6.build.sd_version=6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +ninab112.menu.debug.l0=Level 0 (Release) +ninab112.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab112.menu.debug.l1=Level 1 (Error Message) +ninab112.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab112.menu.debug.l2=Level 2 (Full Debug) +ninab112.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab112.menu.debug.l3=Level 3 (Segger SystemView) +ninab112.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab112.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/cores/nRF5/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/cores/nRF5/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/cores/nRF5/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/cores/nRF5/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/cores/nRF5/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/cores/nRF5/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/cores/nRF5/Udp.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/cores/nRF5/Udp.h new file mode 100644 index 0000000..cc814d3 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/cores/nRF5/Udp.h @@ -0,0 +1,92 @@ +/* + * Udp.cpp: Library to send/receive UDP packets. + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + */ + +#ifndef udp_h +#define udp_h + +#include +#include + +class UDP : public Stream { + +public: + virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + + // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) + virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + + virtual void stop() =0; // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port) =0; + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port) =0; + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket() =0; + // Write a single byte into the packet + virtual size_t write(uint8_t) =0; + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size) =0; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket() =0; + // Number of bytes remaining in the current packet + virtual int available() =0; + // Read a single byte from the current packet + virtual int read() =0; + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len) =0; + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) =0; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek() =0; + virtual void flush() =0; // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() =0; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() =0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/platform.txt new file mode 100644 index 0000000..f2877b8 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/platform.txt @@ -0,0 +1,165 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All rights reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +name=Adafruit nRF52 Boards +version=0.22.0 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-pointer-arith + +# Allow changing optimization settings via platform.local.txt / boards.local.txt +compiler.optimization_flag=-Ofast + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD + +# KH, Error here to use gcc, must use g++ +#compiler.c.elf.cmd=arm-none-eabi-gcc +compiler.c.elf.cmd=arm-none-eabi-g++ + +compiler.c.elf.flags={compiler.optimization_flag} -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-mcpu={build.mcu} -mthumb -mabi=aapcs {compiler.optimization_flag} -g -c {build.float_flags} -x assembler-with-cpp + +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2bin.flags=-O binary +compiler.elf2bin.cmd=arm-none-eabi-objcopy +compiler.elf2hex.flags=-O ihex +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb {build.float_flags} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align --specs=nano.specs --specs=nosys.specs +compiler.size.cmd=arm-none-eabi-size + +# this can be overriden in boards.txt +build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float +build.debug_flags=-DCFG_DEBUG=0 +build.logger_flags=-DCFG_LOGGER=1 +build.sysview_flags=-DCFG_SYSVIEW=0 + +# common compiler for nrf +rtos.path={build.core.path}/freertos +nordic.path={build.core.path}/nordic + +# build.logger_flags and build.sysview_flags are intentionally empty, +# to allow modification via a user's own boards.local.txt or platform.local.txt files. +build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DDX_CC_TEE -DLFS_NAME_MAX=64 {compiler.optimization_flag} {build.debug_flags} {build.logger_flags} {build.sysview_flags} "-I{build.core.path}/cmsis/Core/Include" "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include/nrf52" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# usb flags +build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.libraries.ldflags= +compiler.elf2bin.extra_flags= +compiler.elf2hex.extra_flags= + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Create archives +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-L{build.core.path}/linker" "-T{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} -Wl,--start-group -lm "{build.path}/{archive_file}" {compiler.libraries.ldflags} -Wl,--end-group + +## Create output (bin file) +#recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2bin.cmd}" {compiler.elf2bin.flags} {compiler.elf2bin.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +## Create dfu package zip file +recipe.objcopy.zip.pattern="{tools.nrfutil.cmd}" dfu genpkg --dev-type 0x0052 --sd-req {build.sd_fwid} --application "{build.path}/{build.project_name}.hex" "{build.path}/{build.project_name}.zip" + +## Create uf2 file +#recipe.objcopy.uf2.pattern=python "{runtime.platform.path}/tools/uf2conv/uf2conv.py" -f 0xADA52840 -c -o "{build.path}/{build.project_name}.uf2" "{build.path}/{build.project_name}.hex" + +## Save bin +recipe.output.tmp_file_bin={build.project_name}.bin +recipe.output.save_file_bin={build.project_name}.save.bin + +## Save hex +recipe.output.tmp_file_hex={build.project_name}.hex +recipe.output.save_file_hexu={build.project_name}.save.hex + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + +## Export Compiled Binary +recipe.output.tmp_file={build.project_name}.hex +recipe.output.save_file={build.project_name}.{build.variant}.hex + +#*************************************************** +# adafruit-nrfutil for uploading +# https://github.com/adafruit/Adafruit_nRF52_nrfutil +# pre-built binaries are provided for macos and windows +#*************************************************** +tools.nrfutil.cmd=adafruit-nrfutil +tools.nrfutil.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe +tools.nrfutil.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil + +tools.nrfutil.upload.params.verbose=--verbose +tools.nrfutil.upload.params.quiet= +tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.path}/{build.project_name}.zip" -p {serial.port} -b 115200 --singlebank + +#*************************************************** +# Burning bootloader with either jlink or nrfutil +#*************************************************** + +# Bootloader version +tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.3.2_{build.sd_name}_{build.sd_version} + +tools.bootburn.bootloader.params.verbose= +tools.bootburn.bootloader.params.quiet= +tools.bootburn.bootloader.pattern={program.burn_pattern} + +# erase flash page while programming +tools.bootburn.erase.params.verbose= +tools.bootburn.erase.params.quiet= +tools.bootburn.erase.pattern= + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/variants/NINA_B112_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/variants/NINA_B112_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/variants/NINA_B112_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/variants/NINA_B112_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/variants/NINA_B112_ublox/variant.cpp new file mode 100644 index 0000000..f43f3a4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/variants/NINA_B112_ublox/variant.cpp @@ -0,0 +1,59 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" + +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +const uint32_t g_ADigitalPinMap[] = { + // D0 .. D13 + 5, // D0 is P0.05 (UART RX) + 6, // D1 is P0.06 (UART TX) + 7, // D2 is P0.07 + 31, // D3 is P0.31 + 18, // D4 is P0.18 (LED Blue) + 99, // D5 (NC) + 9, // D6 is P0.09 NFC1 + 10, // D7 is P0.10 (Button) NFC2 + 99, // D8 (NC) + 8, // D9 is P0.08 + 11, // D10 is P0.11 CS + 13, // D11 is P0.13 MOSI + 12, // D12 is P0.12 MISO + 14, // D13 is P0.14 SCK + //I2C + 2, // D14 is P0.2 (SDA) + 3, // D15 is P0.3 (SCL) + // D16 .. D21 (aka A0 .. A5) + 3, // D16 is P0.03 (A0) + 2, // D17 is P0.02 (A1) + 4, // D18 is P0.04 (A2) + 30, // D19 is P0.30 (A3) SW2 + 29, // D20 is P0.29 (A4) + 28, // D21 is P0.28 (A5) + 9, // P0.09 NFC + 10, // P0.10 NFC + 16, // SW1 (LED Green) +}; \ No newline at end of file diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/variants/NINA_B112_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/variants/NINA_B112_ublox/variant.h new file mode 100644 index 0000000..833cbf6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/variants/NINA_B112_ublox/variant.h @@ -0,0 +1,172 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +#ifndef _VARIANT_NINA_B112_UBLOX_ +#define _VARIANT_NINA_B112_UBLOX_ + +#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \ + .rc_ctiv = 0, \ +.rc_temp_ctiv = 0, \ +.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM} + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (32u) +#define NUM_DIGITAL_PINS (32u) +#define NUM_ANALOG_INPUTS (6u) +#define NUM_ANALOG_OUTPUTS (0u) + +// LEDs +#define PIN_LED LED1 +#define LED_BUILTIN PIN_LED + +//LEDs onboard +#define LED1 (0) // Red +#define LED2 (24) // Green/SW1 +#define LED3 (4) // Blue + +#define LED_STATE_ON 1 // State when LED is litted + +//Switch +#define SW1 (24) +#define SW2 (19) + +// NFC +#define PIN_NFC_1 (6) // P0.9 +#define PIN_NFC_2 (7) // P0.10 + +/* + * Analog pins + */ +#define PIN_A0 (16) // P0.03 +#define PIN_A1 (17) // P0.02 +#define PIN_A2 (18) // P0.04 +#define PIN_A3 (19) // P0.30 +#define PIN_A4 (20) // P0.29 +#define PIN_A5 (21) // P0.28 + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_D0 (0) // P0.05 +#define PIN_D1 (1) // P0.06 +#define PIN_D2 (2) // P0.07 +#define PIN_D3 (4) // P0.31 +#define PIN_D4 (5) // P0.18 +#define PIN_D6 (6) // P0.09 +#define PIN_D7 (7) // P0.10 +#define PIN_D9 (9) // P0.08 +#define PIN_D10 (11) // P0.11 +#define PIN_D11 (13) // P0.13 +#define PIN_D12 (12) // P0.12 +#define PIN_D13 (14) // P0.14 +#define PIN_D14 (2) // P0.02 +#define PIN_D15 (3) // P0.03 + +static const uint8_t D0 = PIN_D0 ; +static const uint8_t D1 = PIN_D1 ; +static const uint8_t D2 = PIN_D2 ; +static const uint8_t D3 = PIN_D3 ; +static const uint8_t D4 = PIN_D4 ; +static const uint8_t D6 = PIN_D6 ; +static const uint8_t D7 = PIN_D7 ; +static const uint8_t D9 = PIN_D9 ; +static const uint8_t D10 = PIN_D10 ; +static const uint8_t D11 = PIN_D11 ; +static const uint8_t D12 = PIN_D12 ; +static const uint8_t D13 = PIN_D13 ; +static const uint8_t D14 = PIN_D14 ; +static const uint8_t D15 = PIN_D15 ; + +// Other pins +//static const uint8_t AREF = PIN_AREF; + +//#define PIN_AREF (24) +//#define PIN_VBAT PIN_A7 + +/* + * Serial interfaces + */ +#define PIN_SERIAL_RX (0) // P0.05 +#define PIN_SERIAL_TX (1) // P0.06 +#define PIN_SERIAL_CTS (2) // P0.07 +#define PIN_SERIAL_RTS (3) // P0.31 +#define PIN_SERIAL_DTR (28) // P0.28 +#define PIN_SERIAL_DSR (29) // P0.29 + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (12) // P0.12 +#define PIN_SPI_MOSI (11) // P0.13 +#define PIN_SPI_SCK (13) // P0.14 + +static const uint8_t SS = 10 ; // P0.11 +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (14) // P0.02 +#define PIN_WIRE_SCL (15) // P0.03 + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + + +#endif //_VARIANT_NINA_B112_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/variants/NINA_B302_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/variants/NINA_B302_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/variants/NINA_B302_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/variants/NINA_B302_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/variants/NINA_B302_ublox/variant.cpp new file mode 100644 index 0000000..8b4df2e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/variants/NINA_B302_ublox/variant.cpp @@ -0,0 +1,87 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 + 29, // D0 is P0.29 (UART RX) + 45, // D1 is P1.13 (UART TX) + 44, // D2 is P1.12 (NFC2) + 31, // D3 is P0.31 (LED1) + 13, // D4 is P0.13 (LED2) + 11, // D5 is P0.11 + 9, // D6 is P0.09 + 10, // D7 is P0.10 (Button) + 41, // D8 is P1.09 + 12, // D9 is P0.12 + 14, // D10 is P0.14 + 15, // D11 is P0.15 + 32, // D12 is P1.00 + 7, // D13 is P0.07 + + // D14 .. D21 (aka A0 .. A5) + 4, // D14 is P0.04 (A0) + 30, // D15 is P0.30 (A1) + 5, // D16 is P0.05 (A2) + 2, // D17 is P0.02 (A3) + 28, // D18 is P0.28 (A4) + 3, // D19 is P0.03 (A5) + + // D20 .. D21 (aka I2C pins) + 16, // D20 is P0.16 (SDA) + 24, // D21 is P0.24 (SCL) + + // QSPI pins (not exposed via any header / test point) + 19, // D22 is P0.19 (QSPI CLK) + 17, // D23 is P0.17 (QSPI CS) + 20, // D24 is P0.20 (QSPI Data 0) + 21, // D25 is P0.21 (QSPI Data 1) + 22, // D26 is P0.22 (QSPI Data 2) + 26, // D27 is P0.23 (QSPI Data 3) + + 40, // D28 is P1.08 - IO34 + 41, // D29 is P1.01 - IO35 + 44, // D30 is P1.02 - IO36 + 45, // D31 is P1.03 - IO37 + 42, // D32 is P1.10 - IO38 + 43, // D33 is P1.11 - IO39 + 47, // D34 is P1.15 - IO40 + 46, // D35 is P1.14 - IO41 + 26, // D36 is P0.26 - IO42 + 6, // D37 is P0.6 - IO43 + 27, // D38 is P0.27 - IO44 +}; + +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/variants/NINA_B302_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/variants/NINA_B302_ublox/variant.h new file mode 100644 index 0000000..a69575f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.0/variants/NINA_B302_ublox/variant.h @@ -0,0 +1,149 @@ + /* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#ifndef _VARIANT_NINA_B302_UBLOX_ +#define _VARIANT_NINA_B302_UBLOX_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus +// Number of pins defined in PinDescription array +#define PINS_COUNT (40) +#define NUM_DIGITAL_PINS (34) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (3) +#define PIN_LED2 (4) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_RED PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +/* + * Buttons + */ +#define PIN_BUTTON1 (7) + +/* + * Analog pins + */ +#define PIN_A0 (14) +#define PIN_A1 (15) +#define PIN_A2 (16) +#define PIN_A3 (17) +#define PIN_A4 (18) +#define PIN_A5 (19) + +#define D0 (0) +#define D1 (1) +#define D2 (2) +#define D3 (3) +#define D4 (4) +#define D5 (5) +#define D6 (6) +#define D7 (7) +#define D8 (8) +#define D9 (9) +#define D10 (10) +#define D11 (11) +#define D12 (12) +#define D13 (13) + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_NFC1 (31) +#define PIN_NFC2 (2) + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (0) +#define PIN_SERIAL1_TX (1) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (22) //24 original +#define PIN_SPI_MOSI (23) //25 original +#define PIN_SPI_SCK (24) //26 original + +static const uint8_t SS = (13); +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (20) +#define PIN_WIRE_SCL (21) + +// QSPI Pins +#define PIN_QSPI_SCK 22 +#define PIN_QSPI_CS 23 +#define PIN_QSPI_IO0 24 +#define PIN_QSPI_IO1 25 +#define PIN_QSPI_IO2 26 +#define PIN_QSPI_IO3 27 + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES GD25Q16C +#define EXTERNAL_FLASH_USE_QSPI + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif //_VARIANT_NINA_B302_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/boards.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/boards.txt new file mode 100644 index 0000000..1368e40 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/boards.txt @@ -0,0 +1,596 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +menu.softdevice=Bootloader +menu.debug=Debug + +# ---------------------------------- +# Bluefruit Feather nRF52832 +# ---------------------------------- +feather52832.name=Adafruit Feather nRF52832 +feather52832.bootloader.tool=bootburn + +# Upload +feather52832.upload.tool=nrfutil +feather52832.upload.protocol=nrfutil +feather52832.upload.use_1200bps_touch=false +feather52832.upload.wait_for_upload_port=false +feather52832.upload.native_usb=false +feather52832.upload.maximum_size=290816 +feather52832.upload.maximum_data_size=52224 + +# Build +feather52832.build.mcu=cortex-m4 +feather52832.build.f_cpu=64000000 +feather52832.build.board=NRF52832_FEATHER +feather52832.build.core=nRF5 +feather52832.build.variant=feather_nrf52832 +feather52832.build.usb_manufacturer="Adafruit LLC" +feather52832.build.usb_product="Feather nRF52832" +feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52 +feather52832.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +feather52832.menu.softdevice.s132v6=0.5.0 SoftDevice s132 6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_name=s132 +feather52832.menu.softdevice.s132v6.build.sd_version=6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +feather52832.menu.debug.l0=Level 0 (Release) +feather52832.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52832.menu.debug.l1=Level 1 (Error Message) +feather52832.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52832.menu.debug.l2=Level 2 (Full Debug) +feather52832.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52832.menu.debug.l3=Level 3 (Segger SystemView) +feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52832.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Bluefruit Feather nRF52840 Express +# ---------------------------------- +feather52840.name=Adafruit Feather nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840.vid.0=0x239A +feather52840.pid.0=0x8029 +feather52840.vid.1=0x239A +feather52840.pid.1=0x0029 +feather52840.vid.2=0x239A +feather52840.pid.2=0x002A +feather52840.vid.3=0x239A +feather52840.pid.3=0x802A + +# Upload +feather52840.bootloader.tool=bootburn +feather52840.upload.tool=nrfutil +feather52840.upload.protocol=nrfutil +feather52840.upload.use_1200bps_touch=true +feather52840.upload.wait_for_upload_port=true +feather52840.upload.maximum_size=815104 +feather52840.upload.maximum_data_size=237568 + +# Build +feather52840.build.mcu=cortex-m4 +feather52840.build.f_cpu=64000000 +feather52840.build.board=NRF52840_FEATHER +feather52840.build.core=nRF5 +feather52840.build.variant=feather_nrf52840_express +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52840 Express" +feather52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +feather52840.build.ldscript=nrf52840_s140_v6.ld +feather52840.build.vid=0x239A +feather52840.build.pid=0x8029 + +# SofDevice Menu +feather52840.menu.softdevice.s140v6=0.5.0 SoftDevice s140 6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_name=s140 +feather52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840.menu.debug.l0=Level 0 (Release) +feather52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840.menu.debug.l1=Level 1 (Error Message) +feather52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840.menu.debug.l2=Level 2 (Full Debug) +feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840.menu.debug.l3=Level 3 (Segger SystemView) +feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# ---------------------------------- +# Feather nRF52840 sense +# ---------------------------------- +feather52840sense.name=Adafruit Feather nRF52840 Sense + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840sense.vid.0=0x239A +feather52840sense.pid.0=0x8087 +feather52840sense.vid.1=0x239A +feather52840sense.pid.1=0x0087 +feather52840sense.vid.2=0x239A +feather52840sense.pid.2=0x0088 +feather52840sense.vid.3=0x239A +feather52840sense.pid.3=0x8088 + +# Upload +feather52840sense.bootloader.tool=bootburn +feather52840sense.upload.tool=nrfutil +feather52840sense.upload.protocol=nrfutil +feather52840sense.upload.use_1200bps_touch=true +feather52840sense.upload.wait_for_upload_port=true +feather52840sense.upload.maximum_size=815104 +feather52840sense.upload.maximum_data_size=237568 + +# Build +feather52840sense.build.mcu=cortex-m4 +feather52840sense.build.f_cpu=64000000 +feather52840sense.build.board=NRF52840_FEATHER_SENSE +feather52840sense.build.core=nRF5 +feather52840sense.build.variant=feather_nrf52840_sense +feather52840sense.build.usb_manufacturer="Adafruit LLC" +feather52840sense.build.usb_product="Feather nRF52840 Sense" +feather52840sense.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +feather52840sense.build.ldscript=nrf52840_s140_v6.ld +feather52840sense.build.vid=0x239A +feather52840sense.build.pid=0x8087 + +# SofDevice Menu +feather52840sense.menu.softdevice.s140v6=0.5.0 SoftDevice s140 6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_name=s140 +feather52840sense.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840sense.menu.debug.l0=Level 0 (Release) +feather52840sense.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840sense.menu.debug.l1=Level 1 (Error Message) +feather52840sense.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840sense.menu.debug.l2=Level 2 (Full Debug) +feather52840sense.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840sense.menu.debug.l3=Level 3 (Segger SystemView) +feather52840sense.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840sense.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Bluefruit ItsyBitsy nRF52840 Express +# --------------------------------------------- +itsybitsy52840.name=Adafruit ItsyBitsy nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +itsybitsy52840.vid.0=0x239A +itsybitsy52840.pid.0=0x8051 +itsybitsy52840.vid.1=0x239A +itsybitsy52840.pid.1=0x0051 +itsybitsy52840.vid.2=0x239A +itsybitsy52840.pid.2=0x0052 +itsybitsy52840.vid.3=0x239A +itsybitsy52840.pid.3=0x8052 + +# Upload +itsybitsy52840.bootloader.tool=bootburn +itsybitsy52840.upload.tool=nrfutil +itsybitsy52840.upload.protocol=nrfutil +itsybitsy52840.upload.use_1200bps_touch=true +itsybitsy52840.upload.wait_for_upload_port=true +itsybitsy52840.upload.maximum_size=815104 +itsybitsy52840.upload.maximum_data_size=237568 + +# Build +itsybitsy52840.build.mcu=cortex-m4 +itsybitsy52840.build.f_cpu=64000000 +itsybitsy52840.build.board=NRF52840_ITSYBITSY +itsybitsy52840.build.core=nRF5 +itsybitsy52840.build.variant=itsybitsy_nrf52840_express +itsybitsy52840.build.usb_manufacturer="Adafruit LLC" +itsybitsy52840.build.usb_product="ItsyBitsy nRF52840 Express" +itsybitsy52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52_ITSYBITSY {build.flags.usb} +itsybitsy52840.build.ldscript=nrf52840_s140_v6.ld +itsybitsy52840.build.vid=0x239A +itsybitsy52840.build.pid=0x8051 + +# SofDevice Menu +itsybitsy52840.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_name=s140 +itsybitsy52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +itsybitsy52840.menu.debug.l0=Level 0 (Release) +itsybitsy52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +itsybitsy52840.menu.debug.l1=Level 1 (Error Message) +itsybitsy52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +itsybitsy52840.menu.debug.l2=Level 2 (Full Debug) +itsybitsy52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +itsybitsy52840.menu.debug.l3=Level 3 (Segger SystemView) +itsybitsy52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +itsybitsy52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# --------------------------------------------- +# Bluefruit Circuit Playground nRF52840 Express +# --------------------------------------------- +cplaynrf52840.name=Adafruit Circuit Playground Bluefruit + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cplaynrf52840.vid.0=0x239A +cplaynrf52840.pid.0=0x8045 +cplaynrf52840.vid.1=0x239A +cplaynrf52840.pid.1=0x0045 +cplaynrf52840.vid.2=0x239A +cplaynrf52840.pid.2=0x0046 +cplaynrf52840.vid.3=0x239A +cplaynrf52840.pid.3=0x8046 + +# Upload +cplaynrf52840.bootloader.tool=bootburn +cplaynrf52840.upload.tool=nrfutil +cplaynrf52840.upload.protocol=nrfutil +cplaynrf52840.upload.use_1200bps_touch=true +cplaynrf52840.upload.wait_for_upload_port=true +cplaynrf52840.upload.maximum_size=815104 +cplaynrf52840.upload.maximum_data_size=237568 + +# Build +cplaynrf52840.build.mcu=cortex-m4 +cplaynrf52840.build.f_cpu=64000000 +cplaynrf52840.build.board=NRF52840_CIRCUITPLAY +cplaynrf52840.build.core=nRF5 +cplaynrf52840.build.variant=circuitplayground_nrf52840 +cplaynrf52840.build.usb_manufacturer="Adafruit LLC" +cplaynrf52840.build.usb_product="Circuit Playground Bluefruit" +cplaynrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld +cplaynrf52840.build.vid=0x239A +cplaynrf52840.build.pid=0x8045 + +# SofDevice Menu +cplaynrf52840.menu.softdevice.s140v6=0.5.0 SoftDevice s140 6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cplaynrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cplaynrf52840.menu.debug.l0=Level 0 (Release) +cplaynrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cplaynrf52840.menu.debug.l1=Level 1 (Error Message) +cplaynrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cplaynrf52840.menu.debug.l2=Level 2 (Full Debug) +cplaynrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cplaynrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cplaynrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Clue nRF52840 +# --------------------------------------------- +cluenrf52840.name=Adafruit CLUE + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cluenrf52840.vid.0=0x239A +cluenrf52840.pid.0=0x8072 +cluenrf52840.vid.1=0x239A +cluenrf52840.pid.1=0x0072 +cluenrf52840.vid.2=0x239A +cluenrf52840.pid.2=0x0071 +cluenrf52840.vid.3=0x239A +cluenrf52840.pid.3=0x8071 + +# Upload +cluenrf52840.bootloader.tool=bootburn +cluenrf52840.upload.tool=nrfutil +cluenrf52840.upload.protocol=nrfutil +cluenrf52840.upload.use_1200bps_touch=true +cluenrf52840.upload.wait_for_upload_port=true +cluenrf52840.upload.maximum_size=815104 +cluenrf52840.upload.maximum_data_size=237568 + +# Build +cluenrf52840.build.mcu=cortex-m4 +cluenrf52840.build.f_cpu=64000000 +cluenrf52840.build.board=NRF52840_CLUE +cluenrf52840.build.core=nRF5 +cluenrf52840.build.variant=clue_nrf52840 +cluenrf52840.build.usb_manufacturer="Adafruit LLC" +cluenrf52840.build.usb_product="CLUE" +cluenrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +cluenrf52840.build.ldscript=nrf52840_s140_v6.ld +cluenrf52840.build.vid=0x239A +cluenrf52840.build.pid=0x8071 + +# SofDevice Menu +cluenrf52840.menu.softdevice.s140v6=0.5.0 SoftDevice s140 6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cluenrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cluenrf52840.menu.debug.l0=Level 0 (Release) +cluenrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cluenrf52840.menu.debug.l1=Level 1 (Error Message) +cluenrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cluenrf52840.menu.debug.l2=Level 2 (Full Debug) +cluenrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cluenrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cluenrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cluenrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Metro nRF52840 Express +# ---------------------------------- +metro52840.name=Adafruit Metro nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +metro52840.vid.0=0x239A +metro52840.pid.0=0x803F +metro52840.vid.1=0x239A +metro52840.pid.1=0x003F +metro52840.vid.2=0x239A +metro52840.pid.2=0x0040 +metro52840.vid.3=0x239A +metro52840.pid.3=0x8040 + +# Upload +metro52840.bootloader.tool=bootburn +metro52840.upload.tool=nrfutil +metro52840.upload.protocol=nrfutil +metro52840.upload.use_1200bps_touch=true +metro52840.upload.wait_for_upload_port=true +metro52840.upload.maximum_size=815104 +metro52840.upload.maximum_data_size=237568 + +# Build +metro52840.build.mcu=cortex-m4 +metro52840.build.f_cpu=64000000 +metro52840.build.board=NRF52840_METRO +metro52840.build.core=nRF5 +metro52840.build.variant=metro_nrf52840_express +metro52840.build.usb_manufacturer="Adafruit LLC" +metro52840.build.usb_product="Metro nRF52840 Express" +metro52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +metro52840.build.ldscript=nrf52840_s140_v6.ld +metro52840.build.vid=0x239A +metro52840.build.pid=0x803F + +# SofDevice Menu +metro52840.menu.softdevice.s140v6=0.5.0 SoftDevice s140 6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_name=s140 +metro52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +metro52840.menu.debug.l0=Level 0 (Release) +metro52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +metro52840.menu.debug.l1=Level 1 (Error Message) +metro52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +metro52840.menu.debug.l2=Level 2 (Full Debug) +metro52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +metro52840.menu.debug.l3=Level 3 (Segger SystemView) +metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +metro52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + + + +# ------------------------------------------------------- +# +# Boards that aren't made by Adafruit +# +# ------------------------------------------------------- + + +# ---------------------------------- +# Nordic nRF52840DK (PCA10056) +# ---------------------------------- +pca10056.name=Nordic nRF52840DK (PCA10056) +pca10056.bootloader.tool=bootburn + +# Upload +pca10056.upload.tool=nrfutil +pca10056.upload.protocol=nrfutil +pca10056.upload.use_1200bps_touch=true +pca10056.upload.wait_for_upload_port=true +pca10056.upload.maximum_size=815104 +pca10056.upload.maximum_data_size=237568 + +# Build +pca10056.build.mcu=cortex-m4 +pca10056.build.f_cpu=64000000 +pca10056.build.board=NRF52840_PCA10056 +pca10056.build.core=nRF5 +pca10056.build.variant=pca10056 +pca10056.build.usb_manufacturer="Nordic" +pca10056.build.usb_product="nRF52840 DK" +pca10056.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +pca10056.build.ldscript=nrf52840_s140_v6.ld +pca10056.build.vid=0x239A +pca10056.build.pid=0x8029 + +# SofDevice Menu +pca10056.menu.softdevice.s140v6=0.5.0 SoftDevice s140 6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_name=s140 +pca10056.menu.softdevice.s140v6.build.sd_version=6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +pca10056.menu.debug.l0=Level 0 (Release) +pca10056.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +pca10056.menu.debug.l1=Level 1 (Error Message) +pca10056.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +pca10056.menu.debug.l2=Level 2 (Full Debug) +pca10056.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +pca10056.menu.debug.l3=Level 3 (Segger SystemView) +pca10056.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +pca10056.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Particle Xenon +# ---------------------------------- +particle_xenon.name=Particle Xenon + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +particle_xenon.vid.0=0x239A +particle_xenon.pid.0=0x8029 +particle_xenon.vid.1=0x239A +particle_xenon.pid.1=0x0029 +particle_xenon.vid.2=0x239A +particle_xenon.pid.2=0x002A +particle_xenon.vid.3=0x239A +particle_xenon.pid.3=0x802A + +# Upload +particle_xenon.bootloader.tool=bootburn +particle_xenon.upload.tool=nrfutil +particle_xenon.upload.protocol=nrfutil +particle_xenon.upload.use_1200bps_touch=true +particle_xenon.upload.wait_for_upload_port=true +particle_xenon.upload.maximum_size=815104 +particle_xenon.upload.maximum_data_size=237568 + +# Build +particle_xenon.build.mcu=cortex-m4 +particle_xenon.build.f_cpu=64000000 +particle_xenon.build.board=PARTICLE_XENON +particle_xenon.build.core=nRF5 +particle_xenon.build.variant=particle_xenon +particle_xenon.build.usb_manufacturer="Particle Industries" +particle_xenon.build.usb_product="Particle Xenon" +particle_xenon.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +particle_xenon.build.ldscript=nrf52840_s140_v6.ld +particle_xenon.build.vid=0x239A +particle_xenon.build.pid=0x8029 + +# SofDevice Menu +particle_xenon.menu.softdevice.s140v6=0.5.0 SoftDevice s140 6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_name=s140 +particle_xenon.menu.softdevice.s140v6.build.sd_version=6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +particle_xenon.menu.debug.l0=Level 0 (Release) +particle_xenon.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +particle_xenon.menu.debug.l1=Level 1 (Error Message) +particle_xenon.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +particle_xenon.menu.debug.l2=Level 2 (Full Debug) +particle_xenon.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +particle_xenon.menu.debug.l3=Level 3 (Segger SystemView) +particle_xenon.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +particle_xenon.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# ---------------------------------- +# NINA B302 +# ---------------------------------- +ninab302.name=NINA B302 ublox + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +ninab302.vid.0=0x239A +ninab302.pid.0=0x8029 +ninab302.vid.1=0x239A +ninab302.pid.1=0x0029 +ninab302.vid.2=0x7239A +ninab302.pid.2=0x002A +ninab302.vid.3=0x239A +ninab302.pid.3=0x802A + +# Upload +ninab302.bootloader.tool=bootburn +ninab302.upload.tool=nrfutil +ninab302.upload.protocol=nrfutil +ninab302.upload.use_1200bps_touch=true +ninab302.upload.wait_for_upload_port=true +ninab302.upload.maximum_size=815104 +ninab302.upload.maximum_data_size=237568 + +# Build +ninab302.build.mcu=cortex-m4 +ninab302.build.f_cpu=64000000 +ninab302.build.board=NINA_B302_ublox +ninab302.build.core=nRF5 +ninab302.build.variant=NINA_B302_ublox +ninab302.build.usb_manufacturer="Nordic" +ninab302.build.usb_product="NINA B302 ublox" +ninab302.build.extra_flags=-DNRF52840_XXAA -DNINA_B302_ublox {build.flags.usb} +ninab302.build.ldscript=nrf52840_s140_v6.ld +ninab302.build.vid=0x239A +ninab302.build.pid=0x8029 + +# SofDevice Menu +ninab302.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_name=s140 +ninab302.menu.softdevice.s140v6.build.sd_version=6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +ninab302.menu.debug.l0=Level 0 (Release) +ninab302.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab302.menu.debug.l1=Level 1 (Error Message) +ninab302.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab302.menu.debug.l2=Level 2 (Full Debug) +ninab302.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab302.menu.debug.l3=Level 3 (Segger SystemView) +ninab302.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab302.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# NINA B112 +# ---------------------------------- +ninab112.name=NINA B112 ublox +ninab112.bootloader.tool=bootburn + +# Upload +ninab112.upload.tool=nrfutil +ninab112.upload.protocol=nrfutil +ninab112.upload.use_1200bps_touch=false +ninab112.upload.wait_for_upload_port=false +ninab112.upload.native_usb=false +ninab112.upload.maximum_size=290816 +ninab112.upload.maximum_data_size=52224 + +# Build +ninab112.build.mcu=cortex-m4 +ninab112.build.f_cpu=64000000 +ninab112.build.board=NINA_B112_ublox +ninab112.build.core=nRF5 +ninab112.build.variant=NINA_B112_ublox +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52832" +ninab112.build.extra_flags=-DNRF52832_XXAA -DNINA_B112_ublox -DNRF52 +ninab112.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +ninab112.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_name=s132 +ninab112.menu.softdevice.s132v6.build.sd_version=6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +ninab112.menu.debug.l0=Level 0 (Release) +ninab112.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab112.menu.debug.l1=Level 1 (Error Message) +ninab112.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab112.menu.debug.l2=Level 2 (Full Debug) +ninab112.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab112.menu.debug.l3=Level 3 (Segger SystemView) +ninab112.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab112.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/cores/nRF5/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/cores/nRF5/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/cores/nRF5/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/cores/nRF5/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/cores/nRF5/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/cores/nRF5/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/cores/nRF5/Udp.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/cores/nRF5/Udp.h new file mode 100644 index 0000000..cc814d3 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/cores/nRF5/Udp.h @@ -0,0 +1,92 @@ +/* + * Udp.cpp: Library to send/receive UDP packets. + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + */ + +#ifndef udp_h +#define udp_h + +#include +#include + +class UDP : public Stream { + +public: + virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + + // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) + virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + + virtual void stop() =0; // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port) =0; + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port) =0; + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket() =0; + // Write a single byte into the packet + virtual size_t write(uint8_t) =0; + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size) =0; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket() =0; + // Number of bytes remaining in the current packet + virtual int available() =0; + // Read a single byte from the current packet + virtual int read() =0; + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len) =0; + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) =0; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek() =0; + virtual void flush() =0; // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() =0; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() =0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/platform.txt new file mode 100644 index 0000000..7d0f6b6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/platform.txt @@ -0,0 +1,169 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All rights reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +name=Adafruit nRF52 Boards +version=0.22.1 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-pointer-arith + +# Allow changing optimization settings via platform.local.txt / boards.local.txt +compiler.optimization_flag=-Ofast + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD + +# KH, Error here to use gcc, must use g++ +#compiler.c.elf.cmd=arm-none-eabi-gcc +compiler.c.elf.cmd=arm-none-eabi-g++ + +compiler.c.elf.flags={compiler.optimization_flag} -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-mcpu={build.mcu} -mthumb -mabi=aapcs {compiler.optimization_flag} -g -c {build.float_flags} -x assembler-with-cpp + +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2bin.flags=-O binary +compiler.elf2bin.cmd=arm-none-eabi-objcopy +compiler.elf2hex.flags=-O ihex +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb {build.float_flags} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align --specs=nano.specs --specs=nosys.specs +compiler.size.cmd=arm-none-eabi-size + +# this can be overriden in boards.txt +build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float +build.debug_flags=-DCFG_DEBUG=0 +build.logger_flags=-DCFG_LOGGER=1 +build.sysview_flags=-DCFG_SYSVIEW=0 + +# USB flags +build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.libraries.ldflags= +compiler.elf2bin.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" + +# TODO enable linking with libmath later on +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM4lf_math + +# common compiler for nrf +rtos.path={build.core.path}/freertos +nordic.path={build.core.path}/nordic + +# build.logger_flags and build.sysview_flags are intentionally empty, +# to allow modification via a user's own boards.local.txt or platform.local.txt files. +build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DDX_CC_TEE -DLFS_NAME_MAX=64 {compiler.optimization_flag} {build.debug_flags} {build.logger_flags} {build.sysview_flags} {compiler.arm.cmsis.c.flags} "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include/nrf52" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Create archives +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-L{build.core.path}/linker" "-T{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} -Wl,--start-group -lm "{build.path}/{archive_file}" {compiler.libraries.ldflags} -Wl,--end-group + +## Create output (bin file) +#recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2bin.cmd}" {compiler.elf2bin.flags} {compiler.elf2bin.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +## Create dfu package zip file +recipe.objcopy.zip.pattern="{tools.nrfutil.cmd}" dfu genpkg --dev-type 0x0052 --sd-req {build.sd_fwid} --application "{build.path}/{build.project_name}.hex" "{build.path}/{build.project_name}.zip" + +## Create uf2 file +#recipe.objcopy.uf2.pattern=python "{runtime.platform.path}/tools/uf2conv/uf2conv.py" -f 0xADA52840 -c -o "{build.path}/{build.project_name}.uf2" "{build.path}/{build.project_name}.hex" + +## Save bin +recipe.output.tmp_file_bin={build.project_name}.bin +recipe.output.save_file_bin={build.project_name}.save.bin + +## Save hex +recipe.output.tmp_file_hex={build.project_name}.hex +recipe.output.save_file_hexu={build.project_name}.save.hex + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + +## Export Compiled Binary +recipe.output.tmp_file={build.project_name}.hex +recipe.output.save_file={build.project_name}.{build.variant}.hex + +#*************************************************** +# adafruit-nrfutil for uploading +# https://github.com/adafruit/Adafruit_nRF52_nrfutil +# pre-built binaries are provided for macos and windows +#*************************************************** +tools.nrfutil.cmd=adafruit-nrfutil +tools.nrfutil.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe +tools.nrfutil.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil + +tools.nrfutil.upload.params.verbose=--verbose +tools.nrfutil.upload.params.quiet= +tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.path}/{build.project_name}.zip" -p {serial.port} -b 115200 --singlebank + +#*************************************************** +# Burning bootloader with either jlink or nrfutil +#*************************************************** + +# Bootloader version +tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.5.0_{build.sd_name}_{build.sd_version} + +tools.bootburn.bootloader.params.verbose= +tools.bootburn.bootloader.params.quiet= +tools.bootburn.bootloader.pattern={program.burn_pattern} + +# erase flash page while programming +tools.bootburn.erase.params.verbose= +tools.bootburn.erase.params.quiet= +tools.bootburn.erase.pattern= + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/variants/NINA_B112_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/variants/NINA_B112_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/variants/NINA_B112_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/variants/NINA_B112_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/variants/NINA_B112_ublox/variant.cpp new file mode 100644 index 0000000..f43f3a4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/variants/NINA_B112_ublox/variant.cpp @@ -0,0 +1,59 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" + +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +const uint32_t g_ADigitalPinMap[] = { + // D0 .. D13 + 5, // D0 is P0.05 (UART RX) + 6, // D1 is P0.06 (UART TX) + 7, // D2 is P0.07 + 31, // D3 is P0.31 + 18, // D4 is P0.18 (LED Blue) + 99, // D5 (NC) + 9, // D6 is P0.09 NFC1 + 10, // D7 is P0.10 (Button) NFC2 + 99, // D8 (NC) + 8, // D9 is P0.08 + 11, // D10 is P0.11 CS + 13, // D11 is P0.13 MOSI + 12, // D12 is P0.12 MISO + 14, // D13 is P0.14 SCK + //I2C + 2, // D14 is P0.2 (SDA) + 3, // D15 is P0.3 (SCL) + // D16 .. D21 (aka A0 .. A5) + 3, // D16 is P0.03 (A0) + 2, // D17 is P0.02 (A1) + 4, // D18 is P0.04 (A2) + 30, // D19 is P0.30 (A3) SW2 + 29, // D20 is P0.29 (A4) + 28, // D21 is P0.28 (A5) + 9, // P0.09 NFC + 10, // P0.10 NFC + 16, // SW1 (LED Green) +}; \ No newline at end of file diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/variants/NINA_B112_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/variants/NINA_B112_ublox/variant.h new file mode 100644 index 0000000..833cbf6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/variants/NINA_B112_ublox/variant.h @@ -0,0 +1,172 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +#ifndef _VARIANT_NINA_B112_UBLOX_ +#define _VARIANT_NINA_B112_UBLOX_ + +#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \ + .rc_ctiv = 0, \ +.rc_temp_ctiv = 0, \ +.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM} + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (32u) +#define NUM_DIGITAL_PINS (32u) +#define NUM_ANALOG_INPUTS (6u) +#define NUM_ANALOG_OUTPUTS (0u) + +// LEDs +#define PIN_LED LED1 +#define LED_BUILTIN PIN_LED + +//LEDs onboard +#define LED1 (0) // Red +#define LED2 (24) // Green/SW1 +#define LED3 (4) // Blue + +#define LED_STATE_ON 1 // State when LED is litted + +//Switch +#define SW1 (24) +#define SW2 (19) + +// NFC +#define PIN_NFC_1 (6) // P0.9 +#define PIN_NFC_2 (7) // P0.10 + +/* + * Analog pins + */ +#define PIN_A0 (16) // P0.03 +#define PIN_A1 (17) // P0.02 +#define PIN_A2 (18) // P0.04 +#define PIN_A3 (19) // P0.30 +#define PIN_A4 (20) // P0.29 +#define PIN_A5 (21) // P0.28 + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_D0 (0) // P0.05 +#define PIN_D1 (1) // P0.06 +#define PIN_D2 (2) // P0.07 +#define PIN_D3 (4) // P0.31 +#define PIN_D4 (5) // P0.18 +#define PIN_D6 (6) // P0.09 +#define PIN_D7 (7) // P0.10 +#define PIN_D9 (9) // P0.08 +#define PIN_D10 (11) // P0.11 +#define PIN_D11 (13) // P0.13 +#define PIN_D12 (12) // P0.12 +#define PIN_D13 (14) // P0.14 +#define PIN_D14 (2) // P0.02 +#define PIN_D15 (3) // P0.03 + +static const uint8_t D0 = PIN_D0 ; +static const uint8_t D1 = PIN_D1 ; +static const uint8_t D2 = PIN_D2 ; +static const uint8_t D3 = PIN_D3 ; +static const uint8_t D4 = PIN_D4 ; +static const uint8_t D6 = PIN_D6 ; +static const uint8_t D7 = PIN_D7 ; +static const uint8_t D9 = PIN_D9 ; +static const uint8_t D10 = PIN_D10 ; +static const uint8_t D11 = PIN_D11 ; +static const uint8_t D12 = PIN_D12 ; +static const uint8_t D13 = PIN_D13 ; +static const uint8_t D14 = PIN_D14 ; +static const uint8_t D15 = PIN_D15 ; + +// Other pins +//static const uint8_t AREF = PIN_AREF; + +//#define PIN_AREF (24) +//#define PIN_VBAT PIN_A7 + +/* + * Serial interfaces + */ +#define PIN_SERIAL_RX (0) // P0.05 +#define PIN_SERIAL_TX (1) // P0.06 +#define PIN_SERIAL_CTS (2) // P0.07 +#define PIN_SERIAL_RTS (3) // P0.31 +#define PIN_SERIAL_DTR (28) // P0.28 +#define PIN_SERIAL_DSR (29) // P0.29 + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (12) // P0.12 +#define PIN_SPI_MOSI (11) // P0.13 +#define PIN_SPI_SCK (13) // P0.14 + +static const uint8_t SS = 10 ; // P0.11 +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (14) // P0.02 +#define PIN_WIRE_SCL (15) // P0.03 + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + + +#endif //_VARIANT_NINA_B112_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/variants/NINA_B302_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/variants/NINA_B302_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/variants/NINA_B302_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/variants/NINA_B302_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/variants/NINA_B302_ublox/variant.cpp new file mode 100644 index 0000000..8b4df2e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/variants/NINA_B302_ublox/variant.cpp @@ -0,0 +1,87 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 + 29, // D0 is P0.29 (UART RX) + 45, // D1 is P1.13 (UART TX) + 44, // D2 is P1.12 (NFC2) + 31, // D3 is P0.31 (LED1) + 13, // D4 is P0.13 (LED2) + 11, // D5 is P0.11 + 9, // D6 is P0.09 + 10, // D7 is P0.10 (Button) + 41, // D8 is P1.09 + 12, // D9 is P0.12 + 14, // D10 is P0.14 + 15, // D11 is P0.15 + 32, // D12 is P1.00 + 7, // D13 is P0.07 + + // D14 .. D21 (aka A0 .. A5) + 4, // D14 is P0.04 (A0) + 30, // D15 is P0.30 (A1) + 5, // D16 is P0.05 (A2) + 2, // D17 is P0.02 (A3) + 28, // D18 is P0.28 (A4) + 3, // D19 is P0.03 (A5) + + // D20 .. D21 (aka I2C pins) + 16, // D20 is P0.16 (SDA) + 24, // D21 is P0.24 (SCL) + + // QSPI pins (not exposed via any header / test point) + 19, // D22 is P0.19 (QSPI CLK) + 17, // D23 is P0.17 (QSPI CS) + 20, // D24 is P0.20 (QSPI Data 0) + 21, // D25 is P0.21 (QSPI Data 1) + 22, // D26 is P0.22 (QSPI Data 2) + 26, // D27 is P0.23 (QSPI Data 3) + + 40, // D28 is P1.08 - IO34 + 41, // D29 is P1.01 - IO35 + 44, // D30 is P1.02 - IO36 + 45, // D31 is P1.03 - IO37 + 42, // D32 is P1.10 - IO38 + 43, // D33 is P1.11 - IO39 + 47, // D34 is P1.15 - IO40 + 46, // D35 is P1.14 - IO41 + 26, // D36 is P0.26 - IO42 + 6, // D37 is P0.6 - IO43 + 27, // D38 is P0.27 - IO44 +}; + +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/variants/NINA_B302_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/variants/NINA_B302_ublox/variant.h new file mode 100644 index 0000000..a69575f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.22.1/variants/NINA_B302_ublox/variant.h @@ -0,0 +1,149 @@ + /* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#ifndef _VARIANT_NINA_B302_UBLOX_ +#define _VARIANT_NINA_B302_UBLOX_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus +// Number of pins defined in PinDescription array +#define PINS_COUNT (40) +#define NUM_DIGITAL_PINS (34) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (3) +#define PIN_LED2 (4) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_RED PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +/* + * Buttons + */ +#define PIN_BUTTON1 (7) + +/* + * Analog pins + */ +#define PIN_A0 (14) +#define PIN_A1 (15) +#define PIN_A2 (16) +#define PIN_A3 (17) +#define PIN_A4 (18) +#define PIN_A5 (19) + +#define D0 (0) +#define D1 (1) +#define D2 (2) +#define D3 (3) +#define D4 (4) +#define D5 (5) +#define D6 (6) +#define D7 (7) +#define D8 (8) +#define D9 (9) +#define D10 (10) +#define D11 (11) +#define D12 (12) +#define D13 (13) + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_NFC1 (31) +#define PIN_NFC2 (2) + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (0) +#define PIN_SERIAL1_TX (1) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (22) //24 original +#define PIN_SPI_MOSI (23) //25 original +#define PIN_SPI_SCK (24) //26 original + +static const uint8_t SS = (13); +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (20) +#define PIN_WIRE_SCL (21) + +// QSPI Pins +#define PIN_QSPI_SCK 22 +#define PIN_QSPI_CS 23 +#define PIN_QSPI_IO0 24 +#define PIN_QSPI_IO1 25 +#define PIN_QSPI_IO2 26 +#define PIN_QSPI_IO3 27 + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES GD25Q16C +#define EXTERNAL_FLASH_USE_QSPI + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif //_VARIANT_NINA_B302_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/boards.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/boards.txt new file mode 100644 index 0000000..14f6252 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/boards.txt @@ -0,0 +1,648 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +menu.softdevice=SoftDevice +menu.debug=Debug + +# ---------------------------------- +# Bluefruit Feather nRF52832 +# ---------------------------------- +feather52832.name=Adafruit Feather nRF52832 +feather52832.bootloader.tool=bootburn + +# Upload +feather52832.upload.tool=nrfutil +feather52832.upload.protocol=nrfutil +feather52832.upload.use_1200bps_touch=false +feather52832.upload.wait_for_upload_port=false +feather52832.upload.native_usb=false +feather52832.upload.maximum_size=290816 +feather52832.upload.maximum_data_size=52224 + +# Build +feather52832.build.mcu=cortex-m4 +feather52832.build.f_cpu=64000000 +feather52832.build.board=NRF52832_FEATHER +feather52832.build.core=nRF5 +feather52832.build.variant=feather_nrf52832 +feather52832.build.usb_manufacturer="Adafruit LLC" +feather52832.build.usb_product="Feather nRF52832" +feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52 +feather52832.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +feather52832.menu.softdevice.s132v6=S132 6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_name=s132 +feather52832.menu.softdevice.s132v6.build.sd_version=6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +feather52832.menu.debug.l0=Level 0 (Release) +feather52832.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52832.menu.debug.l1=Level 1 (Error Message) +feather52832.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52832.menu.debug.l2=Level 2 (Full Debug) +feather52832.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52832.menu.debug.l3=Level 3 (Segger SystemView) +feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52832.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Bluefruit Feather nRF52840 Express +# ---------------------------------- +feather52840.name=Adafruit Feather nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840.vid.0=0x239A +feather52840.pid.0=0x8029 +feather52840.vid.1=0x239A +feather52840.pid.1=0x0029 +feather52840.vid.2=0x239A +feather52840.pid.2=0x002A +feather52840.vid.3=0x239A +feather52840.pid.3=0x802A + +# Upload +feather52840.bootloader.tool=bootburn +feather52840.upload.tool=nrfutil +feather52840.upload.protocol=nrfutil +feather52840.upload.use_1200bps_touch=true +feather52840.upload.wait_for_upload_port=true +feather52840.upload.maximum_size=815104 +feather52840.upload.maximum_data_size=237568 + +# Build +feather52840.build.mcu=cortex-m4 +feather52840.build.f_cpu=64000000 +feather52840.build.board=NRF52840_FEATHER +feather52840.build.core=nRF5 +feather52840.build.variant=feather_nrf52840_express +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52840 Express" +feather52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +feather52840.build.ldscript=nrf52840_s140_v6.ld +feather52840.build.vid=0x239A +feather52840.build.pid=0x8029 + +# SofDevice Menu +feather52840.menu.softdevice.s140v6=S140 6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_name=s140 +feather52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840.menu.debug.l0=Level 0 (Release) +feather52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840.menu.debug.l1=Level 1 (Error Message) +feather52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840.menu.debug.l2=Level 2 (Full Debug) +feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840.menu.debug.l3=Level 3 (Segger SystemView) +feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# ---------------------------------- +# Feather nRF52840 sense +# ---------------------------------- +feather52840sense.name=Adafruit Feather nRF52840 Sense + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840sense.vid.0=0x239A +feather52840sense.pid.0=0x8087 +feather52840sense.vid.1=0x239A +feather52840sense.pid.1=0x0087 +feather52840sense.vid.2=0x239A +feather52840sense.pid.2=0x0088 +feather52840sense.vid.3=0x239A +feather52840sense.pid.3=0x8088 + +# Upload +feather52840sense.bootloader.tool=bootburn +feather52840sense.upload.tool=nrfutil +feather52840sense.upload.protocol=nrfutil +feather52840sense.upload.use_1200bps_touch=true +feather52840sense.upload.wait_for_upload_port=true +feather52840sense.upload.maximum_size=815104 +feather52840sense.upload.maximum_data_size=237568 + +# Build +feather52840sense.build.mcu=cortex-m4 +feather52840sense.build.f_cpu=64000000 +feather52840sense.build.board=NRF52840_FEATHER_SENSE +feather52840sense.build.core=nRF5 +feather52840sense.build.variant=feather_nrf52840_sense +feather52840sense.build.usb_manufacturer="Adafruit LLC" +feather52840sense.build.usb_product="Feather nRF52840 Sense" +feather52840sense.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +feather52840sense.build.ldscript=nrf52840_s140_v6.ld +feather52840sense.build.vid=0x239A +feather52840sense.build.pid=0x8087 + +# SofDevice Menu +feather52840sense.menu.softdevice.s140v6=S140 6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_name=s140 +feather52840sense.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840sense.menu.debug.l0=Level 0 (Release) +feather52840sense.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840sense.menu.debug.l1=Level 1 (Error Message) +feather52840sense.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840sense.menu.debug.l2=Level 2 (Full Debug) +feather52840sense.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840sense.menu.debug.l3=Level 3 (Segger SystemView) +feather52840sense.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840sense.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Bluefruit ItsyBitsy nRF52840 Express +# --------------------------------------------- +itsybitsy52840.name=Adafruit ItsyBitsy nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +itsybitsy52840.vid.0=0x239A +itsybitsy52840.pid.0=0x8051 +itsybitsy52840.vid.1=0x239A +itsybitsy52840.pid.1=0x0051 +itsybitsy52840.vid.2=0x239A +itsybitsy52840.pid.2=0x0052 +itsybitsy52840.vid.3=0x239A +itsybitsy52840.pid.3=0x8052 + +# Upload +itsybitsy52840.bootloader.tool=bootburn +itsybitsy52840.upload.tool=nrfutil +itsybitsy52840.upload.protocol=nrfutil +itsybitsy52840.upload.use_1200bps_touch=true +itsybitsy52840.upload.wait_for_upload_port=true +itsybitsy52840.upload.maximum_size=815104 +itsybitsy52840.upload.maximum_data_size=237568 + +# Build +itsybitsy52840.build.mcu=cortex-m4 +itsybitsy52840.build.f_cpu=64000000 +itsybitsy52840.build.board=NRF52840_ITSYBITSY +itsybitsy52840.build.core=nRF5 +itsybitsy52840.build.variant=itsybitsy_nrf52840_express +itsybitsy52840.build.usb_manufacturer="Adafruit LLC" +itsybitsy52840.build.usb_product="ItsyBitsy nRF52840 Express" +itsybitsy52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52_ITSYBITSY {build.flags.usb} +itsybitsy52840.build.ldscript=nrf52840_s140_v6.ld +itsybitsy52840.build.vid=0x239A +itsybitsy52840.build.pid=0x8051 + +# SofDevice Menu +itsybitsy52840.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_name=s140 +itsybitsy52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +itsybitsy52840.menu.debug.l0=Level 0 (Release) +itsybitsy52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +itsybitsy52840.menu.debug.l1=Level 1 (Error Message) +itsybitsy52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +itsybitsy52840.menu.debug.l2=Level 2 (Full Debug) +itsybitsy52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +itsybitsy52840.menu.debug.l3=Level 3 (Segger SystemView) +itsybitsy52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +itsybitsy52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# --------------------------------------------- +# Bluefruit Circuit Playground nRF52840 Express +# --------------------------------------------- +cplaynrf52840.name=Adafruit Circuit Playground Bluefruit + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cplaynrf52840.vid.0=0x239A +cplaynrf52840.pid.0=0x8045 +cplaynrf52840.vid.1=0x239A +cplaynrf52840.pid.1=0x0045 +cplaynrf52840.vid.2=0x239A +cplaynrf52840.pid.2=0x0046 +cplaynrf52840.vid.3=0x239A +cplaynrf52840.pid.3=0x8046 + +# Upload +cplaynrf52840.bootloader.tool=bootburn +cplaynrf52840.upload.tool=nrfutil +cplaynrf52840.upload.protocol=nrfutil +cplaynrf52840.upload.use_1200bps_touch=true +cplaynrf52840.upload.wait_for_upload_port=true +cplaynrf52840.upload.maximum_size=815104 +cplaynrf52840.upload.maximum_data_size=237568 + +# Build +cplaynrf52840.build.mcu=cortex-m4 +cplaynrf52840.build.f_cpu=64000000 +cplaynrf52840.build.board=NRF52840_CIRCUITPLAY +cplaynrf52840.build.core=nRF5 +cplaynrf52840.build.variant=circuitplayground_nrf52840 +cplaynrf52840.build.usb_manufacturer="Adafruit LLC" +cplaynrf52840.build.usb_product="Circuit Playground Bluefruit" +cplaynrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld +cplaynrf52840.build.vid=0x239A +cplaynrf52840.build.pid=0x8045 + +# SofDevice Menu +cplaynrf52840.menu.softdevice.s140v6=S140 6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cplaynrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cplaynrf52840.menu.debug.l0=Level 0 (Release) +cplaynrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cplaynrf52840.menu.debug.l1=Level 1 (Error Message) +cplaynrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cplaynrf52840.menu.debug.l2=Level 2 (Full Debug) +cplaynrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cplaynrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cplaynrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Clue nRF52840 +# --------------------------------------------- +cluenrf52840.name=Adafruit CLUE + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cluenrf52840.vid.0=0x239A +cluenrf52840.pid.0=0x8072 +cluenrf52840.vid.1=0x239A +cluenrf52840.pid.1=0x0072 +cluenrf52840.vid.2=0x239A +cluenrf52840.pid.2=0x0071 +cluenrf52840.vid.3=0x239A +cluenrf52840.pid.3=0x8071 + +# Upload +cluenrf52840.bootloader.tool=bootburn +cluenrf52840.upload.tool=nrfutil +cluenrf52840.upload.protocol=nrfutil +cluenrf52840.upload.use_1200bps_touch=true +cluenrf52840.upload.wait_for_upload_port=true +cluenrf52840.upload.maximum_size=815104 +cluenrf52840.upload.maximum_data_size=237568 + +# Build +cluenrf52840.build.mcu=cortex-m4 +cluenrf52840.build.f_cpu=64000000 +cluenrf52840.build.board=NRF52840_CLUE +cluenrf52840.build.core=nRF5 +cluenrf52840.build.variant=clue_nrf52840 +cluenrf52840.build.usb_manufacturer="Adafruit LLC" +cluenrf52840.build.usb_product="CLUE" +cluenrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +cluenrf52840.build.ldscript=nrf52840_s140_v6.ld +cluenrf52840.build.vid=0x239A +cluenrf52840.build.pid=0x8071 + +# SofDevice Menu +cluenrf52840.menu.softdevice.s140v6=S140 6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cluenrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cluenrf52840.menu.debug.l0=Level 0 (Release) +cluenrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cluenrf52840.menu.debug.l1=Level 1 (Error Message) +cluenrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cluenrf52840.menu.debug.l2=Level 2 (Full Debug) +cluenrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cluenrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cluenrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cluenrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Metro nRF52840 Express +# ---------------------------------- +metro52840.name=Adafruit Metro nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +metro52840.vid.0=0x239A +metro52840.pid.0=0x803F +metro52840.vid.1=0x239A +metro52840.pid.1=0x003F +metro52840.vid.2=0x239A +metro52840.pid.2=0x0040 +metro52840.vid.3=0x239A +metro52840.pid.3=0x8040 + +# Upload +metro52840.bootloader.tool=bootburn +metro52840.upload.tool=nrfutil +metro52840.upload.protocol=nrfutil +metro52840.upload.use_1200bps_touch=true +metro52840.upload.wait_for_upload_port=true +metro52840.upload.maximum_size=815104 +metro52840.upload.maximum_data_size=237568 + +# Build +metro52840.build.mcu=cortex-m4 +metro52840.build.f_cpu=64000000 +metro52840.build.board=NRF52840_METRO +metro52840.build.core=nRF5 +metro52840.build.variant=metro_nrf52840_express +metro52840.build.usb_manufacturer="Adafruit LLC" +metro52840.build.usb_product="Metro nRF52840 Express" +metro52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +metro52840.build.ldscript=nrf52840_s140_v6.ld +metro52840.build.vid=0x239A +metro52840.build.pid=0x803F + +# SofDevice Menu +metro52840.menu.softdevice.s140v6=S140 6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_name=s140 +metro52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +metro52840.menu.debug.l0=Level 0 (Release) +metro52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +metro52840.menu.debug.l1=Level 1 (Error Message) +metro52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +metro52840.menu.debug.l2=Level 2 (Full Debug) +metro52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +metro52840.menu.debug.l3=Level 3 (Segger SystemView) +metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +metro52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + + + +# ------------------------------------------------------- +# +# Boards that aren't made by Adafruit +# +# ------------------------------------------------------- + + +# ---------------------------------- +# Nordic nRF52840DK (PCA10056) +# ---------------------------------- +pca10056.name=Nordic nRF52840DK (PCA10056) +pca10056.bootloader.tool=bootburn + +# Upload +pca10056.upload.tool=nrfutil +pca10056.upload.protocol=nrfutil +pca10056.upload.use_1200bps_touch=true +pca10056.upload.wait_for_upload_port=true +pca10056.upload.maximum_size=815104 +pca10056.upload.maximum_data_size=237568 + +# Build +pca10056.build.mcu=cortex-m4 +pca10056.build.f_cpu=64000000 +pca10056.build.board=NRF52840_PCA10056 +pca10056.build.core=nRF5 +pca10056.build.variant=pca10056 +pca10056.build.usb_manufacturer="Nordic" +pca10056.build.usb_product="nRF52840 DK" +pca10056.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +pca10056.build.ldscript=nrf52840_s140_v6.ld +pca10056.build.vid=0x239A +pca10056.build.pid=0x8029 + +# SofDevice Menu +pca10056.menu.softdevice.s140v6=S140 6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_name=s140 +pca10056.menu.softdevice.s140v6.build.sd_version=6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +pca10056.menu.debug.l0=Level 0 (Release) +pca10056.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +pca10056.menu.debug.l1=Level 1 (Error Message) +pca10056.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +pca10056.menu.debug.l2=Level 2 (Full Debug) +pca10056.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +pca10056.menu.debug.l3=Level 3 (Segger SystemView) +pca10056.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +pca10056.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Particle Xenon +# ---------------------------------- +particle_xenon.name=Particle Xenon + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +particle_xenon.vid.0=0x239A +particle_xenon.pid.0=0x8029 +particle_xenon.vid.1=0x239A +particle_xenon.pid.1=0x0029 +particle_xenon.vid.2=0x239A +particle_xenon.pid.2=0x002A +particle_xenon.vid.3=0x239A +particle_xenon.pid.3=0x802A + +# Upload +particle_xenon.bootloader.tool=bootburn +particle_xenon.upload.tool=nrfutil +particle_xenon.upload.protocol=nrfutil +particle_xenon.upload.use_1200bps_touch=true +particle_xenon.upload.wait_for_upload_port=true +particle_xenon.upload.maximum_size=815104 +particle_xenon.upload.maximum_data_size=237568 + +# Build +particle_xenon.build.mcu=cortex-m4 +particle_xenon.build.f_cpu=64000000 +particle_xenon.build.board=PARTICLE_XENON +particle_xenon.build.core=nRF5 +particle_xenon.build.variant=particle_xenon +particle_xenon.build.usb_manufacturer="Particle Industries" +particle_xenon.build.usb_product="Particle Xenon" +particle_xenon.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +particle_xenon.build.ldscript=nrf52840_s140_v6.ld +particle_xenon.build.vid=0x239A +particle_xenon.build.pid=0x8029 + +# SofDevice Menu +particle_xenon.menu.softdevice.s140v6=S140 6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_name=s140 +particle_xenon.menu.softdevice.s140v6.build.sd_version=6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +particle_xenon.menu.debug.l0=Level 0 (Release) +particle_xenon.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +particle_xenon.menu.debug.l1=Level 1 (Error Message) +particle_xenon.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +particle_xenon.menu.debug.l2=Level 2 (Full Debug) +particle_xenon.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +particle_xenon.menu.debug.l3=Level 3 (Segger SystemView) +particle_xenon.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +particle_xenon.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Raytac MDBT50Q - RX +# ---------------------------------- +mdbt50qrx.name=Raytac MDBT50Q-RX Dongle + +# VID/PID for bootloader, Arduino + Circuitpython App +mdbt50qrx.vid.0=0x239A +mdbt50qrx.pid.0=0x810B +mdbt50qrx.vid.1=0x239A +mdbt50qrx.pid.1=0x010B +mdbt50qrx.vid.2=0x239A +mdbt50qrx.pid.2=0x810C + +# Upload +mdbt50qrx.bootloader.tool=bootburn +mdbt50qrx.upload.tool=nrfutil +mdbt50qrx.upload.protocol=nrfutil +mdbt50qrx.upload.use_1200bps_touch=true +mdbt50qrx.upload.wait_for_upload_port=true +mdbt50qrx.upload.maximum_size=815104 +mdbt50qrx.upload.maximum_data_size=237568 + +# Build +mdbt50qrx.build.mcu=cortex-m4 +mdbt50qrx.build.f_cpu=64000000 +mdbt50qrx.build.board=MDBT50Q_RX +mdbt50qrx.build.core=nRF5 +mdbt50qrx.build.variant=raytac_mdbt50q_rx +mdbt50qrx.build.usb_manufacturer="Raytac" +mdbt50qrx.build.usb_product="nRF52840 Dongle" +mdbt50qrx.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld +mdbt50qrx.build.vid=0x239A +mdbt50qrx.build.pid=0x810B + +# SofDevice Menu +mdbt50qrx.menu.softdevice.s140v6=S140 6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_name=s140 +mdbt50qrx.menu.softdevice.s140v6.build.sd_version=6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +mdbt50qrx.menu.debug.l0=Level 0 (Release) +mdbt50qrx.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +mdbt50qrx.menu.debug.l1=Level 1 (Error Message) +mdbt50qrx.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +mdbt50qrx.menu.debug.l2=Level 2 (Full Debug) +mdbt50qrx.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +mdbt50qrx.menu.debug.l3=Level 3 (Segger SystemView) +mdbt50qrx.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +mdbt50qrx.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# ---------------------------------- +# NINA B302 +# ---------------------------------- +ninab302.name=NINA B302 ublox + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +ninab302.vid.0=0x239A +ninab302.pid.0=0x8029 +ninab302.vid.1=0x239A +ninab302.pid.1=0x0029 +ninab302.vid.2=0x7239A +ninab302.pid.2=0x002A +ninab302.vid.3=0x239A +ninab302.pid.3=0x802A + +# Upload +ninab302.bootloader.tool=bootburn +ninab302.upload.tool=nrfutil +ninab302.upload.protocol=nrfutil +ninab302.upload.use_1200bps_touch=true +ninab302.upload.wait_for_upload_port=true +ninab302.upload.maximum_size=815104 +ninab302.upload.maximum_data_size=237568 + +# Build +ninab302.build.mcu=cortex-m4 +ninab302.build.f_cpu=64000000 +ninab302.build.board=NINA_B302_ublox +ninab302.build.core=nRF5 +ninab302.build.variant=NINA_B302_ublox +ninab302.build.usb_manufacturer="Nordic" +ninab302.build.usb_product="NINA B302 ublox" +ninab302.build.extra_flags=-DNRF52840_XXAA -DNINA_B302_ublox {build.flags.usb} +ninab302.build.ldscript=nrf52840_s140_v6.ld +ninab302.build.vid=0x239A +ninab302.build.pid=0x8029 + +# SofDevice Menu +ninab302.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_name=s140 +ninab302.menu.softdevice.s140v6.build.sd_version=6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +ninab302.menu.debug.l0=Level 0 (Release) +ninab302.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab302.menu.debug.l1=Level 1 (Error Message) +ninab302.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab302.menu.debug.l2=Level 2 (Full Debug) +ninab302.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab302.menu.debug.l3=Level 3 (Segger SystemView) +ninab302.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab302.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# NINA B112 +# ---------------------------------- +ninab112.name=NINA B112 ublox +ninab112.bootloader.tool=bootburn + +# Upload +ninab112.upload.tool=nrfutil +ninab112.upload.protocol=nrfutil +ninab112.upload.use_1200bps_touch=false +ninab112.upload.wait_for_upload_port=false +ninab112.upload.native_usb=false +ninab112.upload.maximum_size=290816 +ninab112.upload.maximum_data_size=52224 + +# Build +ninab112.build.mcu=cortex-m4 +ninab112.build.f_cpu=64000000 +ninab112.build.board=NINA_B112_ublox +ninab112.build.core=nRF5 +ninab112.build.variant=NINA_B112_ublox +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52832" +ninab112.build.extra_flags=-DNRF52832_XXAA -DNINA_B112_ublox -DNRF52 +ninab112.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +ninab112.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_name=s132 +ninab112.menu.softdevice.s132v6.build.sd_version=6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +ninab112.menu.debug.l0=Level 0 (Release) +ninab112.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab112.menu.debug.l1=Level 1 (Error Message) +ninab112.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab112.menu.debug.l2=Level 2 (Full Debug) +ninab112.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab112.menu.debug.l3=Level 3 (Segger SystemView) +ninab112.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab112.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Udp.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Udp.h new file mode 100644 index 0000000..cc814d3 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Udp.h @@ -0,0 +1,92 @@ +/* + * Udp.cpp: Library to send/receive UDP packets. + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + */ + +#ifndef udp_h +#define udp_h + +#include +#include + +class UDP : public Stream { + +public: + virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + + // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) + virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + + virtual void stop() =0; // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port) =0; + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port) =0; + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket() =0; + // Write a single byte into the packet + virtual size_t write(uint8_t) =0; + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size) =0; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket() =0; + // Number of bytes remaining in the current packet + virtual int available() =0; + // Read a single byte from the current packet + virtual int read() =0; + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len) =0; + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) =0; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek() =0; + virtual void flush() =0; // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() =0; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() =0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/platform.txt new file mode 100644 index 0000000..5c9167d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/platform.txt @@ -0,0 +1,168 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All rights reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +name=Adafruit nRF52 Boards +version=0.23.0 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-pointer-arith + +# Allow changing optimization settings via platform.local.txt / boards.local.txt +compiler.optimization_flag=-Ofast + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD + + +# KH, Error here to use gcc, must use g++ +#compiler.c.elf.cmd=arm-none-eabi-gcc +compiler.c.elf.cmd=arm-none-eabi-g++ + +compiler.c.elf.flags={compiler.optimization_flag} -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-mcpu={build.mcu} -mthumb -mabi=aapcs {compiler.optimization_flag} -g -c {build.float_flags} -x assembler-with-cpp + +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2bin.flags=-O binary +compiler.elf2bin.cmd=arm-none-eabi-objcopy +compiler.elf2hex.flags=-O ihex +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb {build.float_flags} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align --specs=nano.specs --specs=nosys.specs +compiler.size.cmd=arm-none-eabi-size + +# this can be overriden in boards.txt +build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float +build.debug_flags=-DCFG_DEBUG=0 +build.logger_flags=-DCFG_LOGGER=1 +build.sysview_flags=-DCFG_SYSVIEW=0 + +# USB flags +build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.libraries.ldflags= +compiler.elf2bin.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.7.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.7.0.path}/CMSIS/DSP/Include/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.7.0.path}/CMSIS/DSP/Lib/GCC/" -larm_cortexM4lf_math + +# common compiler for nrf +rtos.path={build.core.path}/freertos +nordic.path={build.core.path}/nordic + +# build.logger_flags and build.sysview_flags are intentionally empty, +# to allow modification via a user's own boards.local.txt or platform.local.txt files. +build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DDX_CC_TEE -DLFS_NAME_MAX=64 {compiler.optimization_flag} {build.debug_flags} {build.logger_flags} {build.sysview_flags} {compiler.arm.cmsis.c.flags} "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include/nrf52" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Create archives +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-L{build.core.path}/linker" "-T{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} -Wl,--start-group {compiler.arm.cmsis.ldflags} -lm "{build.path}/{archive_file}" {compiler.libraries.ldflags} -Wl,--end-group + +## Create output (bin file) +#recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2bin.cmd}" {compiler.elf2bin.flags} {compiler.elf2bin.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +## Create dfu package zip file +recipe.objcopy.zip.pattern="{tools.nrfutil.cmd}" dfu genpkg --dev-type 0x0052 --sd-req {build.sd_fwid} --application "{build.path}/{build.project_name}.hex" "{build.path}/{build.project_name}.zip" + +## Create uf2 file +#recipe.objcopy.uf2.pattern=python "{runtime.platform.path}/tools/uf2conv/uf2conv.py" -f 0xADA52840 -c -o "{build.path}/{build.project_name}.uf2" "{build.path}/{build.project_name}.hex" + +## Save bin +recipe.output.tmp_file_bin={build.project_name}.bin +recipe.output.save_file_bin={build.project_name}.save.bin + +## Save hex +recipe.output.tmp_file_hex={build.project_name}.hex +recipe.output.save_file_hexu={build.project_name}.save.hex + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + +## Export Compiled Binary +recipe.output.tmp_file={build.project_name}.hex +recipe.output.save_file={build.project_name}.{build.variant}.hex + +#*************************************************** +# adafruit-nrfutil for uploading +# https://github.com/adafruit/Adafruit_nRF52_nrfutil +# pre-built binaries are provided for macos and windows +#*************************************************** +tools.nrfutil.cmd=adafruit-nrfutil +tools.nrfutil.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe +tools.nrfutil.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil + +tools.nrfutil.upload.params.verbose=--verbose +tools.nrfutil.upload.params.quiet= +tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.path}/{build.project_name}.zip" -p {serial.port} -b 115200 --singlebank + +#*************************************************** +# Burning bootloader with either jlink or nrfutil +#*************************************************** + +# Bootloader version +tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.6.0_{build.sd_name}_{build.sd_version} + +tools.bootburn.bootloader.params.verbose= +tools.bootburn.bootloader.params.quiet= +tools.bootburn.bootloader.pattern={program.burn_pattern} + +# erase flash page while programming +tools.bootburn.erase.params.verbose= +tools.bootburn.erase.params.quiet= +tools.bootburn.erase.pattern= + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B112_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B112_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B112_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B112_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B112_ublox/variant.cpp new file mode 100644 index 0000000..f43f3a4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B112_ublox/variant.cpp @@ -0,0 +1,59 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" + +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +const uint32_t g_ADigitalPinMap[] = { + // D0 .. D13 + 5, // D0 is P0.05 (UART RX) + 6, // D1 is P0.06 (UART TX) + 7, // D2 is P0.07 + 31, // D3 is P0.31 + 18, // D4 is P0.18 (LED Blue) + 99, // D5 (NC) + 9, // D6 is P0.09 NFC1 + 10, // D7 is P0.10 (Button) NFC2 + 99, // D8 (NC) + 8, // D9 is P0.08 + 11, // D10 is P0.11 CS + 13, // D11 is P0.13 MOSI + 12, // D12 is P0.12 MISO + 14, // D13 is P0.14 SCK + //I2C + 2, // D14 is P0.2 (SDA) + 3, // D15 is P0.3 (SCL) + // D16 .. D21 (aka A0 .. A5) + 3, // D16 is P0.03 (A0) + 2, // D17 is P0.02 (A1) + 4, // D18 is P0.04 (A2) + 30, // D19 is P0.30 (A3) SW2 + 29, // D20 is P0.29 (A4) + 28, // D21 is P0.28 (A5) + 9, // P0.09 NFC + 10, // P0.10 NFC + 16, // SW1 (LED Green) +}; \ No newline at end of file diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B112_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B112_ublox/variant.h new file mode 100644 index 0000000..833cbf6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B112_ublox/variant.h @@ -0,0 +1,172 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +#ifndef _VARIANT_NINA_B112_UBLOX_ +#define _VARIANT_NINA_B112_UBLOX_ + +#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \ + .rc_ctiv = 0, \ +.rc_temp_ctiv = 0, \ +.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM} + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (32u) +#define NUM_DIGITAL_PINS (32u) +#define NUM_ANALOG_INPUTS (6u) +#define NUM_ANALOG_OUTPUTS (0u) + +// LEDs +#define PIN_LED LED1 +#define LED_BUILTIN PIN_LED + +//LEDs onboard +#define LED1 (0) // Red +#define LED2 (24) // Green/SW1 +#define LED3 (4) // Blue + +#define LED_STATE_ON 1 // State when LED is litted + +//Switch +#define SW1 (24) +#define SW2 (19) + +// NFC +#define PIN_NFC_1 (6) // P0.9 +#define PIN_NFC_2 (7) // P0.10 + +/* + * Analog pins + */ +#define PIN_A0 (16) // P0.03 +#define PIN_A1 (17) // P0.02 +#define PIN_A2 (18) // P0.04 +#define PIN_A3 (19) // P0.30 +#define PIN_A4 (20) // P0.29 +#define PIN_A5 (21) // P0.28 + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_D0 (0) // P0.05 +#define PIN_D1 (1) // P0.06 +#define PIN_D2 (2) // P0.07 +#define PIN_D3 (4) // P0.31 +#define PIN_D4 (5) // P0.18 +#define PIN_D6 (6) // P0.09 +#define PIN_D7 (7) // P0.10 +#define PIN_D9 (9) // P0.08 +#define PIN_D10 (11) // P0.11 +#define PIN_D11 (13) // P0.13 +#define PIN_D12 (12) // P0.12 +#define PIN_D13 (14) // P0.14 +#define PIN_D14 (2) // P0.02 +#define PIN_D15 (3) // P0.03 + +static const uint8_t D0 = PIN_D0 ; +static const uint8_t D1 = PIN_D1 ; +static const uint8_t D2 = PIN_D2 ; +static const uint8_t D3 = PIN_D3 ; +static const uint8_t D4 = PIN_D4 ; +static const uint8_t D6 = PIN_D6 ; +static const uint8_t D7 = PIN_D7 ; +static const uint8_t D9 = PIN_D9 ; +static const uint8_t D10 = PIN_D10 ; +static const uint8_t D11 = PIN_D11 ; +static const uint8_t D12 = PIN_D12 ; +static const uint8_t D13 = PIN_D13 ; +static const uint8_t D14 = PIN_D14 ; +static const uint8_t D15 = PIN_D15 ; + +// Other pins +//static const uint8_t AREF = PIN_AREF; + +//#define PIN_AREF (24) +//#define PIN_VBAT PIN_A7 + +/* + * Serial interfaces + */ +#define PIN_SERIAL_RX (0) // P0.05 +#define PIN_SERIAL_TX (1) // P0.06 +#define PIN_SERIAL_CTS (2) // P0.07 +#define PIN_SERIAL_RTS (3) // P0.31 +#define PIN_SERIAL_DTR (28) // P0.28 +#define PIN_SERIAL_DSR (29) // P0.29 + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (12) // P0.12 +#define PIN_SPI_MOSI (11) // P0.13 +#define PIN_SPI_SCK (13) // P0.14 + +static const uint8_t SS = 10 ; // P0.11 +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (14) // P0.02 +#define PIN_WIRE_SCL (15) // P0.03 + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + + +#endif //_VARIANT_NINA_B112_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B302_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B302_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B302_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B302_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B302_ublox/variant.cpp new file mode 100644 index 0000000..8b4df2e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B302_ublox/variant.cpp @@ -0,0 +1,87 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 + 29, // D0 is P0.29 (UART RX) + 45, // D1 is P1.13 (UART TX) + 44, // D2 is P1.12 (NFC2) + 31, // D3 is P0.31 (LED1) + 13, // D4 is P0.13 (LED2) + 11, // D5 is P0.11 + 9, // D6 is P0.09 + 10, // D7 is P0.10 (Button) + 41, // D8 is P1.09 + 12, // D9 is P0.12 + 14, // D10 is P0.14 + 15, // D11 is P0.15 + 32, // D12 is P1.00 + 7, // D13 is P0.07 + + // D14 .. D21 (aka A0 .. A5) + 4, // D14 is P0.04 (A0) + 30, // D15 is P0.30 (A1) + 5, // D16 is P0.05 (A2) + 2, // D17 is P0.02 (A3) + 28, // D18 is P0.28 (A4) + 3, // D19 is P0.03 (A5) + + // D20 .. D21 (aka I2C pins) + 16, // D20 is P0.16 (SDA) + 24, // D21 is P0.24 (SCL) + + // QSPI pins (not exposed via any header / test point) + 19, // D22 is P0.19 (QSPI CLK) + 17, // D23 is P0.17 (QSPI CS) + 20, // D24 is P0.20 (QSPI Data 0) + 21, // D25 is P0.21 (QSPI Data 1) + 22, // D26 is P0.22 (QSPI Data 2) + 26, // D27 is P0.23 (QSPI Data 3) + + 40, // D28 is P1.08 - IO34 + 41, // D29 is P1.01 - IO35 + 44, // D30 is P1.02 - IO36 + 45, // D31 is P1.03 - IO37 + 42, // D32 is P1.10 - IO38 + 43, // D33 is P1.11 - IO39 + 47, // D34 is P1.15 - IO40 + 46, // D35 is P1.14 - IO41 + 26, // D36 is P0.26 - IO42 + 6, // D37 is P0.6 - IO43 + 27, // D38 is P0.27 - IO44 +}; + +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B302_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B302_ublox/variant.h new file mode 100644 index 0000000..a69575f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B302_ublox/variant.h @@ -0,0 +1,149 @@ + /* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#ifndef _VARIANT_NINA_B302_UBLOX_ +#define _VARIANT_NINA_B302_UBLOX_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus +// Number of pins defined in PinDescription array +#define PINS_COUNT (40) +#define NUM_DIGITAL_PINS (34) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (3) +#define PIN_LED2 (4) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_RED PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +/* + * Buttons + */ +#define PIN_BUTTON1 (7) + +/* + * Analog pins + */ +#define PIN_A0 (14) +#define PIN_A1 (15) +#define PIN_A2 (16) +#define PIN_A3 (17) +#define PIN_A4 (18) +#define PIN_A5 (19) + +#define D0 (0) +#define D1 (1) +#define D2 (2) +#define D3 (3) +#define D4 (4) +#define D5 (5) +#define D6 (6) +#define D7 (7) +#define D8 (8) +#define D9 (9) +#define D10 (10) +#define D11 (11) +#define D12 (12) +#define D13 (13) + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_NFC1 (31) +#define PIN_NFC2 (2) + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (0) +#define PIN_SERIAL1_TX (1) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (22) //24 original +#define PIN_SPI_MOSI (23) //25 original +#define PIN_SPI_SCK (24) //26 original + +static const uint8_t SS = (13); +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (20) +#define PIN_WIRE_SCL (21) + +// QSPI Pins +#define PIN_QSPI_SCK 22 +#define PIN_QSPI_CS 23 +#define PIN_QSPI_IO0 24 +#define PIN_QSPI_IO1 25 +#define PIN_QSPI_IO2 26 +#define PIN_QSPI_IO3 27 + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES GD25Q16C +#define EXTERNAL_FLASH_USE_QSPI + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif //_VARIANT_NINA_B302_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/boards.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/boards.txt new file mode 100644 index 0000000..06f117a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/boards.txt @@ -0,0 +1,649 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +menu.softdevice=SoftDevice +menu.debug=Debug + +# ---------------------------------- +# Bluefruit Feather nRF52832 +# ---------------------------------- +feather52832.name=Adafruit Feather nRF52832 +feather52832.bootloader.tool=bootburn + +# Upload +feather52832.upload.tool=nrfutil +feather52832.upload.protocol=nrfutil +feather52832.upload.use_1200bps_touch=false +feather52832.upload.wait_for_upload_port=false +feather52832.upload.native_usb=false +feather52832.upload.maximum_size=290816 +feather52832.upload.maximum_data_size=52224 + +# Build +feather52832.build.mcu=cortex-m4 +feather52832.build.f_cpu=64000000 +feather52832.build.board=NRF52832_FEATHER +feather52832.build.core=nRF5 +feather52832.build.variant=feather_nrf52832 +feather52832.build.usb_manufacturer="Adafruit LLC" +feather52832.build.usb_product="Feather nRF52832" +feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52 +feather52832.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +feather52832.menu.softdevice.s132v6=S132 6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_name=s132 +feather52832.menu.softdevice.s132v6.build.sd_version=6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +feather52832.menu.debug.l0=Level 0 (Release) +feather52832.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52832.menu.debug.l1=Level 1 (Error Message) +feather52832.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52832.menu.debug.l2=Level 2 (Full Debug) +feather52832.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52832.menu.debug.l3=Level 3 (Segger SystemView) +feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52832.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Bluefruit Feather nRF52840 Express +# ---------------------------------- +feather52840.name=Adafruit Feather nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840.vid.0=0x239A +feather52840.pid.0=0x8029 +feather52840.vid.1=0x239A +feather52840.pid.1=0x0029 +feather52840.vid.2=0x239A +feather52840.pid.2=0x002A +feather52840.vid.3=0x239A +feather52840.pid.3=0x802A + +# Upload +feather52840.bootloader.tool=bootburn +feather52840.upload.tool=nrfutil +feather52840.upload.protocol=nrfutil +feather52840.upload.use_1200bps_touch=true +feather52840.upload.wait_for_upload_port=true +feather52840.upload.maximum_size=815104 +feather52840.upload.maximum_data_size=237568 + +# Build +feather52840.build.mcu=cortex-m4 +feather52840.build.f_cpu=64000000 +feather52840.build.board=NRF52840_FEATHER +feather52840.build.core=nRF5 +feather52840.build.variant=feather_nrf52840_express +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52840 Express" +feather52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +feather52840.build.ldscript=nrf52840_s140_v6.ld +feather52840.build.vid=0x239A +feather52840.build.pid=0x8029 + +# SofDevice Menu +feather52840.menu.softdevice.s140v6=S140 6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_name=s140 +feather52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840.menu.debug.l0=Level 0 (Release) +feather52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840.menu.debug.l1=Level 1 (Error Message) +feather52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840.menu.debug.l2=Level 2 (Full Debug) +feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840.menu.debug.l3=Level 3 (Segger SystemView) +feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# ---------------------------------- +# Feather nRF52840 sense +# ---------------------------------- +feather52840sense.name=Adafruit Feather nRF52840 Sense + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840sense.vid.0=0x239A +feather52840sense.pid.0=0x8087 +feather52840sense.vid.1=0x239A +feather52840sense.pid.1=0x0087 +feather52840sense.vid.2=0x239A +feather52840sense.pid.2=0x0088 +feather52840sense.vid.3=0x239A +feather52840sense.pid.3=0x8088 + +# Upload +feather52840sense.bootloader.tool=bootburn +feather52840sense.upload.tool=nrfutil +feather52840sense.upload.protocol=nrfutil +feather52840sense.upload.use_1200bps_touch=true +feather52840sense.upload.wait_for_upload_port=true +feather52840sense.upload.maximum_size=815104 +feather52840sense.upload.maximum_data_size=237568 + +# Build +feather52840sense.build.mcu=cortex-m4 +feather52840sense.build.f_cpu=64000000 +feather52840sense.build.board=NRF52840_FEATHER_SENSE +feather52840sense.build.core=nRF5 +feather52840sense.build.variant=feather_nrf52840_sense +feather52840sense.build.usb_manufacturer="Adafruit LLC" +feather52840sense.build.usb_product="Feather nRF52840 Sense" +feather52840sense.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +feather52840sense.build.ldscript=nrf52840_s140_v6.ld +feather52840sense.build.vid=0x239A +feather52840sense.build.pid=0x8087 + +# SofDevice Menu +feather52840sense.menu.softdevice.s140v6=S140 6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_name=s140 +feather52840sense.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840sense.menu.debug.l0=Level 0 (Release) +feather52840sense.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840sense.menu.debug.l1=Level 1 (Error Message) +feather52840sense.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840sense.menu.debug.l2=Level 2 (Full Debug) +feather52840sense.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840sense.menu.debug.l3=Level 3 (Segger SystemView) +feather52840sense.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840sense.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Bluefruit ItsyBitsy nRF52840 Express +# --------------------------------------------- +itsybitsy52840.name=Adafruit ItsyBitsy nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +itsybitsy52840.vid.0=0x239A +itsybitsy52840.pid.0=0x8051 +itsybitsy52840.vid.1=0x239A +itsybitsy52840.pid.1=0x0051 +itsybitsy52840.vid.2=0x239A +itsybitsy52840.pid.2=0x0052 +itsybitsy52840.vid.3=0x239A +itsybitsy52840.pid.3=0x8052 + +# Upload +itsybitsy52840.bootloader.tool=bootburn +itsybitsy52840.upload.tool=nrfutil +itsybitsy52840.upload.protocol=nrfutil +itsybitsy52840.upload.use_1200bps_touch=true +itsybitsy52840.upload.wait_for_upload_port=true +itsybitsy52840.upload.maximum_size=815104 +itsybitsy52840.upload.maximum_data_size=237568 + +# Build +itsybitsy52840.build.mcu=cortex-m4 +itsybitsy52840.build.f_cpu=64000000 +itsybitsy52840.build.board=NRF52840_ITSYBITSY +itsybitsy52840.build.core=nRF5 +itsybitsy52840.build.variant=itsybitsy_nrf52840_express +itsybitsy52840.build.usb_manufacturer="Adafruit LLC" +itsybitsy52840.build.usb_product="ItsyBitsy nRF52840 Express" +itsybitsy52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52_ITSYBITSY {build.flags.usb} +itsybitsy52840.build.ldscript=nrf52840_s140_v6.ld +itsybitsy52840.build.vid=0x239A +itsybitsy52840.build.pid=0x8051 + +# SofDevice Menu +itsybitsy52840.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_name=s140 +itsybitsy52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +itsybitsy52840.menu.debug.l0=Level 0 (Release) +itsybitsy52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +itsybitsy52840.menu.debug.l1=Level 1 (Error Message) +itsybitsy52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +itsybitsy52840.menu.debug.l2=Level 2 (Full Debug) +itsybitsy52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +itsybitsy52840.menu.debug.l3=Level 3 (Segger SystemView) +itsybitsy52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +itsybitsy52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# --------------------------------------------- +# Bluefruit Circuit Playground nRF52840 Express +# --------------------------------------------- +cplaynrf52840.name=Adafruit Circuit Playground Bluefruit + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cplaynrf52840.vid.0=0x239A +cplaynrf52840.pid.0=0x8045 +cplaynrf52840.vid.1=0x239A +cplaynrf52840.pid.1=0x0045 +cplaynrf52840.vid.2=0x239A +cplaynrf52840.pid.2=0x0046 +cplaynrf52840.vid.3=0x239A +cplaynrf52840.pid.3=0x8046 + +# Upload +cplaynrf52840.bootloader.tool=bootburn +cplaynrf52840.upload.tool=nrfutil +cplaynrf52840.upload.protocol=nrfutil +cplaynrf52840.upload.use_1200bps_touch=true +cplaynrf52840.upload.wait_for_upload_port=true +cplaynrf52840.upload.maximum_size=815104 +cplaynrf52840.upload.maximum_data_size=237568 + +# Build +cplaynrf52840.build.mcu=cortex-m4 +cplaynrf52840.build.f_cpu=64000000 +cplaynrf52840.build.board=NRF52840_CIRCUITPLAY +cplaynrf52840.build.core=nRF5 +cplaynrf52840.build.variant=circuitplayground_nrf52840 +cplaynrf52840.build.usb_manufacturer="Adafruit LLC" +cplaynrf52840.build.usb_product="Circuit Playground Bluefruit" +cplaynrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld +cplaynrf52840.build.vid=0x239A +cplaynrf52840.build.pid=0x8045 + +# SofDevice Menu +cplaynrf52840.menu.softdevice.s140v6=S140 6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cplaynrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cplaynrf52840.menu.debug.l0=Level 0 (Release) +cplaynrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cplaynrf52840.menu.debug.l1=Level 1 (Error Message) +cplaynrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cplaynrf52840.menu.debug.l2=Level 2 (Full Debug) +cplaynrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cplaynrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cplaynrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Clue nRF52840 +# --------------------------------------------- +cluenrf52840.name=Adafruit CLUE + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cluenrf52840.vid.0=0x239A +cluenrf52840.pid.0=0x8072 +cluenrf52840.vid.1=0x239A +cluenrf52840.pid.1=0x0072 +cluenrf52840.vid.2=0x239A +cluenrf52840.pid.2=0x0071 +cluenrf52840.vid.3=0x239A +cluenrf52840.pid.3=0x8071 + +# Upload +cluenrf52840.bootloader.tool=bootburn +cluenrf52840.upload.tool=nrfutil +cluenrf52840.upload.protocol=nrfutil +cluenrf52840.upload.use_1200bps_touch=true +cluenrf52840.upload.wait_for_upload_port=true +cluenrf52840.upload.maximum_size=815104 +cluenrf52840.upload.maximum_data_size=237568 + +# Build +cluenrf52840.build.mcu=cortex-m4 +cluenrf52840.build.f_cpu=64000000 +cluenrf52840.build.board=NRF52840_CLUE +cluenrf52840.build.core=nRF5 +cluenrf52840.build.variant=clue_nrf52840 +cluenrf52840.build.usb_manufacturer="Adafruit LLC" +cluenrf52840.build.usb_product="CLUE" +cluenrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +cluenrf52840.build.ldscript=nrf52840_s140_v6.ld +cluenrf52840.build.vid=0x239A +cluenrf52840.build.pid=0x8071 + +# SofDevice Menu +cluenrf52840.menu.softdevice.s140v6=S140 6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cluenrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cluenrf52840.menu.debug.l0=Level 0 (Release) +cluenrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cluenrf52840.menu.debug.l1=Level 1 (Error Message) +cluenrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cluenrf52840.menu.debug.l2=Level 2 (Full Debug) +cluenrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cluenrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cluenrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cluenrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Metro nRF52840 Express +# ---------------------------------- +metro52840.name=Adafruit Metro nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +metro52840.vid.0=0x239A +metro52840.pid.0=0x803F +metro52840.vid.1=0x239A +metro52840.pid.1=0x003F +metro52840.vid.2=0x239A +metro52840.pid.2=0x0040 +metro52840.vid.3=0x239A +metro52840.pid.3=0x8040 + +# Upload +metro52840.bootloader.tool=bootburn +metro52840.upload.tool=nrfutil +metro52840.upload.protocol=nrfutil +metro52840.upload.use_1200bps_touch=true +metro52840.upload.wait_for_upload_port=true +metro52840.upload.maximum_size=815104 +metro52840.upload.maximum_data_size=237568 + +# Build +metro52840.build.mcu=cortex-m4 +metro52840.build.f_cpu=64000000 +metro52840.build.board=NRF52840_METRO +metro52840.build.core=nRF5 +metro52840.build.variant=metro_nrf52840_express +metro52840.build.usb_manufacturer="Adafruit LLC" +metro52840.build.usb_product="Metro nRF52840 Express" +metro52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +metro52840.build.ldscript=nrf52840_s140_v6.ld +metro52840.build.vid=0x239A +metro52840.build.pid=0x803F + +# SofDevice Menu +metro52840.menu.softdevice.s140v6=S140 6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_name=s140 +metro52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +metro52840.menu.debug.l0=Level 0 (Release) +metro52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +metro52840.menu.debug.l1=Level 1 (Error Message) +metro52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +metro52840.menu.debug.l2=Level 2 (Full Debug) +metro52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +metro52840.menu.debug.l3=Level 3 (Segger SystemView) +metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +metro52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + + + +# ------------------------------------------------------- +# +# Boards that aren't made by Adafruit +# +# ------------------------------------------------------- + + +# ---------------------------------- +# Nordic nRF52840DK (PCA10056) +# ---------------------------------- +pca10056.name=Nordic nRF52840DK (PCA10056) +pca10056.bootloader.tool=bootburn + +# Upload +pca10056.upload.tool=nrfutil +pca10056.upload.protocol=nrfutil +pca10056.upload.use_1200bps_touch=true +pca10056.upload.wait_for_upload_port=true +pca10056.upload.maximum_size=815104 +pca10056.upload.maximum_data_size=237568 + +# Build +pca10056.build.mcu=cortex-m4 +pca10056.build.f_cpu=64000000 +pca10056.build.board=NRF52840_PCA10056 +pca10056.build.core=nRF5 +pca10056.build.variant=pca10056 +pca10056.build.usb_manufacturer="Nordic" +pca10056.build.usb_product="nRF52840 DK" +pca10056.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +pca10056.build.ldscript=nrf52840_s140_v6.ld +pca10056.build.vid=0x239A +pca10056.build.pid=0x8029 + +# SofDevice Menu +pca10056.menu.softdevice.s140v6=S140 6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_name=s140 +pca10056.menu.softdevice.s140v6.build.sd_version=6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +pca10056.menu.debug.l0=Level 0 (Release) +pca10056.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +pca10056.menu.debug.l1=Level 1 (Error Message) +pca10056.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +pca10056.menu.debug.l2=Level 2 (Full Debug) +pca10056.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +pca10056.menu.debug.l3=Level 3 (Segger SystemView) +pca10056.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +pca10056.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Particle Xenon +# ---------------------------------- +particle_xenon.name=Particle Xenon + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +particle_xenon.vid.0=0x239A +particle_xenon.pid.0=0x8029 +particle_xenon.vid.1=0x239A +particle_xenon.pid.1=0x0029 +particle_xenon.vid.2=0x239A +particle_xenon.pid.2=0x002A +particle_xenon.vid.3=0x239A +particle_xenon.pid.3=0x802A + +# Upload +particle_xenon.bootloader.tool=bootburn +particle_xenon.upload.tool=nrfutil +particle_xenon.upload.protocol=nrfutil +particle_xenon.upload.use_1200bps_touch=true +particle_xenon.upload.wait_for_upload_port=true +particle_xenon.upload.maximum_size=815104 +particle_xenon.upload.maximum_data_size=237568 + +# Build +particle_xenon.build.mcu=cortex-m4 +particle_xenon.build.f_cpu=64000000 +particle_xenon.build.board=PARTICLE_XENON +particle_xenon.build.core=nRF5 +particle_xenon.build.variant=particle_xenon +particle_xenon.build.usb_manufacturer="Particle Industries" +particle_xenon.build.usb_product="Particle Xenon" +particle_xenon.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +particle_xenon.build.ldscript=nrf52840_s140_v6.ld +particle_xenon.build.vid=0x239A +particle_xenon.build.pid=0x8029 + +# SofDevice Menu +particle_xenon.menu.softdevice.s140v6=S140 6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_name=s140 +particle_xenon.menu.softdevice.s140v6.build.sd_version=6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +particle_xenon.menu.debug.l0=Level 0 (Release) +particle_xenon.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +particle_xenon.menu.debug.l1=Level 1 (Error Message) +particle_xenon.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +particle_xenon.menu.debug.l2=Level 2 (Full Debug) +particle_xenon.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +particle_xenon.menu.debug.l3=Level 3 (Segger SystemView) +particle_xenon.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +particle_xenon.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Raytac MDBT50Q - RX +# ---------------------------------- +mdbt50qrx.name=Raytac MDBT50Q-RX Dongle + +# VID/PID for bootloader, Arduino + Circuitpython App +mdbt50qrx.vid.0=0x239A +mdbt50qrx.pid.0=0x810B +mdbt50qrx.vid.1=0x239A +mdbt50qrx.pid.1=0x010B +mdbt50qrx.vid.2=0x239A +mdbt50qrx.pid.2=0x810C + +# Upload +mdbt50qrx.bootloader.tool=bootburn +mdbt50qrx.upload.tool=nrfutil +mdbt50qrx.upload.protocol=nrfutil +mdbt50qrx.upload.use_1200bps_touch=true +mdbt50qrx.upload.wait_for_upload_port=true +mdbt50qrx.upload.maximum_size=815104 +mdbt50qrx.upload.maximum_data_size=237568 + +# Build +mdbt50qrx.build.mcu=cortex-m4 +mdbt50qrx.build.f_cpu=64000000 +mdbt50qrx.build.board=MDBT50Q_RX +mdbt50qrx.build.core=nRF5 +mdbt50qrx.build.variant=raytac_mdbt50q_rx +mdbt50qrx.build.usb_manufacturer="Raytac" +mdbt50qrx.build.usb_product="nRF52840 Dongle" +mdbt50qrx.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld +mdbt50qrx.build.vid=0x239A +mdbt50qrx.build.pid=0x810B + +# SofDevice Menu +mdbt50qrx.menu.softdevice.s140v6=S140 6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_name=s140 +mdbt50qrx.menu.softdevice.s140v6.build.sd_version=6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +mdbt50qrx.menu.debug.l0=Level 0 (Release) +mdbt50qrx.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +mdbt50qrx.menu.debug.l1=Level 1 (Error Message) +mdbt50qrx.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +mdbt50qrx.menu.debug.l2=Level 2 (Full Debug) +mdbt50qrx.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +mdbt50qrx.menu.debug.l3=Level 3 (Segger SystemView) +mdbt50qrx.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +mdbt50qrx.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + + +# ---------------------------------- +# NINA B302 +# ---------------------------------- +ninab302.name=NINA B302 ublox + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +ninab302.vid.0=0x239A +ninab302.pid.0=0x8029 +ninab302.vid.1=0x239A +ninab302.pid.1=0x0029 +ninab302.vid.2=0x7239A +ninab302.pid.2=0x002A +ninab302.vid.3=0x239A +ninab302.pid.3=0x802A + +# Upload +ninab302.bootloader.tool=bootburn +ninab302.upload.tool=nrfutil +ninab302.upload.protocol=nrfutil +ninab302.upload.use_1200bps_touch=true +ninab302.upload.wait_for_upload_port=true +ninab302.upload.maximum_size=815104 +ninab302.upload.maximum_data_size=237568 + +# Build +ninab302.build.mcu=cortex-m4 +ninab302.build.f_cpu=64000000 +ninab302.build.board=NINA_B302_ublox +ninab302.build.core=nRF5 +ninab302.build.variant=NINA_B302_ublox +ninab302.build.usb_manufacturer="Nordic" +ninab302.build.usb_product="NINA B302 ublox" +ninab302.build.extra_flags=-DNRF52840_XXAA -DNINA_B302_ublox {build.flags.usb} +ninab302.build.ldscript=nrf52840_s140_v6.ld +ninab302.build.vid=0x239A +ninab302.build.pid=0x8029 + +# SofDevice Menu +ninab302.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_name=s140 +ninab302.menu.softdevice.s140v6.build.sd_version=6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +ninab302.menu.debug.l0=Level 0 (Release) +ninab302.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab302.menu.debug.l1=Level 1 (Error Message) +ninab302.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab302.menu.debug.l2=Level 2 (Full Debug) +ninab302.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab302.menu.debug.l3=Level 3 (Segger SystemView) +ninab302.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab302.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# NINA B112 +# ---------------------------------- +ninab112.name=NINA B112 ublox +ninab112.bootloader.tool=bootburn + +# Upload +ninab112.upload.tool=nrfutil +ninab112.upload.protocol=nrfutil +ninab112.upload.use_1200bps_touch=false +ninab112.upload.wait_for_upload_port=false +ninab112.upload.native_usb=false +ninab112.upload.maximum_size=290816 +ninab112.upload.maximum_data_size=52224 + +# Build +ninab112.build.mcu=cortex-m4 +ninab112.build.f_cpu=64000000 +ninab112.build.board=NINA_B112_ublox +ninab112.build.core=nRF5 +ninab112.build.variant=NINA_B112_ublox +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52832" +ninab112.build.extra_flags=-DNRF52832_XXAA -DNINA_B112_ublox -DNRF52 +ninab112.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +ninab112.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_name=s132 +ninab112.menu.softdevice.s132v6.build.sd_version=6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +ninab112.menu.debug.l0=Level 0 (Release) +ninab112.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab112.menu.debug.l1=Level 1 (Error Message) +ninab112.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab112.menu.debug.l2=Level 2 (Full Debug) +ninab112.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab112.menu.debug.l3=Level 3 (Segger SystemView) +ninab112.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab112.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Udp.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Udp.h new file mode 100644 index 0000000..cc814d3 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Udp.h @@ -0,0 +1,92 @@ +/* + * Udp.cpp: Library to send/receive UDP packets. + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + */ + +#ifndef udp_h +#define udp_h + +#include +#include + +class UDP : public Stream { + +public: + virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + + // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) + virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + + virtual void stop() =0; // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port) =0; + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port) =0; + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket() =0; + // Write a single byte into the packet + virtual size_t write(uint8_t) =0; + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size) =0; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket() =0; + // Number of bytes remaining in the current packet + virtual int available() =0; + // Read a single byte from the current packet + virtual int read() =0; + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len) =0; + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) =0; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek() =0; + virtual void flush() =0; // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() =0; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() =0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/platform.txt new file mode 100644 index 0000000..469647d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/platform.txt @@ -0,0 +1,167 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All rights reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +name=Adafruit nRF52 Boards +version=0.24.0 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-pointer-arith + +# Allow changing optimization settings via platform.local.txt / boards.local.txt +compiler.optimization_flag=-Ofast + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD + +# KH, Error here to use gcc, must use g++ +#compiler.c.elf.cmd=arm-none-eabi-gcc +compiler.c.elf.cmd=arm-none-eabi-g++ + +compiler.c.elf.flags={compiler.optimization_flag} -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-mcpu={build.mcu} -mthumb -mabi=aapcs {compiler.optimization_flag} -g -c {build.float_flags} -x assembler-with-cpp + +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2bin.flags=-O binary +compiler.elf2bin.cmd=arm-none-eabi-objcopy +compiler.elf2hex.flags=-O ihex +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb {build.float_flags} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align --specs=nano.specs --specs=nosys.specs +compiler.size.cmd=arm-none-eabi-size + +# this can be overriden in boards.txt +build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float +build.debug_flags=-DCFG_DEBUG=0 +build.logger_flags=-DCFG_LOGGER=1 +build.sysview_flags=-DCFG_SYSVIEW=0 + +# USB flags +build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.libraries.ldflags= +compiler.elf2bin.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.7.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.7.0.path}/CMSIS/DSP/Include/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.7.0.path}/CMSIS/DSP/Lib/GCC/" -larm_cortexM4lf_math + +# common compiler for nrf +rtos.path={build.core.path}/freertos +nordic.path={build.core.path}/nordic + +# build.logger_flags and build.sysview_flags are intentionally empty, +# to allow modification via a user's own boards.local.txt or platform.local.txt files. +build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DDX_CC_TEE -DLFS_NAME_MAX=64 {compiler.optimization_flag} {build.debug_flags} {build.logger_flags} {build.sysview_flags} {compiler.arm.cmsis.c.flags} "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include/nrf52" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Create archives +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-L{build.core.path}/linker" "-T{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} -Wl,--start-group {compiler.arm.cmsis.ldflags} -lm "{build.path}/{archive_file}" {compiler.libraries.ldflags} -Wl,--end-group + +## Create output (bin file) +#recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2bin.cmd}" {compiler.elf2bin.flags} {compiler.elf2bin.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +## Create dfu package zip file +recipe.objcopy.zip.pattern="{tools.nrfutil.cmd}" dfu genpkg --dev-type 0x0052 --sd-req {build.sd_fwid} --application "{build.path}/{build.project_name}.hex" "{build.path}/{build.project_name}.zip" + +## Create uf2 file +#recipe.objcopy.uf2.pattern=python "{runtime.platform.path}/tools/uf2conv/uf2conv.py" -f 0xADA52840 -c -o "{build.path}/{build.project_name}.uf2" "{build.path}/{build.project_name}.hex" + +## Save bin +recipe.output.tmp_file_bin={build.project_name}.bin +recipe.output.save_file_bin={build.project_name}.save.bin + +## Save hex +recipe.output.tmp_file_hex={build.project_name}.hex +recipe.output.save_file_hexu={build.project_name}.save.hex + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + +## Export Compiled Binary +recipe.output.tmp_file={build.project_name}.hex +recipe.output.save_file={build.project_name}.{build.variant}.hex + +#*************************************************** +# adafruit-nrfutil for uploading +# https://github.com/adafruit/Adafruit_nRF52_nrfutil +# pre-built binaries are provided for macos and windows +#*************************************************** +tools.nrfutil.cmd=adafruit-nrfutil +tools.nrfutil.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe +tools.nrfutil.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil + +tools.nrfutil.upload.params.verbose=--verbose +tools.nrfutil.upload.params.quiet= +tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.path}/{build.project_name}.zip" -p {serial.port} -b 115200 --singlebank + +#*************************************************** +# Burning bootloader with either jlink or nrfutil +#*************************************************** + +# Bootloader version +tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.6.0_{build.sd_name}_{build.sd_version} + +tools.bootburn.bootloader.params.verbose= +tools.bootburn.bootloader.params.quiet= +tools.bootburn.bootloader.pattern={program.burn_pattern} + +# erase flash page while programming +tools.bootburn.erase.params.verbose= +tools.bootburn.erase.params.quiet= +tools.bootburn.erase.pattern= + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B112_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B112_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B112_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B112_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B112_ublox/variant.cpp new file mode 100644 index 0000000..f43f3a4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B112_ublox/variant.cpp @@ -0,0 +1,59 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" + +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +const uint32_t g_ADigitalPinMap[] = { + // D0 .. D13 + 5, // D0 is P0.05 (UART RX) + 6, // D1 is P0.06 (UART TX) + 7, // D2 is P0.07 + 31, // D3 is P0.31 + 18, // D4 is P0.18 (LED Blue) + 99, // D5 (NC) + 9, // D6 is P0.09 NFC1 + 10, // D7 is P0.10 (Button) NFC2 + 99, // D8 (NC) + 8, // D9 is P0.08 + 11, // D10 is P0.11 CS + 13, // D11 is P0.13 MOSI + 12, // D12 is P0.12 MISO + 14, // D13 is P0.14 SCK + //I2C + 2, // D14 is P0.2 (SDA) + 3, // D15 is P0.3 (SCL) + // D16 .. D21 (aka A0 .. A5) + 3, // D16 is P0.03 (A0) + 2, // D17 is P0.02 (A1) + 4, // D18 is P0.04 (A2) + 30, // D19 is P0.30 (A3) SW2 + 29, // D20 is P0.29 (A4) + 28, // D21 is P0.28 (A5) + 9, // P0.09 NFC + 10, // P0.10 NFC + 16, // SW1 (LED Green) +}; \ No newline at end of file diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B112_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B112_ublox/variant.h new file mode 100644 index 0000000..833cbf6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B112_ublox/variant.h @@ -0,0 +1,172 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +#ifndef _VARIANT_NINA_B112_UBLOX_ +#define _VARIANT_NINA_B112_UBLOX_ + +#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \ + .rc_ctiv = 0, \ +.rc_temp_ctiv = 0, \ +.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM} + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (32u) +#define NUM_DIGITAL_PINS (32u) +#define NUM_ANALOG_INPUTS (6u) +#define NUM_ANALOG_OUTPUTS (0u) + +// LEDs +#define PIN_LED LED1 +#define LED_BUILTIN PIN_LED + +//LEDs onboard +#define LED1 (0) // Red +#define LED2 (24) // Green/SW1 +#define LED3 (4) // Blue + +#define LED_STATE_ON 1 // State when LED is litted + +//Switch +#define SW1 (24) +#define SW2 (19) + +// NFC +#define PIN_NFC_1 (6) // P0.9 +#define PIN_NFC_2 (7) // P0.10 + +/* + * Analog pins + */ +#define PIN_A0 (16) // P0.03 +#define PIN_A1 (17) // P0.02 +#define PIN_A2 (18) // P0.04 +#define PIN_A3 (19) // P0.30 +#define PIN_A4 (20) // P0.29 +#define PIN_A5 (21) // P0.28 + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_D0 (0) // P0.05 +#define PIN_D1 (1) // P0.06 +#define PIN_D2 (2) // P0.07 +#define PIN_D3 (4) // P0.31 +#define PIN_D4 (5) // P0.18 +#define PIN_D6 (6) // P0.09 +#define PIN_D7 (7) // P0.10 +#define PIN_D9 (9) // P0.08 +#define PIN_D10 (11) // P0.11 +#define PIN_D11 (13) // P0.13 +#define PIN_D12 (12) // P0.12 +#define PIN_D13 (14) // P0.14 +#define PIN_D14 (2) // P0.02 +#define PIN_D15 (3) // P0.03 + +static const uint8_t D0 = PIN_D0 ; +static const uint8_t D1 = PIN_D1 ; +static const uint8_t D2 = PIN_D2 ; +static const uint8_t D3 = PIN_D3 ; +static const uint8_t D4 = PIN_D4 ; +static const uint8_t D6 = PIN_D6 ; +static const uint8_t D7 = PIN_D7 ; +static const uint8_t D9 = PIN_D9 ; +static const uint8_t D10 = PIN_D10 ; +static const uint8_t D11 = PIN_D11 ; +static const uint8_t D12 = PIN_D12 ; +static const uint8_t D13 = PIN_D13 ; +static const uint8_t D14 = PIN_D14 ; +static const uint8_t D15 = PIN_D15 ; + +// Other pins +//static const uint8_t AREF = PIN_AREF; + +//#define PIN_AREF (24) +//#define PIN_VBAT PIN_A7 + +/* + * Serial interfaces + */ +#define PIN_SERIAL_RX (0) // P0.05 +#define PIN_SERIAL_TX (1) // P0.06 +#define PIN_SERIAL_CTS (2) // P0.07 +#define PIN_SERIAL_RTS (3) // P0.31 +#define PIN_SERIAL_DTR (28) // P0.28 +#define PIN_SERIAL_DSR (29) // P0.29 + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (12) // P0.12 +#define PIN_SPI_MOSI (11) // P0.13 +#define PIN_SPI_SCK (13) // P0.14 + +static const uint8_t SS = 10 ; // P0.11 +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (14) // P0.02 +#define PIN_WIRE_SCL (15) // P0.03 + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + + +#endif //_VARIANT_NINA_B112_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B302_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B302_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B302_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B302_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B302_ublox/variant.cpp new file mode 100644 index 0000000..8b4df2e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B302_ublox/variant.cpp @@ -0,0 +1,87 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 + 29, // D0 is P0.29 (UART RX) + 45, // D1 is P1.13 (UART TX) + 44, // D2 is P1.12 (NFC2) + 31, // D3 is P0.31 (LED1) + 13, // D4 is P0.13 (LED2) + 11, // D5 is P0.11 + 9, // D6 is P0.09 + 10, // D7 is P0.10 (Button) + 41, // D8 is P1.09 + 12, // D9 is P0.12 + 14, // D10 is P0.14 + 15, // D11 is P0.15 + 32, // D12 is P1.00 + 7, // D13 is P0.07 + + // D14 .. D21 (aka A0 .. A5) + 4, // D14 is P0.04 (A0) + 30, // D15 is P0.30 (A1) + 5, // D16 is P0.05 (A2) + 2, // D17 is P0.02 (A3) + 28, // D18 is P0.28 (A4) + 3, // D19 is P0.03 (A5) + + // D20 .. D21 (aka I2C pins) + 16, // D20 is P0.16 (SDA) + 24, // D21 is P0.24 (SCL) + + // QSPI pins (not exposed via any header / test point) + 19, // D22 is P0.19 (QSPI CLK) + 17, // D23 is P0.17 (QSPI CS) + 20, // D24 is P0.20 (QSPI Data 0) + 21, // D25 is P0.21 (QSPI Data 1) + 22, // D26 is P0.22 (QSPI Data 2) + 26, // D27 is P0.23 (QSPI Data 3) + + 40, // D28 is P1.08 - IO34 + 41, // D29 is P1.01 - IO35 + 44, // D30 is P1.02 - IO36 + 45, // D31 is P1.03 - IO37 + 42, // D32 is P1.10 - IO38 + 43, // D33 is P1.11 - IO39 + 47, // D34 is P1.15 - IO40 + 46, // D35 is P1.14 - IO41 + 26, // D36 is P0.26 - IO42 + 6, // D37 is P0.6 - IO43 + 27, // D38 is P0.27 - IO44 +}; + +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B302_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B302_ublox/variant.h new file mode 100644 index 0000000..a69575f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B302_ublox/variant.h @@ -0,0 +1,149 @@ + /* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#ifndef _VARIANT_NINA_B302_UBLOX_ +#define _VARIANT_NINA_B302_UBLOX_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus +// Number of pins defined in PinDescription array +#define PINS_COUNT (40) +#define NUM_DIGITAL_PINS (34) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (3) +#define PIN_LED2 (4) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_RED PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +/* + * Buttons + */ +#define PIN_BUTTON1 (7) + +/* + * Analog pins + */ +#define PIN_A0 (14) +#define PIN_A1 (15) +#define PIN_A2 (16) +#define PIN_A3 (17) +#define PIN_A4 (18) +#define PIN_A5 (19) + +#define D0 (0) +#define D1 (1) +#define D2 (2) +#define D3 (3) +#define D4 (4) +#define D5 (5) +#define D6 (6) +#define D7 (7) +#define D8 (8) +#define D9 (9) +#define D10 (10) +#define D11 (11) +#define D12 (12) +#define D13 (13) + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_NFC1 (31) +#define PIN_NFC2 (2) + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (0) +#define PIN_SERIAL1_TX (1) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (22) //24 original +#define PIN_SPI_MOSI (23) //25 original +#define PIN_SPI_SCK (24) //26 original + +static const uint8_t SS = (13); +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (20) +#define PIN_WIRE_SCL (21) + +// QSPI Pins +#define PIN_QSPI_SCK 22 +#define PIN_QSPI_CS 23 +#define PIN_QSPI_IO0 24 +#define PIN_QSPI_IO1 25 +#define PIN_QSPI_IO2 26 +#define PIN_QSPI_IO3 27 + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES GD25Q16C +#define EXTERNAL_FLASH_USE_QSPI + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif //_VARIANT_NINA_B302_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/boards.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/boards.txt new file mode 100644 index 0000000..c21a831 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/boards.txt @@ -0,0 +1,716 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +menu.softdevice=SoftDevice +menu.debug=Debug + +# ---------------------------------- +# Bluefruit Feather nRF52832 +# ---------------------------------- +feather52832.name=Adafruit Feather nRF52832 +feather52832.bootloader.tool=bootburn + +# Upload +feather52832.upload.tool=nrfutil +feather52832.upload.protocol=nrfutil +feather52832.upload.use_1200bps_touch=false +feather52832.upload.wait_for_upload_port=false +feather52832.upload.native_usb=false +feather52832.upload.maximum_size=290816 +feather52832.upload.maximum_data_size=52224 + +# Build +feather52832.build.mcu=cortex-m4 +feather52832.build.f_cpu=64000000 +feather52832.build.board=NRF52832_FEATHER +feather52832.build.core=nRF5 +feather52832.build.variant=feather_nrf52832 +feather52832.build.usb_manufacturer="Adafruit LLC" +feather52832.build.usb_product="Feather nRF52832" +feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52 +feather52832.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +feather52832.menu.softdevice.s132v6=S132 6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_name=s132 +feather52832.menu.softdevice.s132v6.build.sd_version=6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +feather52832.menu.debug.l0=Level 0 (Release) +feather52832.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52832.menu.debug.l1=Level 1 (Error Message) +feather52832.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52832.menu.debug.l2=Level 2 (Full Debug) +feather52832.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52832.menu.debug.l3=Level 3 (Segger SystemView) +feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52832.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Bluefruit Feather nRF52840 Express +# ---------------------------------- +feather52840.name=Adafruit Feather nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840.vid.0=0x239A +feather52840.pid.0=0x8029 +feather52840.vid.1=0x239A +feather52840.pid.1=0x0029 +feather52840.vid.2=0x239A +feather52840.pid.2=0x002A +feather52840.vid.3=0x239A +feather52840.pid.3=0x802A + +# Upload +feather52840.bootloader.tool=bootburn +feather52840.upload.tool=nrfutil +feather52840.upload.protocol=nrfutil +feather52840.upload.use_1200bps_touch=true +feather52840.upload.wait_for_upload_port=true +feather52840.upload.maximum_size=815104 +feather52840.upload.maximum_data_size=237568 + +# Build +feather52840.build.mcu=cortex-m4 +feather52840.build.f_cpu=64000000 +feather52840.build.board=NRF52840_FEATHER +feather52840.build.core=nRF5 +feather52840.build.variant=feather_nrf52840_express +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52840 Express" +feather52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +feather52840.build.ldscript=nrf52840_s140_v6.ld +feather52840.build.vid=0x239A +feather52840.build.pid=0x8029 + +# SofDevice Menu +feather52840.menu.softdevice.s140v6=S140 6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_name=s140 +feather52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840.menu.debug.l0=Level 0 (Release) +feather52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840.menu.debug.l1=Level 1 (Error Message) +feather52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840.menu.debug.l2=Level 2 (Full Debug) +feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840.menu.debug.l3=Level 3 (Segger SystemView) +feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# ---------------------------------- +# Feather nRF52840 sense +# ---------------------------------- +feather52840sense.name=Adafruit Feather nRF52840 Sense + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840sense.vid.0=0x239A +feather52840sense.pid.0=0x8087 +feather52840sense.vid.1=0x239A +feather52840sense.pid.1=0x0087 +feather52840sense.vid.2=0x239A +feather52840sense.pid.2=0x0088 +feather52840sense.vid.3=0x239A +feather52840sense.pid.3=0x8088 + +# Upload +feather52840sense.bootloader.tool=bootburn +feather52840sense.upload.tool=nrfutil +feather52840sense.upload.protocol=nrfutil +feather52840sense.upload.use_1200bps_touch=true +feather52840sense.upload.wait_for_upload_port=true +feather52840sense.upload.maximum_size=815104 +feather52840sense.upload.maximum_data_size=237568 + +# Build +feather52840sense.build.mcu=cortex-m4 +feather52840sense.build.f_cpu=64000000 +feather52840sense.build.board=NRF52840_FEATHER_SENSE +feather52840sense.build.core=nRF5 +feather52840sense.build.variant=feather_nrf52840_sense +feather52840sense.build.usb_manufacturer="Adafruit LLC" +feather52840sense.build.usb_product="Feather nRF52840 Sense" +feather52840sense.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +feather52840sense.build.ldscript=nrf52840_s140_v6.ld +feather52840sense.build.vid=0x239A +feather52840sense.build.pid=0x8087 + +# SofDevice Menu +feather52840sense.menu.softdevice.s140v6=S140 6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_name=s140 +feather52840sense.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840sense.menu.debug.l0=Level 0 (Release) +feather52840sense.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840sense.menu.debug.l1=Level 1 (Error Message) +feather52840sense.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840sense.menu.debug.l2=Level 2 (Full Debug) +feather52840sense.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840sense.menu.debug.l3=Level 3 (Segger SystemView) +feather52840sense.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840sense.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Bluefruit ItsyBitsy nRF52840 Express +# --------------------------------------------- +itsybitsy52840.name=Adafruit ItsyBitsy nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +itsybitsy52840.vid.0=0x239A +itsybitsy52840.pid.0=0x8051 +itsybitsy52840.vid.1=0x239A +itsybitsy52840.pid.1=0x0051 +itsybitsy52840.vid.2=0x239A +itsybitsy52840.pid.2=0x0052 +itsybitsy52840.vid.3=0x239A +itsybitsy52840.pid.3=0x8052 + +# Upload +itsybitsy52840.bootloader.tool=bootburn +itsybitsy52840.upload.tool=nrfutil +itsybitsy52840.upload.protocol=nrfutil +itsybitsy52840.upload.use_1200bps_touch=true +itsybitsy52840.upload.wait_for_upload_port=true +itsybitsy52840.upload.maximum_size=815104 +itsybitsy52840.upload.maximum_data_size=237568 + +# Build +itsybitsy52840.build.mcu=cortex-m4 +itsybitsy52840.build.f_cpu=64000000 +itsybitsy52840.build.board=NRF52840_ITSYBITSY +itsybitsy52840.build.core=nRF5 +itsybitsy52840.build.variant=itsybitsy_nrf52840_express +itsybitsy52840.build.usb_manufacturer="Adafruit LLC" +itsybitsy52840.build.usb_product="ItsyBitsy nRF52840 Express" +itsybitsy52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52_ITSYBITSY {build.flags.usb} +itsybitsy52840.build.ldscript=nrf52840_s140_v6.ld +itsybitsy52840.build.vid=0x239A +itsybitsy52840.build.pid=0x8051 + +# SofDevice Menu +itsybitsy52840.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_name=s140 +itsybitsy52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +itsybitsy52840.menu.debug.l0=Level 0 (Release) +itsybitsy52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +itsybitsy52840.menu.debug.l1=Level 1 (Error Message) +itsybitsy52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +itsybitsy52840.menu.debug.l2=Level 2 (Full Debug) +itsybitsy52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +itsybitsy52840.menu.debug.l3=Level 3 (Segger SystemView) +itsybitsy52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +itsybitsy52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# --------------------------------------------- +# Bluefruit Circuit Playground nRF52840 Express +# --------------------------------------------- +cplaynrf52840.name=Adafruit Circuit Playground Bluefruit + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cplaynrf52840.vid.0=0x239A +cplaynrf52840.pid.0=0x8045 +cplaynrf52840.vid.1=0x239A +cplaynrf52840.pid.1=0x0045 +cplaynrf52840.vid.2=0x239A +cplaynrf52840.pid.2=0x0046 +cplaynrf52840.vid.3=0x239A +cplaynrf52840.pid.3=0x8046 + +# Upload +cplaynrf52840.bootloader.tool=bootburn +cplaynrf52840.upload.tool=nrfutil +cplaynrf52840.upload.protocol=nrfutil +cplaynrf52840.upload.use_1200bps_touch=true +cplaynrf52840.upload.wait_for_upload_port=true +cplaynrf52840.upload.maximum_size=815104 +cplaynrf52840.upload.maximum_data_size=237568 + +# Build +cplaynrf52840.build.mcu=cortex-m4 +cplaynrf52840.build.f_cpu=64000000 +cplaynrf52840.build.board=NRF52840_CIRCUITPLAY +cplaynrf52840.build.core=nRF5 +cplaynrf52840.build.variant=circuitplayground_nrf52840 +cplaynrf52840.build.usb_manufacturer="Adafruit LLC" +cplaynrf52840.build.usb_product="Circuit Playground Bluefruit" +cplaynrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld +cplaynrf52840.build.vid=0x239A +cplaynrf52840.build.pid=0x8045 + +# SofDevice Menu +cplaynrf52840.menu.softdevice.s140v6=S140 6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cplaynrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cplaynrf52840.menu.debug.l0=Level 0 (Release) +cplaynrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cplaynrf52840.menu.debug.l1=Level 1 (Error Message) +cplaynrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cplaynrf52840.menu.debug.l2=Level 2 (Full Debug) +cplaynrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cplaynrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cplaynrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Clue nRF52840 +# --------------------------------------------- +cluenrf52840.name=Adafruit CLUE + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cluenrf52840.vid.0=0x239A +cluenrf52840.pid.0=0x8072 +cluenrf52840.vid.1=0x239A +cluenrf52840.pid.1=0x0072 +cluenrf52840.vid.2=0x239A +cluenrf52840.pid.2=0x0071 +cluenrf52840.vid.3=0x239A +cluenrf52840.pid.3=0x8071 + +# Upload +cluenrf52840.bootloader.tool=bootburn +cluenrf52840.upload.tool=nrfutil +cluenrf52840.upload.protocol=nrfutil +cluenrf52840.upload.use_1200bps_touch=true +cluenrf52840.upload.wait_for_upload_port=true +cluenrf52840.upload.maximum_size=815104 +cluenrf52840.upload.maximum_data_size=237568 + +# Build +cluenrf52840.build.mcu=cortex-m4 +cluenrf52840.build.f_cpu=64000000 +cluenrf52840.build.board=NRF52840_CLUE +cluenrf52840.build.core=nRF5 +cluenrf52840.build.variant=clue_nrf52840 +cluenrf52840.build.usb_manufacturer="Adafruit LLC" +cluenrf52840.build.usb_product="CLUE" +cluenrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +cluenrf52840.build.ldscript=nrf52840_s140_v6.ld +cluenrf52840.build.vid=0x239A +cluenrf52840.build.pid=0x8071 + +# SofDevice Menu +cluenrf52840.menu.softdevice.s140v6=S140 6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cluenrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cluenrf52840.menu.debug.l0=Level 0 (Release) +cluenrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cluenrf52840.menu.debug.l1=Level 1 (Error Message) +cluenrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cluenrf52840.menu.debug.l2=Level 2 (Full Debug) +cluenrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cluenrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cluenrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cluenrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Metro nRF52840 Express +# ---------------------------------- +metro52840.name=Adafruit Metro nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +metro52840.vid.0=0x239A +metro52840.pid.0=0x803F +metro52840.vid.1=0x239A +metro52840.pid.1=0x003F +metro52840.vid.2=0x239A +metro52840.pid.2=0x0040 +metro52840.vid.3=0x239A +metro52840.pid.3=0x8040 + +# Upload +metro52840.bootloader.tool=bootburn +metro52840.upload.tool=nrfutil +metro52840.upload.protocol=nrfutil +metro52840.upload.use_1200bps_touch=true +metro52840.upload.wait_for_upload_port=true +metro52840.upload.maximum_size=815104 +metro52840.upload.maximum_data_size=237568 + +# Build +metro52840.build.mcu=cortex-m4 +metro52840.build.f_cpu=64000000 +metro52840.build.board=NRF52840_METRO +metro52840.build.core=nRF5 +metro52840.build.variant=metro_nrf52840_express +metro52840.build.usb_manufacturer="Adafruit LLC" +metro52840.build.usb_product="Metro nRF52840 Express" +metro52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +metro52840.build.ldscript=nrf52840_s140_v6.ld +metro52840.build.vid=0x239A +metro52840.build.pid=0x803F + +# SofDevice Menu +metro52840.menu.softdevice.s140v6=S140 6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_name=s140 +metro52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +metro52840.menu.debug.l0=Level 0 (Release) +metro52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +metro52840.menu.debug.l1=Level 1 (Error Message) +metro52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +metro52840.menu.debug.l2=Level 2 (Full Debug) +metro52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +metro52840.menu.debug.l3=Level 3 (Segger SystemView) +metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +metro52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + + + +# ------------------------------------------------------- +# +# Boards that aren't made by Adafruit +# +# ------------------------------------------------------- + + +# ---------------------------------- +# Nordic nRF52840DK (PCA10056) +# ---------------------------------- +pca10056.name=Nordic nRF52840DK (PCA10056) +pca10056.bootloader.tool=bootburn + +# Upload +pca10056.upload.tool=nrfutil +pca10056.upload.protocol=nrfutil +pca10056.upload.use_1200bps_touch=true +pca10056.upload.wait_for_upload_port=true +pca10056.upload.maximum_size=815104 +pca10056.upload.maximum_data_size=237568 + +# Build +pca10056.build.mcu=cortex-m4 +pca10056.build.f_cpu=64000000 +pca10056.build.board=NRF52840_PCA10056 +pca10056.build.core=nRF5 +pca10056.build.variant=pca10056 +pca10056.build.usb_manufacturer="Nordic" +pca10056.build.usb_product="nRF52840 DK" +pca10056.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +pca10056.build.ldscript=nrf52840_s140_v6.ld +pca10056.build.vid=0x239A +pca10056.build.pid=0x8029 + +# SofDevice Menu +pca10056.menu.softdevice.s140v6=S140 6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_name=s140 +pca10056.menu.softdevice.s140v6.build.sd_version=6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +pca10056.menu.debug.l0=Level 0 (Release) +pca10056.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +pca10056.menu.debug.l1=Level 1 (Error Message) +pca10056.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +pca10056.menu.debug.l2=Level 2 (Full Debug) +pca10056.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +pca10056.menu.debug.l3=Level 3 (Segger SystemView) +pca10056.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +pca10056.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Particle Xenon +# ---------------------------------- +particle_xenon.name=Particle Xenon + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +particle_xenon.vid.0=0x239A +particle_xenon.pid.0=0x8029 +particle_xenon.vid.1=0x239A +particle_xenon.pid.1=0x0029 +particle_xenon.vid.2=0x239A +particle_xenon.pid.2=0x002A +particle_xenon.vid.3=0x239A +particle_xenon.pid.3=0x802A + +# Upload +particle_xenon.bootloader.tool=bootburn +particle_xenon.upload.tool=nrfutil +particle_xenon.upload.protocol=nrfutil +particle_xenon.upload.use_1200bps_touch=true +particle_xenon.upload.wait_for_upload_port=true +particle_xenon.upload.maximum_size=815104 +particle_xenon.upload.maximum_data_size=237568 + +# Build +particle_xenon.build.mcu=cortex-m4 +particle_xenon.build.f_cpu=64000000 +particle_xenon.build.board=PARTICLE_XENON +particle_xenon.build.core=nRF5 +particle_xenon.build.variant=particle_xenon +particle_xenon.build.usb_manufacturer="Particle Industries" +particle_xenon.build.usb_product="Particle Xenon" +particle_xenon.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +particle_xenon.build.ldscript=nrf52840_s140_v6.ld +particle_xenon.build.vid=0x239A +particle_xenon.build.pid=0x8029 + +# SofDevice Menu +particle_xenon.menu.softdevice.s140v6=S140 6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_name=s140 +particle_xenon.menu.softdevice.s140v6.build.sd_version=6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +particle_xenon.menu.debug.l0=Level 0 (Release) +particle_xenon.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +particle_xenon.menu.debug.l1=Level 1 (Error Message) +particle_xenon.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +particle_xenon.menu.debug.l2=Level 2 (Full Debug) +particle_xenon.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +particle_xenon.menu.debug.l3=Level 3 (Segger SystemView) +particle_xenon.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +particle_xenon.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Raytac MDBT50Q - RX +# ---------------------------------- +mdbt50qrx.name=Raytac MDBT50Q-RX Dongle + +# VID/PID for bootloader, Arduino + Circuitpython App +mdbt50qrx.vid.0=0x239A +mdbt50qrx.pid.0=0x810B +mdbt50qrx.vid.1=0x239A +mdbt50qrx.pid.1=0x010B +mdbt50qrx.vid.2=0x239A +mdbt50qrx.pid.2=0x810C + +# Upload +mdbt50qrx.bootloader.tool=bootburn +mdbt50qrx.upload.tool=nrfutil +mdbt50qrx.upload.protocol=nrfutil +mdbt50qrx.upload.use_1200bps_touch=true +mdbt50qrx.upload.wait_for_upload_port=true +mdbt50qrx.upload.maximum_size=815104 +mdbt50qrx.upload.maximum_data_size=237568 + +# Build +mdbt50qrx.build.mcu=cortex-m4 +mdbt50qrx.build.f_cpu=64000000 +mdbt50qrx.build.board=MDBT50Q_RX +mdbt50qrx.build.core=nRF5 +mdbt50qrx.build.variant=raytac_mdbt50q_rx +mdbt50qrx.build.usb_manufacturer="Raytac" +mdbt50qrx.build.usb_product="nRF52840 Dongle" +mdbt50qrx.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld +mdbt50qrx.build.vid=0x239A +mdbt50qrx.build.pid=0x810B + +# SofDevice Menu +mdbt50qrx.menu.softdevice.s140v6=S140 6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_name=s140 +mdbt50qrx.menu.softdevice.s140v6.build.sd_version=6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +mdbt50qrx.menu.debug.l0=Level 0 (Release) +mdbt50qrx.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +mdbt50qrx.menu.debug.l1=Level 1 (Error Message) +mdbt50qrx.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +mdbt50qrx.menu.debug.l2=Level 2 (Full Debug) +mdbt50qrx.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +mdbt50qrx.menu.debug.l3=Level 3 (Segger SystemView) +mdbt50qrx.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +mdbt50qrx.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# NINA B302 +# ---------------------------------- +ninab302.name=NINA B302 ublox + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +ninab302.vid.0=0x239A +ninab302.pid.0=0x8029 +ninab302.vid.1=0x239A +ninab302.pid.1=0x0029 +ninab302.vid.2=0x7239A +ninab302.pid.2=0x002A +ninab302.vid.3=0x239A +ninab302.pid.3=0x802A + +# Upload +ninab302.bootloader.tool=bootburn +ninab302.upload.tool=nrfutil +ninab302.upload.protocol=nrfutil +ninab302.upload.use_1200bps_touch=true +ninab302.upload.wait_for_upload_port=true +ninab302.upload.maximum_size=815104 +ninab302.upload.maximum_data_size=237568 + +# Build +ninab302.build.mcu=cortex-m4 +ninab302.build.f_cpu=64000000 +ninab302.build.board=NINA_B302_ublox +ninab302.build.core=nRF5 +ninab302.build.variant=NINA_B302_ublox +ninab302.build.usb_manufacturer="Nordic" +ninab302.build.usb_product="NINA B302 ublox" +ninab302.build.extra_flags=-DNRF52840_XXAA -DNINA_B302_ublox {build.flags.usb} +ninab302.build.ldscript=nrf52840_s140_v6.ld +ninab302.build.vid=0x239A +ninab302.build.pid=0x8029 + +# SofDevice Menu +ninab302.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_name=s140 +ninab302.menu.softdevice.s140v6.build.sd_version=6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +ninab302.menu.debug.l0=Level 0 (Release) +ninab302.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab302.menu.debug.l1=Level 1 (Error Message) +ninab302.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab302.menu.debug.l2=Level 2 (Full Debug) +ninab302.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab302.menu.debug.l3=Level 3 (Segger SystemView) +ninab302.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab302.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# NINA B112 +# ---------------------------------- +ninab112.name=NINA B112 ublox +ninab112.bootloader.tool=bootburn + +# Upload +ninab112.upload.tool=nrfutil +ninab112.upload.protocol=nrfutil +ninab112.upload.use_1200bps_touch=false +ninab112.upload.wait_for_upload_port=false +ninab112.upload.native_usb=false +ninab112.upload.maximum_size=290816 +ninab112.upload.maximum_data_size=52224 + +# Build +ninab112.build.mcu=cortex-m4 +ninab112.build.f_cpu=64000000 +ninab112.build.board=NINA_B112_ublox +ninab112.build.core=nRF5 +ninab112.build.variant=NINA_B112_ublox +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52832" +ninab112.build.extra_flags=-DNRF52832_XXAA -DNINA_B112_ublox -DNRF52 +ninab112.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +ninab112.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_name=s132 +ninab112.menu.softdevice.s132v6.build.sd_version=6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +ninab112.menu.debug.l0=Level 0 (Release) +ninab112.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab112.menu.debug.l1=Level 1 (Error Message) +ninab112.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab112.menu.debug.l2=Level 2 (Full Debug) +ninab112.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab112.menu.debug.l3=Level 3 (Segger SystemView) +ninab112.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab112.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +################################################################## +## KH Add SparkFun Pro nRF52840 Mini +################################################################## +#********************************************** +# SparkFun Pro nRF52840 Mini +#********************************************** +sparkfunnrf52840mini.name=SparkFun Pro nRF52840 Mini + +# DFU Mode with CDC only +sparkfunnrf52840mini.vid.0=0x1B4F +sparkfunnrf52840mini.pid.0=0x002A + +# DFU Mode with CDC + MSC (UF2) +sparkfunnrf52840mini.vid.1=0x1B4F +sparkfunnrf52840mini.pid.1=0x0029 + +# Application with CDC + MSC +sparkfunnrf52840mini.vid.2=0x1B4F +sparkfunnrf52840mini.pid.2=0x8029 + +# CircuitPython +sparkfunnrf52840mini.vid.2=0x1B4F +sparkfunnrf52840mini.pid.2=0x802A + +sparkfunnrf52840mini.bootloader.tool=bootburn + +# Upload +sparkfunnrf52840mini.upload.tool=nrfutil +sparkfunnrf52840mini.upload.protocol=nrfutil +sparkfunnrf52840mini.upload.use_1200bps_touch=true +sparkfunnrf52840mini.upload.wait_for_upload_port=true +#sparkfunnrf52840mini.upload.native_usb=true + +# Build +sparkfunnrf52840mini.build.mcu=cortex-m4 +sparkfunnrf52840mini.build.f_cpu=64000000 +sparkfunnrf52840mini.build.board=NRF52840_FEATHER +sparkfunnrf52840mini.build.core=nRF5 +sparkfunnrf52840mini.build.variant=sparkfun_nrf52840_mini +sparkfunnrf52840mini.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +sparkfunnrf52840mini.build.vid=0x1B4F +sparkfunnrf52840mini.build.pid=0x5284 +sparkfunnrf52840mini.build.usb_manufacturer="SparkFun" +sparkfunnrf52840mini.build.usb_product="nRF52840 Mini Breakout" + +# SofDevice Menu +# Ram & ROM size varies depending on SoftDevice (check linker script) + +sparkfunnrf52840mini.menu.softdevice.s140v6=s140 6.1.1 r0 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.sd_flags=-DS140 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.sd_name=s140 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.sd_version=6.1.1 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.sd_fwid=0x00B6 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.ldscript=nrf52840_s140_v6.ld +sparkfunnrf52840mini.menu.softdevice.s140v6.upload.maximum_size=815104 +sparkfunnrf52840mini.menu.softdevice.s140v6.upload.maximum_data_size=248832 + +# Debug Menu +sparkfunnrf52840mini.menu.debug.l0=Level 0 (Release) +sparkfunnrf52840mini.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 -Os +sparkfunnrf52840mini.menu.debug.l1=Level 1 (Error Message) +sparkfunnrf52840mini.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 -Os +sparkfunnrf52840mini.menu.debug.l2=Level 2 (Full Debug) +sparkfunnrf52840mini.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 -Os +sparkfunnrf52840mini.menu.debug.l3=Level 3 (Segger SystemView) +sparkfunnrf52840mini.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 -Os + +################################################################## diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Udp.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Udp.h new file mode 100644 index 0000000..cc814d3 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Udp.h @@ -0,0 +1,92 @@ +/* + * Udp.cpp: Library to send/receive UDP packets. + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + */ + +#ifndef udp_h +#define udp_h + +#include +#include + +class UDP : public Stream { + +public: + virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + + // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) + virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + + virtual void stop() =0; // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port) =0; + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port) =0; + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket() =0; + // Write a single byte into the packet + virtual size_t write(uint8_t) =0; + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size) =0; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket() =0; + // Number of bytes remaining in the current packet + virtual int available() =0; + // Read a single byte from the current packet + virtual int read() =0; + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len) =0; + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) =0; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek() =0; + virtual void flush() =0; // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() =0; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() =0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/platform.txt new file mode 100644 index 0000000..8e858fa --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/platform.txt @@ -0,0 +1,167 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All rights reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +name=Adafruit nRF52 Boards +version=1.0.0 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-pointer-arith + +# Allow changing optimization settings via platform.local.txt / boards.local.txt +compiler.optimization_flag=-Ofast + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD + +# KH, Error here to use gcc, must use g++ +#compiler.c.elf.cmd=arm-none-eabi-gcc +compiler.c.elf.cmd=arm-none-eabi-g++ + +compiler.c.elf.flags={compiler.optimization_flag} -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-mcpu={build.mcu} -mthumb -mabi=aapcs {compiler.optimization_flag} -g -c {build.float_flags} -x assembler-with-cpp + +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2bin.flags=-O binary +compiler.elf2bin.cmd=arm-none-eabi-objcopy +compiler.elf2hex.flags=-O ihex +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb {build.float_flags} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align --specs=nano.specs --specs=nosys.specs +compiler.size.cmd=arm-none-eabi-size + +# this can be overriden in boards.txt +build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float +build.debug_flags=-DCFG_DEBUG=0 +build.logger_flags=-DCFG_LOGGER=1 +build.sysview_flags=-DCFG_SYSVIEW=0 + +# USB flags +build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.libraries.ldflags= +compiler.elf2bin.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.7.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.7.0.path}/CMSIS/DSP/Include/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.7.0.path}/CMSIS/DSP/Lib/GCC/" -larm_cortexM4lf_math + +# common compiler for nrf +rtos.path={build.core.path}/freertos +nordic.path={build.core.path}/nordic + +# build.logger_flags and build.sysview_flags are intentionally empty, +# to allow modification via a user's own boards.local.txt or platform.local.txt files. +build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DDX_CC_TEE -DLFS_NAME_MAX=64 {compiler.optimization_flag} {build.debug_flags} {build.logger_flags} {build.sysview_flags} {compiler.arm.cmsis.c.flags} "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include/nrf52" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Create archives +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-L{build.core.path}/linker" "-T{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} -Wl,--start-group {compiler.arm.cmsis.ldflags} -lm "{build.path}/{archive_file}" {compiler.libraries.ldflags} -Wl,--end-group + +## Create output (bin file) +#recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2bin.cmd}" {compiler.elf2bin.flags} {compiler.elf2bin.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +## Create dfu package zip file +recipe.objcopy.zip.pattern="{tools.nrfutil.cmd}" dfu genpkg --dev-type 0x0052 --sd-req {build.sd_fwid} --application "{build.path}/{build.project_name}.hex" "{build.path}/{build.project_name}.zip" + +## Create uf2 file +#recipe.objcopy.uf2.pattern=python "{runtime.platform.path}/tools/uf2conv/uf2conv.py" -f 0xADA52840 -c -o "{build.path}/{build.project_name}.uf2" "{build.path}/{build.project_name}.hex" + +## Save bin +recipe.output.tmp_file_bin={build.project_name}.bin +recipe.output.save_file_bin={build.project_name}.save.bin + +## Save hex +recipe.output.tmp_file_hex={build.project_name}.hex +recipe.output.save_file_hexu={build.project_name}.save.hex + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + +## Export Compiled Binary +recipe.output.tmp_file={build.project_name}.hex +recipe.output.save_file={build.project_name}.{build.variant}.hex + +#*************************************************** +# adafruit-nrfutil for uploading +# https://github.com/adafruit/Adafruit_nRF52_nrfutil +# pre-built binaries are provided for macos and windows +#*************************************************** +tools.nrfutil.cmd=adafruit-nrfutil +tools.nrfutil.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe +tools.nrfutil.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil + +tools.nrfutil.upload.params.verbose=--verbose +tools.nrfutil.upload.params.quiet= +tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.path}/{build.project_name}.zip" -p {serial.port} -b 115200 --singlebank + +#*************************************************** +# Burning bootloader with either jlink or nrfutil +#*************************************************** + +# Bootloader version +tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.6.1_{build.sd_name}_{build.sd_version} + +tools.bootburn.bootloader.params.verbose= +tools.bootburn.bootloader.params.quiet= +tools.bootburn.bootloader.pattern={program.burn_pattern} + +# erase flash page while programming +tools.bootburn.erase.params.verbose= +tools.bootburn.erase.params.quiet= +tools.bootburn.erase.pattern= + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/variant.cpp new file mode 100644 index 0000000..f43f3a4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/variant.cpp @@ -0,0 +1,59 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" + +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +const uint32_t g_ADigitalPinMap[] = { + // D0 .. D13 + 5, // D0 is P0.05 (UART RX) + 6, // D1 is P0.06 (UART TX) + 7, // D2 is P0.07 + 31, // D3 is P0.31 + 18, // D4 is P0.18 (LED Blue) + 99, // D5 (NC) + 9, // D6 is P0.09 NFC1 + 10, // D7 is P0.10 (Button) NFC2 + 99, // D8 (NC) + 8, // D9 is P0.08 + 11, // D10 is P0.11 CS + 13, // D11 is P0.13 MOSI + 12, // D12 is P0.12 MISO + 14, // D13 is P0.14 SCK + //I2C + 2, // D14 is P0.2 (SDA) + 3, // D15 is P0.3 (SCL) + // D16 .. D21 (aka A0 .. A5) + 3, // D16 is P0.03 (A0) + 2, // D17 is P0.02 (A1) + 4, // D18 is P0.04 (A2) + 30, // D19 is P0.30 (A3) SW2 + 29, // D20 is P0.29 (A4) + 28, // D21 is P0.28 (A5) + 9, // P0.09 NFC + 10, // P0.10 NFC + 16, // SW1 (LED Green) +}; \ No newline at end of file diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/variant.h new file mode 100644 index 0000000..833cbf6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/variant.h @@ -0,0 +1,172 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +#ifndef _VARIANT_NINA_B112_UBLOX_ +#define _VARIANT_NINA_B112_UBLOX_ + +#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \ + .rc_ctiv = 0, \ +.rc_temp_ctiv = 0, \ +.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM} + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (32u) +#define NUM_DIGITAL_PINS (32u) +#define NUM_ANALOG_INPUTS (6u) +#define NUM_ANALOG_OUTPUTS (0u) + +// LEDs +#define PIN_LED LED1 +#define LED_BUILTIN PIN_LED + +//LEDs onboard +#define LED1 (0) // Red +#define LED2 (24) // Green/SW1 +#define LED3 (4) // Blue + +#define LED_STATE_ON 1 // State when LED is litted + +//Switch +#define SW1 (24) +#define SW2 (19) + +// NFC +#define PIN_NFC_1 (6) // P0.9 +#define PIN_NFC_2 (7) // P0.10 + +/* + * Analog pins + */ +#define PIN_A0 (16) // P0.03 +#define PIN_A1 (17) // P0.02 +#define PIN_A2 (18) // P0.04 +#define PIN_A3 (19) // P0.30 +#define PIN_A4 (20) // P0.29 +#define PIN_A5 (21) // P0.28 + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_D0 (0) // P0.05 +#define PIN_D1 (1) // P0.06 +#define PIN_D2 (2) // P0.07 +#define PIN_D3 (4) // P0.31 +#define PIN_D4 (5) // P0.18 +#define PIN_D6 (6) // P0.09 +#define PIN_D7 (7) // P0.10 +#define PIN_D9 (9) // P0.08 +#define PIN_D10 (11) // P0.11 +#define PIN_D11 (13) // P0.13 +#define PIN_D12 (12) // P0.12 +#define PIN_D13 (14) // P0.14 +#define PIN_D14 (2) // P0.02 +#define PIN_D15 (3) // P0.03 + +static const uint8_t D0 = PIN_D0 ; +static const uint8_t D1 = PIN_D1 ; +static const uint8_t D2 = PIN_D2 ; +static const uint8_t D3 = PIN_D3 ; +static const uint8_t D4 = PIN_D4 ; +static const uint8_t D6 = PIN_D6 ; +static const uint8_t D7 = PIN_D7 ; +static const uint8_t D9 = PIN_D9 ; +static const uint8_t D10 = PIN_D10 ; +static const uint8_t D11 = PIN_D11 ; +static const uint8_t D12 = PIN_D12 ; +static const uint8_t D13 = PIN_D13 ; +static const uint8_t D14 = PIN_D14 ; +static const uint8_t D15 = PIN_D15 ; + +// Other pins +//static const uint8_t AREF = PIN_AREF; + +//#define PIN_AREF (24) +//#define PIN_VBAT PIN_A7 + +/* + * Serial interfaces + */ +#define PIN_SERIAL_RX (0) // P0.05 +#define PIN_SERIAL_TX (1) // P0.06 +#define PIN_SERIAL_CTS (2) // P0.07 +#define PIN_SERIAL_RTS (3) // P0.31 +#define PIN_SERIAL_DTR (28) // P0.28 +#define PIN_SERIAL_DSR (29) // P0.29 + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (12) // P0.12 +#define PIN_SPI_MOSI (11) // P0.13 +#define PIN_SPI_SCK (13) // P0.14 + +static const uint8_t SS = 10 ; // P0.11 +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (14) // P0.02 +#define PIN_WIRE_SCL (15) // P0.03 + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + + +#endif //_VARIANT_NINA_B112_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/variant.cpp new file mode 100644 index 0000000..8b4df2e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/variant.cpp @@ -0,0 +1,87 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 + 29, // D0 is P0.29 (UART RX) + 45, // D1 is P1.13 (UART TX) + 44, // D2 is P1.12 (NFC2) + 31, // D3 is P0.31 (LED1) + 13, // D4 is P0.13 (LED2) + 11, // D5 is P0.11 + 9, // D6 is P0.09 + 10, // D7 is P0.10 (Button) + 41, // D8 is P1.09 + 12, // D9 is P0.12 + 14, // D10 is P0.14 + 15, // D11 is P0.15 + 32, // D12 is P1.00 + 7, // D13 is P0.07 + + // D14 .. D21 (aka A0 .. A5) + 4, // D14 is P0.04 (A0) + 30, // D15 is P0.30 (A1) + 5, // D16 is P0.05 (A2) + 2, // D17 is P0.02 (A3) + 28, // D18 is P0.28 (A4) + 3, // D19 is P0.03 (A5) + + // D20 .. D21 (aka I2C pins) + 16, // D20 is P0.16 (SDA) + 24, // D21 is P0.24 (SCL) + + // QSPI pins (not exposed via any header / test point) + 19, // D22 is P0.19 (QSPI CLK) + 17, // D23 is P0.17 (QSPI CS) + 20, // D24 is P0.20 (QSPI Data 0) + 21, // D25 is P0.21 (QSPI Data 1) + 22, // D26 is P0.22 (QSPI Data 2) + 26, // D27 is P0.23 (QSPI Data 3) + + 40, // D28 is P1.08 - IO34 + 41, // D29 is P1.01 - IO35 + 44, // D30 is P1.02 - IO36 + 45, // D31 is P1.03 - IO37 + 42, // D32 is P1.10 - IO38 + 43, // D33 is P1.11 - IO39 + 47, // D34 is P1.15 - IO40 + 46, // D35 is P1.14 - IO41 + 26, // D36 is P0.26 - IO42 + 6, // D37 is P0.6 - IO43 + 27, // D38 is P0.27 - IO44 +}; + +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/variant.h new file mode 100644 index 0000000..a69575f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/variant.h @@ -0,0 +1,149 @@ + /* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#ifndef _VARIANT_NINA_B302_UBLOX_ +#define _VARIANT_NINA_B302_UBLOX_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus +// Number of pins defined in PinDescription array +#define PINS_COUNT (40) +#define NUM_DIGITAL_PINS (34) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (3) +#define PIN_LED2 (4) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_RED PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +/* + * Buttons + */ +#define PIN_BUTTON1 (7) + +/* + * Analog pins + */ +#define PIN_A0 (14) +#define PIN_A1 (15) +#define PIN_A2 (16) +#define PIN_A3 (17) +#define PIN_A4 (18) +#define PIN_A5 (19) + +#define D0 (0) +#define D1 (1) +#define D2 (2) +#define D3 (3) +#define D4 (4) +#define D5 (5) +#define D6 (6) +#define D7 (7) +#define D8 (8) +#define D9 (9) +#define D10 (10) +#define D11 (11) +#define D12 (12) +#define D13 (13) + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_NFC1 (31) +#define PIN_NFC2 (2) + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (0) +#define PIN_SERIAL1_TX (1) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (22) //24 original +#define PIN_SPI_MOSI (23) //25 original +#define PIN_SPI_SCK (24) //26 original + +static const uint8_t SS = (13); +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (20) +#define PIN_WIRE_SCL (21) + +// QSPI Pins +#define PIN_QSPI_SCK 22 +#define PIN_QSPI_CS 23 +#define PIN_QSPI_IO0 24 +#define PIN_QSPI_IO1 25 +#define PIN_QSPI_IO2 26 +#define PIN_QSPI_IO3 27 + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES GD25Q16C +#define EXTERNAL_FLASH_USE_QSPI + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif //_VARIANT_NINA_B302_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/sparkfun_nrf52840_mini/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/sparkfun_nrf52840_mini/variant.cpp new file mode 100644 index 0000000..b01c147 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/sparkfun_nrf52840_mini/variant.cpp @@ -0,0 +1,49 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // P0 + 0 , 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, + + // P1 + 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, 61, 62, 63 +}; +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/sparkfun_nrf52840_mini/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/sparkfun_nrf52840_mini/variant.h new file mode 100644 index 0000000..c534ceb --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/sparkfun_nrf52840_mini/variant.h @@ -0,0 +1,152 @@ + /* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_SPARKFUN52840MINI_ +#define _VARIANT_SPARKFUN52840MINI_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (64) +#define NUM_DIGITAL_PINS (64) +#define NUM_ANALOG_INPUTS (8) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (7) +#define PIN_LED2 (14) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_BLUE PIN_LED1 +#define LED_RED PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +// Buttons +/* +#define PIN_BUTTON1 (2) +#define PIN_BUTTON2 (3) +#define PIN_BUTTON3 (4) +#define PIN_BUTTON4 (5) +*/ + +/* + * Analog pins + */ +#define PIN_A0 (2) +#define PIN_A1 (3) +#define PIN_A2 (4) +#define PIN_A3 (5) +#define PIN_A4 (28) +#define PIN_A5 (29) +#define PIN_A6 (30) +#define PIN_A7 (31) + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; +static const uint8_t A6 = PIN_A6 ; +static const uint8_t A7 = PIN_A7 ; +#define ADC_RESOLUTION 14 + +// Other pins +#define PIN_AREF (2) +#define PIN_DFU (13) +#define PIN_NFC1 (9) +#define PIN_NFC2 (10) + +static const uint8_t AREF = PIN_AREF; + +/* + * Serial interfaces + */ +// Serial +//Previous Hardware UART definition for nRF52 Arduino Core, below 0.16.0 +//Feel free to comment out these two lines below if there are conflicts with latest release +#define PIN_SERIAL_RX (15) +#define PIN_SERIAL_TX (17) + +//Hardware UART definition for nRF52 Arduino Core, 0.17.0 and above +#define PIN_SERIAL1_RX (15) +#define PIN_SERIAL1_TX (17) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (31) +#define PIN_SPI_MOSI (3) +#define PIN_SPI_SCK (30) + +static const uint8_t SS = 2 ; +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (8) +#define PIN_WIRE_SCL (11) + +/* + * QSPI interface for external flash + */ +#define PIN_QSPI_SCK 32 +#define PIN_QSPI_CS 33 +#define PIN_QSPI_DATA0 34 +#define PIN_QSPI_DATA1 35 +#define PIN_QSPI_DATA2 36 +#define PIN_QSPI_DATA3 37 + +// On-board QSPI Flash +// If EXTERNAL_FLASH_DEVICES is not defined, all supported devices will be used +#define EXTERNAL_FLASH_DEVICES GD25Q16C + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif \ No newline at end of file diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/boards.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/boards.txt new file mode 100644 index 0000000..c21a831 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/boards.txt @@ -0,0 +1,716 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +menu.softdevice=SoftDevice +menu.debug=Debug + +# ---------------------------------- +# Bluefruit Feather nRF52832 +# ---------------------------------- +feather52832.name=Adafruit Feather nRF52832 +feather52832.bootloader.tool=bootburn + +# Upload +feather52832.upload.tool=nrfutil +feather52832.upload.protocol=nrfutil +feather52832.upload.use_1200bps_touch=false +feather52832.upload.wait_for_upload_port=false +feather52832.upload.native_usb=false +feather52832.upload.maximum_size=290816 +feather52832.upload.maximum_data_size=52224 + +# Build +feather52832.build.mcu=cortex-m4 +feather52832.build.f_cpu=64000000 +feather52832.build.board=NRF52832_FEATHER +feather52832.build.core=nRF5 +feather52832.build.variant=feather_nrf52832 +feather52832.build.usb_manufacturer="Adafruit LLC" +feather52832.build.usb_product="Feather nRF52832" +feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52 +feather52832.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +feather52832.menu.softdevice.s132v6=S132 6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_name=s132 +feather52832.menu.softdevice.s132v6.build.sd_version=6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +feather52832.menu.debug.l0=Level 0 (Release) +feather52832.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52832.menu.debug.l1=Level 1 (Error Message) +feather52832.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52832.menu.debug.l2=Level 2 (Full Debug) +feather52832.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52832.menu.debug.l3=Level 3 (Segger SystemView) +feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52832.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Bluefruit Feather nRF52840 Express +# ---------------------------------- +feather52840.name=Adafruit Feather nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840.vid.0=0x239A +feather52840.pid.0=0x8029 +feather52840.vid.1=0x239A +feather52840.pid.1=0x0029 +feather52840.vid.2=0x239A +feather52840.pid.2=0x002A +feather52840.vid.3=0x239A +feather52840.pid.3=0x802A + +# Upload +feather52840.bootloader.tool=bootburn +feather52840.upload.tool=nrfutil +feather52840.upload.protocol=nrfutil +feather52840.upload.use_1200bps_touch=true +feather52840.upload.wait_for_upload_port=true +feather52840.upload.maximum_size=815104 +feather52840.upload.maximum_data_size=237568 + +# Build +feather52840.build.mcu=cortex-m4 +feather52840.build.f_cpu=64000000 +feather52840.build.board=NRF52840_FEATHER +feather52840.build.core=nRF5 +feather52840.build.variant=feather_nrf52840_express +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52840 Express" +feather52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +feather52840.build.ldscript=nrf52840_s140_v6.ld +feather52840.build.vid=0x239A +feather52840.build.pid=0x8029 + +# SofDevice Menu +feather52840.menu.softdevice.s140v6=S140 6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_name=s140 +feather52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840.menu.debug.l0=Level 0 (Release) +feather52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840.menu.debug.l1=Level 1 (Error Message) +feather52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840.menu.debug.l2=Level 2 (Full Debug) +feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840.menu.debug.l3=Level 3 (Segger SystemView) +feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# ---------------------------------- +# Feather nRF52840 sense +# ---------------------------------- +feather52840sense.name=Adafruit Feather nRF52840 Sense + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +feather52840sense.vid.0=0x239A +feather52840sense.pid.0=0x8087 +feather52840sense.vid.1=0x239A +feather52840sense.pid.1=0x0087 +feather52840sense.vid.2=0x239A +feather52840sense.pid.2=0x0088 +feather52840sense.vid.3=0x239A +feather52840sense.pid.3=0x8088 + +# Upload +feather52840sense.bootloader.tool=bootburn +feather52840sense.upload.tool=nrfutil +feather52840sense.upload.protocol=nrfutil +feather52840sense.upload.use_1200bps_touch=true +feather52840sense.upload.wait_for_upload_port=true +feather52840sense.upload.maximum_size=815104 +feather52840sense.upload.maximum_data_size=237568 + +# Build +feather52840sense.build.mcu=cortex-m4 +feather52840sense.build.f_cpu=64000000 +feather52840sense.build.board=NRF52840_FEATHER_SENSE +feather52840sense.build.core=nRF5 +feather52840sense.build.variant=feather_nrf52840_sense +feather52840sense.build.usb_manufacturer="Adafruit LLC" +feather52840sense.build.usb_product="Feather nRF52840 Sense" +feather52840sense.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +feather52840sense.build.ldscript=nrf52840_s140_v6.ld +feather52840sense.build.vid=0x239A +feather52840sense.build.pid=0x8087 + +# SofDevice Menu +feather52840sense.menu.softdevice.s140v6=S140 6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_name=s140 +feather52840sense.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840sense.menu.debug.l0=Level 0 (Release) +feather52840sense.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840sense.menu.debug.l1=Level 1 (Error Message) +feather52840sense.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840sense.menu.debug.l2=Level 2 (Full Debug) +feather52840sense.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840sense.menu.debug.l3=Level 3 (Segger SystemView) +feather52840sense.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840sense.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Bluefruit ItsyBitsy nRF52840 Express +# --------------------------------------------- +itsybitsy52840.name=Adafruit ItsyBitsy nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +itsybitsy52840.vid.0=0x239A +itsybitsy52840.pid.0=0x8051 +itsybitsy52840.vid.1=0x239A +itsybitsy52840.pid.1=0x0051 +itsybitsy52840.vid.2=0x239A +itsybitsy52840.pid.2=0x0052 +itsybitsy52840.vid.3=0x239A +itsybitsy52840.pid.3=0x8052 + +# Upload +itsybitsy52840.bootloader.tool=bootburn +itsybitsy52840.upload.tool=nrfutil +itsybitsy52840.upload.protocol=nrfutil +itsybitsy52840.upload.use_1200bps_touch=true +itsybitsy52840.upload.wait_for_upload_port=true +itsybitsy52840.upload.maximum_size=815104 +itsybitsy52840.upload.maximum_data_size=237568 + +# Build +itsybitsy52840.build.mcu=cortex-m4 +itsybitsy52840.build.f_cpu=64000000 +itsybitsy52840.build.board=NRF52840_ITSYBITSY +itsybitsy52840.build.core=nRF5 +itsybitsy52840.build.variant=itsybitsy_nrf52840_express +itsybitsy52840.build.usb_manufacturer="Adafruit LLC" +itsybitsy52840.build.usb_product="ItsyBitsy nRF52840 Express" +itsybitsy52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52_ITSYBITSY {build.flags.usb} +itsybitsy52840.build.ldscript=nrf52840_s140_v6.ld +itsybitsy52840.build.vid=0x239A +itsybitsy52840.build.pid=0x8051 + +# SofDevice Menu +itsybitsy52840.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_name=s140 +itsybitsy52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +itsybitsy52840.menu.debug.l0=Level 0 (Release) +itsybitsy52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +itsybitsy52840.menu.debug.l1=Level 1 (Error Message) +itsybitsy52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +itsybitsy52840.menu.debug.l2=Level 2 (Full Debug) +itsybitsy52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +itsybitsy52840.menu.debug.l3=Level 3 (Segger SystemView) +itsybitsy52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +itsybitsy52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# --------------------------------------------- +# Bluefruit Circuit Playground nRF52840 Express +# --------------------------------------------- +cplaynrf52840.name=Adafruit Circuit Playground Bluefruit + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cplaynrf52840.vid.0=0x239A +cplaynrf52840.pid.0=0x8045 +cplaynrf52840.vid.1=0x239A +cplaynrf52840.pid.1=0x0045 +cplaynrf52840.vid.2=0x239A +cplaynrf52840.pid.2=0x0046 +cplaynrf52840.vid.3=0x239A +cplaynrf52840.pid.3=0x8046 + +# Upload +cplaynrf52840.bootloader.tool=bootburn +cplaynrf52840.upload.tool=nrfutil +cplaynrf52840.upload.protocol=nrfutil +cplaynrf52840.upload.use_1200bps_touch=true +cplaynrf52840.upload.wait_for_upload_port=true +cplaynrf52840.upload.maximum_size=815104 +cplaynrf52840.upload.maximum_data_size=237568 + +# Build +cplaynrf52840.build.mcu=cortex-m4 +cplaynrf52840.build.f_cpu=64000000 +cplaynrf52840.build.board=NRF52840_CIRCUITPLAY +cplaynrf52840.build.core=nRF5 +cplaynrf52840.build.variant=circuitplayground_nrf52840 +cplaynrf52840.build.usb_manufacturer="Adafruit LLC" +cplaynrf52840.build.usb_product="Circuit Playground Bluefruit" +cplaynrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld +cplaynrf52840.build.vid=0x239A +cplaynrf52840.build.pid=0x8045 + +# SofDevice Menu +cplaynrf52840.menu.softdevice.s140v6=S140 6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cplaynrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cplaynrf52840.menu.debug.l0=Level 0 (Release) +cplaynrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cplaynrf52840.menu.debug.l1=Level 1 (Error Message) +cplaynrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cplaynrf52840.menu.debug.l2=Level 2 (Full Debug) +cplaynrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cplaynrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cplaynrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + +# --------------------------------------------- +# Clue nRF52840 +# --------------------------------------------- +cluenrf52840.name=Adafruit CLUE + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cluenrf52840.vid.0=0x239A +cluenrf52840.pid.0=0x8072 +cluenrf52840.vid.1=0x239A +cluenrf52840.pid.1=0x0072 +cluenrf52840.vid.2=0x239A +cluenrf52840.pid.2=0x0071 +cluenrf52840.vid.3=0x239A +cluenrf52840.pid.3=0x8071 + +# Upload +cluenrf52840.bootloader.tool=bootburn +cluenrf52840.upload.tool=nrfutil +cluenrf52840.upload.protocol=nrfutil +cluenrf52840.upload.use_1200bps_touch=true +cluenrf52840.upload.wait_for_upload_port=true +cluenrf52840.upload.maximum_size=815104 +cluenrf52840.upload.maximum_data_size=237568 + +# Build +cluenrf52840.build.mcu=cortex-m4 +cluenrf52840.build.f_cpu=64000000 +cluenrf52840.build.board=NRF52840_CLUE +cluenrf52840.build.core=nRF5 +cluenrf52840.build.variant=clue_nrf52840 +cluenrf52840.build.usb_manufacturer="Adafruit LLC" +cluenrf52840.build.usb_product="CLUE" +cluenrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +cluenrf52840.build.ldscript=nrf52840_s140_v6.ld +cluenrf52840.build.vid=0x239A +cluenrf52840.build.pid=0x8071 + +# SofDevice Menu +cluenrf52840.menu.softdevice.s140v6=S140 6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cluenrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cluenrf52840.menu.debug.l0=Level 0 (Release) +cluenrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cluenrf52840.menu.debug.l1=Level 1 (Error Message) +cluenrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cluenrf52840.menu.debug.l2=Level 2 (Full Debug) +cluenrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cluenrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cluenrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cluenrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Metro nRF52840 Express +# ---------------------------------- +metro52840.name=Adafruit Metro nRF52840 Express + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +metro52840.vid.0=0x239A +metro52840.pid.0=0x803F +metro52840.vid.1=0x239A +metro52840.pid.1=0x003F +metro52840.vid.2=0x239A +metro52840.pid.2=0x0040 +metro52840.vid.3=0x239A +metro52840.pid.3=0x8040 + +# Upload +metro52840.bootloader.tool=bootburn +metro52840.upload.tool=nrfutil +metro52840.upload.protocol=nrfutil +metro52840.upload.use_1200bps_touch=true +metro52840.upload.wait_for_upload_port=true +metro52840.upload.maximum_size=815104 +metro52840.upload.maximum_data_size=237568 + +# Build +metro52840.build.mcu=cortex-m4 +metro52840.build.f_cpu=64000000 +metro52840.build.board=NRF52840_METRO +metro52840.build.core=nRF5 +metro52840.build.variant=metro_nrf52840_express +metro52840.build.usb_manufacturer="Adafruit LLC" +metro52840.build.usb_product="Metro nRF52840 Express" +metro52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +metro52840.build.ldscript=nrf52840_s140_v6.ld +metro52840.build.vid=0x239A +metro52840.build.pid=0x803F + +# SofDevice Menu +metro52840.menu.softdevice.s140v6=S140 6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_name=s140 +metro52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +metro52840.menu.debug.l0=Level 0 (Release) +metro52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +metro52840.menu.debug.l1=Level 1 (Error Message) +metro52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +metro52840.menu.debug.l2=Level 2 (Full Debug) +metro52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +metro52840.menu.debug.l3=Level 3 (Segger SystemView) +metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +metro52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + + + + +# ------------------------------------------------------- +# +# Boards that aren't made by Adafruit +# +# ------------------------------------------------------- + + +# ---------------------------------- +# Nordic nRF52840DK (PCA10056) +# ---------------------------------- +pca10056.name=Nordic nRF52840DK (PCA10056) +pca10056.bootloader.tool=bootburn + +# Upload +pca10056.upload.tool=nrfutil +pca10056.upload.protocol=nrfutil +pca10056.upload.use_1200bps_touch=true +pca10056.upload.wait_for_upload_port=true +pca10056.upload.maximum_size=815104 +pca10056.upload.maximum_data_size=237568 + +# Build +pca10056.build.mcu=cortex-m4 +pca10056.build.f_cpu=64000000 +pca10056.build.board=NRF52840_PCA10056 +pca10056.build.core=nRF5 +pca10056.build.variant=pca10056 +pca10056.build.usb_manufacturer="Nordic" +pca10056.build.usb_product="nRF52840 DK" +pca10056.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +pca10056.build.ldscript=nrf52840_s140_v6.ld +pca10056.build.vid=0x239A +pca10056.build.pid=0x8029 + +# SofDevice Menu +pca10056.menu.softdevice.s140v6=S140 6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_name=s140 +pca10056.menu.softdevice.s140v6.build.sd_version=6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +pca10056.menu.debug.l0=Level 0 (Release) +pca10056.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +pca10056.menu.debug.l1=Level 1 (Error Message) +pca10056.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +pca10056.menu.debug.l2=Level 2 (Full Debug) +pca10056.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +pca10056.menu.debug.l3=Level 3 (Segger SystemView) +pca10056.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +pca10056.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Particle Xenon +# ---------------------------------- +particle_xenon.name=Particle Xenon + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +particle_xenon.vid.0=0x239A +particle_xenon.pid.0=0x8029 +particle_xenon.vid.1=0x239A +particle_xenon.pid.1=0x0029 +particle_xenon.vid.2=0x239A +particle_xenon.pid.2=0x002A +particle_xenon.vid.3=0x239A +particle_xenon.pid.3=0x802A + +# Upload +particle_xenon.bootloader.tool=bootburn +particle_xenon.upload.tool=nrfutil +particle_xenon.upload.protocol=nrfutil +particle_xenon.upload.use_1200bps_touch=true +particle_xenon.upload.wait_for_upload_port=true +particle_xenon.upload.maximum_size=815104 +particle_xenon.upload.maximum_data_size=237568 + +# Build +particle_xenon.build.mcu=cortex-m4 +particle_xenon.build.f_cpu=64000000 +particle_xenon.build.board=PARTICLE_XENON +particle_xenon.build.core=nRF5 +particle_xenon.build.variant=particle_xenon +particle_xenon.build.usb_manufacturer="Particle Industries" +particle_xenon.build.usb_product="Particle Xenon" +particle_xenon.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +particle_xenon.build.ldscript=nrf52840_s140_v6.ld +particle_xenon.build.vid=0x239A +particle_xenon.build.pid=0x8029 + +# SofDevice Menu +particle_xenon.menu.softdevice.s140v6=S140 6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_name=s140 +particle_xenon.menu.softdevice.s140v6.build.sd_version=6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +particle_xenon.menu.debug.l0=Level 0 (Release) +particle_xenon.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +particle_xenon.menu.debug.l1=Level 1 (Error Message) +particle_xenon.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +particle_xenon.menu.debug.l2=Level 2 (Full Debug) +particle_xenon.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +particle_xenon.menu.debug.l3=Level 3 (Segger SystemView) +particle_xenon.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +particle_xenon.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Raytac MDBT50Q - RX +# ---------------------------------- +mdbt50qrx.name=Raytac MDBT50Q-RX Dongle + +# VID/PID for bootloader, Arduino + Circuitpython App +mdbt50qrx.vid.0=0x239A +mdbt50qrx.pid.0=0x810B +mdbt50qrx.vid.1=0x239A +mdbt50qrx.pid.1=0x010B +mdbt50qrx.vid.2=0x239A +mdbt50qrx.pid.2=0x810C + +# Upload +mdbt50qrx.bootloader.tool=bootburn +mdbt50qrx.upload.tool=nrfutil +mdbt50qrx.upload.protocol=nrfutil +mdbt50qrx.upload.use_1200bps_touch=true +mdbt50qrx.upload.wait_for_upload_port=true +mdbt50qrx.upload.maximum_size=815104 +mdbt50qrx.upload.maximum_data_size=237568 + +# Build +mdbt50qrx.build.mcu=cortex-m4 +mdbt50qrx.build.f_cpu=64000000 +mdbt50qrx.build.board=MDBT50Q_RX +mdbt50qrx.build.core=nRF5 +mdbt50qrx.build.variant=raytac_mdbt50q_rx +mdbt50qrx.build.usb_manufacturer="Raytac" +mdbt50qrx.build.usb_product="nRF52840 Dongle" +mdbt50qrx.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld +mdbt50qrx.build.vid=0x239A +mdbt50qrx.build.pid=0x810B + +# SofDevice Menu +mdbt50qrx.menu.softdevice.s140v6=S140 6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_name=s140 +mdbt50qrx.menu.softdevice.s140v6.build.sd_version=6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +mdbt50qrx.menu.debug.l0=Level 0 (Release) +mdbt50qrx.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +mdbt50qrx.menu.debug.l1=Level 1 (Error Message) +mdbt50qrx.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +mdbt50qrx.menu.debug.l2=Level 2 (Full Debug) +mdbt50qrx.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +mdbt50qrx.menu.debug.l3=Level 3 (Segger SystemView) +mdbt50qrx.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +mdbt50qrx.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# NINA B302 +# ---------------------------------- +ninab302.name=NINA B302 ublox + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +ninab302.vid.0=0x239A +ninab302.pid.0=0x8029 +ninab302.vid.1=0x239A +ninab302.pid.1=0x0029 +ninab302.vid.2=0x7239A +ninab302.pid.2=0x002A +ninab302.vid.3=0x239A +ninab302.pid.3=0x802A + +# Upload +ninab302.bootloader.tool=bootburn +ninab302.upload.tool=nrfutil +ninab302.upload.protocol=nrfutil +ninab302.upload.use_1200bps_touch=true +ninab302.upload.wait_for_upload_port=true +ninab302.upload.maximum_size=815104 +ninab302.upload.maximum_data_size=237568 + +# Build +ninab302.build.mcu=cortex-m4 +ninab302.build.f_cpu=64000000 +ninab302.build.board=NINA_B302_ublox +ninab302.build.core=nRF5 +ninab302.build.variant=NINA_B302_ublox +ninab302.build.usb_manufacturer="Nordic" +ninab302.build.usb_product="NINA B302 ublox" +ninab302.build.extra_flags=-DNRF52840_XXAA -DNINA_B302_ublox {build.flags.usb} +ninab302.build.ldscript=nrf52840_s140_v6.ld +ninab302.build.vid=0x239A +ninab302.build.pid=0x8029 + +# SofDevice Menu +ninab302.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_name=s140 +ninab302.menu.softdevice.s140v6.build.sd_version=6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +ninab302.menu.debug.l0=Level 0 (Release) +ninab302.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab302.menu.debug.l1=Level 1 (Error Message) +ninab302.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab302.menu.debug.l2=Level 2 (Full Debug) +ninab302.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab302.menu.debug.l3=Level 3 (Segger SystemView) +ninab302.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab302.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# NINA B112 +# ---------------------------------- +ninab112.name=NINA B112 ublox +ninab112.bootloader.tool=bootburn + +# Upload +ninab112.upload.tool=nrfutil +ninab112.upload.protocol=nrfutil +ninab112.upload.use_1200bps_touch=false +ninab112.upload.wait_for_upload_port=false +ninab112.upload.native_usb=false +ninab112.upload.maximum_size=290816 +ninab112.upload.maximum_data_size=52224 + +# Build +ninab112.build.mcu=cortex-m4 +ninab112.build.f_cpu=64000000 +ninab112.build.board=NINA_B112_ublox +ninab112.build.core=nRF5 +ninab112.build.variant=NINA_B112_ublox +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52832" +ninab112.build.extra_flags=-DNRF52832_XXAA -DNINA_B112_ublox -DNRF52 +ninab112.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +ninab112.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_name=s132 +ninab112.menu.softdevice.s132v6.build.sd_version=6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +ninab112.menu.debug.l0=Level 0 (Release) +ninab112.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab112.menu.debug.l1=Level 1 (Error Message) +ninab112.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab112.menu.debug.l2=Level 2 (Full Debug) +ninab112.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab112.menu.debug.l3=Level 3 (Segger SystemView) +ninab112.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab112.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +################################################################## +## KH Add SparkFun Pro nRF52840 Mini +################################################################## +#********************************************** +# SparkFun Pro nRF52840 Mini +#********************************************** +sparkfunnrf52840mini.name=SparkFun Pro nRF52840 Mini + +# DFU Mode with CDC only +sparkfunnrf52840mini.vid.0=0x1B4F +sparkfunnrf52840mini.pid.0=0x002A + +# DFU Mode with CDC + MSC (UF2) +sparkfunnrf52840mini.vid.1=0x1B4F +sparkfunnrf52840mini.pid.1=0x0029 + +# Application with CDC + MSC +sparkfunnrf52840mini.vid.2=0x1B4F +sparkfunnrf52840mini.pid.2=0x8029 + +# CircuitPython +sparkfunnrf52840mini.vid.2=0x1B4F +sparkfunnrf52840mini.pid.2=0x802A + +sparkfunnrf52840mini.bootloader.tool=bootburn + +# Upload +sparkfunnrf52840mini.upload.tool=nrfutil +sparkfunnrf52840mini.upload.protocol=nrfutil +sparkfunnrf52840mini.upload.use_1200bps_touch=true +sparkfunnrf52840mini.upload.wait_for_upload_port=true +#sparkfunnrf52840mini.upload.native_usb=true + +# Build +sparkfunnrf52840mini.build.mcu=cortex-m4 +sparkfunnrf52840mini.build.f_cpu=64000000 +sparkfunnrf52840mini.build.board=NRF52840_FEATHER +sparkfunnrf52840mini.build.core=nRF5 +sparkfunnrf52840mini.build.variant=sparkfun_nrf52840_mini +sparkfunnrf52840mini.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +sparkfunnrf52840mini.build.vid=0x1B4F +sparkfunnrf52840mini.build.pid=0x5284 +sparkfunnrf52840mini.build.usb_manufacturer="SparkFun" +sparkfunnrf52840mini.build.usb_product="nRF52840 Mini Breakout" + +# SofDevice Menu +# Ram & ROM size varies depending on SoftDevice (check linker script) + +sparkfunnrf52840mini.menu.softdevice.s140v6=s140 6.1.1 r0 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.sd_flags=-DS140 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.sd_name=s140 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.sd_version=6.1.1 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.sd_fwid=0x00B6 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.ldscript=nrf52840_s140_v6.ld +sparkfunnrf52840mini.menu.softdevice.s140v6.upload.maximum_size=815104 +sparkfunnrf52840mini.menu.softdevice.s140v6.upload.maximum_data_size=248832 + +# Debug Menu +sparkfunnrf52840mini.menu.debug.l0=Level 0 (Release) +sparkfunnrf52840mini.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 -Os +sparkfunnrf52840mini.menu.debug.l1=Level 1 (Error Message) +sparkfunnrf52840mini.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 -Os +sparkfunnrf52840mini.menu.debug.l2=Level 2 (Full Debug) +sparkfunnrf52840mini.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 -Os +sparkfunnrf52840mini.menu.debug.l3=Level 3 (Segger SystemView) +sparkfunnrf52840mini.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 -Os + +################################################################## diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Udp.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Udp.h new file mode 100644 index 0000000..cc814d3 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Udp.h @@ -0,0 +1,92 @@ +/* + * Udp.cpp: Library to send/receive UDP packets. + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + */ + +#ifndef udp_h +#define udp_h + +#include +#include + +class UDP : public Stream { + +public: + virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + + // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) + virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + + virtual void stop() =0; // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port) =0; + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port) =0; + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket() =0; + // Write a single byte into the packet + virtual size_t write(uint8_t) =0; + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size) =0; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket() =0; + // Number of bytes remaining in the current packet + virtual int available() =0; + // Read a single byte from the current packet + virtual int read() =0; + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len) =0; + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) =0; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek() =0; + virtual void flush() =0; // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() =0; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() =0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/platform.txt new file mode 100644 index 0000000..34a515e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/platform.txt @@ -0,0 +1,167 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All rights reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +name=Adafruit nRF52 Boards +version=1.1.0 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-pointer-arith + +# Allow changing optimization settings via platform.local.txt / boards.local.txt +compiler.optimization_flag=-Ofast + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD + +# KH, Error here to use gcc, must use g++ +#compiler.c.elf.cmd=arm-none-eabi-gcc +compiler.c.elf.cmd=arm-none-eabi-g++ + +compiler.c.elf.flags={compiler.optimization_flag} -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-mcpu={build.mcu} -mthumb -mabi=aapcs {compiler.optimization_flag} -g -c {build.float_flags} -x assembler-with-cpp + +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2bin.flags=-O binary +compiler.elf2bin.cmd=arm-none-eabi-objcopy +compiler.elf2hex.flags=-O ihex +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb {build.float_flags} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--wrap=malloc -Wl,--wrap=free --specs=nano.specs --specs=nosys.specs +compiler.size.cmd=arm-none-eabi-size + +# this can be overriden in boards.txt +build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float +build.debug_flags=-DCFG_DEBUG=0 +build.logger_flags=-DCFG_LOGGER=1 +build.sysview_flags=-DCFG_SYSVIEW=0 + +# USB flags +build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.libraries.ldflags= +compiler.elf2bin.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.7.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.7.0.path}/CMSIS/DSP/Include/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.7.0.path}/CMSIS/DSP/Lib/GCC/" -larm_cortexM4lf_math + +# common compiler for nrf +rtos.path={build.core.path}/freertos +nordic.path={build.core.path}/nordic + +# build.logger_flags and build.sysview_flags are intentionally empty, +# to allow modification via a user's own boards.local.txt or platform.local.txt files. +build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DDX_CC_TEE -DLFS_NAME_MAX=64 {compiler.optimization_flag} {build.debug_flags} {build.logger_flags} {build.sysview_flags} {compiler.arm.cmsis.c.flags} "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include/nrf52" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Create archives +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-L{build.core.path}/linker" "-T{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} -Wl,--start-group {compiler.arm.cmsis.ldflags} -lm "{build.path}/{archive_file}" {compiler.libraries.ldflags} -Wl,--end-group + +## Create output (bin file) +#recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2bin.cmd}" {compiler.elf2bin.flags} {compiler.elf2bin.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +## Create dfu package zip file +recipe.objcopy.zip.pattern="{tools.nrfutil.cmd}" dfu genpkg --dev-type 0x0052 --sd-req {build.sd_fwid} --application "{build.path}/{build.project_name}.hex" "{build.path}/{build.project_name}.zip" + +## Create uf2 file +#recipe.objcopy.uf2.pattern=python "{runtime.platform.path}/tools/uf2conv/uf2conv.py" -f 0xADA52840 -c -o "{build.path}/{build.project_name}.uf2" "{build.path}/{build.project_name}.hex" + +## Save bin +recipe.output.tmp_file_bin={build.project_name}.bin +recipe.output.save_file_bin={build.project_name}.save.bin + +## Save hex +recipe.output.tmp_file_hex={build.project_name}.hex +recipe.output.save_file_hexu={build.project_name}.save.hex + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + +## Export Compiled Binary +recipe.output.tmp_file={build.project_name}.hex +recipe.output.save_file={build.project_name}.{build.variant}.hex + +#*************************************************** +# adafruit-nrfutil for uploading +# https://github.com/adafruit/Adafruit_nRF52_nrfutil +# pre-built binaries are provided for macos and windows +#*************************************************** +tools.nrfutil.cmd=adafruit-nrfutil +tools.nrfutil.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe +tools.nrfutil.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil + +tools.nrfutil.upload.params.verbose=--verbose +tools.nrfutil.upload.params.quiet= +tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.path}/{build.project_name}.zip" -p {serial.port} -b 115200 --singlebank + +#*************************************************** +# Burning bootloader with either jlink or nrfutil +#*************************************************** + +# Bootloader version +tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.6.2_{build.sd_name}_{build.sd_version} + +tools.bootburn.bootloader.params.verbose= +tools.bootburn.bootloader.params.quiet= +tools.bootburn.bootloader.pattern={program.burn_pattern} + +# erase flash page while programming +tools.bootburn.erase.params.verbose= +tools.bootburn.erase.params.quiet= +tools.bootburn.erase.pattern= + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/variant.cpp new file mode 100644 index 0000000..f43f3a4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/variant.cpp @@ -0,0 +1,59 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" + +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +const uint32_t g_ADigitalPinMap[] = { + // D0 .. D13 + 5, // D0 is P0.05 (UART RX) + 6, // D1 is P0.06 (UART TX) + 7, // D2 is P0.07 + 31, // D3 is P0.31 + 18, // D4 is P0.18 (LED Blue) + 99, // D5 (NC) + 9, // D6 is P0.09 NFC1 + 10, // D7 is P0.10 (Button) NFC2 + 99, // D8 (NC) + 8, // D9 is P0.08 + 11, // D10 is P0.11 CS + 13, // D11 is P0.13 MOSI + 12, // D12 is P0.12 MISO + 14, // D13 is P0.14 SCK + //I2C + 2, // D14 is P0.2 (SDA) + 3, // D15 is P0.3 (SCL) + // D16 .. D21 (aka A0 .. A5) + 3, // D16 is P0.03 (A0) + 2, // D17 is P0.02 (A1) + 4, // D18 is P0.04 (A2) + 30, // D19 is P0.30 (A3) SW2 + 29, // D20 is P0.29 (A4) + 28, // D21 is P0.28 (A5) + 9, // P0.09 NFC + 10, // P0.10 NFC + 16, // SW1 (LED Green) +}; \ No newline at end of file diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/variant.h new file mode 100644 index 0000000..833cbf6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/variant.h @@ -0,0 +1,172 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +#ifndef _VARIANT_NINA_B112_UBLOX_ +#define _VARIANT_NINA_B112_UBLOX_ + +#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \ + .rc_ctiv = 0, \ +.rc_temp_ctiv = 0, \ +.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM} + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (32u) +#define NUM_DIGITAL_PINS (32u) +#define NUM_ANALOG_INPUTS (6u) +#define NUM_ANALOG_OUTPUTS (0u) + +// LEDs +#define PIN_LED LED1 +#define LED_BUILTIN PIN_LED + +//LEDs onboard +#define LED1 (0) // Red +#define LED2 (24) // Green/SW1 +#define LED3 (4) // Blue + +#define LED_STATE_ON 1 // State when LED is litted + +//Switch +#define SW1 (24) +#define SW2 (19) + +// NFC +#define PIN_NFC_1 (6) // P0.9 +#define PIN_NFC_2 (7) // P0.10 + +/* + * Analog pins + */ +#define PIN_A0 (16) // P0.03 +#define PIN_A1 (17) // P0.02 +#define PIN_A2 (18) // P0.04 +#define PIN_A3 (19) // P0.30 +#define PIN_A4 (20) // P0.29 +#define PIN_A5 (21) // P0.28 + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_D0 (0) // P0.05 +#define PIN_D1 (1) // P0.06 +#define PIN_D2 (2) // P0.07 +#define PIN_D3 (4) // P0.31 +#define PIN_D4 (5) // P0.18 +#define PIN_D6 (6) // P0.09 +#define PIN_D7 (7) // P0.10 +#define PIN_D9 (9) // P0.08 +#define PIN_D10 (11) // P0.11 +#define PIN_D11 (13) // P0.13 +#define PIN_D12 (12) // P0.12 +#define PIN_D13 (14) // P0.14 +#define PIN_D14 (2) // P0.02 +#define PIN_D15 (3) // P0.03 + +static const uint8_t D0 = PIN_D0 ; +static const uint8_t D1 = PIN_D1 ; +static const uint8_t D2 = PIN_D2 ; +static const uint8_t D3 = PIN_D3 ; +static const uint8_t D4 = PIN_D4 ; +static const uint8_t D6 = PIN_D6 ; +static const uint8_t D7 = PIN_D7 ; +static const uint8_t D9 = PIN_D9 ; +static const uint8_t D10 = PIN_D10 ; +static const uint8_t D11 = PIN_D11 ; +static const uint8_t D12 = PIN_D12 ; +static const uint8_t D13 = PIN_D13 ; +static const uint8_t D14 = PIN_D14 ; +static const uint8_t D15 = PIN_D15 ; + +// Other pins +//static const uint8_t AREF = PIN_AREF; + +//#define PIN_AREF (24) +//#define PIN_VBAT PIN_A7 + +/* + * Serial interfaces + */ +#define PIN_SERIAL_RX (0) // P0.05 +#define PIN_SERIAL_TX (1) // P0.06 +#define PIN_SERIAL_CTS (2) // P0.07 +#define PIN_SERIAL_RTS (3) // P0.31 +#define PIN_SERIAL_DTR (28) // P0.28 +#define PIN_SERIAL_DSR (29) // P0.29 + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (12) // P0.12 +#define PIN_SPI_MOSI (11) // P0.13 +#define PIN_SPI_SCK (13) // P0.14 + +static const uint8_t SS = 10 ; // P0.11 +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (14) // P0.02 +#define PIN_WIRE_SCL (15) // P0.03 + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + + +#endif //_VARIANT_NINA_B112_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/variant.cpp new file mode 100644 index 0000000..8b4df2e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/variant.cpp @@ -0,0 +1,87 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 + 29, // D0 is P0.29 (UART RX) + 45, // D1 is P1.13 (UART TX) + 44, // D2 is P1.12 (NFC2) + 31, // D3 is P0.31 (LED1) + 13, // D4 is P0.13 (LED2) + 11, // D5 is P0.11 + 9, // D6 is P0.09 + 10, // D7 is P0.10 (Button) + 41, // D8 is P1.09 + 12, // D9 is P0.12 + 14, // D10 is P0.14 + 15, // D11 is P0.15 + 32, // D12 is P1.00 + 7, // D13 is P0.07 + + // D14 .. D21 (aka A0 .. A5) + 4, // D14 is P0.04 (A0) + 30, // D15 is P0.30 (A1) + 5, // D16 is P0.05 (A2) + 2, // D17 is P0.02 (A3) + 28, // D18 is P0.28 (A4) + 3, // D19 is P0.03 (A5) + + // D20 .. D21 (aka I2C pins) + 16, // D20 is P0.16 (SDA) + 24, // D21 is P0.24 (SCL) + + // QSPI pins (not exposed via any header / test point) + 19, // D22 is P0.19 (QSPI CLK) + 17, // D23 is P0.17 (QSPI CS) + 20, // D24 is P0.20 (QSPI Data 0) + 21, // D25 is P0.21 (QSPI Data 1) + 22, // D26 is P0.22 (QSPI Data 2) + 26, // D27 is P0.23 (QSPI Data 3) + + 40, // D28 is P1.08 - IO34 + 41, // D29 is P1.01 - IO35 + 44, // D30 is P1.02 - IO36 + 45, // D31 is P1.03 - IO37 + 42, // D32 is P1.10 - IO38 + 43, // D33 is P1.11 - IO39 + 47, // D34 is P1.15 - IO40 + 46, // D35 is P1.14 - IO41 + 26, // D36 is P0.26 - IO42 + 6, // D37 is P0.6 - IO43 + 27, // D38 is P0.27 - IO44 +}; + +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/variant.h new file mode 100644 index 0000000..a69575f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/variant.h @@ -0,0 +1,149 @@ + /* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#ifndef _VARIANT_NINA_B302_UBLOX_ +#define _VARIANT_NINA_B302_UBLOX_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus +// Number of pins defined in PinDescription array +#define PINS_COUNT (40) +#define NUM_DIGITAL_PINS (34) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (3) +#define PIN_LED2 (4) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_RED PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +/* + * Buttons + */ +#define PIN_BUTTON1 (7) + +/* + * Analog pins + */ +#define PIN_A0 (14) +#define PIN_A1 (15) +#define PIN_A2 (16) +#define PIN_A3 (17) +#define PIN_A4 (18) +#define PIN_A5 (19) + +#define D0 (0) +#define D1 (1) +#define D2 (2) +#define D3 (3) +#define D4 (4) +#define D5 (5) +#define D6 (6) +#define D7 (7) +#define D8 (8) +#define D9 (9) +#define D10 (10) +#define D11 (11) +#define D12 (12) +#define D13 (13) + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_NFC1 (31) +#define PIN_NFC2 (2) + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (0) +#define PIN_SERIAL1_TX (1) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (22) //24 original +#define PIN_SPI_MOSI (23) //25 original +#define PIN_SPI_SCK (24) //26 original + +static const uint8_t SS = (13); +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (20) +#define PIN_WIRE_SCL (21) + +// QSPI Pins +#define PIN_QSPI_SCK 22 +#define PIN_QSPI_CS 23 +#define PIN_QSPI_IO0 24 +#define PIN_QSPI_IO1 25 +#define PIN_QSPI_IO2 26 +#define PIN_QSPI_IO3 27 + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES GD25Q16C +#define EXTERNAL_FLASH_USE_QSPI + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif //_VARIANT_NINA_B302_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/sparkfun_nrf52840_mini/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/sparkfun_nrf52840_mini/variant.cpp new file mode 100644 index 0000000..b01c147 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/sparkfun_nrf52840_mini/variant.cpp @@ -0,0 +1,49 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // P0 + 0 , 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, + + // P1 + 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, 61, 62, 63 +}; +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/sparkfun_nrf52840_mini/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/sparkfun_nrf52840_mini/variant.h new file mode 100644 index 0000000..c534ceb --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/sparkfun_nrf52840_mini/variant.h @@ -0,0 +1,152 @@ + /* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_SPARKFUN52840MINI_ +#define _VARIANT_SPARKFUN52840MINI_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (64) +#define NUM_DIGITAL_PINS (64) +#define NUM_ANALOG_INPUTS (8) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (7) +#define PIN_LED2 (14) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_BLUE PIN_LED1 +#define LED_RED PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +// Buttons +/* +#define PIN_BUTTON1 (2) +#define PIN_BUTTON2 (3) +#define PIN_BUTTON3 (4) +#define PIN_BUTTON4 (5) +*/ + +/* + * Analog pins + */ +#define PIN_A0 (2) +#define PIN_A1 (3) +#define PIN_A2 (4) +#define PIN_A3 (5) +#define PIN_A4 (28) +#define PIN_A5 (29) +#define PIN_A6 (30) +#define PIN_A7 (31) + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; +static const uint8_t A6 = PIN_A6 ; +static const uint8_t A7 = PIN_A7 ; +#define ADC_RESOLUTION 14 + +// Other pins +#define PIN_AREF (2) +#define PIN_DFU (13) +#define PIN_NFC1 (9) +#define PIN_NFC2 (10) + +static const uint8_t AREF = PIN_AREF; + +/* + * Serial interfaces + */ +// Serial +//Previous Hardware UART definition for nRF52 Arduino Core, below 0.16.0 +//Feel free to comment out these two lines below if there are conflicts with latest release +#define PIN_SERIAL_RX (15) +#define PIN_SERIAL_TX (17) + +//Hardware UART definition for nRF52 Arduino Core, 0.17.0 and above +#define PIN_SERIAL1_RX (15) +#define PIN_SERIAL1_TX (17) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (31) +#define PIN_SPI_MOSI (3) +#define PIN_SPI_SCK (30) + +static const uint8_t SS = 2 ; +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (8) +#define PIN_WIRE_SCL (11) + +/* + * QSPI interface for external flash + */ +#define PIN_QSPI_SCK 32 +#define PIN_QSPI_CS 33 +#define PIN_QSPI_DATA0 34 +#define PIN_QSPI_DATA1 35 +#define PIN_QSPI_DATA2 36 +#define PIN_QSPI_DATA3 37 + +// On-board QSPI Flash +// If EXTERNAL_FLASH_DEVICES is not defined, all supported devices will be used +#define EXTERNAL_FLASH_DEVICES GD25Q16C + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif \ No newline at end of file diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/boards.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/boards.txt new file mode 100644 index 0000000..541eb10 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/boards.txt @@ -0,0 +1,834 @@ +menu.softdevice=SoftDevice +menu.debug=Debug +menu.debug_output=Debug Output + +# ----------------------------------- +# Adafruit Feather nRF52832 +# ----------------------------------- +feather52832.name=Adafruit Feather nRF52832 + +# VID/PID for Bootloader, Arduino & CircuitPython + +# Upload +feather52832.bootloader.tool=bootburn +feather52832.upload.tool=nrfutil +feather52832.upload.protocol=nrfutil +feather52832.upload.use_1200bps_touch=false +feather52832.upload.wait_for_upload_port=false +feather52832.upload.native_usb=false +feather52832.upload.maximum_size=290816 +feather52832.upload.maximum_data_size=52224 + +# Build +feather52832.build.mcu=cortex-m4 +feather52832.build.f_cpu=64000000 +feather52832.build.board=NRF52832_FEATHER +feather52832.build.core=nRF5 +feather52832.build.variant=feather_nrf52832 +feather52832.build.usb_manufacturer="Adafruit" +feather52832.build.usb_product="Feather nRF52832" +feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52 +feather52832.build.ldscript=nrf52832_s132_v6.ld + +# SoftDevice Menu +feather52832.menu.softdevice.s132v6=S132 6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_name=s132 +feather52832.menu.softdevice.s132v6.build.sd_version=6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +feather52832.menu.debug.l0=Level 0 (Release) +feather52832.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52832.menu.debug.l1=Level 1 (Error Message) +feather52832.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52832.menu.debug.l2=Level 2 (Full Debug) +feather52832.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52832.menu.debug.l3=Level 3 (Segger SystemView) +feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52832.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +feather52832.menu.debug_output.serial=Serial +feather52832.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +feather52832.menu.debug_output.serial1=Serial1 +feather52832.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +feather52832.menu.debug_output.rtt=Segger RTT +feather52832.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + +# ----------------------------------- +# Adafruit Feather nRF52840 Express +# ----------------------------------- +feather52840.name=Adafruit Feather nRF52840 Express + +# VID/PID for Bootloader, Arduino & CircuitPython +feather52840.vid.0=0x239A +feather52840.pid.0=0x8029 +feather52840.vid.1=0x239A +feather52840.pid.1=0x0029 +feather52840.vid.2=0x239A +feather52840.pid.2=0x002A +feather52840.vid.3=0x239A +feather52840.pid.3=0x802A + +# Upload +feather52840.bootloader.tool=bootburn +feather52840.upload.tool=nrfutil +feather52840.upload.protocol=nrfutil +feather52840.upload.use_1200bps_touch=true +feather52840.upload.wait_for_upload_port=true +feather52840.upload.maximum_size=815104 +feather52840.upload.maximum_data_size=237568 + +# Build +feather52840.build.mcu=cortex-m4 +feather52840.build.f_cpu=64000000 +feather52840.build.board=NRF52840_FEATHER +feather52840.build.core=nRF5 +feather52840.build.variant=feather_nrf52840_express +feather52840.build.usb_manufacturer="Adafruit" +feather52840.build.usb_product="Feather nRF52840 Express" +feather52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +feather52840.build.ldscript=nrf52840_s140_v6.ld +feather52840.build.vid=0x239A +feather52840.build.pid=0x8029 + +# SoftDevice Menu +feather52840.menu.softdevice.s140v6=S140 6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_name=s140 +feather52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840.menu.debug.l0=Level 0 (Release) +feather52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840.menu.debug.l1=Level 1 (Error Message) +feather52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840.menu.debug.l2=Level 2 (Full Debug) +feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840.menu.debug.l3=Level 3 (Segger SystemView) +feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +feather52840.menu.debug_output.serial=Serial +feather52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +feather52840.menu.debug_output.serial1=Serial1 +feather52840.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +feather52840.menu.debug_output.rtt=Segger RTT +feather52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + +# ----------------------------------- +# Adafruit Feather nRF52840 Sense +# ----------------------------------- +feather52840sense.name=Adafruit Feather nRF52840 Sense + +# VID/PID for Bootloader, Arduino & CircuitPython +feather52840sense.vid.0=0x239A +feather52840sense.pid.0=0x8087 +feather52840sense.vid.1=0x239A +feather52840sense.pid.1=0x0087 +feather52840sense.vid.2=0x239A +feather52840sense.pid.2=0x0088 +feather52840sense.vid.3=0x239A +feather52840sense.pid.3=0x8088 + +# Upload +feather52840sense.bootloader.tool=bootburn +feather52840sense.upload.tool=nrfutil +feather52840sense.upload.protocol=nrfutil +feather52840sense.upload.use_1200bps_touch=true +feather52840sense.upload.wait_for_upload_port=true +feather52840sense.upload.maximum_size=815104 +feather52840sense.upload.maximum_data_size=237568 + +# Build +feather52840sense.build.mcu=cortex-m4 +feather52840sense.build.f_cpu=64000000 +feather52840sense.build.board=NRF52840_FEATHER_SENSE +feather52840sense.build.core=nRF5 +feather52840sense.build.variant=feather_nrf52840_sense +feather52840sense.build.usb_manufacturer="Adafruit" +feather52840sense.build.usb_product="Feather nRF52840 Sense" +feather52840sense.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +feather52840sense.build.ldscript=nrf52840_s140_v6.ld +feather52840sense.build.vid=0x239A +feather52840sense.build.pid=0x8087 + +# SoftDevice Menu +feather52840sense.menu.softdevice.s140v6=S140 6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_name=s140 +feather52840sense.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840sense.menu.debug.l0=Level 0 (Release) +feather52840sense.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840sense.menu.debug.l1=Level 1 (Error Message) +feather52840sense.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840sense.menu.debug.l2=Level 2 (Full Debug) +feather52840sense.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840sense.menu.debug.l3=Level 3 (Segger SystemView) +feather52840sense.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840sense.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +feather52840sense.menu.debug_output.serial=Serial +feather52840sense.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +feather52840sense.menu.debug_output.serial1=Serial1 +feather52840sense.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +feather52840sense.menu.debug_output.rtt=Segger RTT +feather52840sense.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + +# ----------------------------------- +# Adafruit ItsyBitsy nRF52840 Express +# ----------------------------------- +itsybitsy52840.name=Adafruit ItsyBitsy nRF52840 Express + +# VID/PID for Bootloader, Arduino & CircuitPython +itsybitsy52840.vid.0=0x239A +itsybitsy52840.pid.0=0x8051 +itsybitsy52840.vid.1=0x239A +itsybitsy52840.pid.1=0x0051 +itsybitsy52840.vid.2=0x239A +itsybitsy52840.pid.2=0x0052 +itsybitsy52840.vid.3=0x239A +itsybitsy52840.pid.3=0x8052 + +# Upload +itsybitsy52840.bootloader.tool=bootburn +itsybitsy52840.upload.tool=nrfutil +itsybitsy52840.upload.protocol=nrfutil +itsybitsy52840.upload.use_1200bps_touch=true +itsybitsy52840.upload.wait_for_upload_port=true +itsybitsy52840.upload.maximum_size=815104 +itsybitsy52840.upload.maximum_data_size=237568 + +# Build +itsybitsy52840.build.mcu=cortex-m4 +itsybitsy52840.build.f_cpu=64000000 +itsybitsy52840.build.board=NRF52840_ITSYBITSY +itsybitsy52840.build.core=nRF5 +itsybitsy52840.build.variant=itsybitsy_nrf52840_express +itsybitsy52840.build.usb_manufacturer="Adafruit" +itsybitsy52840.build.usb_product="ItsyBitsy nRF52840 Express" +itsybitsy52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +itsybitsy52840.build.ldscript=nrf52840_s140_v6.ld +itsybitsy52840.build.vid=0x239A +itsybitsy52840.build.pid=0x8051 + +# SoftDevice Menu +itsybitsy52840.menu.softdevice.s140v6=S140 6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_name=s140 +itsybitsy52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +itsybitsy52840.menu.debug.l0=Level 0 (Release) +itsybitsy52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +itsybitsy52840.menu.debug.l1=Level 1 (Error Message) +itsybitsy52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +itsybitsy52840.menu.debug.l2=Level 2 (Full Debug) +itsybitsy52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +itsybitsy52840.menu.debug.l3=Level 3 (Segger SystemView) +itsybitsy52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +itsybitsy52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +itsybitsy52840.menu.debug_output.serial=Serial +itsybitsy52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +itsybitsy52840.menu.debug_output.serial1=Serial1 +itsybitsy52840.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +itsybitsy52840.menu.debug_output.rtt=Segger RTT +itsybitsy52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + +# ----------------------------------- +# Adafruit Circuit Playground Bluefruit +# ----------------------------------- +cplaynrf52840.name=Adafruit Circuit Playground Bluefruit + +# VID/PID for Bootloader, Arduino & CircuitPython +cplaynrf52840.vid.0=0x239A +cplaynrf52840.pid.0=0x8045 +cplaynrf52840.vid.1=0x239A +cplaynrf52840.pid.1=0x0045 +cplaynrf52840.vid.2=0x239A +cplaynrf52840.pid.2=0x8046 + +# Upload +cplaynrf52840.bootloader.tool=bootburn +cplaynrf52840.upload.tool=nrfutil +cplaynrf52840.upload.protocol=nrfutil +cplaynrf52840.upload.use_1200bps_touch=true +cplaynrf52840.upload.wait_for_upload_port=true +cplaynrf52840.upload.maximum_size=815104 +cplaynrf52840.upload.maximum_data_size=237568 + +# Build +cplaynrf52840.build.mcu=cortex-m4 +cplaynrf52840.build.f_cpu=64000000 +cplaynrf52840.build.board=NRF52840_CIRCUITPLAY +cplaynrf52840.build.core=nRF5 +cplaynrf52840.build.variant=circuitplayground_nrf52840 +cplaynrf52840.build.usb_manufacturer="Adafruit" +cplaynrf52840.build.usb_product="Circuit Playground Bluefruit" +cplaynrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld +cplaynrf52840.build.vid=0x239A +cplaynrf52840.build.pid=0x8045 + +# SoftDevice Menu +cplaynrf52840.menu.softdevice.s140v6=S140 6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cplaynrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cplaynrf52840.menu.debug.l0=Level 0 (Release) +cplaynrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cplaynrf52840.menu.debug.l1=Level 1 (Error Message) +cplaynrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cplaynrf52840.menu.debug.l2=Level 2 (Full Debug) +cplaynrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cplaynrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cplaynrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +cplaynrf52840.menu.debug_output.serial=Serial +cplaynrf52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +cplaynrf52840.menu.debug_output.serial1=Serial1 +cplaynrf52840.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +cplaynrf52840.menu.debug_output.rtt=Segger RTT +cplaynrf52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + +# ----------------------------------- +# Adafruit CLUE +# ----------------------------------- +cluenrf52840.name=Adafruit CLUE + +# VID/PID for Bootloader, Arduino & CircuitPython +cluenrf52840.vid.0=0x239A +cluenrf52840.pid.0=0x8071 +cluenrf52840.vid.1=0x239A +cluenrf52840.pid.1=0x0071 +cluenrf52840.vid.2=0x239A +cluenrf52840.pid.2=0x8072 + +# Upload +cluenrf52840.bootloader.tool=bootburn +cluenrf52840.upload.tool=nrfutil +cluenrf52840.upload.protocol=nrfutil +cluenrf52840.upload.use_1200bps_touch=true +cluenrf52840.upload.wait_for_upload_port=true +cluenrf52840.upload.maximum_size=815104 +cluenrf52840.upload.maximum_data_size=237568 + +# Build +cluenrf52840.build.mcu=cortex-m4 +cluenrf52840.build.f_cpu=64000000 +cluenrf52840.build.board=NRF52840_CLUE +cluenrf52840.build.core=nRF5 +cluenrf52840.build.variant=clue_nrf52840 +cluenrf52840.build.usb_manufacturer="Adafruit" +cluenrf52840.build.usb_product="CLUE" +cluenrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +cluenrf52840.build.ldscript=nrf52840_s140_v6.ld +cluenrf52840.build.vid=0x239A +cluenrf52840.build.pid=0x8071 + +# SoftDevice Menu +cluenrf52840.menu.softdevice.s140v6=S140 6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cluenrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cluenrf52840.menu.debug.l0=Level 0 (Release) +cluenrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cluenrf52840.menu.debug.l1=Level 1 (Error Message) +cluenrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cluenrf52840.menu.debug.l2=Level 2 (Full Debug) +cluenrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cluenrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cluenrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cluenrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +cluenrf52840.menu.debug_output.serial=Serial +cluenrf52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +cluenrf52840.menu.debug_output.serial1=Serial1 +cluenrf52840.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +cluenrf52840.menu.debug_output.rtt=Segger RTT +cluenrf52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + +# ----------------------------------- +# Adafruit LED Glasses Driver nRF52840 +# ----------------------------------- +ledglasses_nrf52840.name=Adafruit LED Glasses Driver nRF52840 + +# VID/PID for Bootloader, Arduino & CircuitPython +ledglasses_nrf52840.vid.0=0x239A +ledglasses_nrf52840.pid.0=0x810D +ledglasses_nrf52840.vid.1=0x239A +ledglasses_nrf52840.pid.1=0x010D +ledglasses_nrf52840.vid.2=0x239A +ledglasses_nrf52840.pid.2=0x810E + +# Upload +ledglasses_nrf52840.bootloader.tool=bootburn +ledglasses_nrf52840.upload.tool=nrfutil +ledglasses_nrf52840.upload.protocol=nrfutil +ledglasses_nrf52840.upload.use_1200bps_touch=true +ledglasses_nrf52840.upload.wait_for_upload_port=true +ledglasses_nrf52840.upload.maximum_size=815104 +ledglasses_nrf52840.upload.maximum_data_size=237568 + +# Build +ledglasses_nrf52840.build.mcu=cortex-m4 +ledglasses_nrf52840.build.f_cpu=64000000 +ledglasses_nrf52840.build.board=NRF52840_LED_GLASSES +ledglasses_nrf52840.build.core=nRF5 +ledglasses_nrf52840.build.variant=ledglasses_nrf52840 +ledglasses_nrf52840.build.usb_manufacturer="Adafruit" +ledglasses_nrf52840.build.usb_product="LED Glasses Driver nRF52840" +ledglasses_nrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +ledglasses_nrf52840.build.ldscript=nrf52840_s140_v6.ld +ledglasses_nrf52840.build.vid=0x239A +ledglasses_nrf52840.build.pid=0x810D + +# SoftDevice Menu +ledglasses_nrf52840.menu.softdevice.s140v6=S140 6.1.1 +ledglasses_nrf52840.menu.softdevice.s140v6.build.sd_name=s140 +ledglasses_nrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +ledglasses_nrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +ledglasses_nrf52840.menu.debug.l0=Level 0 (Release) +ledglasses_nrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ledglasses_nrf52840.menu.debug.l1=Level 1 (Error Message) +ledglasses_nrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ledglasses_nrf52840.menu.debug.l2=Level 2 (Full Debug) +ledglasses_nrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ledglasses_nrf52840.menu.debug.l3=Level 3 (Segger SystemView) +ledglasses_nrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ledglasses_nrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +ledglasses_nrf52840.menu.debug_output.serial=Serial +ledglasses_nrf52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +ledglasses_nrf52840.menu.debug_output.serial1=Serial1 +ledglasses_nrf52840.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +ledglasses_nrf52840.menu.debug_output.rtt=Segger RTT +ledglasses_nrf52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + +# ----------------------------------- +# Raytac nRF52840 Dongle +# ----------------------------------- +mdbt50qrx.name=Raytac nRF52840 Dongle + +# VID/PID for Bootloader, Arduino & CircuitPython +mdbt50qrx.vid.0=0x239A +mdbt50qrx.pid.0=0x810B +mdbt50qrx.vid.1=0x239A +mdbt50qrx.pid.1=0x010B +mdbt50qrx.vid.2=0x239A +mdbt50qrx.pid.2=0x810C + +# Upload +mdbt50qrx.bootloader.tool=bootburn +mdbt50qrx.upload.tool=nrfutil +mdbt50qrx.upload.protocol=nrfutil +mdbt50qrx.upload.use_1200bps_touch=true +mdbt50qrx.upload.wait_for_upload_port=true +mdbt50qrx.upload.maximum_size=815104 +mdbt50qrx.upload.maximum_data_size=237568 + +# Build +mdbt50qrx.build.mcu=cortex-m4 +mdbt50qrx.build.f_cpu=64000000 +mdbt50qrx.build.board=MDBT50Q_RX +mdbt50qrx.build.core=nRF5 +mdbt50qrx.build.variant=raytac_mdbt50q_rx +mdbt50qrx.build.usb_manufacturer="Raytac" +mdbt50qrx.build.usb_product="nRF52840 Dongle" +mdbt50qrx.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld +mdbt50qrx.build.vid=0x239A +mdbt50qrx.build.pid=0x810B + +# SoftDevice Menu +mdbt50qrx.menu.softdevice.s140v6=S140 6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_name=s140 +mdbt50qrx.menu.softdevice.s140v6.build.sd_version=6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +mdbt50qrx.menu.debug.l0=Level 0 (Release) +mdbt50qrx.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +mdbt50qrx.menu.debug.l1=Level 1 (Error Message) +mdbt50qrx.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +mdbt50qrx.menu.debug.l2=Level 2 (Full Debug) +mdbt50qrx.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +mdbt50qrx.menu.debug.l3=Level 3 (Segger SystemView) +mdbt50qrx.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +mdbt50qrx.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +mdbt50qrx.menu.debug_output.serial=Serial +mdbt50qrx.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +mdbt50qrx.menu.debug_output.serial1=Serial1 +mdbt50qrx.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +mdbt50qrx.menu.debug_output.rtt=Segger RTT +mdbt50qrx.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + +# ----------------------------------- +# Adafruit Metro nRF52840 Express +# ----------------------------------- +metro52840.name=Adafruit Metro nRF52840 Express + +# VID/PID for Bootloader, Arduino & CircuitPython +metro52840.vid.0=0x239A +metro52840.pid.0=0x803F +metro52840.vid.1=0x239A +metro52840.pid.1=0x003F +metro52840.vid.2=0x239A +metro52840.pid.2=0x0040 +metro52840.vid.3=0x239A +metro52840.pid.3=0x8040 + +# Upload +metro52840.bootloader.tool=bootburn +metro52840.upload.tool=nrfutil +metro52840.upload.protocol=nrfutil +metro52840.upload.use_1200bps_touch=true +metro52840.upload.wait_for_upload_port=true +metro52840.upload.maximum_size=815104 +metro52840.upload.maximum_data_size=237568 + +# Build +metro52840.build.mcu=cortex-m4 +metro52840.build.f_cpu=64000000 +metro52840.build.board=NRF52840_METRO +metro52840.build.core=nRF5 +metro52840.build.variant=metro_nrf52840_express +metro52840.build.usb_manufacturer="Adafruit" +metro52840.build.usb_product="Metro nRF52840 Express" +metro52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +metro52840.build.ldscript=nrf52840_s140_v6.ld +metro52840.build.vid=0x239A +metro52840.build.pid=0x803F + +# SoftDevice Menu +metro52840.menu.softdevice.s140v6=S140 6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_name=s140 +metro52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +metro52840.menu.debug.l0=Level 0 (Release) +metro52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +metro52840.menu.debug.l1=Level 1 (Error Message) +metro52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +metro52840.menu.debug.l2=Level 2 (Full Debug) +metro52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +metro52840.menu.debug.l3=Level 3 (Segger SystemView) +metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +metro52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +metro52840.menu.debug_output.serial=Serial +metro52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +metro52840.menu.debug_output.serial1=Serial1 +metro52840.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +metro52840.menu.debug_output.rtt=Segger RTT +metro52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + + +# ------------------------------------------------------- +# +# Boards that aren't made by Adafruit +# +# ------------------------------------------------------- + +# ----------------------------------- +# Nordic nRF52840 DK +# ----------------------------------- +pca10056.name=Nordic nRF52840 DK + +# VID/PID for Bootloader, Arduino & CircuitPython +pca10056.vid.0=0x239A +pca10056.pid.0=0x8029 +pca10056.vid.1=0x239A +pca10056.pid.1=0x0029 + +# Upload +pca10056.bootloader.tool=bootburn +pca10056.upload.tool=nrfutil +pca10056.upload.protocol=nrfutil +pca10056.upload.use_1200bps_touch=true +pca10056.upload.wait_for_upload_port=true +pca10056.upload.maximum_size=815104 +pca10056.upload.maximum_data_size=237568 + +# Build +pca10056.build.mcu=cortex-m4 +pca10056.build.f_cpu=64000000 +pca10056.build.board=NRF52840_PCA10056 +pca10056.build.core=nRF5 +pca10056.build.variant=pca10056 +pca10056.build.usb_manufacturer="Nordic" +pca10056.build.usb_product="nRF52840 DK" +pca10056.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +pca10056.build.ldscript=nrf52840_s140_v6.ld +pca10056.build.vid=0x239A +pca10056.build.pid=0x8029 + +# SoftDevice Menu +pca10056.menu.softdevice.s140v6=S140 6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_name=s140 +pca10056.menu.softdevice.s140v6.build.sd_version=6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +pca10056.menu.debug.l0=Level 0 (Release) +pca10056.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +pca10056.menu.debug.l1=Level 1 (Error Message) +pca10056.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +pca10056.menu.debug.l2=Level 2 (Full Debug) +pca10056.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +pca10056.menu.debug.l3=Level 3 (Segger SystemView) +pca10056.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +pca10056.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +pca10056.menu.debug_output.serial=Serial +pca10056.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +pca10056.menu.debug_output.serial1=Serial1 +pca10056.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +pca10056.menu.debug_output.rtt=Segger RTT +pca10056.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + +# ----------------------------------- +# Particle Xenon +# ----------------------------------- +particle_xenon.name=Particle Xenon + +# VID/PID for Bootloader, Arduino & CircuitPython +particle_xenon.vid.0=0x239A +particle_xenon.pid.0=0x8029 +particle_xenon.vid.1=0x239A +particle_xenon.pid.1=0x0029 + +# Upload +particle_xenon.bootloader.tool=bootburn +particle_xenon.upload.tool=nrfutil +particle_xenon.upload.protocol=nrfutil +particle_xenon.upload.use_1200bps_touch=true +particle_xenon.upload.wait_for_upload_port=true +particle_xenon.upload.maximum_size=815104 +particle_xenon.upload.maximum_data_size=237568 + +# Build +particle_xenon.build.mcu=cortex-m4 +particle_xenon.build.f_cpu=64000000 +particle_xenon.build.board=PARTICLE_XENON +particle_xenon.build.core=nRF5 +particle_xenon.build.variant=particle_xenon +particle_xenon.build.usb_manufacturer="Particle" +particle_xenon.build.usb_product="Xenon" +particle_xenon.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +particle_xenon.build.ldscript=nrf52840_s140_v6.ld +particle_xenon.build.vid=0x239A +particle_xenon.build.pid=0x8029 + +# SoftDevice Menu +particle_xenon.menu.softdevice.s140v6=S140 6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_name=s140 +particle_xenon.menu.softdevice.s140v6.build.sd_version=6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +particle_xenon.menu.debug.l0=Level 0 (Release) +particle_xenon.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +particle_xenon.menu.debug.l1=Level 1 (Error Message) +particle_xenon.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +particle_xenon.menu.debug.l2=Level 2 (Full Debug) +particle_xenon.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +particle_xenon.menu.debug.l3=Level 3 (Segger SystemView) +particle_xenon.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +particle_xenon.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +particle_xenon.menu.debug_output.serial=Serial +particle_xenon.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +particle_xenon.menu.debug_output.serial1=Serial1 +particle_xenon.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +particle_xenon.menu.debug_output.rtt=Segger RTT +particle_xenon.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + + +# ---------------------------------- +# NINA B302 +# ---------------------------------- +ninab302.name=NINA B302 ublox + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +ninab302.vid.0=0x239A +ninab302.pid.0=0x8029 +ninab302.vid.1=0x239A +ninab302.pid.1=0x0029 +ninab302.vid.2=0x7239A +ninab302.pid.2=0x002A +ninab302.vid.3=0x239A +ninab302.pid.3=0x802A + +# Upload +ninab302.bootloader.tool=bootburn +ninab302.upload.tool=nrfutil +ninab302.upload.protocol=nrfutil +ninab302.upload.use_1200bps_touch=true +ninab302.upload.wait_for_upload_port=true +ninab302.upload.maximum_size=815104 +ninab302.upload.maximum_data_size=237568 + +# Build +ninab302.build.mcu=cortex-m4 +ninab302.build.f_cpu=64000000 +ninab302.build.board=NINA_B302_ublox +ninab302.build.core=nRF5 +ninab302.build.variant=NINA_B302_ublox +ninab302.build.usb_manufacturer="Nordic" +ninab302.build.usb_product="NINA B302 ublox" +ninab302.build.extra_flags=-DNRF52840_XXAA -DNINA_B302_ublox {build.flags.usb} +ninab302.build.ldscript=nrf52840_s140_v6.ld +ninab302.build.vid=0x239A +ninab302.build.pid=0x8029 + +# SofDevice Menu +ninab302.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_name=s140 +ninab302.menu.softdevice.s140v6.build.sd_version=6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +ninab302.menu.debug.l0=Level 0 (Release) +ninab302.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab302.menu.debug.l1=Level 1 (Error Message) +ninab302.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab302.menu.debug.l2=Level 2 (Full Debug) +ninab302.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab302.menu.debug.l3=Level 3 (Segger SystemView) +ninab302.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab302.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# NINA B112 +# ---------------------------------- +ninab112.name=NINA B112 ublox +ninab112.bootloader.tool=bootburn + +# Upload +ninab112.upload.tool=nrfutil +ninab112.upload.protocol=nrfutil +ninab112.upload.use_1200bps_touch=false +ninab112.upload.wait_for_upload_port=false +ninab112.upload.native_usb=false +ninab112.upload.maximum_size=290816 +ninab112.upload.maximum_data_size=52224 + +# Build +ninab112.build.mcu=cortex-m4 +ninab112.build.f_cpu=64000000 +ninab112.build.board=NINA_B112_ublox +ninab112.build.core=nRF5 +ninab112.build.variant=NINA_B112_ublox +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52832" +ninab112.build.extra_flags=-DNRF52832_XXAA -DNINA_B112_ublox -DNRF52 +ninab112.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +ninab112.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_name=s132 +ninab112.menu.softdevice.s132v6.build.sd_version=6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +ninab112.menu.debug.l0=Level 0 (Release) +ninab112.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab112.menu.debug.l1=Level 1 (Error Message) +ninab112.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab112.menu.debug.l2=Level 2 (Full Debug) +ninab112.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab112.menu.debug.l3=Level 3 (Segger SystemView) +ninab112.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab112.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +################################################################## +## KH Add SparkFun Pro nRF52840 Mini +################################################################## +#********************************************** +# SparkFun Pro nRF52840 Mini +#********************************************** +sparkfunnrf52840mini.name=SparkFun Pro nRF52840 Mini + +# DFU Mode with CDC only +sparkfunnrf52840mini.vid.0=0x1B4F +sparkfunnrf52840mini.pid.0=0x002A + +# DFU Mode with CDC + MSC (UF2) +sparkfunnrf52840mini.vid.1=0x1B4F +sparkfunnrf52840mini.pid.1=0x0029 + +# Application with CDC + MSC +sparkfunnrf52840mini.vid.2=0x1B4F +sparkfunnrf52840mini.pid.2=0x8029 + +# CircuitPython +sparkfunnrf52840mini.vid.2=0x1B4F +sparkfunnrf52840mini.pid.2=0x802A + +sparkfunnrf52840mini.bootloader.tool=bootburn + +# Upload +sparkfunnrf52840mini.upload.tool=nrfutil +sparkfunnrf52840mini.upload.protocol=nrfutil +sparkfunnrf52840mini.upload.use_1200bps_touch=true +sparkfunnrf52840mini.upload.wait_for_upload_port=true +#sparkfunnrf52840mini.upload.native_usb=true + +# Build +sparkfunnrf52840mini.build.mcu=cortex-m4 +sparkfunnrf52840mini.build.f_cpu=64000000 +sparkfunnrf52840mini.build.board=NRF52840_FEATHER +sparkfunnrf52840mini.build.core=nRF5 +sparkfunnrf52840mini.build.variant=sparkfun_nrf52840_mini +sparkfunnrf52840mini.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +sparkfunnrf52840mini.build.vid=0x1B4F +sparkfunnrf52840mini.build.pid=0x5284 +sparkfunnrf52840mini.build.usb_manufacturer="SparkFun" +sparkfunnrf52840mini.build.usb_product="nRF52840 Mini Breakout" + +# SofDevice Menu +# Ram & ROM size varies depending on SoftDevice (check linker script) + +sparkfunnrf52840mini.menu.softdevice.s140v6=s140 6.1.1 r0 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.sd_flags=-DS140 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.sd_name=s140 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.sd_version=6.1.1 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.sd_fwid=0x00B6 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.ldscript=nrf52840_s140_v6.ld +sparkfunnrf52840mini.menu.softdevice.s140v6.upload.maximum_size=815104 +sparkfunnrf52840mini.menu.softdevice.s140v6.upload.maximum_data_size=248832 + +# Debug Menu +sparkfunnrf52840mini.menu.debug.l0=Level 0 (Release) +sparkfunnrf52840mini.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 -Os +sparkfunnrf52840mini.menu.debug.l1=Level 1 (Error Message) +sparkfunnrf52840mini.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 -Os +sparkfunnrf52840mini.menu.debug.l2=Level 2 (Full Debug) +sparkfunnrf52840mini.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 -Os +sparkfunnrf52840mini.menu.debug.l3=Level 3 (Segger SystemView) +sparkfunnrf52840mini.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 -Os + +################################################################## diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Udp.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Udp.h new file mode 100644 index 0000000..cc814d3 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Udp.h @@ -0,0 +1,92 @@ +/* + * Udp.cpp: Library to send/receive UDP packets. + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + */ + +#ifndef udp_h +#define udp_h + +#include +#include + +class UDP : public Stream { + +public: + virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + + // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) + virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + + virtual void stop() =0; // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port) =0; + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port) =0; + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket() =0; + // Write a single byte into the packet + virtual size_t write(uint8_t) =0; + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size) =0; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket() =0; + // Number of bytes remaining in the current packet + virtual int available() =0; + // Read a single byte from the current packet + virtual int read() =0; + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len) =0; + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) =0; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek() =0; + virtual void flush() =0; // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() =0; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() =0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/platform.txt new file mode 100644 index 0000000..8bc132d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/platform.txt @@ -0,0 +1,166 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All rights reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +name=Adafruit nRF52 Boards +version=1.2.0 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-pointer-arith + +# Allow changing optimization settings via platform.local.txt / boards.local.txt +compiler.optimization_flag=-Ofast + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD + +# KH, Error here to use gcc, must use g++ +#compiler.c.elf.cmd=arm-none-eabi-gcc +compiler.c.elf.cmd=arm-none-eabi-g++ + +compiler.c.elf.flags={compiler.optimization_flag} -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-mcpu={build.mcu} -mthumb -mabi=aapcs {compiler.optimization_flag} -g -c {build.float_flags} -x assembler-with-cpp + +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2bin.flags=-O binary +compiler.elf2bin.cmd=arm-none-eabi-objcopy +compiler.elf2hex.flags=-O ihex +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb {build.float_flags} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--wrap=malloc -Wl,--wrap=free --specs=nano.specs --specs=nosys.specs +compiler.size.cmd=arm-none-eabi-size + +# this can be overriden in boards.txt +# Logger 0: Serial (CDC), 1 Serial1 (UART), 2 Segger RTT +build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float +build.debug_flags=-DCFG_DEBUG=0 +build.logger_flags=-DCFG_LOGGER=0 +build.sysview_flags=-DCFG_SYSVIEW=0 + +# USB flags +build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.libraries.ldflags= +compiler.elf2bin.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.7.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.7.0.path}/CMSIS/DSP/Include/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.7.0.path}/CMSIS/DSP/Lib/GCC/" -larm_cortexM4lf_math + +# common compiler for nrf +rtos.path={build.core.path}/freertos +nordic.path={build.core.path}/nordic + +build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DDX_CC_TEE -DLFS_NAME_MAX=64 {compiler.optimization_flag} {build.debug_flags} {build.logger_flags} {build.sysview_flags} {compiler.arm.cmsis.c.flags} "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include/nrf52" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add '-DBOARD_NAME="{build.board}"' +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} '-DBOARD_NAME="{build.board}"' -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add '-DBOARD_NAME="{build.board}"' +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} '-DBOARD_NAME="{build.board}"' -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add '-DBOARD_NAME="{build.board}"' +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} '-DBOARD_NAME="{build.board}"' -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Create archives +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-L{build.core.path}/linker" "-T{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} -Wl,--start-group {compiler.arm.cmsis.ldflags} -lm "{build.path}/{archive_file}" {compiler.libraries.ldflags} -Wl,--end-group + +## Create output (bin file) +#recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2bin.cmd}" {compiler.elf2bin.flags} {compiler.elf2bin.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +## Create dfu package zip file +recipe.objcopy.zip.pattern="{tools.nrfutil.cmd}" dfu genpkg --dev-type 0x0052 --sd-req {build.sd_fwid} --application "{build.path}/{build.project_name}.hex" "{build.path}/{build.project_name}.zip" + +## Create uf2 file +#recipe.objcopy.uf2.pattern=python "{runtime.platform.path}/tools/uf2conv/uf2conv.py" -f 0xADA52840 -c -o "{build.path}/{build.project_name}.uf2" "{build.path}/{build.project_name}.hex" + +## Save bin +recipe.output.tmp_file_bin={build.project_name}.bin +recipe.output.save_file_bin={build.project_name}.save.bin + +## Save hex +recipe.output.tmp_file_hex={build.project_name}.hex +recipe.output.save_file_hexu={build.project_name}.save.hex + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + +## Export Compiled Binary +recipe.output.tmp_file={build.project_name}.hex +recipe.output.save_file={build.project_name}.{build.variant}.hex + +#*************************************************** +# adafruit-nrfutil for uploading +# https://github.com/adafruit/Adafruit_nRF52_nrfutil +# pre-built binaries are provided for macos and windows +#*************************************************** +tools.nrfutil.cmd=adafruit-nrfutil +tools.nrfutil.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe +tools.nrfutil.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil + +tools.nrfutil.upload.params.verbose=--verbose +tools.nrfutil.upload.params.quiet= +tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.path}/{build.project_name}.zip" -p {serial.port} -b 115200 --singlebank + +#*************************************************** +# Burning bootloader with either jlink or nrfutil +#*************************************************** + +# Bootloader version +tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.6.2_{build.sd_name}_{build.sd_version} + +tools.bootburn.bootloader.params.verbose= +tools.bootburn.bootloader.params.quiet= +tools.bootburn.bootloader.pattern={program.burn_pattern} + +# erase flash page while programming +tools.bootburn.erase.params.verbose= +tools.bootburn.erase.params.quiet= +tools.bootburn.erase.pattern= + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B112_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B112_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B112_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B112_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B112_ublox/variant.cpp new file mode 100644 index 0000000..f43f3a4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B112_ublox/variant.cpp @@ -0,0 +1,59 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" + +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +const uint32_t g_ADigitalPinMap[] = { + // D0 .. D13 + 5, // D0 is P0.05 (UART RX) + 6, // D1 is P0.06 (UART TX) + 7, // D2 is P0.07 + 31, // D3 is P0.31 + 18, // D4 is P0.18 (LED Blue) + 99, // D5 (NC) + 9, // D6 is P0.09 NFC1 + 10, // D7 is P0.10 (Button) NFC2 + 99, // D8 (NC) + 8, // D9 is P0.08 + 11, // D10 is P0.11 CS + 13, // D11 is P0.13 MOSI + 12, // D12 is P0.12 MISO + 14, // D13 is P0.14 SCK + //I2C + 2, // D14 is P0.2 (SDA) + 3, // D15 is P0.3 (SCL) + // D16 .. D21 (aka A0 .. A5) + 3, // D16 is P0.03 (A0) + 2, // D17 is P0.02 (A1) + 4, // D18 is P0.04 (A2) + 30, // D19 is P0.30 (A3) SW2 + 29, // D20 is P0.29 (A4) + 28, // D21 is P0.28 (A5) + 9, // P0.09 NFC + 10, // P0.10 NFC + 16, // SW1 (LED Green) +}; \ No newline at end of file diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B112_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B112_ublox/variant.h new file mode 100644 index 0000000..833cbf6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B112_ublox/variant.h @@ -0,0 +1,172 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +#ifndef _VARIANT_NINA_B112_UBLOX_ +#define _VARIANT_NINA_B112_UBLOX_ + +#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \ + .rc_ctiv = 0, \ +.rc_temp_ctiv = 0, \ +.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM} + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (32u) +#define NUM_DIGITAL_PINS (32u) +#define NUM_ANALOG_INPUTS (6u) +#define NUM_ANALOG_OUTPUTS (0u) + +// LEDs +#define PIN_LED LED1 +#define LED_BUILTIN PIN_LED + +//LEDs onboard +#define LED1 (0) // Red +#define LED2 (24) // Green/SW1 +#define LED3 (4) // Blue + +#define LED_STATE_ON 1 // State when LED is litted + +//Switch +#define SW1 (24) +#define SW2 (19) + +// NFC +#define PIN_NFC_1 (6) // P0.9 +#define PIN_NFC_2 (7) // P0.10 + +/* + * Analog pins + */ +#define PIN_A0 (16) // P0.03 +#define PIN_A1 (17) // P0.02 +#define PIN_A2 (18) // P0.04 +#define PIN_A3 (19) // P0.30 +#define PIN_A4 (20) // P0.29 +#define PIN_A5 (21) // P0.28 + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_D0 (0) // P0.05 +#define PIN_D1 (1) // P0.06 +#define PIN_D2 (2) // P0.07 +#define PIN_D3 (4) // P0.31 +#define PIN_D4 (5) // P0.18 +#define PIN_D6 (6) // P0.09 +#define PIN_D7 (7) // P0.10 +#define PIN_D9 (9) // P0.08 +#define PIN_D10 (11) // P0.11 +#define PIN_D11 (13) // P0.13 +#define PIN_D12 (12) // P0.12 +#define PIN_D13 (14) // P0.14 +#define PIN_D14 (2) // P0.02 +#define PIN_D15 (3) // P0.03 + +static const uint8_t D0 = PIN_D0 ; +static const uint8_t D1 = PIN_D1 ; +static const uint8_t D2 = PIN_D2 ; +static const uint8_t D3 = PIN_D3 ; +static const uint8_t D4 = PIN_D4 ; +static const uint8_t D6 = PIN_D6 ; +static const uint8_t D7 = PIN_D7 ; +static const uint8_t D9 = PIN_D9 ; +static const uint8_t D10 = PIN_D10 ; +static const uint8_t D11 = PIN_D11 ; +static const uint8_t D12 = PIN_D12 ; +static const uint8_t D13 = PIN_D13 ; +static const uint8_t D14 = PIN_D14 ; +static const uint8_t D15 = PIN_D15 ; + +// Other pins +//static const uint8_t AREF = PIN_AREF; + +//#define PIN_AREF (24) +//#define PIN_VBAT PIN_A7 + +/* + * Serial interfaces + */ +#define PIN_SERIAL_RX (0) // P0.05 +#define PIN_SERIAL_TX (1) // P0.06 +#define PIN_SERIAL_CTS (2) // P0.07 +#define PIN_SERIAL_RTS (3) // P0.31 +#define PIN_SERIAL_DTR (28) // P0.28 +#define PIN_SERIAL_DSR (29) // P0.29 + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (12) // P0.12 +#define PIN_SPI_MOSI (11) // P0.13 +#define PIN_SPI_SCK (13) // P0.14 + +static const uint8_t SS = 10 ; // P0.11 +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (14) // P0.02 +#define PIN_WIRE_SCL (15) // P0.03 + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + + +#endif //_VARIANT_NINA_B112_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B302_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B302_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B302_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B302_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B302_ublox/variant.cpp new file mode 100644 index 0000000..8b4df2e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B302_ublox/variant.cpp @@ -0,0 +1,87 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 + 29, // D0 is P0.29 (UART RX) + 45, // D1 is P1.13 (UART TX) + 44, // D2 is P1.12 (NFC2) + 31, // D3 is P0.31 (LED1) + 13, // D4 is P0.13 (LED2) + 11, // D5 is P0.11 + 9, // D6 is P0.09 + 10, // D7 is P0.10 (Button) + 41, // D8 is P1.09 + 12, // D9 is P0.12 + 14, // D10 is P0.14 + 15, // D11 is P0.15 + 32, // D12 is P1.00 + 7, // D13 is P0.07 + + // D14 .. D21 (aka A0 .. A5) + 4, // D14 is P0.04 (A0) + 30, // D15 is P0.30 (A1) + 5, // D16 is P0.05 (A2) + 2, // D17 is P0.02 (A3) + 28, // D18 is P0.28 (A4) + 3, // D19 is P0.03 (A5) + + // D20 .. D21 (aka I2C pins) + 16, // D20 is P0.16 (SDA) + 24, // D21 is P0.24 (SCL) + + // QSPI pins (not exposed via any header / test point) + 19, // D22 is P0.19 (QSPI CLK) + 17, // D23 is P0.17 (QSPI CS) + 20, // D24 is P0.20 (QSPI Data 0) + 21, // D25 is P0.21 (QSPI Data 1) + 22, // D26 is P0.22 (QSPI Data 2) + 26, // D27 is P0.23 (QSPI Data 3) + + 40, // D28 is P1.08 - IO34 + 41, // D29 is P1.01 - IO35 + 44, // D30 is P1.02 - IO36 + 45, // D31 is P1.03 - IO37 + 42, // D32 is P1.10 - IO38 + 43, // D33 is P1.11 - IO39 + 47, // D34 is P1.15 - IO40 + 46, // D35 is P1.14 - IO41 + 26, // D36 is P0.26 - IO42 + 6, // D37 is P0.6 - IO43 + 27, // D38 is P0.27 - IO44 +}; + +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B302_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B302_ublox/variant.h new file mode 100644 index 0000000..a69575f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B302_ublox/variant.h @@ -0,0 +1,149 @@ + /* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#ifndef _VARIANT_NINA_B302_UBLOX_ +#define _VARIANT_NINA_B302_UBLOX_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus +// Number of pins defined in PinDescription array +#define PINS_COUNT (40) +#define NUM_DIGITAL_PINS (34) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (3) +#define PIN_LED2 (4) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_RED PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +/* + * Buttons + */ +#define PIN_BUTTON1 (7) + +/* + * Analog pins + */ +#define PIN_A0 (14) +#define PIN_A1 (15) +#define PIN_A2 (16) +#define PIN_A3 (17) +#define PIN_A4 (18) +#define PIN_A5 (19) + +#define D0 (0) +#define D1 (1) +#define D2 (2) +#define D3 (3) +#define D4 (4) +#define D5 (5) +#define D6 (6) +#define D7 (7) +#define D8 (8) +#define D9 (9) +#define D10 (10) +#define D11 (11) +#define D12 (12) +#define D13 (13) + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_NFC1 (31) +#define PIN_NFC2 (2) + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (0) +#define PIN_SERIAL1_TX (1) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (22) //24 original +#define PIN_SPI_MOSI (23) //25 original +#define PIN_SPI_SCK (24) //26 original + +static const uint8_t SS = (13); +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (20) +#define PIN_WIRE_SCL (21) + +// QSPI Pins +#define PIN_QSPI_SCK 22 +#define PIN_QSPI_CS 23 +#define PIN_QSPI_IO0 24 +#define PIN_QSPI_IO1 25 +#define PIN_QSPI_IO2 26 +#define PIN_QSPI_IO3 27 + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES GD25Q16C +#define EXTERNAL_FLASH_USE_QSPI + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif //_VARIANT_NINA_B302_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/sparkfun_nrf52840_mini/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/sparkfun_nrf52840_mini/variant.cpp new file mode 100644 index 0000000..b01c147 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/sparkfun_nrf52840_mini/variant.cpp @@ -0,0 +1,49 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // P0 + 0 , 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, + + // P1 + 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, 61, 62, 63 +}; +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/sparkfun_nrf52840_mini/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/sparkfun_nrf52840_mini/variant.h new file mode 100644 index 0000000..c534ceb --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/sparkfun_nrf52840_mini/variant.h @@ -0,0 +1,152 @@ + /* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_SPARKFUN52840MINI_ +#define _VARIANT_SPARKFUN52840MINI_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (64) +#define NUM_DIGITAL_PINS (64) +#define NUM_ANALOG_INPUTS (8) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (7) +#define PIN_LED2 (14) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_BLUE PIN_LED1 +#define LED_RED PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +// Buttons +/* +#define PIN_BUTTON1 (2) +#define PIN_BUTTON2 (3) +#define PIN_BUTTON3 (4) +#define PIN_BUTTON4 (5) +*/ + +/* + * Analog pins + */ +#define PIN_A0 (2) +#define PIN_A1 (3) +#define PIN_A2 (4) +#define PIN_A3 (5) +#define PIN_A4 (28) +#define PIN_A5 (29) +#define PIN_A6 (30) +#define PIN_A7 (31) + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; +static const uint8_t A6 = PIN_A6 ; +static const uint8_t A7 = PIN_A7 ; +#define ADC_RESOLUTION 14 + +// Other pins +#define PIN_AREF (2) +#define PIN_DFU (13) +#define PIN_NFC1 (9) +#define PIN_NFC2 (10) + +static const uint8_t AREF = PIN_AREF; + +/* + * Serial interfaces + */ +// Serial +//Previous Hardware UART definition for nRF52 Arduino Core, below 0.16.0 +//Feel free to comment out these two lines below if there are conflicts with latest release +#define PIN_SERIAL_RX (15) +#define PIN_SERIAL_TX (17) + +//Hardware UART definition for nRF52 Arduino Core, 0.17.0 and above +#define PIN_SERIAL1_RX (15) +#define PIN_SERIAL1_TX (17) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (31) +#define PIN_SPI_MOSI (3) +#define PIN_SPI_SCK (30) + +static const uint8_t SS = 2 ; +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (8) +#define PIN_WIRE_SCL (11) + +/* + * QSPI interface for external flash + */ +#define PIN_QSPI_SCK 32 +#define PIN_QSPI_CS 33 +#define PIN_QSPI_DATA0 34 +#define PIN_QSPI_DATA1 35 +#define PIN_QSPI_DATA2 36 +#define PIN_QSPI_DATA3 37 + +// On-board QSPI Flash +// If EXTERNAL_FLASH_DEVICES is not defined, all supported devices will be used +#define EXTERNAL_FLASH_DEVICES GD25Q16C + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif \ No newline at end of file diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/boards.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/boards.txt new file mode 100644 index 0000000..541eb10 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/boards.txt @@ -0,0 +1,834 @@ +menu.softdevice=SoftDevice +menu.debug=Debug +menu.debug_output=Debug Output + +# ----------------------------------- +# Adafruit Feather nRF52832 +# ----------------------------------- +feather52832.name=Adafruit Feather nRF52832 + +# VID/PID for Bootloader, Arduino & CircuitPython + +# Upload +feather52832.bootloader.tool=bootburn +feather52832.upload.tool=nrfutil +feather52832.upload.protocol=nrfutil +feather52832.upload.use_1200bps_touch=false +feather52832.upload.wait_for_upload_port=false +feather52832.upload.native_usb=false +feather52832.upload.maximum_size=290816 +feather52832.upload.maximum_data_size=52224 + +# Build +feather52832.build.mcu=cortex-m4 +feather52832.build.f_cpu=64000000 +feather52832.build.board=NRF52832_FEATHER +feather52832.build.core=nRF5 +feather52832.build.variant=feather_nrf52832 +feather52832.build.usb_manufacturer="Adafruit" +feather52832.build.usb_product="Feather nRF52832" +feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52 +feather52832.build.ldscript=nrf52832_s132_v6.ld + +# SoftDevice Menu +feather52832.menu.softdevice.s132v6=S132 6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_name=s132 +feather52832.menu.softdevice.s132v6.build.sd_version=6.1.1 +feather52832.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +feather52832.menu.debug.l0=Level 0 (Release) +feather52832.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52832.menu.debug.l1=Level 1 (Error Message) +feather52832.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52832.menu.debug.l2=Level 2 (Full Debug) +feather52832.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52832.menu.debug.l3=Level 3 (Segger SystemView) +feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52832.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +feather52832.menu.debug_output.serial=Serial +feather52832.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +feather52832.menu.debug_output.serial1=Serial1 +feather52832.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +feather52832.menu.debug_output.rtt=Segger RTT +feather52832.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + +# ----------------------------------- +# Adafruit Feather nRF52840 Express +# ----------------------------------- +feather52840.name=Adafruit Feather nRF52840 Express + +# VID/PID for Bootloader, Arduino & CircuitPython +feather52840.vid.0=0x239A +feather52840.pid.0=0x8029 +feather52840.vid.1=0x239A +feather52840.pid.1=0x0029 +feather52840.vid.2=0x239A +feather52840.pid.2=0x002A +feather52840.vid.3=0x239A +feather52840.pid.3=0x802A + +# Upload +feather52840.bootloader.tool=bootburn +feather52840.upload.tool=nrfutil +feather52840.upload.protocol=nrfutil +feather52840.upload.use_1200bps_touch=true +feather52840.upload.wait_for_upload_port=true +feather52840.upload.maximum_size=815104 +feather52840.upload.maximum_data_size=237568 + +# Build +feather52840.build.mcu=cortex-m4 +feather52840.build.f_cpu=64000000 +feather52840.build.board=NRF52840_FEATHER +feather52840.build.core=nRF5 +feather52840.build.variant=feather_nrf52840_express +feather52840.build.usb_manufacturer="Adafruit" +feather52840.build.usb_product="Feather nRF52840 Express" +feather52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +feather52840.build.ldscript=nrf52840_s140_v6.ld +feather52840.build.vid=0x239A +feather52840.build.pid=0x8029 + +# SoftDevice Menu +feather52840.menu.softdevice.s140v6=S140 6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_name=s140 +feather52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840.menu.debug.l0=Level 0 (Release) +feather52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840.menu.debug.l1=Level 1 (Error Message) +feather52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840.menu.debug.l2=Level 2 (Full Debug) +feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840.menu.debug.l3=Level 3 (Segger SystemView) +feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +feather52840.menu.debug_output.serial=Serial +feather52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +feather52840.menu.debug_output.serial1=Serial1 +feather52840.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +feather52840.menu.debug_output.rtt=Segger RTT +feather52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + +# ----------------------------------- +# Adafruit Feather nRF52840 Sense +# ----------------------------------- +feather52840sense.name=Adafruit Feather nRF52840 Sense + +# VID/PID for Bootloader, Arduino & CircuitPython +feather52840sense.vid.0=0x239A +feather52840sense.pid.0=0x8087 +feather52840sense.vid.1=0x239A +feather52840sense.pid.1=0x0087 +feather52840sense.vid.2=0x239A +feather52840sense.pid.2=0x0088 +feather52840sense.vid.3=0x239A +feather52840sense.pid.3=0x8088 + +# Upload +feather52840sense.bootloader.tool=bootburn +feather52840sense.upload.tool=nrfutil +feather52840sense.upload.protocol=nrfutil +feather52840sense.upload.use_1200bps_touch=true +feather52840sense.upload.wait_for_upload_port=true +feather52840sense.upload.maximum_size=815104 +feather52840sense.upload.maximum_data_size=237568 + +# Build +feather52840sense.build.mcu=cortex-m4 +feather52840sense.build.f_cpu=64000000 +feather52840sense.build.board=NRF52840_FEATHER_SENSE +feather52840sense.build.core=nRF5 +feather52840sense.build.variant=feather_nrf52840_sense +feather52840sense.build.usb_manufacturer="Adafruit" +feather52840sense.build.usb_product="Feather nRF52840 Sense" +feather52840sense.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +feather52840sense.build.ldscript=nrf52840_s140_v6.ld +feather52840sense.build.vid=0x239A +feather52840sense.build.pid=0x8087 + +# SoftDevice Menu +feather52840sense.menu.softdevice.s140v6=S140 6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_name=s140 +feather52840sense.menu.softdevice.s140v6.build.sd_version=6.1.1 +feather52840sense.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +feather52840sense.menu.debug.l0=Level 0 (Release) +feather52840sense.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +feather52840sense.menu.debug.l1=Level 1 (Error Message) +feather52840sense.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +feather52840sense.menu.debug.l2=Level 2 (Full Debug) +feather52840sense.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +feather52840sense.menu.debug.l3=Level 3 (Segger SystemView) +feather52840sense.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +feather52840sense.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +feather52840sense.menu.debug_output.serial=Serial +feather52840sense.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +feather52840sense.menu.debug_output.serial1=Serial1 +feather52840sense.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +feather52840sense.menu.debug_output.rtt=Segger RTT +feather52840sense.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + +# ----------------------------------- +# Adafruit ItsyBitsy nRF52840 Express +# ----------------------------------- +itsybitsy52840.name=Adafruit ItsyBitsy nRF52840 Express + +# VID/PID for Bootloader, Arduino & CircuitPython +itsybitsy52840.vid.0=0x239A +itsybitsy52840.pid.0=0x8051 +itsybitsy52840.vid.1=0x239A +itsybitsy52840.pid.1=0x0051 +itsybitsy52840.vid.2=0x239A +itsybitsy52840.pid.2=0x0052 +itsybitsy52840.vid.3=0x239A +itsybitsy52840.pid.3=0x8052 + +# Upload +itsybitsy52840.bootloader.tool=bootburn +itsybitsy52840.upload.tool=nrfutil +itsybitsy52840.upload.protocol=nrfutil +itsybitsy52840.upload.use_1200bps_touch=true +itsybitsy52840.upload.wait_for_upload_port=true +itsybitsy52840.upload.maximum_size=815104 +itsybitsy52840.upload.maximum_data_size=237568 + +# Build +itsybitsy52840.build.mcu=cortex-m4 +itsybitsy52840.build.f_cpu=64000000 +itsybitsy52840.build.board=NRF52840_ITSYBITSY +itsybitsy52840.build.core=nRF5 +itsybitsy52840.build.variant=itsybitsy_nrf52840_express +itsybitsy52840.build.usb_manufacturer="Adafruit" +itsybitsy52840.build.usb_product="ItsyBitsy nRF52840 Express" +itsybitsy52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +itsybitsy52840.build.ldscript=nrf52840_s140_v6.ld +itsybitsy52840.build.vid=0x239A +itsybitsy52840.build.pid=0x8051 + +# SoftDevice Menu +itsybitsy52840.menu.softdevice.s140v6=S140 6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_name=s140 +itsybitsy52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +itsybitsy52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +itsybitsy52840.menu.debug.l0=Level 0 (Release) +itsybitsy52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +itsybitsy52840.menu.debug.l1=Level 1 (Error Message) +itsybitsy52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +itsybitsy52840.menu.debug.l2=Level 2 (Full Debug) +itsybitsy52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +itsybitsy52840.menu.debug.l3=Level 3 (Segger SystemView) +itsybitsy52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +itsybitsy52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +itsybitsy52840.menu.debug_output.serial=Serial +itsybitsy52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +itsybitsy52840.menu.debug_output.serial1=Serial1 +itsybitsy52840.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +itsybitsy52840.menu.debug_output.rtt=Segger RTT +itsybitsy52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + +# ----------------------------------- +# Adafruit Circuit Playground Bluefruit +# ----------------------------------- +cplaynrf52840.name=Adafruit Circuit Playground Bluefruit + +# VID/PID for Bootloader, Arduino & CircuitPython +cplaynrf52840.vid.0=0x239A +cplaynrf52840.pid.0=0x8045 +cplaynrf52840.vid.1=0x239A +cplaynrf52840.pid.1=0x0045 +cplaynrf52840.vid.2=0x239A +cplaynrf52840.pid.2=0x8046 + +# Upload +cplaynrf52840.bootloader.tool=bootburn +cplaynrf52840.upload.tool=nrfutil +cplaynrf52840.upload.protocol=nrfutil +cplaynrf52840.upload.use_1200bps_touch=true +cplaynrf52840.upload.wait_for_upload_port=true +cplaynrf52840.upload.maximum_size=815104 +cplaynrf52840.upload.maximum_data_size=237568 + +# Build +cplaynrf52840.build.mcu=cortex-m4 +cplaynrf52840.build.f_cpu=64000000 +cplaynrf52840.build.board=NRF52840_CIRCUITPLAY +cplaynrf52840.build.core=nRF5 +cplaynrf52840.build.variant=circuitplayground_nrf52840 +cplaynrf52840.build.usb_manufacturer="Adafruit" +cplaynrf52840.build.usb_product="Circuit Playground Bluefruit" +cplaynrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld +cplaynrf52840.build.vid=0x239A +cplaynrf52840.build.pid=0x8045 + +# SoftDevice Menu +cplaynrf52840.menu.softdevice.s140v6=S140 6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cplaynrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cplaynrf52840.menu.debug.l0=Level 0 (Release) +cplaynrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cplaynrf52840.menu.debug.l1=Level 1 (Error Message) +cplaynrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cplaynrf52840.menu.debug.l2=Level 2 (Full Debug) +cplaynrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cplaynrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cplaynrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +cplaynrf52840.menu.debug_output.serial=Serial +cplaynrf52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +cplaynrf52840.menu.debug_output.serial1=Serial1 +cplaynrf52840.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +cplaynrf52840.menu.debug_output.rtt=Segger RTT +cplaynrf52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + +# ----------------------------------- +# Adafruit CLUE +# ----------------------------------- +cluenrf52840.name=Adafruit CLUE + +# VID/PID for Bootloader, Arduino & CircuitPython +cluenrf52840.vid.0=0x239A +cluenrf52840.pid.0=0x8071 +cluenrf52840.vid.1=0x239A +cluenrf52840.pid.1=0x0071 +cluenrf52840.vid.2=0x239A +cluenrf52840.pid.2=0x8072 + +# Upload +cluenrf52840.bootloader.tool=bootburn +cluenrf52840.upload.tool=nrfutil +cluenrf52840.upload.protocol=nrfutil +cluenrf52840.upload.use_1200bps_touch=true +cluenrf52840.upload.wait_for_upload_port=true +cluenrf52840.upload.maximum_size=815104 +cluenrf52840.upload.maximum_data_size=237568 + +# Build +cluenrf52840.build.mcu=cortex-m4 +cluenrf52840.build.f_cpu=64000000 +cluenrf52840.build.board=NRF52840_CLUE +cluenrf52840.build.core=nRF5 +cluenrf52840.build.variant=clue_nrf52840 +cluenrf52840.build.usb_manufacturer="Adafruit" +cluenrf52840.build.usb_product="CLUE" +cluenrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +cluenrf52840.build.ldscript=nrf52840_s140_v6.ld +cluenrf52840.build.vid=0x239A +cluenrf52840.build.pid=0x8071 + +# SoftDevice Menu +cluenrf52840.menu.softdevice.s140v6=S140 6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cluenrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cluenrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cluenrf52840.menu.debug.l0=Level 0 (Release) +cluenrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cluenrf52840.menu.debug.l1=Level 1 (Error Message) +cluenrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cluenrf52840.menu.debug.l2=Level 2 (Full Debug) +cluenrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cluenrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cluenrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +cluenrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +cluenrf52840.menu.debug_output.serial=Serial +cluenrf52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +cluenrf52840.menu.debug_output.serial1=Serial1 +cluenrf52840.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +cluenrf52840.menu.debug_output.rtt=Segger RTT +cluenrf52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + +# ----------------------------------- +# Adafruit LED Glasses Driver nRF52840 +# ----------------------------------- +ledglasses_nrf52840.name=Adafruit LED Glasses Driver nRF52840 + +# VID/PID for Bootloader, Arduino & CircuitPython +ledglasses_nrf52840.vid.0=0x239A +ledglasses_nrf52840.pid.0=0x810D +ledglasses_nrf52840.vid.1=0x239A +ledglasses_nrf52840.pid.1=0x010D +ledglasses_nrf52840.vid.2=0x239A +ledglasses_nrf52840.pid.2=0x810E + +# Upload +ledglasses_nrf52840.bootloader.tool=bootburn +ledglasses_nrf52840.upload.tool=nrfutil +ledglasses_nrf52840.upload.protocol=nrfutil +ledglasses_nrf52840.upload.use_1200bps_touch=true +ledglasses_nrf52840.upload.wait_for_upload_port=true +ledglasses_nrf52840.upload.maximum_size=815104 +ledglasses_nrf52840.upload.maximum_data_size=237568 + +# Build +ledglasses_nrf52840.build.mcu=cortex-m4 +ledglasses_nrf52840.build.f_cpu=64000000 +ledglasses_nrf52840.build.board=NRF52840_LED_GLASSES +ledglasses_nrf52840.build.core=nRF5 +ledglasses_nrf52840.build.variant=ledglasses_nrf52840 +ledglasses_nrf52840.build.usb_manufacturer="Adafruit" +ledglasses_nrf52840.build.usb_product="LED Glasses Driver nRF52840" +ledglasses_nrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +ledglasses_nrf52840.build.ldscript=nrf52840_s140_v6.ld +ledglasses_nrf52840.build.vid=0x239A +ledglasses_nrf52840.build.pid=0x810D + +# SoftDevice Menu +ledglasses_nrf52840.menu.softdevice.s140v6=S140 6.1.1 +ledglasses_nrf52840.menu.softdevice.s140v6.build.sd_name=s140 +ledglasses_nrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +ledglasses_nrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +ledglasses_nrf52840.menu.debug.l0=Level 0 (Release) +ledglasses_nrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ledglasses_nrf52840.menu.debug.l1=Level 1 (Error Message) +ledglasses_nrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ledglasses_nrf52840.menu.debug.l2=Level 2 (Full Debug) +ledglasses_nrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ledglasses_nrf52840.menu.debug.l3=Level 3 (Segger SystemView) +ledglasses_nrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ledglasses_nrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +ledglasses_nrf52840.menu.debug_output.serial=Serial +ledglasses_nrf52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +ledglasses_nrf52840.menu.debug_output.serial1=Serial1 +ledglasses_nrf52840.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +ledglasses_nrf52840.menu.debug_output.rtt=Segger RTT +ledglasses_nrf52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + +# ----------------------------------- +# Raytac nRF52840 Dongle +# ----------------------------------- +mdbt50qrx.name=Raytac nRF52840 Dongle + +# VID/PID for Bootloader, Arduino & CircuitPython +mdbt50qrx.vid.0=0x239A +mdbt50qrx.pid.0=0x810B +mdbt50qrx.vid.1=0x239A +mdbt50qrx.pid.1=0x010B +mdbt50qrx.vid.2=0x239A +mdbt50qrx.pid.2=0x810C + +# Upload +mdbt50qrx.bootloader.tool=bootburn +mdbt50qrx.upload.tool=nrfutil +mdbt50qrx.upload.protocol=nrfutil +mdbt50qrx.upload.use_1200bps_touch=true +mdbt50qrx.upload.wait_for_upload_port=true +mdbt50qrx.upload.maximum_size=815104 +mdbt50qrx.upload.maximum_data_size=237568 + +# Build +mdbt50qrx.build.mcu=cortex-m4 +mdbt50qrx.build.f_cpu=64000000 +mdbt50qrx.build.board=MDBT50Q_RX +mdbt50qrx.build.core=nRF5 +mdbt50qrx.build.variant=raytac_mdbt50q_rx +mdbt50qrx.build.usb_manufacturer="Raytac" +mdbt50qrx.build.usb_product="nRF52840 Dongle" +mdbt50qrx.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld +mdbt50qrx.build.vid=0x239A +mdbt50qrx.build.pid=0x810B + +# SoftDevice Menu +mdbt50qrx.menu.softdevice.s140v6=S140 6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_name=s140 +mdbt50qrx.menu.softdevice.s140v6.build.sd_version=6.1.1 +mdbt50qrx.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +mdbt50qrx.menu.debug.l0=Level 0 (Release) +mdbt50qrx.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +mdbt50qrx.menu.debug.l1=Level 1 (Error Message) +mdbt50qrx.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +mdbt50qrx.menu.debug.l2=Level 2 (Full Debug) +mdbt50qrx.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +mdbt50qrx.menu.debug.l3=Level 3 (Segger SystemView) +mdbt50qrx.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +mdbt50qrx.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +mdbt50qrx.menu.debug_output.serial=Serial +mdbt50qrx.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +mdbt50qrx.menu.debug_output.serial1=Serial1 +mdbt50qrx.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +mdbt50qrx.menu.debug_output.rtt=Segger RTT +mdbt50qrx.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + +# ----------------------------------- +# Adafruit Metro nRF52840 Express +# ----------------------------------- +metro52840.name=Adafruit Metro nRF52840 Express + +# VID/PID for Bootloader, Arduino & CircuitPython +metro52840.vid.0=0x239A +metro52840.pid.0=0x803F +metro52840.vid.1=0x239A +metro52840.pid.1=0x003F +metro52840.vid.2=0x239A +metro52840.pid.2=0x0040 +metro52840.vid.3=0x239A +metro52840.pid.3=0x8040 + +# Upload +metro52840.bootloader.tool=bootburn +metro52840.upload.tool=nrfutil +metro52840.upload.protocol=nrfutil +metro52840.upload.use_1200bps_touch=true +metro52840.upload.wait_for_upload_port=true +metro52840.upload.maximum_size=815104 +metro52840.upload.maximum_data_size=237568 + +# Build +metro52840.build.mcu=cortex-m4 +metro52840.build.f_cpu=64000000 +metro52840.build.board=NRF52840_METRO +metro52840.build.core=nRF5 +metro52840.build.variant=metro_nrf52840_express +metro52840.build.usb_manufacturer="Adafruit" +metro52840.build.usb_product="Metro nRF52840 Express" +metro52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +metro52840.build.ldscript=nrf52840_s140_v6.ld +metro52840.build.vid=0x239A +metro52840.build.pid=0x803F + +# SoftDevice Menu +metro52840.menu.softdevice.s140v6=S140 6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_name=s140 +metro52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +metro52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +metro52840.menu.debug.l0=Level 0 (Release) +metro52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +metro52840.menu.debug.l1=Level 1 (Error Message) +metro52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +metro52840.menu.debug.l2=Level 2 (Full Debug) +metro52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +metro52840.menu.debug.l3=Level 3 (Segger SystemView) +metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +metro52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +metro52840.menu.debug_output.serial=Serial +metro52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +metro52840.menu.debug_output.serial1=Serial1 +metro52840.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +metro52840.menu.debug_output.rtt=Segger RTT +metro52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + + +# ------------------------------------------------------- +# +# Boards that aren't made by Adafruit +# +# ------------------------------------------------------- + +# ----------------------------------- +# Nordic nRF52840 DK +# ----------------------------------- +pca10056.name=Nordic nRF52840 DK + +# VID/PID for Bootloader, Arduino & CircuitPython +pca10056.vid.0=0x239A +pca10056.pid.0=0x8029 +pca10056.vid.1=0x239A +pca10056.pid.1=0x0029 + +# Upload +pca10056.bootloader.tool=bootburn +pca10056.upload.tool=nrfutil +pca10056.upload.protocol=nrfutil +pca10056.upload.use_1200bps_touch=true +pca10056.upload.wait_for_upload_port=true +pca10056.upload.maximum_size=815104 +pca10056.upload.maximum_data_size=237568 + +# Build +pca10056.build.mcu=cortex-m4 +pca10056.build.f_cpu=64000000 +pca10056.build.board=NRF52840_PCA10056 +pca10056.build.core=nRF5 +pca10056.build.variant=pca10056 +pca10056.build.usb_manufacturer="Nordic" +pca10056.build.usb_product="nRF52840 DK" +pca10056.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +pca10056.build.ldscript=nrf52840_s140_v6.ld +pca10056.build.vid=0x239A +pca10056.build.pid=0x8029 + +# SoftDevice Menu +pca10056.menu.softdevice.s140v6=S140 6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_name=s140 +pca10056.menu.softdevice.s140v6.build.sd_version=6.1.1 +pca10056.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +pca10056.menu.debug.l0=Level 0 (Release) +pca10056.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +pca10056.menu.debug.l1=Level 1 (Error Message) +pca10056.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +pca10056.menu.debug.l2=Level 2 (Full Debug) +pca10056.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +pca10056.menu.debug.l3=Level 3 (Segger SystemView) +pca10056.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +pca10056.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +pca10056.menu.debug_output.serial=Serial +pca10056.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +pca10056.menu.debug_output.serial1=Serial1 +pca10056.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +pca10056.menu.debug_output.rtt=Segger RTT +pca10056.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + +# ----------------------------------- +# Particle Xenon +# ----------------------------------- +particle_xenon.name=Particle Xenon + +# VID/PID for Bootloader, Arduino & CircuitPython +particle_xenon.vid.0=0x239A +particle_xenon.pid.0=0x8029 +particle_xenon.vid.1=0x239A +particle_xenon.pid.1=0x0029 + +# Upload +particle_xenon.bootloader.tool=bootburn +particle_xenon.upload.tool=nrfutil +particle_xenon.upload.protocol=nrfutil +particle_xenon.upload.use_1200bps_touch=true +particle_xenon.upload.wait_for_upload_port=true +particle_xenon.upload.maximum_size=815104 +particle_xenon.upload.maximum_data_size=237568 + +# Build +particle_xenon.build.mcu=cortex-m4 +particle_xenon.build.f_cpu=64000000 +particle_xenon.build.board=PARTICLE_XENON +particle_xenon.build.core=nRF5 +particle_xenon.build.variant=particle_xenon +particle_xenon.build.usb_manufacturer="Particle" +particle_xenon.build.usb_product="Xenon" +particle_xenon.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +particle_xenon.build.ldscript=nrf52840_s140_v6.ld +particle_xenon.build.vid=0x239A +particle_xenon.build.pid=0x8029 + +# SoftDevice Menu +particle_xenon.menu.softdevice.s140v6=S140 6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_name=s140 +particle_xenon.menu.softdevice.s140v6.build.sd_version=6.1.1 +particle_xenon.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +particle_xenon.menu.debug.l0=Level 0 (Release) +particle_xenon.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +particle_xenon.menu.debug.l1=Level 1 (Error Message) +particle_xenon.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +particle_xenon.menu.debug.l2=Level 2 (Full Debug) +particle_xenon.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +particle_xenon.menu.debug.l3=Level 3 (Segger SystemView) +particle_xenon.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +particle_xenon.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# Debug Output Menu +particle_xenon.menu.debug_output.serial=Serial +particle_xenon.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0 +particle_xenon.menu.debug_output.serial1=Serial1 +particle_xenon.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG +particle_xenon.menu.debug_output.rtt=Segger RTT +particle_xenon.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + + +# ---------------------------------- +# NINA B302 +# ---------------------------------- +ninab302.name=NINA B302 ublox + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +ninab302.vid.0=0x239A +ninab302.pid.0=0x8029 +ninab302.vid.1=0x239A +ninab302.pid.1=0x0029 +ninab302.vid.2=0x7239A +ninab302.pid.2=0x002A +ninab302.vid.3=0x239A +ninab302.pid.3=0x802A + +# Upload +ninab302.bootloader.tool=bootburn +ninab302.upload.tool=nrfutil +ninab302.upload.protocol=nrfutil +ninab302.upload.use_1200bps_touch=true +ninab302.upload.wait_for_upload_port=true +ninab302.upload.maximum_size=815104 +ninab302.upload.maximum_data_size=237568 + +# Build +ninab302.build.mcu=cortex-m4 +ninab302.build.f_cpu=64000000 +ninab302.build.board=NINA_B302_ublox +ninab302.build.core=nRF5 +ninab302.build.variant=NINA_B302_ublox +ninab302.build.usb_manufacturer="Nordic" +ninab302.build.usb_product="NINA B302 ublox" +ninab302.build.extra_flags=-DNRF52840_XXAA -DNINA_B302_ublox {build.flags.usb} +ninab302.build.ldscript=nrf52840_s140_v6.ld +ninab302.build.vid=0x239A +ninab302.build.pid=0x8029 + +# SofDevice Menu +ninab302.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_name=s140 +ninab302.menu.softdevice.s140v6.build.sd_version=6.1.1 +ninab302.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +ninab302.menu.debug.l0=Level 0 (Release) +ninab302.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab302.menu.debug.l1=Level 1 (Error Message) +ninab302.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab302.menu.debug.l2=Level 2 (Full Debug) +ninab302.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab302.menu.debug.l3=Level 3 (Segger SystemView) +ninab302.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab302.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# NINA B112 +# ---------------------------------- +ninab112.name=NINA B112 ublox +ninab112.bootloader.tool=bootburn + +# Upload +ninab112.upload.tool=nrfutil +ninab112.upload.protocol=nrfutil +ninab112.upload.use_1200bps_touch=false +ninab112.upload.wait_for_upload_port=false +ninab112.upload.native_usb=false +ninab112.upload.maximum_size=290816 +ninab112.upload.maximum_data_size=52224 + +# Build +ninab112.build.mcu=cortex-m4 +ninab112.build.f_cpu=64000000 +ninab112.build.board=NINA_B112_ublox +ninab112.build.core=nRF5 +ninab112.build.variant=NINA_B112_ublox +feather52840.build.usb_manufacturer="Adafruit LLC" +feather52840.build.usb_product="Feather nRF52832" +ninab112.build.extra_flags=-DNRF52832_XXAA -DNINA_B112_ublox -DNRF52 +ninab112.build.ldscript=nrf52832_s132_v6.ld + +# SofDevice Menu +ninab112.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_name=s132 +ninab112.menu.softdevice.s132v6.build.sd_version=6.1.1 +ninab112.menu.softdevice.s132v6.build.sd_fwid=0x00B7 + +# Debug Menu +ninab112.menu.debug.l0=Level 0 (Release) +ninab112.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +ninab112.menu.debug.l1=Level 1 (Error Message) +ninab112.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +ninab112.menu.debug.l2=Level 2 (Full Debug) +ninab112.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +ninab112.menu.debug.l3=Level 3 (Segger SystemView) +ninab112.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +ninab112.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +################################################################## +## KH Add SparkFun Pro nRF52840 Mini +################################################################## +#********************************************** +# SparkFun Pro nRF52840 Mini +#********************************************** +sparkfunnrf52840mini.name=SparkFun Pro nRF52840 Mini + +# DFU Mode with CDC only +sparkfunnrf52840mini.vid.0=0x1B4F +sparkfunnrf52840mini.pid.0=0x002A + +# DFU Mode with CDC + MSC (UF2) +sparkfunnrf52840mini.vid.1=0x1B4F +sparkfunnrf52840mini.pid.1=0x0029 + +# Application with CDC + MSC +sparkfunnrf52840mini.vid.2=0x1B4F +sparkfunnrf52840mini.pid.2=0x8029 + +# CircuitPython +sparkfunnrf52840mini.vid.2=0x1B4F +sparkfunnrf52840mini.pid.2=0x802A + +sparkfunnrf52840mini.bootloader.tool=bootburn + +# Upload +sparkfunnrf52840mini.upload.tool=nrfutil +sparkfunnrf52840mini.upload.protocol=nrfutil +sparkfunnrf52840mini.upload.use_1200bps_touch=true +sparkfunnrf52840mini.upload.wait_for_upload_port=true +#sparkfunnrf52840mini.upload.native_usb=true + +# Build +sparkfunnrf52840mini.build.mcu=cortex-m4 +sparkfunnrf52840mini.build.f_cpu=64000000 +sparkfunnrf52840mini.build.board=NRF52840_FEATHER +sparkfunnrf52840mini.build.core=nRF5 +sparkfunnrf52840mini.build.variant=sparkfun_nrf52840_mini +sparkfunnrf52840mini.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +sparkfunnrf52840mini.build.vid=0x1B4F +sparkfunnrf52840mini.build.pid=0x5284 +sparkfunnrf52840mini.build.usb_manufacturer="SparkFun" +sparkfunnrf52840mini.build.usb_product="nRF52840 Mini Breakout" + +# SofDevice Menu +# Ram & ROM size varies depending on SoftDevice (check linker script) + +sparkfunnrf52840mini.menu.softdevice.s140v6=s140 6.1.1 r0 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.sd_flags=-DS140 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.sd_name=s140 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.sd_version=6.1.1 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.sd_fwid=0x00B6 +sparkfunnrf52840mini.menu.softdevice.s140v6.build.ldscript=nrf52840_s140_v6.ld +sparkfunnrf52840mini.menu.softdevice.s140v6.upload.maximum_size=815104 +sparkfunnrf52840mini.menu.softdevice.s140v6.upload.maximum_data_size=248832 + +# Debug Menu +sparkfunnrf52840mini.menu.debug.l0=Level 0 (Release) +sparkfunnrf52840mini.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 -Os +sparkfunnrf52840mini.menu.debug.l1=Level 1 (Error Message) +sparkfunnrf52840mini.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 -Os +sparkfunnrf52840mini.menu.debug.l2=Level 2 (Full Debug) +sparkfunnrf52840mini.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 -Os +sparkfunnrf52840mini.menu.debug.l3=Level 3 (Segger SystemView) +sparkfunnrf52840mini.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 -Os + +################################################################## diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Udp.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Udp.h new file mode 100644 index 0000000..cc814d3 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Udp.h @@ -0,0 +1,92 @@ +/* + * Udp.cpp: Library to send/receive UDP packets. + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + */ + +#ifndef udp_h +#define udp_h + +#include +#include + +class UDP : public Stream { + +public: + virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + + // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) + virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + + virtual void stop() =0; // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port) =0; + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port) =0; + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket() =0; + // Write a single byte into the packet + virtual size_t write(uint8_t) =0; + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size) =0; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket() =0; + // Number of bytes remaining in the current packet + virtual int available() =0; + // Read a single byte from the current packet + virtual int read() =0; + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len) =0; + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) =0; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek() =0; + virtual void flush() =0; // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() =0; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() =0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/platform.txt new file mode 100644 index 0000000..14296ad --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/platform.txt @@ -0,0 +1,166 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All rights reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +name=Adafruit nRF52 Boards +version=1.3.0 + +# Compile variables +# ----------------- + +compiler.warning_flags=-Werror=return-type +compiler.warning_flags.none=-Werror=return-type +compiler.warning_flags.default=-Werror=return-type +compiler.warning_flags.more=-Wall -Werror=return-type +compiler.warning_flags.all=-Wall -Wextra -Werror=return-type -Wno-unused-parameter -Wno-missing-field-initializers -Wno-pointer-arith + +# Allow changing optimization settings via platform.local.txt / boards.local.txt +compiler.optimization_flag=-Ofast + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD + +# KH, Error here to use gcc, must use g++ +#compiler.c.elf.cmd=arm-none-eabi-gcc +compiler.c.elf.cmd=arm-none-eabi-g++ + +compiler.c.elf.flags={compiler.optimization_flag} -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-mcpu={build.mcu} -mthumb -mabi=aapcs {compiler.optimization_flag} -g -c {build.float_flags} -x assembler-with-cpp + +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2bin.flags=-O binary +compiler.elf2bin.cmd=arm-none-eabi-objcopy +compiler.elf2hex.flags=-O ihex +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb {build.float_flags} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--wrap=malloc -Wl,--wrap=free --specs=nano.specs --specs=nosys.specs +compiler.size.cmd=arm-none-eabi-size + +# this can be overriden in boards.txt +# Logger 0: Serial (CDC), 1 Serial1 (UART), 2 Segger RTT +build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float +build.debug_flags=-DCFG_DEBUG=0 +build.logger_flags=-DCFG_LOGGER=0 +build.sysview_flags=-DCFG_SYSVIEW=0 + +# USB flags +build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.libraries.ldflags= +compiler.elf2bin.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.7.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.7.0.path}/CMSIS/DSP/Include/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.7.0.path}/CMSIS/DSP/Lib/GCC/" -larm_cortexM4lf_math + +# common compiler for nrf +rtos.path={build.core.path}/freertos +nordic.path={build.core.path}/nordic + +build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DDX_CC_TEE -DLFS_NAME_MAX=64 {compiler.optimization_flag} {build.debug_flags} {build.logger_flags} {build.sysview_flags} {compiler.arm.cmsis.c.flags} "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include/nrf52" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add '-DBOARD_NAME="{build.board}"' +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} '-DBOARD_NAME="{build.board}"' -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add '-DBOARD_NAME="{build.board}"' +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} '-DBOARD_NAME="{build.board}"' -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add '-DBOARD_NAME="{build.board}"' +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} '-DBOARD_NAME="{build.board}"' -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" + +## Create archives +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-L{build.core.path}/linker" "-T{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} -Wl,--start-group {compiler.arm.cmsis.ldflags} -lm "{build.path}/{archive_file}" {compiler.libraries.ldflags} -Wl,--end-group + +## Create output (bin file) +#recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2bin.cmd}" {compiler.elf2bin.flags} {compiler.elf2bin.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +## Create dfu package zip file +recipe.objcopy.zip.pattern="{tools.nrfutil.cmd}" dfu genpkg --dev-type 0x0052 --sd-req {build.sd_fwid} --application "{build.path}/{build.project_name}.hex" "{build.path}/{build.project_name}.zip" + +## Create uf2 file +#recipe.objcopy.uf2.pattern=python "{runtime.platform.path}/tools/uf2conv/uf2conv.py" -f 0xADA52840 -c -o "{build.path}/{build.project_name}.uf2" "{build.path}/{build.project_name}.hex" + +## Save bin +recipe.output.tmp_file_bin={build.project_name}.bin +recipe.output.save_file_bin={build.project_name}.save.bin + +## Save hex +recipe.output.tmp_file_hex={build.project_name}.hex +recipe.output.save_file_hexu={build.project_name}.save.hex + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + +## Export Compiled Binary +recipe.output.tmp_file={build.project_name}.hex +recipe.output.save_file={build.project_name}.{build.variant}.hex + +#*************************************************** +# adafruit-nrfutil for uploading +# https://github.com/adafruit/Adafruit_nRF52_nrfutil +# pre-built binaries are provided for macos and windows +#*************************************************** +tools.nrfutil.cmd=adafruit-nrfutil +tools.nrfutil.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe +tools.nrfutil.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil + +tools.nrfutil.upload.params.verbose=--verbose +tools.nrfutil.upload.params.quiet= +tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.path}/{build.project_name}.zip" -p {serial.port} -b 115200 --singlebank + +#*************************************************** +# Burning bootloader with either jlink or nrfutil +#*************************************************** + +# Bootloader version +tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.6.2_{build.sd_name}_{build.sd_version} + +tools.bootburn.bootloader.params.verbose= +tools.bootburn.bootloader.params.quiet= +tools.bootburn.bootloader.pattern={program.burn_pattern} + +# erase flash page while programming +tools.bootburn.erase.params.verbose= +tools.bootburn.erase.params.quiet= +tools.bootburn.erase.pattern= + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.cpp new file mode 100644 index 0000000..f43f3a4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.cpp @@ -0,0 +1,59 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" + +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +const uint32_t g_ADigitalPinMap[] = { + // D0 .. D13 + 5, // D0 is P0.05 (UART RX) + 6, // D1 is P0.06 (UART TX) + 7, // D2 is P0.07 + 31, // D3 is P0.31 + 18, // D4 is P0.18 (LED Blue) + 99, // D5 (NC) + 9, // D6 is P0.09 NFC1 + 10, // D7 is P0.10 (Button) NFC2 + 99, // D8 (NC) + 8, // D9 is P0.08 + 11, // D10 is P0.11 CS + 13, // D11 is P0.13 MOSI + 12, // D12 is P0.12 MISO + 14, // D13 is P0.14 SCK + //I2C + 2, // D14 is P0.2 (SDA) + 3, // D15 is P0.3 (SCL) + // D16 .. D21 (aka A0 .. A5) + 3, // D16 is P0.03 (A0) + 2, // D17 is P0.02 (A1) + 4, // D18 is P0.04 (A2) + 30, // D19 is P0.30 (A3) SW2 + 29, // D20 is P0.29 (A4) + 28, // D21 is P0.28 (A5) + 9, // P0.09 NFC + 10, // P0.10 NFC + 16, // SW1 (LED Green) +}; \ No newline at end of file diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.h new file mode 100644 index 0000000..833cbf6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.h @@ -0,0 +1,172 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf +//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf + +#ifndef _VARIANT_NINA_B112_UBLOX_ +#define _VARIANT_NINA_B112_UBLOX_ + +#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \ + .rc_ctiv = 0, \ +.rc_temp_ctiv = 0, \ +.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM} + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (32u) +#define NUM_DIGITAL_PINS (32u) +#define NUM_ANALOG_INPUTS (6u) +#define NUM_ANALOG_OUTPUTS (0u) + +// LEDs +#define PIN_LED LED1 +#define LED_BUILTIN PIN_LED + +//LEDs onboard +#define LED1 (0) // Red +#define LED2 (24) // Green/SW1 +#define LED3 (4) // Blue + +#define LED_STATE_ON 1 // State when LED is litted + +//Switch +#define SW1 (24) +#define SW2 (19) + +// NFC +#define PIN_NFC_1 (6) // P0.9 +#define PIN_NFC_2 (7) // P0.10 + +/* + * Analog pins + */ +#define PIN_A0 (16) // P0.03 +#define PIN_A1 (17) // P0.02 +#define PIN_A2 (18) // P0.04 +#define PIN_A3 (19) // P0.30 +#define PIN_A4 (20) // P0.29 +#define PIN_A5 (21) // P0.28 + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_D0 (0) // P0.05 +#define PIN_D1 (1) // P0.06 +#define PIN_D2 (2) // P0.07 +#define PIN_D3 (4) // P0.31 +#define PIN_D4 (5) // P0.18 +#define PIN_D6 (6) // P0.09 +#define PIN_D7 (7) // P0.10 +#define PIN_D9 (9) // P0.08 +#define PIN_D10 (11) // P0.11 +#define PIN_D11 (13) // P0.13 +#define PIN_D12 (12) // P0.12 +#define PIN_D13 (14) // P0.14 +#define PIN_D14 (2) // P0.02 +#define PIN_D15 (3) // P0.03 + +static const uint8_t D0 = PIN_D0 ; +static const uint8_t D1 = PIN_D1 ; +static const uint8_t D2 = PIN_D2 ; +static const uint8_t D3 = PIN_D3 ; +static const uint8_t D4 = PIN_D4 ; +static const uint8_t D6 = PIN_D6 ; +static const uint8_t D7 = PIN_D7 ; +static const uint8_t D9 = PIN_D9 ; +static const uint8_t D10 = PIN_D10 ; +static const uint8_t D11 = PIN_D11 ; +static const uint8_t D12 = PIN_D12 ; +static const uint8_t D13 = PIN_D13 ; +static const uint8_t D14 = PIN_D14 ; +static const uint8_t D15 = PIN_D15 ; + +// Other pins +//static const uint8_t AREF = PIN_AREF; + +//#define PIN_AREF (24) +//#define PIN_VBAT PIN_A7 + +/* + * Serial interfaces + */ +#define PIN_SERIAL_RX (0) // P0.05 +#define PIN_SERIAL_TX (1) // P0.06 +#define PIN_SERIAL_CTS (2) // P0.07 +#define PIN_SERIAL_RTS (3) // P0.31 +#define PIN_SERIAL_DTR (28) // P0.28 +#define PIN_SERIAL_DSR (29) // P0.29 + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (12) // P0.12 +#define PIN_SPI_MOSI (11) // P0.13 +#define PIN_SPI_SCK (13) // P0.14 + +static const uint8_t SS = 10 ; // P0.11 +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (14) // P0.02 +#define PIN_WIRE_SCL (15) // P0.03 + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + + +#endif //_VARIANT_NINA_B112_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/pins_arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/pins_arduino.h new file mode 100644 index 0000000..3ef4d4a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/pins_arduino.h @@ -0,0 +1,17 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.cpp new file mode 100644 index 0000000..8b4df2e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.cpp @@ -0,0 +1,87 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 + 29, // D0 is P0.29 (UART RX) + 45, // D1 is P1.13 (UART TX) + 44, // D2 is P1.12 (NFC2) + 31, // D3 is P0.31 (LED1) + 13, // D4 is P0.13 (LED2) + 11, // D5 is P0.11 + 9, // D6 is P0.09 + 10, // D7 is P0.10 (Button) + 41, // D8 is P1.09 + 12, // D9 is P0.12 + 14, // D10 is P0.14 + 15, // D11 is P0.15 + 32, // D12 is P1.00 + 7, // D13 is P0.07 + + // D14 .. D21 (aka A0 .. A5) + 4, // D14 is P0.04 (A0) + 30, // D15 is P0.30 (A1) + 5, // D16 is P0.05 (A2) + 2, // D17 is P0.02 (A3) + 28, // D18 is P0.28 (A4) + 3, // D19 is P0.03 (A5) + + // D20 .. D21 (aka I2C pins) + 16, // D20 is P0.16 (SDA) + 24, // D21 is P0.24 (SCL) + + // QSPI pins (not exposed via any header / test point) + 19, // D22 is P0.19 (QSPI CLK) + 17, // D23 is P0.17 (QSPI CS) + 20, // D24 is P0.20 (QSPI Data 0) + 21, // D25 is P0.21 (QSPI Data 1) + 22, // D26 is P0.22 (QSPI Data 2) + 26, // D27 is P0.23 (QSPI Data 3) + + 40, // D28 is P1.08 - IO34 + 41, // D29 is P1.01 - IO35 + 44, // D30 is P1.02 - IO36 + 45, // D31 is P1.03 - IO37 + 42, // D32 is P1.10 - IO38 + 43, // D33 is P1.11 - IO39 + 47, // D34 is P1.15 - IO40 + 46, // D35 is P1.14 - IO41 + 26, // D36 is P0.26 - IO42 + 6, // D37 is P0.6 - IO43 + 27, // D38 is P0.27 - IO44 +}; + +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.h new file mode 100644 index 0000000..a69575f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.h @@ -0,0 +1,149 @@ + /* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1) + +#ifndef _VARIANT_NINA_B302_UBLOX_ +#define _VARIANT_NINA_B302_UBLOX_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus +// Number of pins defined in PinDescription array +#define PINS_COUNT (40) +#define NUM_DIGITAL_PINS (34) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (3) +#define PIN_LED2 (4) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_RED PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +/* + * Buttons + */ +#define PIN_BUTTON1 (7) + +/* + * Analog pins + */ +#define PIN_A0 (14) +#define PIN_A1 (15) +#define PIN_A2 (16) +#define PIN_A3 (17) +#define PIN_A4 (18) +#define PIN_A5 (19) + +#define D0 (0) +#define D1 (1) +#define D2 (2) +#define D3 (3) +#define D4 (4) +#define D5 (5) +#define D6 (6) +#define D7 (7) +#define D8 (8) +#define D9 (9) +#define D10 (10) +#define D11 (11) +#define D12 (12) +#define D13 (13) + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; + +#define ADC_RESOLUTION 14 + +#define PIN_NFC1 (31) +#define PIN_NFC2 (2) + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (0) +#define PIN_SERIAL1_TX (1) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (22) //24 original +#define PIN_SPI_MOSI (23) //25 original +#define PIN_SPI_SCK (24) //26 original + +static const uint8_t SS = (13); +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (20) +#define PIN_WIRE_SCL (21) + +// QSPI Pins +#define PIN_QSPI_SCK 22 +#define PIN_QSPI_CS 23 +#define PIN_QSPI_IO0 24 +#define PIN_QSPI_IO1 25 +#define PIN_QSPI_IO2 26 +#define PIN_QSPI_IO3 27 + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES GD25Q16C +#define EXTERNAL_FLASH_USE_QSPI + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif //_VARIANT_NINA_B302_UBLOX_ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/sparkfun_nrf52840_mini/variant.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/sparkfun_nrf52840_mini/variant.cpp new file mode 100644 index 0000000..b01c147 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/sparkfun_nrf52840_mini/variant.cpp @@ -0,0 +1,49 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // P0 + 0 , 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, + + // P1 + 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, 61, 62, 63 +}; +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/sparkfun_nrf52840_mini/variant.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/sparkfun_nrf52840_mini/variant.h new file mode 100644 index 0000000..c534ceb --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/sparkfun_nrf52840_mini/variant.h @@ -0,0 +1,152 @@ + /* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_SPARKFUN52840MINI_ +#define _VARIANT_SPARKFUN52840MINI_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (64) +#define NUM_DIGITAL_PINS (64) +#define NUM_ANALOG_INPUTS (8) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (7) +#define PIN_LED2 (14) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_BLUE PIN_LED1 +#define LED_RED PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +// Buttons +/* +#define PIN_BUTTON1 (2) +#define PIN_BUTTON2 (3) +#define PIN_BUTTON3 (4) +#define PIN_BUTTON4 (5) +*/ + +/* + * Analog pins + */ +#define PIN_A0 (2) +#define PIN_A1 (3) +#define PIN_A2 (4) +#define PIN_A3 (5) +#define PIN_A4 (28) +#define PIN_A5 (29) +#define PIN_A6 (30) +#define PIN_A7 (31) + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; +static const uint8_t A6 = PIN_A6 ; +static const uint8_t A7 = PIN_A7 ; +#define ADC_RESOLUTION 14 + +// Other pins +#define PIN_AREF (2) +#define PIN_DFU (13) +#define PIN_NFC1 (9) +#define PIN_NFC2 (10) + +static const uint8_t AREF = PIN_AREF; + +/* + * Serial interfaces + */ +// Serial +//Previous Hardware UART definition for nRF52 Arduino Core, below 0.16.0 +//Feel free to comment out these two lines below if there are conflicts with latest release +#define PIN_SERIAL_RX (15) +#define PIN_SERIAL_TX (17) + +//Hardware UART definition for nRF52 Arduino Core, 0.17.0 and above +#define PIN_SERIAL1_RX (15) +#define PIN_SERIAL1_TX (17) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (31) +#define PIN_SPI_MOSI (3) +#define PIN_SPI_SCK (30) + +static const uint8_t SS = 2 ; +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (8) +#define PIN_WIRE_SCL (11) + +/* + * QSPI interface for external flash + */ +#define PIN_QSPI_SCK 32 +#define PIN_QSPI_CS 33 +#define PIN_QSPI_DATA0 34 +#define PIN_QSPI_DATA1 35 +#define PIN_QSPI_DATA2 36 +#define PIN_QSPI_DATA3 37 + +// On-board QSPI Flash +// If EXTERNAL_FLASH_DEVICES is not defined, all supported devices will be used +#define EXTERNAL_FLASH_DEVICES GD25Q16C + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif \ No newline at end of file diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.5.14/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.5.14/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.5.14/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.5.14/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.5.14/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.5.14/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.5.14/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.5.14/platform.txt new file mode 100644 index 0000000..aa15090 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.5.14/platform.txt @@ -0,0 +1,232 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.5.14 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.0/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.0/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.0/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.0/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.0/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.0/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.0/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.0/platform.txt new file mode 100644 index 0000000..beb5070 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.0/platform.txt @@ -0,0 +1,232 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.6.0 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.3/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.3/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.3/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.3/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.3/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.3/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.3/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.3/platform.txt new file mode 100644 index 0000000..9683594 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.3/platform.txt @@ -0,0 +1,226 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.6.3 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.4/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.4/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.4/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.4/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.4/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.4/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.4/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.4/platform.txt new file mode 100644 index 0000000..dd35ef0 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.4/platform.txt @@ -0,0 +1,226 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.6.4 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.5/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.5/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.5/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.5/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.5/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.5/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.5/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.5/platform.txt new file mode 100644 index 0000000..f72eb2f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.5/platform.txt @@ -0,0 +1,227 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.6.5 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.6/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.6/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.6/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.6/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.6/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.6/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.6/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.6/platform.txt new file mode 100644 index 0000000..babb026 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.6/platform.txt @@ -0,0 +1,226 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.6.6 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.7/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.7/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.7/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.7/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.7/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.7/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.7/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.7/platform.txt new file mode 100644 index 0000000..a5f1d1e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.7/platform.txt @@ -0,0 +1,226 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.6.7 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.1.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.8/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.8/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.8/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.8/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.8/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.8/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.8/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.8/platform.txt new file mode 100644 index 0000000..629111a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.6.8/platform.txt @@ -0,0 +1,226 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.6.8 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.1.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.0/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.0/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.0/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.0/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.0/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.0/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.0/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.0/platform.txt new file mode 100644 index 0000000..4f32220 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.0/platform.txt @@ -0,0 +1,226 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.7.0 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.1.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.1/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.1/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.1/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.1/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.1/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.1/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.1/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.1/platform.txt new file mode 100644 index 0000000..ee0bc42 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.1/platform.txt @@ -0,0 +1,226 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.7.1 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.2.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.10/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.10/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.10/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.10/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.10/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.10/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.10/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.10/platform.txt new file mode 100644 index 0000000..2685ec7 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.10/platform.txt @@ -0,0 +1,226 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.7.10 + +# Compile variables +# ----------------- + +compiler.warning_flags=-Werror=return-type +compiler.warning_flags.none=-Werror=return-type +compiler.warning_flags.default=-Werror=return-type +compiler.warning_flags.more=-Wall -Werror=return-type -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Werror=return-type -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.2.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.2/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.2/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.2/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.2/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.2/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.2/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.2/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.2/platform.txt new file mode 100644 index 0000000..508f914 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.2/platform.txt @@ -0,0 +1,226 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.7.2 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.2.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.3/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.3/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.3/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.3/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.3/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.3/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.3/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.3/platform.txt new file mode 100644 index 0000000..277397f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.3/platform.txt @@ -0,0 +1,226 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.7.3 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.2.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.4/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.4/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.4/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.4/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.4/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.4/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.4/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.4/platform.txt new file mode 100644 index 0000000..42e0777 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.4/platform.txt @@ -0,0 +1,226 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.7.4 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.2.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.5/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.5/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.5/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.5/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.5/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.5/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.5/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.5/platform.txt new file mode 100644 index 0000000..4c71d6d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.5/platform.txt @@ -0,0 +1,226 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.7.5 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.2.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.6/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.6/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.6/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.6/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.6/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.6/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.6/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.6/platform.txt new file mode 100644 index 0000000..1eaf316 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.6/platform.txt @@ -0,0 +1,226 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.7.6 + +# Compile variables +# ----------------- + +compiler.warning_flags=-Werror=return-type +compiler.warning_flags.none=-Werror=return-type +compiler.warning_flags.default=-Werror=return-type +compiler.warning_flags.more=-Wall -Werror=return-type -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Werror=return-type -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.2.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.7/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.7/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.7/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.7/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.7/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.7/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.7/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.7/platform.txt new file mode 100644 index 0000000..a23ed97 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.7/platform.txt @@ -0,0 +1,226 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.7.7 + +# Compile variables +# ----------------- + +compiler.warning_flags=-Werror=return-type +compiler.warning_flags.none=-Werror=return-type +compiler.warning_flags.default=-Werror=return-type +compiler.warning_flags.more=-Wall -Werror=return-type -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Werror=return-type -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.2.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.8/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.8/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.8/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.8/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.8/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.8/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.8/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.8/platform.txt new file mode 100644 index 0000000..534c535 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.8/platform.txt @@ -0,0 +1,238 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.7.8 + +# Compile variables +# ----------------- + +compiler.warning_flags=-Werror=return-type +compiler.warning_flags.none=-Werror=return-type +compiler.warning_flags.default=-Werror=return-type +compiler.warning_flags.more=-Wall -Werror=return-type -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Werror=return-type -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.2.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.9.1 + +tools.bossac19.path={runtime.tools.bossac-1.9.1-arduino2.path} +tools.bossac19.cmd=bossac + +tools.bossac19.upload.params.verbose=-i -d +tools.bossac19.upload.params.quiet= +tools.bossac19.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac19.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac19.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.9/cores/arduino/Print.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.9/cores/arduino/Print.cpp new file mode 100644 index 0000000..09d5864 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.9/cores/arduino/Print.cpp @@ -0,0 +1,420 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#include + +#include +#include +#include + +#include "Arduino.h" + +#include "Print.h" + +//using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +size_t Print::printf(const char * format, ...) +{ + char buf[256]; + int len; + + va_list ap; + va_start(ap, format); + + len = vsnprintf(buf, 256, format, ap); + this->write(buf, len); + + va_end(ap); + return len; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} + +size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[i]); + } + + return (len*3 - 1); +} + +size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) +{ + if (buffer == NULL || len == 0) return 0; + + for(int i=0; iprintf("%02X", buffer[len-1-i]); + } + + return (len*3 - 1); +} + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.9/cores/arduino/Print.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.9/cores/arduino/Print.h new file mode 100644 index 0000000..793a686 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.9/cores/arduino/Print.h @@ -0,0 +1,107 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + size_t printf(const char * format, ...); + + size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBuffer((uint8_t const*) buffer, size, delim, byteline); + } + + size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + { + return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); + } + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.9/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.9/platform.txt new file mode 100644 index 0000000..c364d2e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/adafruit/hardware/samd/1.7.9/platform.txt @@ -0,0 +1,238 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards +version=1.7.9 + +# Compile variables +# ----------------- + +compiler.warning_flags=-Werror=return-type +compiler.warning_flags.none=-Werror=return-type +compiler.warning_flags.default=-Werror=return-type +compiler.warning_flags.more=-Wall -Werror=return-type -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Werror=return-type -Wno-expansion-to-defined + +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}""" +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= +build.cache_flags= +build.flags.optimize= +build.flags.maxspi= +build.flags.maxqspi= +build.flags.usbstack= +build.flags.debug= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.2.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" + +# Default advertised device power setting in mA +build.usb_power=100 + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.8.0 + +tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} +tools.bossac18.cmd=bossac + +tools.bossac18.upload.params.verbose=-i -d +tools.bossac18.upload.params.quiet= +tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# v1.9.1 + +tools.bossac19.path={runtime.tools.bossac-1.9.1-arduino2.path} +tools.bossac19.cmd=bossac + +tools.bossac19.upload.params.verbose=-i -d +tools.bossac19.upload.params.quiet= +tools.bossac19.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac19.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac19.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.4.1/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.4.1/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h new file mode 100644 index 0000000..84c18cf --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.4.1/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h @@ -0,0 +1,347 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef LWIPOPTS_H +#define LWIPOPTS_H + +// Workaround for Linux timeval +#if defined (TOOLCHAIN_GCC) +#define LWIP_TIMEVAL_PRIVATE 0 +#include +#endif +#include "nsapi_types.h" +#include "mbed_retarget.h" + +// KH fix +#include +///////////////////////// + +// Operating System +#define NO_SYS 0 + +#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED +#error "Either IPv4 or IPv6 must be enabled." +#endif + +#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED + +#define LWIP_IPV6 MBED_CONF_LWIP_IPV6_ENABLED + +#define LWIP_PROVIDE_ERRNO 0 + +// On dual stack configuration how long to wait for both or preferred stack +// addresses before completing bring up. +#if LWIP_IPV4 && LWIP_IPV6 +#if MBED_CONF_LWIP_ADDR_TIMEOUT_MODE +#define BOTH_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define PREF_ADDR_TIMEOUT 0 +#else +#define PREF_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define BOTH_ADDR_TIMEOUT 0 +#endif +#else +#define PREF_ADDR_TIMEOUT 0 +#define BOTH_ADDR_TIMEOUT 0 +#endif + + +#define DHCP_TIMEOUT MBED_CONF_LWIP_DHCP_TIMEOUT + +#define LINK_TIMEOUT 60 + +#define PREF_IPV4 1 +#define PREF_IPV6 2 + +#if MBED_CONF_LWIP_IP_VER_PREF == 6 +#define IP_VERSION_PREF PREF_IPV6 +#elif MBED_CONF_LWIP_IP_VER_PREF == 4 +#define IP_VERSION_PREF PREF_IPV4 +#else +#error "Either IPv4 or IPv6 must be preferred." +#endif + +#undef LWIP_DEBUG +#if MBED_CONF_LWIP_DEBUG_ENABLED +#define LWIP_DEBUG 1 +#endif + +#if NO_SYS == 0 +#include "cmsis_os2.h" + +#define SYS_LIGHTWEIGHT_PROT 1 + +#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED + +#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT + +// Thread stacks use 8-byte alignment +#define LWIP_ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos)) + +#ifdef LWIP_DEBUG +// For LWIP debug, double the stack +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2, 8) +#elif MBED_DEBUG +// When debug is enabled on the build increase stack 25 percent +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE + MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE / 4, 8) +#else +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE, 8) +#endif + +// Thread priority (osPriorityNormal by default) +#define TCPIP_THREAD_PRIO (MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY) + +#ifdef LWIP_DEBUG +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2, 8) +#else +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE, 8) +#endif + +#define MEMP_NUM_SYS_TIMEOUT 16 + +#define sys_msleep(ms) sys_msleep(ms) + +#endif + +// 32-bit alignment +#define MEM_ALIGNMENT 4 + +#define LWIP_RAM_HEAP_POINTER lwip_ram_heap + +// Number of simultaneously queued TCP segments. +#define MEMP_NUM_TCP_SEG MBED_CONF_LWIP_MEMP_NUM_TCP_SEG + +// TCP Maximum segment size. +#define TCP_MSS MBED_CONF_LWIP_TCP_MSS + +// TCP sender buffer space (bytes). +#define TCP_SND_BUF MBED_CONF_LWIP_TCP_SND_BUF + +// TCP sender buffer space (bytes). +#define TCP_WND MBED_CONF_LWIP_TCP_WND + +#define TCP_MAXRTX MBED_CONF_LWIP_TCP_MAXRTX + +#define TCP_SYNMAXRTX MBED_CONF_LWIP_TCP_SYNMAXRTX + +// Number of pool pbufs. +// Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS) +#define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE + +#ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE +#undef PBUF_POOL_BUFSIZE +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(MBED_CONF_LWIP_PBUF_POOL_BUFSIZE) +#else +#ifndef PBUF_POOL_BUFSIZE +#if LWIP_IPV6 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#elif LWIP_IPV4 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+20+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#endif +#endif +#endif + +#define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE + +// One tcp_pcb_listen is needed for each TCP server. +// Each requires 72 bytes of RAM. +#define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX + +// One is tcp_pcb needed for each TCPSocket. +// Each requires 196 bytes of RAM. +#define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX + +// One udp_pcb is needed for each UDPSocket. +// Each requires 84 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX + +// Number of non-pool pbufs. +// Each requires 92 bytes of RAM. +#define MEMP_NUM_PBUF MBED_CONF_LWIP_NUM_PBUF + +// Each netbuf requires 64 bytes of RAM. +#define MEMP_NUM_NETBUF MBED_CONF_LWIP_NUM_NETBUF + +// One netconn is needed for each UDPSocket or TCPSocket. +// Each requires 236 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX + +#if MBED_CONF_LWIP_TCP_ENABLED +#define LWIP_TCP 1 +#define TCP_OVERSIZE 0 +#define LWIP_TCP_KEEPALIVE 1 + +#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT + +#else +#define LWIP_TCP 0 +#endif + +#define LWIP_DNS 1 +// Only DNS address storage is enabled +#define LWIP_FULL_DNS 0 +#define LWIP_SOCKET 0 + +#define SO_REUSE 1 + +// Support Multicast +#include "stdlib.h" +#define LWIP_IGMP LWIP_IPV4 +#define LWIP_RAND() lwip_get_random() + +#define LWIP_COMPAT_SOCKETS 0 +#define LWIP_POSIX_SOCKETS_IO_NAMES 0 + +#define LWIP_BROADCAST_PING 1 + +// Fragmentation on, as per IPv4 default +#define LWIP_IPV6_FRAG LWIP_IPV6 + +// Queuing, default is "disabled", as per IPv4 default (so actually queues 1) +#define LWIP_ND6_QUEUEING MBED_CONF_ND6_QUEUEING + +// Debug Options +#define NETIF_DEBUG LWIP_DBG_OFF +#define PBUF_DEBUG LWIP_DBG_OFF +#define API_LIB_DEBUG LWIP_DBG_OFF +#define API_MSG_DEBUG LWIP_DBG_OFF +#define SOCKETS_DEBUG LWIP_DBG_OFF +#define ICMP_DEBUG LWIP_DBG_OFF +#define IGMP_DEBUG LWIP_DBG_OFF +#define INET_DEBUG LWIP_DBG_OFF +#define IP_DEBUG LWIP_DBG_OFF +#define IP_REASS_DEBUG LWIP_DBG_OFF +#define RAW_DEBUG LWIP_DBG_OFF +#define MEM_DEBUG LWIP_DBG_OFF +#define MEMP_DEBUG LWIP_DBG_OFF +#define SYS_DEBUG LWIP_DBG_OFF +#define TIMERS_DEBUG LWIP_DBG_OFF +#define TCP_DEBUG LWIP_DBG_OFF +#define TCP_INPUT_DEBUG LWIP_DBG_OFF +#define TCP_FR_DEBUG LWIP_DBG_OFF +#define TCP_RTO_DEBUG LWIP_DBG_OFF +#define TCP_CWND_DEBUG LWIP_DBG_OFF +#define TCP_WND_DEBUG LWIP_DBG_OFF +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF +#define TCP_RST_DEBUG LWIP_DBG_OFF +#define TCP_QLEN_DEBUG LWIP_DBG_OFF +#define UDP_DEBUG LWIP_DBG_OFF +#define TCPIP_DEBUG LWIP_DBG_OFF +#define SLIP_DEBUG LWIP_DBG_OFF +#define DHCP_DEBUG LWIP_DBG_OFF +#define AUTOIP_DEBUG LWIP_DBG_OFF +#define DNS_DEBUG LWIP_DBG_OFF +#define IP6_DEBUG LWIP_DBG_OFF + +#define ETHARP_DEBUG LWIP_DBG_OFF +#define UDP_LPC_EMAC LWIP_DBG_OFF + +#ifdef LWIP_DEBUG +#define MEMP_OVERFLOW_CHECK 1 +#define MEMP_SANITY_CHECK 1 +#define LWIP_DBG_TYPES_ON LWIP_DBG_ON +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL +#else +#define LWIP_NOASSERT 1 +#define LWIP_STATS 0 +#endif + +#define TRACE_TO_ASCII_HEX_DUMP 0 + +#define LWIP_PLATFORM_BYTESWAP 1 + +#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 + +// Interface type configuration + +#if MBED_CONF_LWIP_ETHERNET_ENABLED +#define LWIP_ARP 1 +#define LWIP_ETHERNET 1 +#define LWIP_DHCP LWIP_IPV4 +#else +#define LWIP_ARP 0 +#define LWIP_ETHERNET 0 +#endif // MBED_CONF_LWIP_ETHERNET_ENABLED + +#if MBED_CONF_LWIP_L3IP_ENABLED +#define LWIP_L3IP 1 +#else +#define LWIP_L3IP 0 +#endif + +//Maximum size of network interface name +#define INTERFACE_NAME_MAX_SIZE NSAPI_INTERFACE_NAME_MAX_SIZE +// Note generic macro name used rather than MBED_CONF_LWIP_PPP_ENABLED +// to allow users like PPPCellularInterface to detect that nsapi_ppp.h is available. + +// Enable PPP for now either from lwIP PPP configuration (obsolete) or from PPP service configuration +#if MBED_CONF_PPP_ENABLED || MBED_CONF_LWIP_PPP_ENABLED + +#define PPP_SUPPORT 1 + +#if MBED_CONF_PPP_IPV4_ENABLED || MBED_CONF_LWIP_IPV4_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV4_ENABLED +#error LWIP: IPv4 PPP enabled but not IPv4 +#endif +#undef LWIP +#define PPP_IPV4_SUPPORT 1 +#endif + +#if MBED_CONF_PPP_IPV6_ENABLED || MBED_CONF_LWIP_IPV6_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV6_ENABLED +#error LWIP: IPv6 PPP enabled but not IPv6 +#endif +#undef LWIP +#define PPP_IPV6_SUPPORT 1 +// Later to be dynamic for use for multiple interfaces +#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0 +#endif + +#endif + +#define LWIP_NETBUF_RECVINFO MBED_CONF_LWIP_NETBUF_RECVINFO_ENABLED + +// Make sure we default these to off, so +// LWIP doesn't default to on +#ifndef LWIP_ARP +#define LWIP_ARP 0 +#endif + +// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914 +#define LWIP_CHECKSUM_ON_COPY 0 + +#define LWIP_NETIF_HOSTNAME 1 +#define LWIP_NETIF_STATUS_CALLBACK 1 +#define LWIP_NETIF_LINK_CALLBACK 1 + +#define DNS_TABLE_SIZE 2 +#define DNS_MAX_NAME_LENGTH 128 + +#include "lwip_random.h" +#include "lwip_tcp_isn.h" +#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn +#ifdef MBEDTLS_MD5_C +#define LWIP_USE_EXTERNAL_MBEDTLS 1 +#else +#define LWIP_USE_EXTERNAL_MBEDTLS 0 +#endif + +#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS + +#endif /* LWIPOPTS_H_ */ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.4.1/libraries/SocketWrapper/src/MbedUdp.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.4.1/libraries/SocketWrapper/src/MbedUdp.cpp new file mode 100644 index 0000000..2a1b0fc --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.4.1/libraries/SocketWrapper/src/MbedUdp.cpp @@ -0,0 +1,217 @@ +#include "MbedUdp.h" + +arduino::MbedUDP::MbedUDP() { + _packet_buffer = new uint8_t[WIFI_UDP_BUFFER_SIZE]; + _current_packet = NULL; + _current_packet_size = 0; + // if this allocation fails then ::begin will fail +} + +arduino::MbedUDP::~MbedUDP() { + delete[] _packet_buffer; +} + +uint8_t arduino::MbedUDP::begin(uint16_t port) { + // success = 1, fail = 0 + + nsapi_error_t rt = _socket.open(getNetwork()); + if (rt != NSAPI_ERROR_OK) { + return 0; + } + + if (_socket.bind(port) < 0) { + return 0; //Failed to bind UDP Socket to port + } + + if (!_packet_buffer) { + return 0; + } + + _socket.set_blocking(false); + _socket.set_timeout(0); + + return 1; +} + +uint8_t arduino::MbedUDP::beginMulticast(IPAddress ip, uint16_t port) { + // success = 1, fail = 0 + if (begin(port) != 1) { + return 0; + } + + SocketAddress socketAddress = SocketHelpers::socketAddressFromIpAddress(ip, port); + + if (_socket.join_multicast_group(socketAddress) != NSAPI_ERROR_OK) { + printf("Error joining the multicast group\n"); + return 0; + } + + return 1; +} + +void arduino::MbedUDP::stop() { + _socket.close(); +} + +int arduino::MbedUDP::beginPacket(IPAddress ip, uint16_t port) { + _host = SocketHelpers::socketAddressFromIpAddress(ip, port); + //If IP is null and port is 0 the initialization failed + txBuffer.clear(); + return (_host.get_ip_address() == nullptr && _host.get_port() == 0) ? 0 : 1; +} + +int arduino::MbedUDP::beginPacket(const char *host, uint16_t port) { + _host = SocketAddress(host, port); + txBuffer.clear(); + getNetwork()->gethostbyname(host, &_host); + //If IP is null and port is 0 the initialization failed + return (_host.get_ip_address() == nullptr && _host.get_port() == 0) ? 0 : 1; +} + +int arduino::MbedUDP::endPacket() { + _socket.set_blocking(true); + _socket.set_timeout(1000); + + size_t size = txBuffer.available(); + uint8_t buffer[size]; + for (int i = 0; i < size; i++) { + buffer[i] = txBuffer.read_char(); + } + + nsapi_size_or_error_t ret = _socket.sendto(_host, buffer, size); + _socket.set_blocking(false); + _socket.set_timeout(0); + if (ret < 0) { + return 0; + } + return size; +} + +// Write a single byte into the packet +size_t arduino::MbedUDP::write(uint8_t byte) { + return write(&byte, 1); +} + +// Write size bytes from buffer into the packet +size_t arduino::MbedUDP::write(const uint8_t *buffer, size_t size) { + for (int i = 0; i _packet_buffer + _current_packet_size) { + // try reading the next packet... + if (parsePacket() > 0) { + // if so, read first byte of next packet; + return read(); + } else { + // no new data... not sure what to return here now + return -1; + } + } + + return _current_packet[0]; +} + +// Read up to len bytes from the current packet and place them into buffer +// Returns the number of bytes read, or 0 if none are available +int arduino::MbedUDP::read(unsigned char *buffer, size_t len) { + // Q: does Arduino read() function handle fragmentation? I won't for now... + if (_current_packet == NULL) { + if (parsePacket() == 0) return 0; + } + + // how much data do we have in the current packet? + int offset = _current_packet - _packet_buffer; + if (offset < 0) { + return 0; + } + + int max_bytes = _current_packet_size - offset; + if (max_bytes < 0) { + return 0; + } + + // at the end of the packet? + if (max_bytes == 0) { + // try read next packet... + if (parsePacket() > 0) { + return read(buffer, len); + } else { + return 0; + } + } + + if (len > (size_t)max_bytes) len = max_bytes; + + // copy to target buffer + memcpy(buffer, _current_packet, len); + + _current_packet += len; + + return len; +} + +IPAddress arduino::MbedUDP::remoteIP() { + nsapi_addr_t address = _remoteHost.get_addr(); + return IPAddress(address.bytes[0], address.bytes[1], address.bytes[2], address.bytes[3]); +} + +uint16_t arduino::MbedUDP::remotePort() { + return _remoteHost.get_port(); +} + +void arduino::MbedUDP::flush() { + // TODO: a real check to ensure transmission has been completed +} + +int arduino::MbedUDP::peek() { + if (_current_packet_size < 1) { + return -1; + } + + return _current_packet[0]; +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.4.1/libraries/SocketWrapper/src/MbedUdp.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.4.1/libraries/SocketWrapper/src/MbedUdp.h new file mode 100644 index 0000000..7f81ede --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.4.1/libraries/SocketWrapper/src/MbedUdp.h @@ -0,0 +1,105 @@ +/* + MbedUdp.h - UDP implementation using mbed Sockets + Copyright (c) 2021 Arduino SA. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef MBEDUDP_H +#define MBEDUDP_H + +#include "Arduino.h" +#include "SocketHelpers.h" +#include "api/Udp.h" + +#include "netsocket/SocketAddress.h" +#include "netsocket/UDPSocket.h" + +#ifndef WIFI_UDP_BUFFER_SIZE +#define WIFI_UDP_BUFFER_SIZE 508 +#endif + +namespace arduino { + +class MbedUDP : public UDP { +private: + UDPSocket _socket; // Mbed OS socket + SocketAddress _host; // Host to be used to send data + SocketAddress _remoteHost; // Remote host that sent incoming packets + + uint8_t* _packet_buffer; // Raw packet buffer (contains data we got from the UDPSocket) + + // The Arduino APIs allow you to iterate through this buffer, so we need to be able to iterate over the current packet + // these two variables are used to cache the state of the current packet + uint8_t* _current_packet; + size_t _current_packet_size; + + RingBufferN txBuffer; + +protected: + virtual NetworkInterface* getNetwork() = 0; + +public: + MbedUDP(); // Constructor + ~MbedUDP(); + virtual uint8_t begin(uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual uint8_t beginMulticast(IPAddress, uint16_t); // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 if there are no sockets available to use + virtual void stop(); // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port); + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char* host, uint16_t port); + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket(); + // Write a single byte into the packet + virtual size_t write(uint8_t); + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t* buffer, size_t size); + + using Print::write; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket(); + // Number of bytes remaining in the current packet + virtual int available(); + // Read a single byte from the current packet + virtual int read(); + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len); + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) { + return read((unsigned char*)buffer, len); + }; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek(); + virtual void flush(); // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP(); + // // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort(); + + friend class MbedSocketClass; +}; + +} + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.4.1/portenta_post_install.sh b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.4.1/portenta_post_install.sh new file mode 100644 index 0000000..7fe71d6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.4.1/portenta_post_install.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +portenta_h7_rules () { + echo "" + echo "# Portenta H7 bootloader mode UDEV rules" + echo "" +cat < /etc/udev/rules.d/49-portenta_h7.rules + +# reload udev rules +echo "Reload rules..." +udevadm trigger +udevadm control --reload-rules diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.5.2/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.5.2/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h new file mode 100644 index 0000000..84c18cf --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.5.2/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h @@ -0,0 +1,347 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef LWIPOPTS_H +#define LWIPOPTS_H + +// Workaround for Linux timeval +#if defined (TOOLCHAIN_GCC) +#define LWIP_TIMEVAL_PRIVATE 0 +#include +#endif +#include "nsapi_types.h" +#include "mbed_retarget.h" + +// KH fix +#include +///////////////////////// + +// Operating System +#define NO_SYS 0 + +#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED +#error "Either IPv4 or IPv6 must be enabled." +#endif + +#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED + +#define LWIP_IPV6 MBED_CONF_LWIP_IPV6_ENABLED + +#define LWIP_PROVIDE_ERRNO 0 + +// On dual stack configuration how long to wait for both or preferred stack +// addresses before completing bring up. +#if LWIP_IPV4 && LWIP_IPV6 +#if MBED_CONF_LWIP_ADDR_TIMEOUT_MODE +#define BOTH_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define PREF_ADDR_TIMEOUT 0 +#else +#define PREF_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define BOTH_ADDR_TIMEOUT 0 +#endif +#else +#define PREF_ADDR_TIMEOUT 0 +#define BOTH_ADDR_TIMEOUT 0 +#endif + + +#define DHCP_TIMEOUT MBED_CONF_LWIP_DHCP_TIMEOUT + +#define LINK_TIMEOUT 60 + +#define PREF_IPV4 1 +#define PREF_IPV6 2 + +#if MBED_CONF_LWIP_IP_VER_PREF == 6 +#define IP_VERSION_PREF PREF_IPV6 +#elif MBED_CONF_LWIP_IP_VER_PREF == 4 +#define IP_VERSION_PREF PREF_IPV4 +#else +#error "Either IPv4 or IPv6 must be preferred." +#endif + +#undef LWIP_DEBUG +#if MBED_CONF_LWIP_DEBUG_ENABLED +#define LWIP_DEBUG 1 +#endif + +#if NO_SYS == 0 +#include "cmsis_os2.h" + +#define SYS_LIGHTWEIGHT_PROT 1 + +#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED + +#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT + +// Thread stacks use 8-byte alignment +#define LWIP_ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos)) + +#ifdef LWIP_DEBUG +// For LWIP debug, double the stack +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2, 8) +#elif MBED_DEBUG +// When debug is enabled on the build increase stack 25 percent +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE + MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE / 4, 8) +#else +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE, 8) +#endif + +// Thread priority (osPriorityNormal by default) +#define TCPIP_THREAD_PRIO (MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY) + +#ifdef LWIP_DEBUG +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2, 8) +#else +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE, 8) +#endif + +#define MEMP_NUM_SYS_TIMEOUT 16 + +#define sys_msleep(ms) sys_msleep(ms) + +#endif + +// 32-bit alignment +#define MEM_ALIGNMENT 4 + +#define LWIP_RAM_HEAP_POINTER lwip_ram_heap + +// Number of simultaneously queued TCP segments. +#define MEMP_NUM_TCP_SEG MBED_CONF_LWIP_MEMP_NUM_TCP_SEG + +// TCP Maximum segment size. +#define TCP_MSS MBED_CONF_LWIP_TCP_MSS + +// TCP sender buffer space (bytes). +#define TCP_SND_BUF MBED_CONF_LWIP_TCP_SND_BUF + +// TCP sender buffer space (bytes). +#define TCP_WND MBED_CONF_LWIP_TCP_WND + +#define TCP_MAXRTX MBED_CONF_LWIP_TCP_MAXRTX + +#define TCP_SYNMAXRTX MBED_CONF_LWIP_TCP_SYNMAXRTX + +// Number of pool pbufs. +// Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS) +#define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE + +#ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE +#undef PBUF_POOL_BUFSIZE +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(MBED_CONF_LWIP_PBUF_POOL_BUFSIZE) +#else +#ifndef PBUF_POOL_BUFSIZE +#if LWIP_IPV6 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#elif LWIP_IPV4 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+20+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#endif +#endif +#endif + +#define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE + +// One tcp_pcb_listen is needed for each TCP server. +// Each requires 72 bytes of RAM. +#define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX + +// One is tcp_pcb needed for each TCPSocket. +// Each requires 196 bytes of RAM. +#define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX + +// One udp_pcb is needed for each UDPSocket. +// Each requires 84 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX + +// Number of non-pool pbufs. +// Each requires 92 bytes of RAM. +#define MEMP_NUM_PBUF MBED_CONF_LWIP_NUM_PBUF + +// Each netbuf requires 64 bytes of RAM. +#define MEMP_NUM_NETBUF MBED_CONF_LWIP_NUM_NETBUF + +// One netconn is needed for each UDPSocket or TCPSocket. +// Each requires 236 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX + +#if MBED_CONF_LWIP_TCP_ENABLED +#define LWIP_TCP 1 +#define TCP_OVERSIZE 0 +#define LWIP_TCP_KEEPALIVE 1 + +#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT + +#else +#define LWIP_TCP 0 +#endif + +#define LWIP_DNS 1 +// Only DNS address storage is enabled +#define LWIP_FULL_DNS 0 +#define LWIP_SOCKET 0 + +#define SO_REUSE 1 + +// Support Multicast +#include "stdlib.h" +#define LWIP_IGMP LWIP_IPV4 +#define LWIP_RAND() lwip_get_random() + +#define LWIP_COMPAT_SOCKETS 0 +#define LWIP_POSIX_SOCKETS_IO_NAMES 0 + +#define LWIP_BROADCAST_PING 1 + +// Fragmentation on, as per IPv4 default +#define LWIP_IPV6_FRAG LWIP_IPV6 + +// Queuing, default is "disabled", as per IPv4 default (so actually queues 1) +#define LWIP_ND6_QUEUEING MBED_CONF_ND6_QUEUEING + +// Debug Options +#define NETIF_DEBUG LWIP_DBG_OFF +#define PBUF_DEBUG LWIP_DBG_OFF +#define API_LIB_DEBUG LWIP_DBG_OFF +#define API_MSG_DEBUG LWIP_DBG_OFF +#define SOCKETS_DEBUG LWIP_DBG_OFF +#define ICMP_DEBUG LWIP_DBG_OFF +#define IGMP_DEBUG LWIP_DBG_OFF +#define INET_DEBUG LWIP_DBG_OFF +#define IP_DEBUG LWIP_DBG_OFF +#define IP_REASS_DEBUG LWIP_DBG_OFF +#define RAW_DEBUG LWIP_DBG_OFF +#define MEM_DEBUG LWIP_DBG_OFF +#define MEMP_DEBUG LWIP_DBG_OFF +#define SYS_DEBUG LWIP_DBG_OFF +#define TIMERS_DEBUG LWIP_DBG_OFF +#define TCP_DEBUG LWIP_DBG_OFF +#define TCP_INPUT_DEBUG LWIP_DBG_OFF +#define TCP_FR_DEBUG LWIP_DBG_OFF +#define TCP_RTO_DEBUG LWIP_DBG_OFF +#define TCP_CWND_DEBUG LWIP_DBG_OFF +#define TCP_WND_DEBUG LWIP_DBG_OFF +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF +#define TCP_RST_DEBUG LWIP_DBG_OFF +#define TCP_QLEN_DEBUG LWIP_DBG_OFF +#define UDP_DEBUG LWIP_DBG_OFF +#define TCPIP_DEBUG LWIP_DBG_OFF +#define SLIP_DEBUG LWIP_DBG_OFF +#define DHCP_DEBUG LWIP_DBG_OFF +#define AUTOIP_DEBUG LWIP_DBG_OFF +#define DNS_DEBUG LWIP_DBG_OFF +#define IP6_DEBUG LWIP_DBG_OFF + +#define ETHARP_DEBUG LWIP_DBG_OFF +#define UDP_LPC_EMAC LWIP_DBG_OFF + +#ifdef LWIP_DEBUG +#define MEMP_OVERFLOW_CHECK 1 +#define MEMP_SANITY_CHECK 1 +#define LWIP_DBG_TYPES_ON LWIP_DBG_ON +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL +#else +#define LWIP_NOASSERT 1 +#define LWIP_STATS 0 +#endif + +#define TRACE_TO_ASCII_HEX_DUMP 0 + +#define LWIP_PLATFORM_BYTESWAP 1 + +#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 + +// Interface type configuration + +#if MBED_CONF_LWIP_ETHERNET_ENABLED +#define LWIP_ARP 1 +#define LWIP_ETHERNET 1 +#define LWIP_DHCP LWIP_IPV4 +#else +#define LWIP_ARP 0 +#define LWIP_ETHERNET 0 +#endif // MBED_CONF_LWIP_ETHERNET_ENABLED + +#if MBED_CONF_LWIP_L3IP_ENABLED +#define LWIP_L3IP 1 +#else +#define LWIP_L3IP 0 +#endif + +//Maximum size of network interface name +#define INTERFACE_NAME_MAX_SIZE NSAPI_INTERFACE_NAME_MAX_SIZE +// Note generic macro name used rather than MBED_CONF_LWIP_PPP_ENABLED +// to allow users like PPPCellularInterface to detect that nsapi_ppp.h is available. + +// Enable PPP for now either from lwIP PPP configuration (obsolete) or from PPP service configuration +#if MBED_CONF_PPP_ENABLED || MBED_CONF_LWIP_PPP_ENABLED + +#define PPP_SUPPORT 1 + +#if MBED_CONF_PPP_IPV4_ENABLED || MBED_CONF_LWIP_IPV4_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV4_ENABLED +#error LWIP: IPv4 PPP enabled but not IPv4 +#endif +#undef LWIP +#define PPP_IPV4_SUPPORT 1 +#endif + +#if MBED_CONF_PPP_IPV6_ENABLED || MBED_CONF_LWIP_IPV6_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV6_ENABLED +#error LWIP: IPv6 PPP enabled but not IPv6 +#endif +#undef LWIP +#define PPP_IPV6_SUPPORT 1 +// Later to be dynamic for use for multiple interfaces +#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0 +#endif + +#endif + +#define LWIP_NETBUF_RECVINFO MBED_CONF_LWIP_NETBUF_RECVINFO_ENABLED + +// Make sure we default these to off, so +// LWIP doesn't default to on +#ifndef LWIP_ARP +#define LWIP_ARP 0 +#endif + +// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914 +#define LWIP_CHECKSUM_ON_COPY 0 + +#define LWIP_NETIF_HOSTNAME 1 +#define LWIP_NETIF_STATUS_CALLBACK 1 +#define LWIP_NETIF_LINK_CALLBACK 1 + +#define DNS_TABLE_SIZE 2 +#define DNS_MAX_NAME_LENGTH 128 + +#include "lwip_random.h" +#include "lwip_tcp_isn.h" +#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn +#ifdef MBEDTLS_MD5_C +#define LWIP_USE_EXTERNAL_MBEDTLS 1 +#else +#define LWIP_USE_EXTERNAL_MBEDTLS 0 +#endif + +#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS + +#endif /* LWIPOPTS_H_ */ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.5.2/libraries/SocketWrapper/src/MbedUdp.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.5.2/libraries/SocketWrapper/src/MbedUdp.cpp new file mode 100644 index 0000000..2a1b0fc --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.5.2/libraries/SocketWrapper/src/MbedUdp.cpp @@ -0,0 +1,217 @@ +#include "MbedUdp.h" + +arduino::MbedUDP::MbedUDP() { + _packet_buffer = new uint8_t[WIFI_UDP_BUFFER_SIZE]; + _current_packet = NULL; + _current_packet_size = 0; + // if this allocation fails then ::begin will fail +} + +arduino::MbedUDP::~MbedUDP() { + delete[] _packet_buffer; +} + +uint8_t arduino::MbedUDP::begin(uint16_t port) { + // success = 1, fail = 0 + + nsapi_error_t rt = _socket.open(getNetwork()); + if (rt != NSAPI_ERROR_OK) { + return 0; + } + + if (_socket.bind(port) < 0) { + return 0; //Failed to bind UDP Socket to port + } + + if (!_packet_buffer) { + return 0; + } + + _socket.set_blocking(false); + _socket.set_timeout(0); + + return 1; +} + +uint8_t arduino::MbedUDP::beginMulticast(IPAddress ip, uint16_t port) { + // success = 1, fail = 0 + if (begin(port) != 1) { + return 0; + } + + SocketAddress socketAddress = SocketHelpers::socketAddressFromIpAddress(ip, port); + + if (_socket.join_multicast_group(socketAddress) != NSAPI_ERROR_OK) { + printf("Error joining the multicast group\n"); + return 0; + } + + return 1; +} + +void arduino::MbedUDP::stop() { + _socket.close(); +} + +int arduino::MbedUDP::beginPacket(IPAddress ip, uint16_t port) { + _host = SocketHelpers::socketAddressFromIpAddress(ip, port); + //If IP is null and port is 0 the initialization failed + txBuffer.clear(); + return (_host.get_ip_address() == nullptr && _host.get_port() == 0) ? 0 : 1; +} + +int arduino::MbedUDP::beginPacket(const char *host, uint16_t port) { + _host = SocketAddress(host, port); + txBuffer.clear(); + getNetwork()->gethostbyname(host, &_host); + //If IP is null and port is 0 the initialization failed + return (_host.get_ip_address() == nullptr && _host.get_port() == 0) ? 0 : 1; +} + +int arduino::MbedUDP::endPacket() { + _socket.set_blocking(true); + _socket.set_timeout(1000); + + size_t size = txBuffer.available(); + uint8_t buffer[size]; + for (int i = 0; i < size; i++) { + buffer[i] = txBuffer.read_char(); + } + + nsapi_size_or_error_t ret = _socket.sendto(_host, buffer, size); + _socket.set_blocking(false); + _socket.set_timeout(0); + if (ret < 0) { + return 0; + } + return size; +} + +// Write a single byte into the packet +size_t arduino::MbedUDP::write(uint8_t byte) { + return write(&byte, 1); +} + +// Write size bytes from buffer into the packet +size_t arduino::MbedUDP::write(const uint8_t *buffer, size_t size) { + for (int i = 0; i _packet_buffer + _current_packet_size) { + // try reading the next packet... + if (parsePacket() > 0) { + // if so, read first byte of next packet; + return read(); + } else { + // no new data... not sure what to return here now + return -1; + } + } + + return _current_packet[0]; +} + +// Read up to len bytes from the current packet and place them into buffer +// Returns the number of bytes read, or 0 if none are available +int arduino::MbedUDP::read(unsigned char *buffer, size_t len) { + // Q: does Arduino read() function handle fragmentation? I won't for now... + if (_current_packet == NULL) { + if (parsePacket() == 0) return 0; + } + + // how much data do we have in the current packet? + int offset = _current_packet - _packet_buffer; + if (offset < 0) { + return 0; + } + + int max_bytes = _current_packet_size - offset; + if (max_bytes < 0) { + return 0; + } + + // at the end of the packet? + if (max_bytes == 0) { + // try read next packet... + if (parsePacket() > 0) { + return read(buffer, len); + } else { + return 0; + } + } + + if (len > (size_t)max_bytes) len = max_bytes; + + // copy to target buffer + memcpy(buffer, _current_packet, len); + + _current_packet += len; + + return len; +} + +IPAddress arduino::MbedUDP::remoteIP() { + nsapi_addr_t address = _remoteHost.get_addr(); + return IPAddress(address.bytes[0], address.bytes[1], address.bytes[2], address.bytes[3]); +} + +uint16_t arduino::MbedUDP::remotePort() { + return _remoteHost.get_port(); +} + +void arduino::MbedUDP::flush() { + // TODO: a real check to ensure transmission has been completed +} + +int arduino::MbedUDP::peek() { + if (_current_packet_size < 1) { + return -1; + } + + return _current_packet[0]; +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.5.2/libraries/SocketWrapper/src/MbedUdp.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.5.2/libraries/SocketWrapper/src/MbedUdp.h new file mode 100644 index 0000000..7f81ede --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.5.2/libraries/SocketWrapper/src/MbedUdp.h @@ -0,0 +1,105 @@ +/* + MbedUdp.h - UDP implementation using mbed Sockets + Copyright (c) 2021 Arduino SA. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef MBEDUDP_H +#define MBEDUDP_H + +#include "Arduino.h" +#include "SocketHelpers.h" +#include "api/Udp.h" + +#include "netsocket/SocketAddress.h" +#include "netsocket/UDPSocket.h" + +#ifndef WIFI_UDP_BUFFER_SIZE +#define WIFI_UDP_BUFFER_SIZE 508 +#endif + +namespace arduino { + +class MbedUDP : public UDP { +private: + UDPSocket _socket; // Mbed OS socket + SocketAddress _host; // Host to be used to send data + SocketAddress _remoteHost; // Remote host that sent incoming packets + + uint8_t* _packet_buffer; // Raw packet buffer (contains data we got from the UDPSocket) + + // The Arduino APIs allow you to iterate through this buffer, so we need to be able to iterate over the current packet + // these two variables are used to cache the state of the current packet + uint8_t* _current_packet; + size_t _current_packet_size; + + RingBufferN txBuffer; + +protected: + virtual NetworkInterface* getNetwork() = 0; + +public: + MbedUDP(); // Constructor + ~MbedUDP(); + virtual uint8_t begin(uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual uint8_t beginMulticast(IPAddress, uint16_t); // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 if there are no sockets available to use + virtual void stop(); // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port); + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char* host, uint16_t port); + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket(); + // Write a single byte into the packet + virtual size_t write(uint8_t); + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t* buffer, size_t size); + + using Print::write; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket(); + // Number of bytes remaining in the current packet + virtual int available(); + // Read a single byte from the current packet + virtual int read(); + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len); + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) { + return read((unsigned char*)buffer, len); + }; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek(); + virtual void flush(); // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP(); + // // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort(); + + friend class MbedSocketClass; +}; + +} + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.5.2/portenta_post_install.sh b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.5.2/portenta_post_install.sh new file mode 100644 index 0000000..7fe71d6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.5.2/portenta_post_install.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +portenta_h7_rules () { + echo "" + echo "# Portenta H7 bootloader mode UDEV rules" + echo "" +cat < /etc/udev/rules.d/49-portenta_h7.rules + +# reload udev rules +echo "Reload rules..." +udevadm trigger +udevadm control --reload-rules diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h new file mode 100644 index 0000000..84c18cf --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h @@ -0,0 +1,347 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef LWIPOPTS_H +#define LWIPOPTS_H + +// Workaround for Linux timeval +#if defined (TOOLCHAIN_GCC) +#define LWIP_TIMEVAL_PRIVATE 0 +#include +#endif +#include "nsapi_types.h" +#include "mbed_retarget.h" + +// KH fix +#include +///////////////////////// + +// Operating System +#define NO_SYS 0 + +#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED +#error "Either IPv4 or IPv6 must be enabled." +#endif + +#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED + +#define LWIP_IPV6 MBED_CONF_LWIP_IPV6_ENABLED + +#define LWIP_PROVIDE_ERRNO 0 + +// On dual stack configuration how long to wait for both or preferred stack +// addresses before completing bring up. +#if LWIP_IPV4 && LWIP_IPV6 +#if MBED_CONF_LWIP_ADDR_TIMEOUT_MODE +#define BOTH_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define PREF_ADDR_TIMEOUT 0 +#else +#define PREF_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define BOTH_ADDR_TIMEOUT 0 +#endif +#else +#define PREF_ADDR_TIMEOUT 0 +#define BOTH_ADDR_TIMEOUT 0 +#endif + + +#define DHCP_TIMEOUT MBED_CONF_LWIP_DHCP_TIMEOUT + +#define LINK_TIMEOUT 60 + +#define PREF_IPV4 1 +#define PREF_IPV6 2 + +#if MBED_CONF_LWIP_IP_VER_PREF == 6 +#define IP_VERSION_PREF PREF_IPV6 +#elif MBED_CONF_LWIP_IP_VER_PREF == 4 +#define IP_VERSION_PREF PREF_IPV4 +#else +#error "Either IPv4 or IPv6 must be preferred." +#endif + +#undef LWIP_DEBUG +#if MBED_CONF_LWIP_DEBUG_ENABLED +#define LWIP_DEBUG 1 +#endif + +#if NO_SYS == 0 +#include "cmsis_os2.h" + +#define SYS_LIGHTWEIGHT_PROT 1 + +#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED + +#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT + +// Thread stacks use 8-byte alignment +#define LWIP_ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos)) + +#ifdef LWIP_DEBUG +// For LWIP debug, double the stack +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2, 8) +#elif MBED_DEBUG +// When debug is enabled on the build increase stack 25 percent +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE + MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE / 4, 8) +#else +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE, 8) +#endif + +// Thread priority (osPriorityNormal by default) +#define TCPIP_THREAD_PRIO (MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY) + +#ifdef LWIP_DEBUG +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2, 8) +#else +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE, 8) +#endif + +#define MEMP_NUM_SYS_TIMEOUT 16 + +#define sys_msleep(ms) sys_msleep(ms) + +#endif + +// 32-bit alignment +#define MEM_ALIGNMENT 4 + +#define LWIP_RAM_HEAP_POINTER lwip_ram_heap + +// Number of simultaneously queued TCP segments. +#define MEMP_NUM_TCP_SEG MBED_CONF_LWIP_MEMP_NUM_TCP_SEG + +// TCP Maximum segment size. +#define TCP_MSS MBED_CONF_LWIP_TCP_MSS + +// TCP sender buffer space (bytes). +#define TCP_SND_BUF MBED_CONF_LWIP_TCP_SND_BUF + +// TCP sender buffer space (bytes). +#define TCP_WND MBED_CONF_LWIP_TCP_WND + +#define TCP_MAXRTX MBED_CONF_LWIP_TCP_MAXRTX + +#define TCP_SYNMAXRTX MBED_CONF_LWIP_TCP_SYNMAXRTX + +// Number of pool pbufs. +// Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS) +#define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE + +#ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE +#undef PBUF_POOL_BUFSIZE +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(MBED_CONF_LWIP_PBUF_POOL_BUFSIZE) +#else +#ifndef PBUF_POOL_BUFSIZE +#if LWIP_IPV6 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#elif LWIP_IPV4 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+20+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#endif +#endif +#endif + +#define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE + +// One tcp_pcb_listen is needed for each TCP server. +// Each requires 72 bytes of RAM. +#define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX + +// One is tcp_pcb needed for each TCPSocket. +// Each requires 196 bytes of RAM. +#define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX + +// One udp_pcb is needed for each UDPSocket. +// Each requires 84 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX + +// Number of non-pool pbufs. +// Each requires 92 bytes of RAM. +#define MEMP_NUM_PBUF MBED_CONF_LWIP_NUM_PBUF + +// Each netbuf requires 64 bytes of RAM. +#define MEMP_NUM_NETBUF MBED_CONF_LWIP_NUM_NETBUF + +// One netconn is needed for each UDPSocket or TCPSocket. +// Each requires 236 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX + +#if MBED_CONF_LWIP_TCP_ENABLED +#define LWIP_TCP 1 +#define TCP_OVERSIZE 0 +#define LWIP_TCP_KEEPALIVE 1 + +#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT + +#else +#define LWIP_TCP 0 +#endif + +#define LWIP_DNS 1 +// Only DNS address storage is enabled +#define LWIP_FULL_DNS 0 +#define LWIP_SOCKET 0 + +#define SO_REUSE 1 + +// Support Multicast +#include "stdlib.h" +#define LWIP_IGMP LWIP_IPV4 +#define LWIP_RAND() lwip_get_random() + +#define LWIP_COMPAT_SOCKETS 0 +#define LWIP_POSIX_SOCKETS_IO_NAMES 0 + +#define LWIP_BROADCAST_PING 1 + +// Fragmentation on, as per IPv4 default +#define LWIP_IPV6_FRAG LWIP_IPV6 + +// Queuing, default is "disabled", as per IPv4 default (so actually queues 1) +#define LWIP_ND6_QUEUEING MBED_CONF_ND6_QUEUEING + +// Debug Options +#define NETIF_DEBUG LWIP_DBG_OFF +#define PBUF_DEBUG LWIP_DBG_OFF +#define API_LIB_DEBUG LWIP_DBG_OFF +#define API_MSG_DEBUG LWIP_DBG_OFF +#define SOCKETS_DEBUG LWIP_DBG_OFF +#define ICMP_DEBUG LWIP_DBG_OFF +#define IGMP_DEBUG LWIP_DBG_OFF +#define INET_DEBUG LWIP_DBG_OFF +#define IP_DEBUG LWIP_DBG_OFF +#define IP_REASS_DEBUG LWIP_DBG_OFF +#define RAW_DEBUG LWIP_DBG_OFF +#define MEM_DEBUG LWIP_DBG_OFF +#define MEMP_DEBUG LWIP_DBG_OFF +#define SYS_DEBUG LWIP_DBG_OFF +#define TIMERS_DEBUG LWIP_DBG_OFF +#define TCP_DEBUG LWIP_DBG_OFF +#define TCP_INPUT_DEBUG LWIP_DBG_OFF +#define TCP_FR_DEBUG LWIP_DBG_OFF +#define TCP_RTO_DEBUG LWIP_DBG_OFF +#define TCP_CWND_DEBUG LWIP_DBG_OFF +#define TCP_WND_DEBUG LWIP_DBG_OFF +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF +#define TCP_RST_DEBUG LWIP_DBG_OFF +#define TCP_QLEN_DEBUG LWIP_DBG_OFF +#define UDP_DEBUG LWIP_DBG_OFF +#define TCPIP_DEBUG LWIP_DBG_OFF +#define SLIP_DEBUG LWIP_DBG_OFF +#define DHCP_DEBUG LWIP_DBG_OFF +#define AUTOIP_DEBUG LWIP_DBG_OFF +#define DNS_DEBUG LWIP_DBG_OFF +#define IP6_DEBUG LWIP_DBG_OFF + +#define ETHARP_DEBUG LWIP_DBG_OFF +#define UDP_LPC_EMAC LWIP_DBG_OFF + +#ifdef LWIP_DEBUG +#define MEMP_OVERFLOW_CHECK 1 +#define MEMP_SANITY_CHECK 1 +#define LWIP_DBG_TYPES_ON LWIP_DBG_ON +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL +#else +#define LWIP_NOASSERT 1 +#define LWIP_STATS 0 +#endif + +#define TRACE_TO_ASCII_HEX_DUMP 0 + +#define LWIP_PLATFORM_BYTESWAP 1 + +#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 + +// Interface type configuration + +#if MBED_CONF_LWIP_ETHERNET_ENABLED +#define LWIP_ARP 1 +#define LWIP_ETHERNET 1 +#define LWIP_DHCP LWIP_IPV4 +#else +#define LWIP_ARP 0 +#define LWIP_ETHERNET 0 +#endif // MBED_CONF_LWIP_ETHERNET_ENABLED + +#if MBED_CONF_LWIP_L3IP_ENABLED +#define LWIP_L3IP 1 +#else +#define LWIP_L3IP 0 +#endif + +//Maximum size of network interface name +#define INTERFACE_NAME_MAX_SIZE NSAPI_INTERFACE_NAME_MAX_SIZE +// Note generic macro name used rather than MBED_CONF_LWIP_PPP_ENABLED +// to allow users like PPPCellularInterface to detect that nsapi_ppp.h is available. + +// Enable PPP for now either from lwIP PPP configuration (obsolete) or from PPP service configuration +#if MBED_CONF_PPP_ENABLED || MBED_CONF_LWIP_PPP_ENABLED + +#define PPP_SUPPORT 1 + +#if MBED_CONF_PPP_IPV4_ENABLED || MBED_CONF_LWIP_IPV4_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV4_ENABLED +#error LWIP: IPv4 PPP enabled but not IPv4 +#endif +#undef LWIP +#define PPP_IPV4_SUPPORT 1 +#endif + +#if MBED_CONF_PPP_IPV6_ENABLED || MBED_CONF_LWIP_IPV6_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV6_ENABLED +#error LWIP: IPv6 PPP enabled but not IPv6 +#endif +#undef LWIP +#define PPP_IPV6_SUPPORT 1 +// Later to be dynamic for use for multiple interfaces +#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0 +#endif + +#endif + +#define LWIP_NETBUF_RECVINFO MBED_CONF_LWIP_NETBUF_RECVINFO_ENABLED + +// Make sure we default these to off, so +// LWIP doesn't default to on +#ifndef LWIP_ARP +#define LWIP_ARP 0 +#endif + +// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914 +#define LWIP_CHECKSUM_ON_COPY 0 + +#define LWIP_NETIF_HOSTNAME 1 +#define LWIP_NETIF_STATUS_CALLBACK 1 +#define LWIP_NETIF_LINK_CALLBACK 1 + +#define DNS_TABLE_SIZE 2 +#define DNS_MAX_NAME_LENGTH 128 + +#include "lwip_random.h" +#include "lwip_tcp_isn.h" +#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn +#ifdef MBEDTLS_MD5_C +#define LWIP_USE_EXTERNAL_MBEDTLS 1 +#else +#define LWIP_USE_EXTERNAL_MBEDTLS 0 +#endif + +#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS + +#endif /* LWIPOPTS_H_ */ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/libraries/SocketWrapper/src/MbedUdp.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/libraries/SocketWrapper/src/MbedUdp.cpp new file mode 100644 index 0000000..2a1b0fc --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/libraries/SocketWrapper/src/MbedUdp.cpp @@ -0,0 +1,217 @@ +#include "MbedUdp.h" + +arduino::MbedUDP::MbedUDP() { + _packet_buffer = new uint8_t[WIFI_UDP_BUFFER_SIZE]; + _current_packet = NULL; + _current_packet_size = 0; + // if this allocation fails then ::begin will fail +} + +arduino::MbedUDP::~MbedUDP() { + delete[] _packet_buffer; +} + +uint8_t arduino::MbedUDP::begin(uint16_t port) { + // success = 1, fail = 0 + + nsapi_error_t rt = _socket.open(getNetwork()); + if (rt != NSAPI_ERROR_OK) { + return 0; + } + + if (_socket.bind(port) < 0) { + return 0; //Failed to bind UDP Socket to port + } + + if (!_packet_buffer) { + return 0; + } + + _socket.set_blocking(false); + _socket.set_timeout(0); + + return 1; +} + +uint8_t arduino::MbedUDP::beginMulticast(IPAddress ip, uint16_t port) { + // success = 1, fail = 0 + if (begin(port) != 1) { + return 0; + } + + SocketAddress socketAddress = SocketHelpers::socketAddressFromIpAddress(ip, port); + + if (_socket.join_multicast_group(socketAddress) != NSAPI_ERROR_OK) { + printf("Error joining the multicast group\n"); + return 0; + } + + return 1; +} + +void arduino::MbedUDP::stop() { + _socket.close(); +} + +int arduino::MbedUDP::beginPacket(IPAddress ip, uint16_t port) { + _host = SocketHelpers::socketAddressFromIpAddress(ip, port); + //If IP is null and port is 0 the initialization failed + txBuffer.clear(); + return (_host.get_ip_address() == nullptr && _host.get_port() == 0) ? 0 : 1; +} + +int arduino::MbedUDP::beginPacket(const char *host, uint16_t port) { + _host = SocketAddress(host, port); + txBuffer.clear(); + getNetwork()->gethostbyname(host, &_host); + //If IP is null and port is 0 the initialization failed + return (_host.get_ip_address() == nullptr && _host.get_port() == 0) ? 0 : 1; +} + +int arduino::MbedUDP::endPacket() { + _socket.set_blocking(true); + _socket.set_timeout(1000); + + size_t size = txBuffer.available(); + uint8_t buffer[size]; + for (int i = 0; i < size; i++) { + buffer[i] = txBuffer.read_char(); + } + + nsapi_size_or_error_t ret = _socket.sendto(_host, buffer, size); + _socket.set_blocking(false); + _socket.set_timeout(0); + if (ret < 0) { + return 0; + } + return size; +} + +// Write a single byte into the packet +size_t arduino::MbedUDP::write(uint8_t byte) { + return write(&byte, 1); +} + +// Write size bytes from buffer into the packet +size_t arduino::MbedUDP::write(const uint8_t *buffer, size_t size) { + for (int i = 0; i _packet_buffer + _current_packet_size) { + // try reading the next packet... + if (parsePacket() > 0) { + // if so, read first byte of next packet; + return read(); + } else { + // no new data... not sure what to return here now + return -1; + } + } + + return _current_packet[0]; +} + +// Read up to len bytes from the current packet and place them into buffer +// Returns the number of bytes read, or 0 if none are available +int arduino::MbedUDP::read(unsigned char *buffer, size_t len) { + // Q: does Arduino read() function handle fragmentation? I won't for now... + if (_current_packet == NULL) { + if (parsePacket() == 0) return 0; + } + + // how much data do we have in the current packet? + int offset = _current_packet - _packet_buffer; + if (offset < 0) { + return 0; + } + + int max_bytes = _current_packet_size - offset; + if (max_bytes < 0) { + return 0; + } + + // at the end of the packet? + if (max_bytes == 0) { + // try read next packet... + if (parsePacket() > 0) { + return read(buffer, len); + } else { + return 0; + } + } + + if (len > (size_t)max_bytes) len = max_bytes; + + // copy to target buffer + memcpy(buffer, _current_packet, len); + + _current_packet += len; + + return len; +} + +IPAddress arduino::MbedUDP::remoteIP() { + nsapi_addr_t address = _remoteHost.get_addr(); + return IPAddress(address.bytes[0], address.bytes[1], address.bytes[2], address.bytes[3]); +} + +uint16_t arduino::MbedUDP::remotePort() { + return _remoteHost.get_port(); +} + +void arduino::MbedUDP::flush() { + // TODO: a real check to ensure transmission has been completed +} + +int arduino::MbedUDP::peek() { + if (_current_packet_size < 1) { + return -1; + } + + return _current_packet[0]; +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/libraries/SocketWrapper/src/MbedUdp.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/libraries/SocketWrapper/src/MbedUdp.h new file mode 100644 index 0000000..7f81ede --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/libraries/SocketWrapper/src/MbedUdp.h @@ -0,0 +1,105 @@ +/* + MbedUdp.h - UDP implementation using mbed Sockets + Copyright (c) 2021 Arduino SA. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef MBEDUDP_H +#define MBEDUDP_H + +#include "Arduino.h" +#include "SocketHelpers.h" +#include "api/Udp.h" + +#include "netsocket/SocketAddress.h" +#include "netsocket/UDPSocket.h" + +#ifndef WIFI_UDP_BUFFER_SIZE +#define WIFI_UDP_BUFFER_SIZE 508 +#endif + +namespace arduino { + +class MbedUDP : public UDP { +private: + UDPSocket _socket; // Mbed OS socket + SocketAddress _host; // Host to be used to send data + SocketAddress _remoteHost; // Remote host that sent incoming packets + + uint8_t* _packet_buffer; // Raw packet buffer (contains data we got from the UDPSocket) + + // The Arduino APIs allow you to iterate through this buffer, so we need to be able to iterate over the current packet + // these two variables are used to cache the state of the current packet + uint8_t* _current_packet; + size_t _current_packet_size; + + RingBufferN txBuffer; + +protected: + virtual NetworkInterface* getNetwork() = 0; + +public: + MbedUDP(); // Constructor + ~MbedUDP(); + virtual uint8_t begin(uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual uint8_t beginMulticast(IPAddress, uint16_t); // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 if there are no sockets available to use + virtual void stop(); // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port); + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char* host, uint16_t port); + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket(); + // Write a single byte into the packet + virtual size_t write(uint8_t); + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t* buffer, size_t size); + + using Print::write; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket(); + // Number of bytes remaining in the current packet + virtual int available(); + // Read a single byte from the current packet + virtual int read(); + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len); + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) { + return read((unsigned char*)buffer, len); + }; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek(); + virtual void flush(); // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP(); + // // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort(); + + friend class MbedSocketClass; +}; + +} + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/portenta_post_install.sh b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/portenta_post_install.sh new file mode 100644 index 0000000..7fe71d6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/portenta_post_install.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +portenta_h7_rules () { + echo "" + echo "# Portenta H7 bootloader mode UDEV rules" + echo "" +cat < /etc/udev/rules.d/49-portenta_h7.rules + +# reload udev rules +echo "Reload rules..." +udevadm trigger +udevadm control --reload-rules diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.7.2/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.7.2/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h new file mode 100644 index 0000000..84c18cf --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.7.2/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h @@ -0,0 +1,347 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef LWIPOPTS_H +#define LWIPOPTS_H + +// Workaround for Linux timeval +#if defined (TOOLCHAIN_GCC) +#define LWIP_TIMEVAL_PRIVATE 0 +#include +#endif +#include "nsapi_types.h" +#include "mbed_retarget.h" + +// KH fix +#include +///////////////////////// + +// Operating System +#define NO_SYS 0 + +#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED +#error "Either IPv4 or IPv6 must be enabled." +#endif + +#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED + +#define LWIP_IPV6 MBED_CONF_LWIP_IPV6_ENABLED + +#define LWIP_PROVIDE_ERRNO 0 + +// On dual stack configuration how long to wait for both or preferred stack +// addresses before completing bring up. +#if LWIP_IPV4 && LWIP_IPV6 +#if MBED_CONF_LWIP_ADDR_TIMEOUT_MODE +#define BOTH_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define PREF_ADDR_TIMEOUT 0 +#else +#define PREF_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define BOTH_ADDR_TIMEOUT 0 +#endif +#else +#define PREF_ADDR_TIMEOUT 0 +#define BOTH_ADDR_TIMEOUT 0 +#endif + + +#define DHCP_TIMEOUT MBED_CONF_LWIP_DHCP_TIMEOUT + +#define LINK_TIMEOUT 60 + +#define PREF_IPV4 1 +#define PREF_IPV6 2 + +#if MBED_CONF_LWIP_IP_VER_PREF == 6 +#define IP_VERSION_PREF PREF_IPV6 +#elif MBED_CONF_LWIP_IP_VER_PREF == 4 +#define IP_VERSION_PREF PREF_IPV4 +#else +#error "Either IPv4 or IPv6 must be preferred." +#endif + +#undef LWIP_DEBUG +#if MBED_CONF_LWIP_DEBUG_ENABLED +#define LWIP_DEBUG 1 +#endif + +#if NO_SYS == 0 +#include "cmsis_os2.h" + +#define SYS_LIGHTWEIGHT_PROT 1 + +#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED + +#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT + +// Thread stacks use 8-byte alignment +#define LWIP_ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos)) + +#ifdef LWIP_DEBUG +// For LWIP debug, double the stack +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2, 8) +#elif MBED_DEBUG +// When debug is enabled on the build increase stack 25 percent +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE + MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE / 4, 8) +#else +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE, 8) +#endif + +// Thread priority (osPriorityNormal by default) +#define TCPIP_THREAD_PRIO (MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY) + +#ifdef LWIP_DEBUG +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2, 8) +#else +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE, 8) +#endif + +#define MEMP_NUM_SYS_TIMEOUT 16 + +#define sys_msleep(ms) sys_msleep(ms) + +#endif + +// 32-bit alignment +#define MEM_ALIGNMENT 4 + +#define LWIP_RAM_HEAP_POINTER lwip_ram_heap + +// Number of simultaneously queued TCP segments. +#define MEMP_NUM_TCP_SEG MBED_CONF_LWIP_MEMP_NUM_TCP_SEG + +// TCP Maximum segment size. +#define TCP_MSS MBED_CONF_LWIP_TCP_MSS + +// TCP sender buffer space (bytes). +#define TCP_SND_BUF MBED_CONF_LWIP_TCP_SND_BUF + +// TCP sender buffer space (bytes). +#define TCP_WND MBED_CONF_LWIP_TCP_WND + +#define TCP_MAXRTX MBED_CONF_LWIP_TCP_MAXRTX + +#define TCP_SYNMAXRTX MBED_CONF_LWIP_TCP_SYNMAXRTX + +// Number of pool pbufs. +// Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS) +#define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE + +#ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE +#undef PBUF_POOL_BUFSIZE +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(MBED_CONF_LWIP_PBUF_POOL_BUFSIZE) +#else +#ifndef PBUF_POOL_BUFSIZE +#if LWIP_IPV6 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#elif LWIP_IPV4 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+20+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#endif +#endif +#endif + +#define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE + +// One tcp_pcb_listen is needed for each TCP server. +// Each requires 72 bytes of RAM. +#define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX + +// One is tcp_pcb needed for each TCPSocket. +// Each requires 196 bytes of RAM. +#define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX + +// One udp_pcb is needed for each UDPSocket. +// Each requires 84 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX + +// Number of non-pool pbufs. +// Each requires 92 bytes of RAM. +#define MEMP_NUM_PBUF MBED_CONF_LWIP_NUM_PBUF + +// Each netbuf requires 64 bytes of RAM. +#define MEMP_NUM_NETBUF MBED_CONF_LWIP_NUM_NETBUF + +// One netconn is needed for each UDPSocket or TCPSocket. +// Each requires 236 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX + +#if MBED_CONF_LWIP_TCP_ENABLED +#define LWIP_TCP 1 +#define TCP_OVERSIZE 0 +#define LWIP_TCP_KEEPALIVE 1 + +#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT + +#else +#define LWIP_TCP 0 +#endif + +#define LWIP_DNS 1 +// Only DNS address storage is enabled +#define LWIP_FULL_DNS 0 +#define LWIP_SOCKET 0 + +#define SO_REUSE 1 + +// Support Multicast +#include "stdlib.h" +#define LWIP_IGMP LWIP_IPV4 +#define LWIP_RAND() lwip_get_random() + +#define LWIP_COMPAT_SOCKETS 0 +#define LWIP_POSIX_SOCKETS_IO_NAMES 0 + +#define LWIP_BROADCAST_PING 1 + +// Fragmentation on, as per IPv4 default +#define LWIP_IPV6_FRAG LWIP_IPV6 + +// Queuing, default is "disabled", as per IPv4 default (so actually queues 1) +#define LWIP_ND6_QUEUEING MBED_CONF_ND6_QUEUEING + +// Debug Options +#define NETIF_DEBUG LWIP_DBG_OFF +#define PBUF_DEBUG LWIP_DBG_OFF +#define API_LIB_DEBUG LWIP_DBG_OFF +#define API_MSG_DEBUG LWIP_DBG_OFF +#define SOCKETS_DEBUG LWIP_DBG_OFF +#define ICMP_DEBUG LWIP_DBG_OFF +#define IGMP_DEBUG LWIP_DBG_OFF +#define INET_DEBUG LWIP_DBG_OFF +#define IP_DEBUG LWIP_DBG_OFF +#define IP_REASS_DEBUG LWIP_DBG_OFF +#define RAW_DEBUG LWIP_DBG_OFF +#define MEM_DEBUG LWIP_DBG_OFF +#define MEMP_DEBUG LWIP_DBG_OFF +#define SYS_DEBUG LWIP_DBG_OFF +#define TIMERS_DEBUG LWIP_DBG_OFF +#define TCP_DEBUG LWIP_DBG_OFF +#define TCP_INPUT_DEBUG LWIP_DBG_OFF +#define TCP_FR_DEBUG LWIP_DBG_OFF +#define TCP_RTO_DEBUG LWIP_DBG_OFF +#define TCP_CWND_DEBUG LWIP_DBG_OFF +#define TCP_WND_DEBUG LWIP_DBG_OFF +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF +#define TCP_RST_DEBUG LWIP_DBG_OFF +#define TCP_QLEN_DEBUG LWIP_DBG_OFF +#define UDP_DEBUG LWIP_DBG_OFF +#define TCPIP_DEBUG LWIP_DBG_OFF +#define SLIP_DEBUG LWIP_DBG_OFF +#define DHCP_DEBUG LWIP_DBG_OFF +#define AUTOIP_DEBUG LWIP_DBG_OFF +#define DNS_DEBUG LWIP_DBG_OFF +#define IP6_DEBUG LWIP_DBG_OFF + +#define ETHARP_DEBUG LWIP_DBG_OFF +#define UDP_LPC_EMAC LWIP_DBG_OFF + +#ifdef LWIP_DEBUG +#define MEMP_OVERFLOW_CHECK 1 +#define MEMP_SANITY_CHECK 1 +#define LWIP_DBG_TYPES_ON LWIP_DBG_ON +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL +#else +#define LWIP_NOASSERT 1 +#define LWIP_STATS 0 +#endif + +#define TRACE_TO_ASCII_HEX_DUMP 0 + +#define LWIP_PLATFORM_BYTESWAP 1 + +#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 + +// Interface type configuration + +#if MBED_CONF_LWIP_ETHERNET_ENABLED +#define LWIP_ARP 1 +#define LWIP_ETHERNET 1 +#define LWIP_DHCP LWIP_IPV4 +#else +#define LWIP_ARP 0 +#define LWIP_ETHERNET 0 +#endif // MBED_CONF_LWIP_ETHERNET_ENABLED + +#if MBED_CONF_LWIP_L3IP_ENABLED +#define LWIP_L3IP 1 +#else +#define LWIP_L3IP 0 +#endif + +//Maximum size of network interface name +#define INTERFACE_NAME_MAX_SIZE NSAPI_INTERFACE_NAME_MAX_SIZE +// Note generic macro name used rather than MBED_CONF_LWIP_PPP_ENABLED +// to allow users like PPPCellularInterface to detect that nsapi_ppp.h is available. + +// Enable PPP for now either from lwIP PPP configuration (obsolete) or from PPP service configuration +#if MBED_CONF_PPP_ENABLED || MBED_CONF_LWIP_PPP_ENABLED + +#define PPP_SUPPORT 1 + +#if MBED_CONF_PPP_IPV4_ENABLED || MBED_CONF_LWIP_IPV4_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV4_ENABLED +#error LWIP: IPv4 PPP enabled but not IPv4 +#endif +#undef LWIP +#define PPP_IPV4_SUPPORT 1 +#endif + +#if MBED_CONF_PPP_IPV6_ENABLED || MBED_CONF_LWIP_IPV6_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV6_ENABLED +#error LWIP: IPv6 PPP enabled but not IPv6 +#endif +#undef LWIP +#define PPP_IPV6_SUPPORT 1 +// Later to be dynamic for use for multiple interfaces +#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0 +#endif + +#endif + +#define LWIP_NETBUF_RECVINFO MBED_CONF_LWIP_NETBUF_RECVINFO_ENABLED + +// Make sure we default these to off, so +// LWIP doesn't default to on +#ifndef LWIP_ARP +#define LWIP_ARP 0 +#endif + +// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914 +#define LWIP_CHECKSUM_ON_COPY 0 + +#define LWIP_NETIF_HOSTNAME 1 +#define LWIP_NETIF_STATUS_CALLBACK 1 +#define LWIP_NETIF_LINK_CALLBACK 1 + +#define DNS_TABLE_SIZE 2 +#define DNS_MAX_NAME_LENGTH 128 + +#include "lwip_random.h" +#include "lwip_tcp_isn.h" +#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn +#ifdef MBEDTLS_MD5_C +#define LWIP_USE_EXTERNAL_MBEDTLS 1 +#else +#define LWIP_USE_EXTERNAL_MBEDTLS 0 +#endif + +#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS + +#endif /* LWIPOPTS_H_ */ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.7.2/portenta_post_install.sh b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.7.2/portenta_post_install.sh new file mode 100644 index 0000000..7fe71d6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.7.2/portenta_post_install.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +portenta_h7_rules () { + echo "" + echo "# Portenta H7 bootloader mode UDEV rules" + echo "" +cat < /etc/udev/rules.d/49-portenta_h7.rules + +# reload udev rules +echo "Reload rules..." +udevadm trigger +udevadm control --reload-rules diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.8.0/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.8.0/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h new file mode 100644 index 0000000..84c18cf --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.8.0/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h @@ -0,0 +1,347 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef LWIPOPTS_H +#define LWIPOPTS_H + +// Workaround for Linux timeval +#if defined (TOOLCHAIN_GCC) +#define LWIP_TIMEVAL_PRIVATE 0 +#include +#endif +#include "nsapi_types.h" +#include "mbed_retarget.h" + +// KH fix +#include +///////////////////////// + +// Operating System +#define NO_SYS 0 + +#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED +#error "Either IPv4 or IPv6 must be enabled." +#endif + +#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED + +#define LWIP_IPV6 MBED_CONF_LWIP_IPV6_ENABLED + +#define LWIP_PROVIDE_ERRNO 0 + +// On dual stack configuration how long to wait for both or preferred stack +// addresses before completing bring up. +#if LWIP_IPV4 && LWIP_IPV6 +#if MBED_CONF_LWIP_ADDR_TIMEOUT_MODE +#define BOTH_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define PREF_ADDR_TIMEOUT 0 +#else +#define PREF_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define BOTH_ADDR_TIMEOUT 0 +#endif +#else +#define PREF_ADDR_TIMEOUT 0 +#define BOTH_ADDR_TIMEOUT 0 +#endif + + +#define DHCP_TIMEOUT MBED_CONF_LWIP_DHCP_TIMEOUT + +#define LINK_TIMEOUT 60 + +#define PREF_IPV4 1 +#define PREF_IPV6 2 + +#if MBED_CONF_LWIP_IP_VER_PREF == 6 +#define IP_VERSION_PREF PREF_IPV6 +#elif MBED_CONF_LWIP_IP_VER_PREF == 4 +#define IP_VERSION_PREF PREF_IPV4 +#else +#error "Either IPv4 or IPv6 must be preferred." +#endif + +#undef LWIP_DEBUG +#if MBED_CONF_LWIP_DEBUG_ENABLED +#define LWIP_DEBUG 1 +#endif + +#if NO_SYS == 0 +#include "cmsis_os2.h" + +#define SYS_LIGHTWEIGHT_PROT 1 + +#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED + +#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT + +// Thread stacks use 8-byte alignment +#define LWIP_ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos)) + +#ifdef LWIP_DEBUG +// For LWIP debug, double the stack +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2, 8) +#elif MBED_DEBUG +// When debug is enabled on the build increase stack 25 percent +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE + MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE / 4, 8) +#else +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE, 8) +#endif + +// Thread priority (osPriorityNormal by default) +#define TCPIP_THREAD_PRIO (MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY) + +#ifdef LWIP_DEBUG +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2, 8) +#else +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE, 8) +#endif + +#define MEMP_NUM_SYS_TIMEOUT 16 + +#define sys_msleep(ms) sys_msleep(ms) + +#endif + +// 32-bit alignment +#define MEM_ALIGNMENT 4 + +#define LWIP_RAM_HEAP_POINTER lwip_ram_heap + +// Number of simultaneously queued TCP segments. +#define MEMP_NUM_TCP_SEG MBED_CONF_LWIP_MEMP_NUM_TCP_SEG + +// TCP Maximum segment size. +#define TCP_MSS MBED_CONF_LWIP_TCP_MSS + +// TCP sender buffer space (bytes). +#define TCP_SND_BUF MBED_CONF_LWIP_TCP_SND_BUF + +// TCP sender buffer space (bytes). +#define TCP_WND MBED_CONF_LWIP_TCP_WND + +#define TCP_MAXRTX MBED_CONF_LWIP_TCP_MAXRTX + +#define TCP_SYNMAXRTX MBED_CONF_LWIP_TCP_SYNMAXRTX + +// Number of pool pbufs. +// Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS) +#define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE + +#ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE +#undef PBUF_POOL_BUFSIZE +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(MBED_CONF_LWIP_PBUF_POOL_BUFSIZE) +#else +#ifndef PBUF_POOL_BUFSIZE +#if LWIP_IPV6 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#elif LWIP_IPV4 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+20+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#endif +#endif +#endif + +#define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE + +// One tcp_pcb_listen is needed for each TCP server. +// Each requires 72 bytes of RAM. +#define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX + +// One is tcp_pcb needed for each TCPSocket. +// Each requires 196 bytes of RAM. +#define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX + +// One udp_pcb is needed for each UDPSocket. +// Each requires 84 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX + +// Number of non-pool pbufs. +// Each requires 92 bytes of RAM. +#define MEMP_NUM_PBUF MBED_CONF_LWIP_NUM_PBUF + +// Each netbuf requires 64 bytes of RAM. +#define MEMP_NUM_NETBUF MBED_CONF_LWIP_NUM_NETBUF + +// One netconn is needed for each UDPSocket or TCPSocket. +// Each requires 236 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX + +#if MBED_CONF_LWIP_TCP_ENABLED +#define LWIP_TCP 1 +#define TCP_OVERSIZE 0 +#define LWIP_TCP_KEEPALIVE 1 + +#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT + +#else +#define LWIP_TCP 0 +#endif + +#define LWIP_DNS 1 +// Only DNS address storage is enabled +#define LWIP_FULL_DNS 0 +#define LWIP_SOCKET 0 + +#define SO_REUSE 1 + +// Support Multicast +#include "stdlib.h" +#define LWIP_IGMP LWIP_IPV4 +#define LWIP_RAND() lwip_get_random() + +#define LWIP_COMPAT_SOCKETS 0 +#define LWIP_POSIX_SOCKETS_IO_NAMES 0 + +#define LWIP_BROADCAST_PING 1 + +// Fragmentation on, as per IPv4 default +#define LWIP_IPV6_FRAG LWIP_IPV6 + +// Queuing, default is "disabled", as per IPv4 default (so actually queues 1) +#define LWIP_ND6_QUEUEING MBED_CONF_ND6_QUEUEING + +// Debug Options +#define NETIF_DEBUG LWIP_DBG_OFF +#define PBUF_DEBUG LWIP_DBG_OFF +#define API_LIB_DEBUG LWIP_DBG_OFF +#define API_MSG_DEBUG LWIP_DBG_OFF +#define SOCKETS_DEBUG LWIP_DBG_OFF +#define ICMP_DEBUG LWIP_DBG_OFF +#define IGMP_DEBUG LWIP_DBG_OFF +#define INET_DEBUG LWIP_DBG_OFF +#define IP_DEBUG LWIP_DBG_OFF +#define IP_REASS_DEBUG LWIP_DBG_OFF +#define RAW_DEBUG LWIP_DBG_OFF +#define MEM_DEBUG LWIP_DBG_OFF +#define MEMP_DEBUG LWIP_DBG_OFF +#define SYS_DEBUG LWIP_DBG_OFF +#define TIMERS_DEBUG LWIP_DBG_OFF +#define TCP_DEBUG LWIP_DBG_OFF +#define TCP_INPUT_DEBUG LWIP_DBG_OFF +#define TCP_FR_DEBUG LWIP_DBG_OFF +#define TCP_RTO_DEBUG LWIP_DBG_OFF +#define TCP_CWND_DEBUG LWIP_DBG_OFF +#define TCP_WND_DEBUG LWIP_DBG_OFF +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF +#define TCP_RST_DEBUG LWIP_DBG_OFF +#define TCP_QLEN_DEBUG LWIP_DBG_OFF +#define UDP_DEBUG LWIP_DBG_OFF +#define TCPIP_DEBUG LWIP_DBG_OFF +#define SLIP_DEBUG LWIP_DBG_OFF +#define DHCP_DEBUG LWIP_DBG_OFF +#define AUTOIP_DEBUG LWIP_DBG_OFF +#define DNS_DEBUG LWIP_DBG_OFF +#define IP6_DEBUG LWIP_DBG_OFF + +#define ETHARP_DEBUG LWIP_DBG_OFF +#define UDP_LPC_EMAC LWIP_DBG_OFF + +#ifdef LWIP_DEBUG +#define MEMP_OVERFLOW_CHECK 1 +#define MEMP_SANITY_CHECK 1 +#define LWIP_DBG_TYPES_ON LWIP_DBG_ON +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL +#else +#define LWIP_NOASSERT 1 +#define LWIP_STATS 0 +#endif + +#define TRACE_TO_ASCII_HEX_DUMP 0 + +#define LWIP_PLATFORM_BYTESWAP 1 + +#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 + +// Interface type configuration + +#if MBED_CONF_LWIP_ETHERNET_ENABLED +#define LWIP_ARP 1 +#define LWIP_ETHERNET 1 +#define LWIP_DHCP LWIP_IPV4 +#else +#define LWIP_ARP 0 +#define LWIP_ETHERNET 0 +#endif // MBED_CONF_LWIP_ETHERNET_ENABLED + +#if MBED_CONF_LWIP_L3IP_ENABLED +#define LWIP_L3IP 1 +#else +#define LWIP_L3IP 0 +#endif + +//Maximum size of network interface name +#define INTERFACE_NAME_MAX_SIZE NSAPI_INTERFACE_NAME_MAX_SIZE +// Note generic macro name used rather than MBED_CONF_LWIP_PPP_ENABLED +// to allow users like PPPCellularInterface to detect that nsapi_ppp.h is available. + +// Enable PPP for now either from lwIP PPP configuration (obsolete) or from PPP service configuration +#if MBED_CONF_PPP_ENABLED || MBED_CONF_LWIP_PPP_ENABLED + +#define PPP_SUPPORT 1 + +#if MBED_CONF_PPP_IPV4_ENABLED || MBED_CONF_LWIP_IPV4_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV4_ENABLED +#error LWIP: IPv4 PPP enabled but not IPv4 +#endif +#undef LWIP +#define PPP_IPV4_SUPPORT 1 +#endif + +#if MBED_CONF_PPP_IPV6_ENABLED || MBED_CONF_LWIP_IPV6_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV6_ENABLED +#error LWIP: IPv6 PPP enabled but not IPv6 +#endif +#undef LWIP +#define PPP_IPV6_SUPPORT 1 +// Later to be dynamic for use for multiple interfaces +#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0 +#endif + +#endif + +#define LWIP_NETBUF_RECVINFO MBED_CONF_LWIP_NETBUF_RECVINFO_ENABLED + +// Make sure we default these to off, so +// LWIP doesn't default to on +#ifndef LWIP_ARP +#define LWIP_ARP 0 +#endif + +// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914 +#define LWIP_CHECKSUM_ON_COPY 0 + +#define LWIP_NETIF_HOSTNAME 1 +#define LWIP_NETIF_STATUS_CALLBACK 1 +#define LWIP_NETIF_LINK_CALLBACK 1 + +#define DNS_TABLE_SIZE 2 +#define DNS_MAX_NAME_LENGTH 128 + +#include "lwip_random.h" +#include "lwip_tcp_isn.h" +#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn +#ifdef MBEDTLS_MD5_C +#define LWIP_USE_EXTERNAL_MBEDTLS 1 +#else +#define LWIP_USE_EXTERNAL_MBEDTLS 0 +#endif + +#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS + +#endif /* LWIPOPTS_H_ */ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.8.0/portenta_post_install.sh b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.8.0/portenta_post_install.sh new file mode 100644 index 0000000..7fe71d6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/2.8.0/portenta_post_install.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +portenta_h7_rules () { + echo "" + echo "# Portenta H7 bootloader mode UDEV rules" + echo "" +cat < /etc/udev/rules.d/49-portenta_h7.rules + +# reload udev rules +echo "Reload rules..." +udevadm trigger +udevadm control --reload-rules diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/3.0.0/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/3.0.0/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h new file mode 100644 index 0000000..84c18cf --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/3.0.0/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h @@ -0,0 +1,347 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef LWIPOPTS_H +#define LWIPOPTS_H + +// Workaround for Linux timeval +#if defined (TOOLCHAIN_GCC) +#define LWIP_TIMEVAL_PRIVATE 0 +#include +#endif +#include "nsapi_types.h" +#include "mbed_retarget.h" + +// KH fix +#include +///////////////////////// + +// Operating System +#define NO_SYS 0 + +#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED +#error "Either IPv4 or IPv6 must be enabled." +#endif + +#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED + +#define LWIP_IPV6 MBED_CONF_LWIP_IPV6_ENABLED + +#define LWIP_PROVIDE_ERRNO 0 + +// On dual stack configuration how long to wait for both or preferred stack +// addresses before completing bring up. +#if LWIP_IPV4 && LWIP_IPV6 +#if MBED_CONF_LWIP_ADDR_TIMEOUT_MODE +#define BOTH_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define PREF_ADDR_TIMEOUT 0 +#else +#define PREF_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define BOTH_ADDR_TIMEOUT 0 +#endif +#else +#define PREF_ADDR_TIMEOUT 0 +#define BOTH_ADDR_TIMEOUT 0 +#endif + + +#define DHCP_TIMEOUT MBED_CONF_LWIP_DHCP_TIMEOUT + +#define LINK_TIMEOUT 60 + +#define PREF_IPV4 1 +#define PREF_IPV6 2 + +#if MBED_CONF_LWIP_IP_VER_PREF == 6 +#define IP_VERSION_PREF PREF_IPV6 +#elif MBED_CONF_LWIP_IP_VER_PREF == 4 +#define IP_VERSION_PREF PREF_IPV4 +#else +#error "Either IPv4 or IPv6 must be preferred." +#endif + +#undef LWIP_DEBUG +#if MBED_CONF_LWIP_DEBUG_ENABLED +#define LWIP_DEBUG 1 +#endif + +#if NO_SYS == 0 +#include "cmsis_os2.h" + +#define SYS_LIGHTWEIGHT_PROT 1 + +#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED + +#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT + +// Thread stacks use 8-byte alignment +#define LWIP_ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos)) + +#ifdef LWIP_DEBUG +// For LWIP debug, double the stack +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2, 8) +#elif MBED_DEBUG +// When debug is enabled on the build increase stack 25 percent +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE + MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE / 4, 8) +#else +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE, 8) +#endif + +// Thread priority (osPriorityNormal by default) +#define TCPIP_THREAD_PRIO (MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY) + +#ifdef LWIP_DEBUG +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2, 8) +#else +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE, 8) +#endif + +#define MEMP_NUM_SYS_TIMEOUT 16 + +#define sys_msleep(ms) sys_msleep(ms) + +#endif + +// 32-bit alignment +#define MEM_ALIGNMENT 4 + +#define LWIP_RAM_HEAP_POINTER lwip_ram_heap + +// Number of simultaneously queued TCP segments. +#define MEMP_NUM_TCP_SEG MBED_CONF_LWIP_MEMP_NUM_TCP_SEG + +// TCP Maximum segment size. +#define TCP_MSS MBED_CONF_LWIP_TCP_MSS + +// TCP sender buffer space (bytes). +#define TCP_SND_BUF MBED_CONF_LWIP_TCP_SND_BUF + +// TCP sender buffer space (bytes). +#define TCP_WND MBED_CONF_LWIP_TCP_WND + +#define TCP_MAXRTX MBED_CONF_LWIP_TCP_MAXRTX + +#define TCP_SYNMAXRTX MBED_CONF_LWIP_TCP_SYNMAXRTX + +// Number of pool pbufs. +// Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS) +#define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE + +#ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE +#undef PBUF_POOL_BUFSIZE +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(MBED_CONF_LWIP_PBUF_POOL_BUFSIZE) +#else +#ifndef PBUF_POOL_BUFSIZE +#if LWIP_IPV6 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#elif LWIP_IPV4 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+20+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#endif +#endif +#endif + +#define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE + +// One tcp_pcb_listen is needed for each TCP server. +// Each requires 72 bytes of RAM. +#define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX + +// One is tcp_pcb needed for each TCPSocket. +// Each requires 196 bytes of RAM. +#define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX + +// One udp_pcb is needed for each UDPSocket. +// Each requires 84 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX + +// Number of non-pool pbufs. +// Each requires 92 bytes of RAM. +#define MEMP_NUM_PBUF MBED_CONF_LWIP_NUM_PBUF + +// Each netbuf requires 64 bytes of RAM. +#define MEMP_NUM_NETBUF MBED_CONF_LWIP_NUM_NETBUF + +// One netconn is needed for each UDPSocket or TCPSocket. +// Each requires 236 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX + +#if MBED_CONF_LWIP_TCP_ENABLED +#define LWIP_TCP 1 +#define TCP_OVERSIZE 0 +#define LWIP_TCP_KEEPALIVE 1 + +#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT + +#else +#define LWIP_TCP 0 +#endif + +#define LWIP_DNS 1 +// Only DNS address storage is enabled +#define LWIP_FULL_DNS 0 +#define LWIP_SOCKET 0 + +#define SO_REUSE 1 + +// Support Multicast +#include "stdlib.h" +#define LWIP_IGMP LWIP_IPV4 +#define LWIP_RAND() lwip_get_random() + +#define LWIP_COMPAT_SOCKETS 0 +#define LWIP_POSIX_SOCKETS_IO_NAMES 0 + +#define LWIP_BROADCAST_PING 1 + +// Fragmentation on, as per IPv4 default +#define LWIP_IPV6_FRAG LWIP_IPV6 + +// Queuing, default is "disabled", as per IPv4 default (so actually queues 1) +#define LWIP_ND6_QUEUEING MBED_CONF_ND6_QUEUEING + +// Debug Options +#define NETIF_DEBUG LWIP_DBG_OFF +#define PBUF_DEBUG LWIP_DBG_OFF +#define API_LIB_DEBUG LWIP_DBG_OFF +#define API_MSG_DEBUG LWIP_DBG_OFF +#define SOCKETS_DEBUG LWIP_DBG_OFF +#define ICMP_DEBUG LWIP_DBG_OFF +#define IGMP_DEBUG LWIP_DBG_OFF +#define INET_DEBUG LWIP_DBG_OFF +#define IP_DEBUG LWIP_DBG_OFF +#define IP_REASS_DEBUG LWIP_DBG_OFF +#define RAW_DEBUG LWIP_DBG_OFF +#define MEM_DEBUG LWIP_DBG_OFF +#define MEMP_DEBUG LWIP_DBG_OFF +#define SYS_DEBUG LWIP_DBG_OFF +#define TIMERS_DEBUG LWIP_DBG_OFF +#define TCP_DEBUG LWIP_DBG_OFF +#define TCP_INPUT_DEBUG LWIP_DBG_OFF +#define TCP_FR_DEBUG LWIP_DBG_OFF +#define TCP_RTO_DEBUG LWIP_DBG_OFF +#define TCP_CWND_DEBUG LWIP_DBG_OFF +#define TCP_WND_DEBUG LWIP_DBG_OFF +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF +#define TCP_RST_DEBUG LWIP_DBG_OFF +#define TCP_QLEN_DEBUG LWIP_DBG_OFF +#define UDP_DEBUG LWIP_DBG_OFF +#define TCPIP_DEBUG LWIP_DBG_OFF +#define SLIP_DEBUG LWIP_DBG_OFF +#define DHCP_DEBUG LWIP_DBG_OFF +#define AUTOIP_DEBUG LWIP_DBG_OFF +#define DNS_DEBUG LWIP_DBG_OFF +#define IP6_DEBUG LWIP_DBG_OFF + +#define ETHARP_DEBUG LWIP_DBG_OFF +#define UDP_LPC_EMAC LWIP_DBG_OFF + +#ifdef LWIP_DEBUG +#define MEMP_OVERFLOW_CHECK 1 +#define MEMP_SANITY_CHECK 1 +#define LWIP_DBG_TYPES_ON LWIP_DBG_ON +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL +#else +#define LWIP_NOASSERT 1 +#define LWIP_STATS 0 +#endif + +#define TRACE_TO_ASCII_HEX_DUMP 0 + +#define LWIP_PLATFORM_BYTESWAP 1 + +#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 + +// Interface type configuration + +#if MBED_CONF_LWIP_ETHERNET_ENABLED +#define LWIP_ARP 1 +#define LWIP_ETHERNET 1 +#define LWIP_DHCP LWIP_IPV4 +#else +#define LWIP_ARP 0 +#define LWIP_ETHERNET 0 +#endif // MBED_CONF_LWIP_ETHERNET_ENABLED + +#if MBED_CONF_LWIP_L3IP_ENABLED +#define LWIP_L3IP 1 +#else +#define LWIP_L3IP 0 +#endif + +//Maximum size of network interface name +#define INTERFACE_NAME_MAX_SIZE NSAPI_INTERFACE_NAME_MAX_SIZE +// Note generic macro name used rather than MBED_CONF_LWIP_PPP_ENABLED +// to allow users like PPPCellularInterface to detect that nsapi_ppp.h is available. + +// Enable PPP for now either from lwIP PPP configuration (obsolete) or from PPP service configuration +#if MBED_CONF_PPP_ENABLED || MBED_CONF_LWIP_PPP_ENABLED + +#define PPP_SUPPORT 1 + +#if MBED_CONF_PPP_IPV4_ENABLED || MBED_CONF_LWIP_IPV4_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV4_ENABLED +#error LWIP: IPv4 PPP enabled but not IPv4 +#endif +#undef LWIP +#define PPP_IPV4_SUPPORT 1 +#endif + +#if MBED_CONF_PPP_IPV6_ENABLED || MBED_CONF_LWIP_IPV6_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV6_ENABLED +#error LWIP: IPv6 PPP enabled but not IPv6 +#endif +#undef LWIP +#define PPP_IPV6_SUPPORT 1 +// Later to be dynamic for use for multiple interfaces +#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0 +#endif + +#endif + +#define LWIP_NETBUF_RECVINFO MBED_CONF_LWIP_NETBUF_RECVINFO_ENABLED + +// Make sure we default these to off, so +// LWIP doesn't default to on +#ifndef LWIP_ARP +#define LWIP_ARP 0 +#endif + +// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914 +#define LWIP_CHECKSUM_ON_COPY 0 + +#define LWIP_NETIF_HOSTNAME 1 +#define LWIP_NETIF_STATUS_CALLBACK 1 +#define LWIP_NETIF_LINK_CALLBACK 1 + +#define DNS_TABLE_SIZE 2 +#define DNS_MAX_NAME_LENGTH 128 + +#include "lwip_random.h" +#include "lwip_tcp_isn.h" +#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn +#ifdef MBEDTLS_MD5_C +#define LWIP_USE_EXTERNAL_MBEDTLS 1 +#else +#define LWIP_USE_EXTERNAL_MBEDTLS 0 +#endif + +#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS + +#endif /* LWIPOPTS_H_ */ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/3.0.0/portenta_post_install.sh b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/3.0.0/portenta_post_install.sh new file mode 100644 index 0000000..7fe71d6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/3.0.0/portenta_post_install.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +portenta_h7_rules () { + echo "" + echo "# Portenta H7 bootloader mode UDEV rules" + echo "" +cat < /etc/udev/rules.d/49-portenta_h7.rules + +# reload udev rules +echo "Reload rules..." +udevadm trigger +udevadm control --reload-rules diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/3.0.1/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/3.0.1/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h new file mode 100644 index 0000000..84c18cf --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/3.0.1/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h @@ -0,0 +1,347 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef LWIPOPTS_H +#define LWIPOPTS_H + +// Workaround for Linux timeval +#if defined (TOOLCHAIN_GCC) +#define LWIP_TIMEVAL_PRIVATE 0 +#include +#endif +#include "nsapi_types.h" +#include "mbed_retarget.h" + +// KH fix +#include +///////////////////////// + +// Operating System +#define NO_SYS 0 + +#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED +#error "Either IPv4 or IPv6 must be enabled." +#endif + +#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED + +#define LWIP_IPV6 MBED_CONF_LWIP_IPV6_ENABLED + +#define LWIP_PROVIDE_ERRNO 0 + +// On dual stack configuration how long to wait for both or preferred stack +// addresses before completing bring up. +#if LWIP_IPV4 && LWIP_IPV6 +#if MBED_CONF_LWIP_ADDR_TIMEOUT_MODE +#define BOTH_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define PREF_ADDR_TIMEOUT 0 +#else +#define PREF_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define BOTH_ADDR_TIMEOUT 0 +#endif +#else +#define PREF_ADDR_TIMEOUT 0 +#define BOTH_ADDR_TIMEOUT 0 +#endif + + +#define DHCP_TIMEOUT MBED_CONF_LWIP_DHCP_TIMEOUT + +#define LINK_TIMEOUT 60 + +#define PREF_IPV4 1 +#define PREF_IPV6 2 + +#if MBED_CONF_LWIP_IP_VER_PREF == 6 +#define IP_VERSION_PREF PREF_IPV6 +#elif MBED_CONF_LWIP_IP_VER_PREF == 4 +#define IP_VERSION_PREF PREF_IPV4 +#else +#error "Either IPv4 or IPv6 must be preferred." +#endif + +#undef LWIP_DEBUG +#if MBED_CONF_LWIP_DEBUG_ENABLED +#define LWIP_DEBUG 1 +#endif + +#if NO_SYS == 0 +#include "cmsis_os2.h" + +#define SYS_LIGHTWEIGHT_PROT 1 + +#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED + +#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT + +// Thread stacks use 8-byte alignment +#define LWIP_ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos)) + +#ifdef LWIP_DEBUG +// For LWIP debug, double the stack +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2, 8) +#elif MBED_DEBUG +// When debug is enabled on the build increase stack 25 percent +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE + MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE / 4, 8) +#else +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE, 8) +#endif + +// Thread priority (osPriorityNormal by default) +#define TCPIP_THREAD_PRIO (MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY) + +#ifdef LWIP_DEBUG +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2, 8) +#else +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE, 8) +#endif + +#define MEMP_NUM_SYS_TIMEOUT 16 + +#define sys_msleep(ms) sys_msleep(ms) + +#endif + +// 32-bit alignment +#define MEM_ALIGNMENT 4 + +#define LWIP_RAM_HEAP_POINTER lwip_ram_heap + +// Number of simultaneously queued TCP segments. +#define MEMP_NUM_TCP_SEG MBED_CONF_LWIP_MEMP_NUM_TCP_SEG + +// TCP Maximum segment size. +#define TCP_MSS MBED_CONF_LWIP_TCP_MSS + +// TCP sender buffer space (bytes). +#define TCP_SND_BUF MBED_CONF_LWIP_TCP_SND_BUF + +// TCP sender buffer space (bytes). +#define TCP_WND MBED_CONF_LWIP_TCP_WND + +#define TCP_MAXRTX MBED_CONF_LWIP_TCP_MAXRTX + +#define TCP_SYNMAXRTX MBED_CONF_LWIP_TCP_SYNMAXRTX + +// Number of pool pbufs. +// Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS) +#define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE + +#ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE +#undef PBUF_POOL_BUFSIZE +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(MBED_CONF_LWIP_PBUF_POOL_BUFSIZE) +#else +#ifndef PBUF_POOL_BUFSIZE +#if LWIP_IPV6 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#elif LWIP_IPV4 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+20+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#endif +#endif +#endif + +#define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE + +// One tcp_pcb_listen is needed for each TCP server. +// Each requires 72 bytes of RAM. +#define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX + +// One is tcp_pcb needed for each TCPSocket. +// Each requires 196 bytes of RAM. +#define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX + +// One udp_pcb is needed for each UDPSocket. +// Each requires 84 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX + +// Number of non-pool pbufs. +// Each requires 92 bytes of RAM. +#define MEMP_NUM_PBUF MBED_CONF_LWIP_NUM_PBUF + +// Each netbuf requires 64 bytes of RAM. +#define MEMP_NUM_NETBUF MBED_CONF_LWIP_NUM_NETBUF + +// One netconn is needed for each UDPSocket or TCPSocket. +// Each requires 236 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX + +#if MBED_CONF_LWIP_TCP_ENABLED +#define LWIP_TCP 1 +#define TCP_OVERSIZE 0 +#define LWIP_TCP_KEEPALIVE 1 + +#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT + +#else +#define LWIP_TCP 0 +#endif + +#define LWIP_DNS 1 +// Only DNS address storage is enabled +#define LWIP_FULL_DNS 0 +#define LWIP_SOCKET 0 + +#define SO_REUSE 1 + +// Support Multicast +#include "stdlib.h" +#define LWIP_IGMP LWIP_IPV4 +#define LWIP_RAND() lwip_get_random() + +#define LWIP_COMPAT_SOCKETS 0 +#define LWIP_POSIX_SOCKETS_IO_NAMES 0 + +#define LWIP_BROADCAST_PING 1 + +// Fragmentation on, as per IPv4 default +#define LWIP_IPV6_FRAG LWIP_IPV6 + +// Queuing, default is "disabled", as per IPv4 default (so actually queues 1) +#define LWIP_ND6_QUEUEING MBED_CONF_ND6_QUEUEING + +// Debug Options +#define NETIF_DEBUG LWIP_DBG_OFF +#define PBUF_DEBUG LWIP_DBG_OFF +#define API_LIB_DEBUG LWIP_DBG_OFF +#define API_MSG_DEBUG LWIP_DBG_OFF +#define SOCKETS_DEBUG LWIP_DBG_OFF +#define ICMP_DEBUG LWIP_DBG_OFF +#define IGMP_DEBUG LWIP_DBG_OFF +#define INET_DEBUG LWIP_DBG_OFF +#define IP_DEBUG LWIP_DBG_OFF +#define IP_REASS_DEBUG LWIP_DBG_OFF +#define RAW_DEBUG LWIP_DBG_OFF +#define MEM_DEBUG LWIP_DBG_OFF +#define MEMP_DEBUG LWIP_DBG_OFF +#define SYS_DEBUG LWIP_DBG_OFF +#define TIMERS_DEBUG LWIP_DBG_OFF +#define TCP_DEBUG LWIP_DBG_OFF +#define TCP_INPUT_DEBUG LWIP_DBG_OFF +#define TCP_FR_DEBUG LWIP_DBG_OFF +#define TCP_RTO_DEBUG LWIP_DBG_OFF +#define TCP_CWND_DEBUG LWIP_DBG_OFF +#define TCP_WND_DEBUG LWIP_DBG_OFF +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF +#define TCP_RST_DEBUG LWIP_DBG_OFF +#define TCP_QLEN_DEBUG LWIP_DBG_OFF +#define UDP_DEBUG LWIP_DBG_OFF +#define TCPIP_DEBUG LWIP_DBG_OFF +#define SLIP_DEBUG LWIP_DBG_OFF +#define DHCP_DEBUG LWIP_DBG_OFF +#define AUTOIP_DEBUG LWIP_DBG_OFF +#define DNS_DEBUG LWIP_DBG_OFF +#define IP6_DEBUG LWIP_DBG_OFF + +#define ETHARP_DEBUG LWIP_DBG_OFF +#define UDP_LPC_EMAC LWIP_DBG_OFF + +#ifdef LWIP_DEBUG +#define MEMP_OVERFLOW_CHECK 1 +#define MEMP_SANITY_CHECK 1 +#define LWIP_DBG_TYPES_ON LWIP_DBG_ON +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL +#else +#define LWIP_NOASSERT 1 +#define LWIP_STATS 0 +#endif + +#define TRACE_TO_ASCII_HEX_DUMP 0 + +#define LWIP_PLATFORM_BYTESWAP 1 + +#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 + +// Interface type configuration + +#if MBED_CONF_LWIP_ETHERNET_ENABLED +#define LWIP_ARP 1 +#define LWIP_ETHERNET 1 +#define LWIP_DHCP LWIP_IPV4 +#else +#define LWIP_ARP 0 +#define LWIP_ETHERNET 0 +#endif // MBED_CONF_LWIP_ETHERNET_ENABLED + +#if MBED_CONF_LWIP_L3IP_ENABLED +#define LWIP_L3IP 1 +#else +#define LWIP_L3IP 0 +#endif + +//Maximum size of network interface name +#define INTERFACE_NAME_MAX_SIZE NSAPI_INTERFACE_NAME_MAX_SIZE +// Note generic macro name used rather than MBED_CONF_LWIP_PPP_ENABLED +// to allow users like PPPCellularInterface to detect that nsapi_ppp.h is available. + +// Enable PPP for now either from lwIP PPP configuration (obsolete) or from PPP service configuration +#if MBED_CONF_PPP_ENABLED || MBED_CONF_LWIP_PPP_ENABLED + +#define PPP_SUPPORT 1 + +#if MBED_CONF_PPP_IPV4_ENABLED || MBED_CONF_LWIP_IPV4_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV4_ENABLED +#error LWIP: IPv4 PPP enabled but not IPv4 +#endif +#undef LWIP +#define PPP_IPV4_SUPPORT 1 +#endif + +#if MBED_CONF_PPP_IPV6_ENABLED || MBED_CONF_LWIP_IPV6_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV6_ENABLED +#error LWIP: IPv6 PPP enabled but not IPv6 +#endif +#undef LWIP +#define PPP_IPV6_SUPPORT 1 +// Later to be dynamic for use for multiple interfaces +#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0 +#endif + +#endif + +#define LWIP_NETBUF_RECVINFO MBED_CONF_LWIP_NETBUF_RECVINFO_ENABLED + +// Make sure we default these to off, so +// LWIP doesn't default to on +#ifndef LWIP_ARP +#define LWIP_ARP 0 +#endif + +// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914 +#define LWIP_CHECKSUM_ON_COPY 0 + +#define LWIP_NETIF_HOSTNAME 1 +#define LWIP_NETIF_STATUS_CALLBACK 1 +#define LWIP_NETIF_LINK_CALLBACK 1 + +#define DNS_TABLE_SIZE 2 +#define DNS_MAX_NAME_LENGTH 128 + +#include "lwip_random.h" +#include "lwip_tcp_isn.h" +#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn +#ifdef MBEDTLS_MD5_C +#define LWIP_USE_EXTERNAL_MBEDTLS 1 +#else +#define LWIP_USE_EXTERNAL_MBEDTLS 0 +#endif + +#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS + +#endif /* LWIPOPTS_H_ */ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/3.0.1/portenta_post_install.sh b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/3.0.1/portenta_post_install.sh new file mode 100644 index 0000000..7fe71d6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/mbed_portenta/3.0.1/portenta_post_install.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +portenta_h7_rules () { + echo "" + echo "# Portenta H7 bootloader mode UDEV rules" + echo "" +cat < /etc/udev/rules.d/49-portenta_h7.rules + +# reload udev rules +echo "Reload rules..." +udevadm trigger +udevadm control --reload-rules diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/sam/1.6.12/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/sam/1.6.12/platform.txt new file mode 100644 index 0000000..52a7aa1 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/sam/1.6.12/platform.txt @@ -0,0 +1,110 @@ + +# Arduino SAM Core and platform. +# ------------------------------ +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification + +name=Arduino ARM (32-bits) Boards +version=1.6.12 + +# SAM3 compile variables +# ---------------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra + +compiler.path={runtime.tools.arm-none-eabi-gcc-4.8.3-2014q1.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -MMD +# KH, Error here to use gcc, mjust use g++ +#compiler.c.elf.cmd=arm-none-eabi-gcc +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-Os -Wl,--gc-sections +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.flags=-O binary +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags= +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.combine.flags=-u _sbrk -u link -u _close -u _fstat -u _isatty -u _lseek -u _read -u _write -u _exit -u kill -u _getpid + +# This can be overridden in boards.txt +build.extra_flags= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + + +compiler.libsam.c.flags="-I{build.system.path}/libsam" "-I{build.system.path}/CMSIS/CMSIS/Include/" "-I{build.system.path}/CMSIS/Device/ATMEL/" + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# SAM3 compile patterns +# --------------------- + +## Compile c files +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mcpu={build.mcu} -mthumb -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.libsam.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mcpu={build.mcu} -mthumb -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.libsam.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -mcpu={build.mcu} -mthumb -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.libsam.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" -mcpu={build.mcu} -mthumb {compiler.c.elf.flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--start-group {compiler.combine.flags} {object_files} "{build.variant.path}/{build.variant_system_lib}" "{build.path}/{archive_file}" -Wl,--end-group -lm -lgcc + +## Create output (.bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Save hex +recipe.output.tmp_file={build.project_name}.bin +recipe.output.save_file={build.project_name}.{build.variant}.bin + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + + +# SAM3 Uploader tools +# ------------------- + +# BOSSA +tools.bossac.path={runtime.tools.bossac.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.params.verify=-v +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -e -w {upload.verify} -b "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v -b /tmp/sketch.bin -R diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.10/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.10/platform.txt new file mode 100644 index 0000000..e144b5d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.10/platform.txt @@ -0,0 +1,246 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Arduino SAMD (32-bits ARM Cortex-M0+) Boards +version=1.8.10 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra + +# EXPERIMENTAL feature: optimization flags +# - this is alpha and may be subject to change without notice +compiler.optimization_flags=-Os +compiler.optimization_flags.release=-Os +compiler.optimization_flags.debug=-Og -g3 + +compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags={compiler.optimization_flags} -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + + +# Debugger configuration (general options) +# ---------------------------------------- +# EXPERIMENTAL feature: +# - this is alpha and may be subject to change without notice +debug.executable={build.path}/{build.project_name}.elf +debug.toolchain=gcc +debug.toolchain.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +debug.toolchain.prefix=arm-none-eabi- +debug.server=openocd +debug.server.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}/bin/openocd +debug.server.openocd.scripts_dir={runtime.tools.openocd-0.10.0-arduino7.path}/share/openocd/scripts/ +debug.server.openocd.script={runtime.platform.path}/variants/{build.variant}/{build.openocdscript} + +# Upload/Debug tools +# ------------------ + +# +# AVRDUDE +# +tools.avrdude.path={runtime.tools.avrdude.path} +tools.avrdude.cmd={path}/bin/avrdude +tools.avrdude.config.path={path}/etc/avrdude.conf + +tools.avrdude.upload.params.verbose=-v -v +tools.avrdude.upload.params.quiet=-q -q +tools.avrdude.upload.params.noverify=-V +tools.avrdude.upload.pattern="{cmd}" "-C{config.path}" {upload.verbose} -p{build.emu.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} "-Uflash:w:{build.path}/{build.project_name}.hex:i" + +tools.avrdude_remote.upload.pattern="openocd --version 2>&1 | grep 2016 && if opkg update; then opkg upgrade openocd; exit 1; else echo 'Please connect your board to the Internet in order to upgrade tools' >&2; exit 1; fi || /usr/bin/run-avrdude /tmp/sketch.hex" + +tools.avrdude.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.avrdude.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +arduinoota.extraflags= +tools.bossac.network_cmd={runtime.tools.arduinoOTA-1.3.0.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b {arduinoota.extraflags} + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.hex} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.11/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.11/platform.txt new file mode 100644 index 0000000..b071d27 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.11/platform.txt @@ -0,0 +1,246 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Arduino SAMD (32-bits ARM Cortex-M0+) Boards +version=1.8.11 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra + +# EXPERIMENTAL feature: optimization flags +# - this is alpha and may be subject to change without notice +compiler.optimization_flags=-Os +compiler.optimization_flags.release=-Os +compiler.optimization_flags.debug=-Og -g3 + +compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags={compiler.optimization_flags} -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DBOARD_NAME="{build.board}" -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + + +# Debugger configuration (general options) +# ---------------------------------------- +# EXPERIMENTAL feature: +# - this is alpha and may be subject to change without notice +debug.executable={build.path}/{build.project_name}.elf +debug.toolchain=gcc +debug.toolchain.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +debug.toolchain.prefix=arm-none-eabi- +debug.server=openocd +debug.server.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}/bin/openocd +debug.server.openocd.scripts_dir={runtime.tools.openocd-0.10.0-arduino7.path}/share/openocd/scripts/ +debug.server.openocd.script={runtime.platform.path}/variants/{build.variant}/{build.openocdscript} + +# Upload/Debug tools +# ------------------ + +# +# AVRDUDE +# +tools.avrdude.path={runtime.tools.avrdude.path} +tools.avrdude.cmd={path}/bin/avrdude +tools.avrdude.config.path={path}/etc/avrdude.conf + +tools.avrdude.upload.params.verbose=-v -v +tools.avrdude.upload.params.quiet=-q -q +tools.avrdude.upload.params.noverify=-V +tools.avrdude.upload.pattern="{cmd}" "-C{config.path}" {upload.verbose} -p{build.emu.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} "-Uflash:w:{build.path}/{build.project_name}.hex:i" + +tools.avrdude_remote.upload.pattern="openocd --version 2>&1 | grep 2016 && if opkg update; then opkg upgrade openocd; exit 1; else echo 'Please connect your board to the Internet in order to upgrade tools' >&2; exit 1; fi || /usr/bin/run-avrdude /tmp/sketch.hex" + +tools.avrdude.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.avrdude.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +arduinoota.extraflags= +tools.bossac.network_cmd={runtime.tools.arduinoOTA-1.3.0.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b {arduinoota.extraflags} + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.hex} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.12/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.12/platform.txt new file mode 100644 index 0000000..1e761f4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.12/platform.txt @@ -0,0 +1,258 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Arduino SAMD (32-bits ARM Cortex-M0+) Boards +version=1.8.12 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra + +# EXPERIMENTAL feature: optimization flags +# - this is alpha and may be subject to change without notice +compiler.optimization_flags=-Os +compiler.optimization_flags.release=-Os +compiler.optimization_flags.debug=-Og -g3 + +compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags={compiler.optimization_flags} -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-mcpu={build.mcu} -mthumb -c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + +# Required discoveries and monitors +# --------------------------------- +pluggable_discovery.required.0=builtin:serial-discovery +pluggable_discovery.required.1=builtin:mdns-discovery +pluggable_monitor.required.serial=builtin:serial-monitor + +# Debugger configuration (general options) +# ---------------------------------------- +# EXPERIMENTAL feature: +# - this is alpha and may be subject to change without notice +debug.executable={build.path}/{build.project_name}.elf +debug.toolchain=gcc +debug.toolchain.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +debug.toolchain.prefix=arm-none-eabi- +debug.server=openocd +debug.server.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}/bin/openocd +debug.server.openocd.scripts_dir={runtime.tools.openocd-0.10.0-arduino7.path}/share/openocd/scripts/ +debug.server.openocd.script={runtime.platform.path}/variants/{build.variant}/{build.openocdscript} + +# Upload/Debug tools +# ------------------ + +# +# AVRDUDE +# +tools.avrdude.path={runtime.tools.avrdude.path} +tools.avrdude.cmd={path}/bin/avrdude +tools.avrdude.config.path={path}/etc/avrdude.conf + +tools.avrdude.upload.params.verbose=-v -v +tools.avrdude.upload.params.quiet=-q -q +tools.avrdude.upload.params.noverify=-V +tools.avrdude.upload.pattern="{cmd}" "-C{config.path}" {upload.verbose} -p{build.emu.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} "-Uflash:w:{build.path}/{build.project_name}.hex:i" + +tools.avrdude_remote.upload.pattern="openocd --version 2>&1 | grep 2016 && if opkg update; then opkg upgrade openocd; exit 1; else echo 'Please connect your board to the Internet in order to upgrade tools' >&2; exit 1; fi || /usr/bin/run-avrdude /tmp/sketch.hex" + +# the following rule is deprecated by pluggable discovery +tools.avrdude.upload.network_pattern="{tools.arduino_ota.cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +# the following rule is deprecated by pluggable discovery +tools.bossac.upload.network_pattern="{tools.arduino_ota.cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b {arduinoota.extraflags} + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +# the following rule is deprecated by pluggable discovery +tools.bossacI.upload.network_pattern="{tools.arduino_ota.cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "interface/{protocol}" -c "set telnet_port 0" {extra_params} -f "target/at91samdXX.cfg" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +# the following rule is deprecated by pluggable discovery +tools.openocd.upload.network_pattern={tools.arduino_ota.cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "interface/{protocol}" -c "set telnet_port 0" {extra_params} -f "target/at91samdXX.cfg" -c "telnet_port disabled; program {{build.path}/{build.project_name}.hex} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "interface/{protocol}" -c "set telnet_port 0" {extra_params} -f "target/at91samdXX.cfg" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# Arduino OTA +# +arduinoota.extraflags= +tools.arduino_ota.cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.arduino_ota.upload.field.password=Password +tools.arduino_ota.upload.field.password.secret=true +tools.arduino_ota.upload.pattern="{cmd}" -address "{upload.port.address}" -port 65280 -username arduino -password "{upload.field.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b {arduinoota.extraflags} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.13/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.13/platform.txt new file mode 100644 index 0000000..0e5ebb9 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.13/platform.txt @@ -0,0 +1,266 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Arduino SAMD (32-bits ARM Cortex-M0+) Boards +version=1.8.13 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra + +# EXPERIMENTAL feature: optimization flags +# - this is alpha and may be subject to change without notice +compiler.optimization_flags=-Os +compiler.optimization_flags.release=-Os +compiler.optimization_flags.debug=-Og -g3 + +compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags={compiler.optimization_flags} -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-mcpu={build.mcu} -mthumb -c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + +# Required discoveries and monitors +# --------------------------------- +pluggable_discovery.required.0=builtin:serial-discovery +pluggable_discovery.required.1=builtin:mdns-discovery +pluggable_monitor.required.serial=builtin:serial-monitor + +# Debugger configuration (general options) +# ---------------------------------------- +# EXPERIMENTAL feature: +# - this is alpha and may be subject to change without notice +debug.executable={build.path}/{build.project_name}.elf +debug.toolchain=gcc +debug.toolchain.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +debug.toolchain.prefix=arm-none-eabi- +debug.server=openocd +debug.server.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}/bin/openocd +debug.server.openocd.scripts_dir={runtime.tools.openocd-0.10.0-arduino7.path}/share/openocd/scripts/ +debug.server.openocd.script={runtime.platform.path}/variants/{build.variant}/{build.openocdscript} + +# Upload/Debug tools +# ------------------ + +# +# AVRDUDE +# +tools.avrdude.path={runtime.tools.avrdude.path} +tools.avrdude.cmd={path}/bin/avrdude +tools.avrdude.config.path={path}/etc/avrdude.conf + +tools.avrdude.upload.params.verbose=-v -v +tools.avrdude.upload.params.quiet=-q -q +tools.avrdude.upload.params.noverify=-V +tools.avrdude.upload.pattern="{cmd}" "-C{config.path}" {upload.verbose} -p{build.emu.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} "-Uflash:w:{build.path}/{build.project_name}.hex:i" + +tools.avrdude_remote.upload.pattern="openocd --version 2>&1 | grep 2016 && if opkg update; then opkg upgrade openocd; exit 1; else echo 'Please connect your board to the Internet in order to upgrade tools' >&2; exit 1; fi || /usr/bin/run-avrdude /tmp/sketch.hex" + +# The following rule is deprecated by pluggable discovery. +# We keep it to avoid breaking compatibility with the Arduino Java IDE. +tools.avrdude.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.avrdude.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +# The following rule is deprecated by pluggable discovery. +# We keep it to avoid breaking compatibility with the Arduino Java IDE. +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b {arduinoota.extraflags} + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +# The following rule is deprecated by pluggable discovery. +# We keep it to avoid breaking compatibility with the Arduino Java IDE. +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +# The following rule is deprecated by pluggable discovery. +# We keep it to avoid breaking compatibility with the Arduino Java IDE. +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "interface/{protocol}" -c "set telnet_port 0" {extra_params} -f "target/at91samdXX.cfg" -c "telnet_port disabled; program {{build.path}/{build.project_name}.hex} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "interface/{protocol}" -c "set telnet_port 0" {extra_params} -f "target/at91samdXX.cfg" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# Arduino OTA +# +arduinoota.extraflags= +tools.arduino_ota.cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.arduino_ota.upload.field.password=Password +tools.arduino_ota.upload.field.password.secret=true +tools.arduino_ota.upload.pattern="{cmd}" -address "{upload.port.address}" -port 65280 -username arduino -password "{upload.field.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b {arduinoota.extraflags} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.6/cores/arduino/Arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.6/cores/arduino/Arduino.h new file mode 100644 index 0000000..795f605 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.6/cores/arduino/Arduino.h @@ -0,0 +1,160 @@ +/* + Arduino.h - Main include file for the Arduino SDK + Copyright (c) 2014 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// KH, This is the fix according to https://github.com/arduino/ArduinoCore-samd/pull/399 +// to avoid notorious compiler error while uing STL (min and max macro error) +// It's terrible Arduino has just released new core and still don't merge the PR + +#ifndef Arduino_h +#define Arduino_h + +#include +#include +#include +#include +#include + +typedef bool boolean; +typedef uint8_t byte; +typedef uint16_t word; + +// some libraries and sketches depend on this AVR stuff, +// assuming Arduino.h or WProgram.h automatically includes it... +// +#include "avr/pgmspace.h" +#include "avr/interrupt.h" +#include "avr/io.h" +#include "binary.h" +#include "itoa.h" + +#ifdef __cplusplus + extern "C"{ +#endif // __cplusplus + +// Include Atmel headers +#include "sam.h" +#include "wiring_constants.h" + +#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L ) +#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) ) +#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) ) +void yield( void ) ; +/* system functions */ +int main( void ); +void init( void ); +/* sketch */ +void setup( void ) ; +void loop( void ) ; +#include "WVariant.h" + +#ifdef __cplusplus +} // extern "C" +#endif + + +// The following headers are for C++ only compilation +#ifdef __cplusplus + #include "WCharacter.h" + #include "WString.h" + #include "Tone.h" + #include "WMath.h" + #include "HardwareSerial.h" + #include "pulse.h" + #include +#endif + +#include "delay.h" + +#ifdef __cplusplus + #include "Uart.h" +#endif + +// Include board variant +#include "variant.h" +#include "wiring.h" +#include "wiring_digital.h" +#include "wiring_analog.h" +#include "wiring_shift.h" +#include "WInterrupts.h" + +#ifndef __cplusplus + // undefine stdlib's abs if encountered + #ifdef abs + #undef abs + #endif // abs + + #define min(a,b) ((a)<(b)?(a):(b)) + #define max(a,b) ((a)>(b)?(a):(b)) + #define abs(x) ((x)>0?(x):-(x)) + #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) + +#else + //using std::min; + //using std::max; + template + auto min(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (b < a) ? b : a; + } + + template + auto max(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (a < b) ? b : a; + } +#endif + +#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) +#define radians(deg) ((deg)*DEG_TO_RAD) +#define degrees(rad) ((rad)*RAD_TO_DEG) +#define sq(x) ((x)*(x)) + +#define interrupts() __enable_irq() +#define noInterrupts() __disable_irq() + +#define lowByte(w) ((uint8_t) ((w) & 0xff)) +#define highByte(w) ((uint8_t) ((w) >> 8)) + +#define bitRead(value, bit) (((value) >> (bit)) & 0x01) +#define bitSet(value, bit) ((value) |= (1UL << (bit))) +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) +#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) +#define bit(b) (1UL << (b)) + +#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606) + // Interrupts + #define digitalPinToInterrupt(P) ( P ) +#endif + +// Allows publishing the Beta core under samd-beta / arduino organization +#ifndef ARDUINO_ARCH_SAMD +#define ARDUINO_ARCH_SAMD +#endif + +// USB Device +#include "USB/USBDesc.h" +#include "USB/USBCore.h" +#include "USB/USBAPI.h" +#include "USB/USB_host.h" + +#ifdef __cplusplus + #include "USB/CDC.h" +#endif + +#endif // Arduino_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.6/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.6/platform.txt new file mode 100644 index 0000000..3516ebe --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.6/platform.txt @@ -0,0 +1,248 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Arduino SAMD (32-bits ARM Cortex-M0+) Boards +version=1.8.6 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +# EXPERIMENTAL feature: optimization flags +# - this is alpha and may be subject to change without notice +compiler.optimization_flags=-Os +compiler.optimization_flags.release=-Os +compiler.optimization_flags.debug=-Og -g3 + +compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags={compiler.optimization_flags} -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + +# Upload/Debug tools +# ------------------ + +# +# AVRDUDE +# +tools.avrdude.path={runtime.tools.avrdude.path} +tools.avrdude.cmd={path}/bin/avrdude +tools.avrdude.config.path={path}/etc/avrdude.conf + +tools.avrdude.upload.params.verbose=-v -v +tools.avrdude.upload.params.quiet=-q -q +tools.avrdude.upload.params.noverify=-V +tools.avrdude.upload.pattern="{cmd}" "-C{config.path}" {upload.verbose} -p{build.emu.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} "-Uflash:w:{build.path}/{build.project_name}.hex:i" + +tools.avrdude_remote.upload.pattern="openocd --version 2>&1 | grep 2016 && if opkg update; then opkg upgrade openocd; exit 1; else echo 'Please connect your board to the Internet in order to upgrade tools' >&2; exit 1; fi || /usr/bin/run-avrdude /tmp/sketch.hex" + +tools.avrdude.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.avrdude.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# GDB (Debugger) +# +# EXPERIMENTAL feature: debug.pattern +# - this is alpha and may be subject to change without notice + +tools.gdb.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +tools.gdb.cmd=arm-none-eabi-gdb +tools.gdb.cmd.windows=arm-none-eabi-gdb.exe +tools.gdb.debug.pattern="{path}/{cmd}" --interpreter=mi2 -ex "set pagination off" -ex 'target extended-remote | {tools.openocd.path}/{tools.openocd.cmd} -s "{tools.openocd.path}/share/openocd/scripts/" --file "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "gdb_port pipe" -c "telnet_port 0"' {build.path}/{build.project_name}.elf diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.7/cores/arduino/Arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.7/cores/arduino/Arduino.h new file mode 100644 index 0000000..795f605 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.7/cores/arduino/Arduino.h @@ -0,0 +1,160 @@ +/* + Arduino.h - Main include file for the Arduino SDK + Copyright (c) 2014 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// KH, This is the fix according to https://github.com/arduino/ArduinoCore-samd/pull/399 +// to avoid notorious compiler error while uing STL (min and max macro error) +// It's terrible Arduino has just released new core and still don't merge the PR + +#ifndef Arduino_h +#define Arduino_h + +#include +#include +#include +#include +#include + +typedef bool boolean; +typedef uint8_t byte; +typedef uint16_t word; + +// some libraries and sketches depend on this AVR stuff, +// assuming Arduino.h or WProgram.h automatically includes it... +// +#include "avr/pgmspace.h" +#include "avr/interrupt.h" +#include "avr/io.h" +#include "binary.h" +#include "itoa.h" + +#ifdef __cplusplus + extern "C"{ +#endif // __cplusplus + +// Include Atmel headers +#include "sam.h" +#include "wiring_constants.h" + +#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L ) +#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) ) +#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) ) +void yield( void ) ; +/* system functions */ +int main( void ); +void init( void ); +/* sketch */ +void setup( void ) ; +void loop( void ) ; +#include "WVariant.h" + +#ifdef __cplusplus +} // extern "C" +#endif + + +// The following headers are for C++ only compilation +#ifdef __cplusplus + #include "WCharacter.h" + #include "WString.h" + #include "Tone.h" + #include "WMath.h" + #include "HardwareSerial.h" + #include "pulse.h" + #include +#endif + +#include "delay.h" + +#ifdef __cplusplus + #include "Uart.h" +#endif + +// Include board variant +#include "variant.h" +#include "wiring.h" +#include "wiring_digital.h" +#include "wiring_analog.h" +#include "wiring_shift.h" +#include "WInterrupts.h" + +#ifndef __cplusplus + // undefine stdlib's abs if encountered + #ifdef abs + #undef abs + #endif // abs + + #define min(a,b) ((a)<(b)?(a):(b)) + #define max(a,b) ((a)>(b)?(a):(b)) + #define abs(x) ((x)>0?(x):-(x)) + #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) + +#else + //using std::min; + //using std::max; + template + auto min(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (b < a) ? b : a; + } + + template + auto max(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (a < b) ? b : a; + } +#endif + +#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) +#define radians(deg) ((deg)*DEG_TO_RAD) +#define degrees(rad) ((rad)*RAD_TO_DEG) +#define sq(x) ((x)*(x)) + +#define interrupts() __enable_irq() +#define noInterrupts() __disable_irq() + +#define lowByte(w) ((uint8_t) ((w) & 0xff)) +#define highByte(w) ((uint8_t) ((w) >> 8)) + +#define bitRead(value, bit) (((value) >> (bit)) & 0x01) +#define bitSet(value, bit) ((value) |= (1UL << (bit))) +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) +#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) +#define bit(b) (1UL << (b)) + +#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606) + // Interrupts + #define digitalPinToInterrupt(P) ( P ) +#endif + +// Allows publishing the Beta core under samd-beta / arduino organization +#ifndef ARDUINO_ARCH_SAMD +#define ARDUINO_ARCH_SAMD +#endif + +// USB Device +#include "USB/USBDesc.h" +#include "USB/USBCore.h" +#include "USB/USBAPI.h" +#include "USB/USB_host.h" + +#ifdef __cplusplus + #include "USB/CDC.h" +#endif + +#endif // Arduino_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.7/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.7/platform.txt new file mode 100644 index 0000000..4157aa4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.7/platform.txt @@ -0,0 +1,248 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Arduino SAMD (32-bits ARM Cortex-M0+) Boards +version=1.8.7 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +# EXPERIMENTAL feature: optimization flags +# - this is alpha and may be subject to change without notice +compiler.optimization_flags=-Os +compiler.optimization_flags.release=-Os +compiler.optimization_flags.debug=-Og -g3 + +compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags={compiler.optimization_flags} -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + +# Upload/Debug tools +# ------------------ + +# +# AVRDUDE +# +tools.avrdude.path={runtime.tools.avrdude.path} +tools.avrdude.cmd={path}/bin/avrdude +tools.avrdude.config.path={path}/etc/avrdude.conf + +tools.avrdude.upload.params.verbose=-v -v +tools.avrdude.upload.params.quiet=-q -q +tools.avrdude.upload.params.noverify=-V +tools.avrdude.upload.pattern="{cmd}" "-C{config.path}" {upload.verbose} -p{build.emu.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} "-Uflash:w:{build.path}/{build.project_name}.hex:i" + +tools.avrdude_remote.upload.pattern="openocd --version 2>&1 | grep 2016 && if opkg update; then opkg upgrade openocd; exit 1; else echo 'Please connect your board to the Internet in order to upgrade tools' >&2; exit 1; fi || /usr/bin/run-avrdude /tmp/sketch.hex" + +tools.avrdude.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.avrdude.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +arduinoota.extraflags= +tools.bossac.network_cmd={runtime.tools.arduinoOTA-1.3.0.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b {arduinoota.extraflags} + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.hex} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# GDB (Debugger) +# +# EXPERIMENTAL feature: debug.pattern +# - this is alpha and may be subject to change without notice +tools.gdb-openocd.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +tools.gdb-openocd.cmd=arm-none-eabi-gdb +tools.gdb-openocd.cmd.windows=arm-none-eabi-gdb.exe +tools.gdb-openocd.interpreter=console +tools.gdb-openocd.debug.pattern="{path}/{cmd}" --interpreter={interpreter} -ex "set remotetimeout 5" -ex "set pagination off" -ex 'target extended-remote | "{tools.openocd.path}/{tools.openocd.cmd}" -s "{tools.openocd.path}/share/openocd/scripts/" --file "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "gdb_port pipe" -c "telnet_port 0"' "{build.path}/{build.project_name}.elf" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.8/cores/Arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.8/cores/Arduino.h new file mode 100644 index 0000000..4c47b5c --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.8/cores/Arduino.h @@ -0,0 +1,165 @@ +/* + Arduino.h - Main include file for the Arduino SDK + Copyright (c) 2014 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// KH, This is the fix according to https://github.com/arduino/ArduinoCore-samd/pull/399 +// to avoid notorious compiler error while uing STL (min and max macro error) +// It's terrible Arduino has just released new core and still don't merge the PR + +#ifndef Arduino_h +#define Arduino_h + +#include +#include +#include +#include +#include + +typedef bool boolean; +typedef uint8_t byte; +typedef uint16_t word; + +// some libraries and sketches depend on this AVR stuff, +// assuming Arduino.h or WProgram.h automatically includes it... +// +#include "avr/pgmspace.h" +#include "avr/interrupt.h" +#include "avr/io.h" + +#include "binary.h" +#include "itoa.h" + +#ifdef __cplusplus + extern "C"{ +#endif // __cplusplus + +// Include Atmel headers +#include "sam.h" + +#include "wiring_constants.h" + +#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L ) +#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) ) +#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) ) + +void yield( void ) ; + +/* system functions */ +int main( void ); +void init( void ); + +/* sketch */ +void setup( void ) ; +void loop( void ) ; + +#include "WVariant.h" + +#ifdef __cplusplus +} // extern "C" +#endif + +// The following headers are for C++ only compilation +#ifdef __cplusplus + #include "WCharacter.h" + #include "WString.h" + #include "Tone.h" + #include "WMath.h" + #include "HardwareSerial.h" + #include "pulse.h" + #include +#endif + +#include "delay.h" + +#ifdef __cplusplus + #include "Uart.h" +#endif + +// Include board variant +#include "variant.h" +#include "wiring.h" +#include "wiring_digital.h" +#include "wiring_analog.h" +#include "wiring_shift.h" +#include "WInterrupts.h" + +#ifndef __cplusplus + // undefine stdlib's abs if encountered + #ifdef abs + #undef abs + #endif // abs + + #define min(a,b) ((a)<(b)?(a):(b)) + #define max(a,b) ((a)>(b)?(a):(b)) + #define abs(x) ((x)>0?(x):-(x)) + #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) + +#else + //using std::min; + //using std::max; + template + auto min(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (b < a) ? b : a; + } + + template + auto max(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (a < b) ? b : a; + } +#endif + +#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) +#define radians(deg) ((deg)*DEG_TO_RAD) +#define degrees(rad) ((rad)*RAD_TO_DEG) +#define sq(x) ((x)*(x)) + +#define interrupts() __enable_irq() +#define noInterrupts() __disable_irq() + +#define lowByte(w) ((uint8_t) ((w) & 0xff)) +#define highByte(w) ((uint8_t) ((w) >> 8)) + +#define bitRead(value, bit) (((value) >> (bit)) & 0x01) +#define bitSet(value, bit) ((value) |= (1UL << (bit))) +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) +#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) +#define bit(b) (1UL << (b)) + +#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606) + // Interrupts + #define digitalPinToInterrupt(P) ( P ) +#endif + +// Allows publishing the Beta core under samd-beta / arduino organization +#ifndef ARDUINO_ARCH_SAMD +#define ARDUINO_ARCH_SAMD +#endif + +// USB Device +#include "USB/USBDesc.h" +#include "USB/USBCore.h" +#include "USB/USBAPI.h" +#include "USB/USB_host.h" + +#ifdef __cplusplus + #include "USB/CDC.h" +#endif + +#endif // Arduino_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.8/cores/arduino/Arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.8/cores/arduino/Arduino.h new file mode 100644 index 0000000..4c47b5c --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.8/cores/arduino/Arduino.h @@ -0,0 +1,165 @@ +/* + Arduino.h - Main include file for the Arduino SDK + Copyright (c) 2014 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// KH, This is the fix according to https://github.com/arduino/ArduinoCore-samd/pull/399 +// to avoid notorious compiler error while uing STL (min and max macro error) +// It's terrible Arduino has just released new core and still don't merge the PR + +#ifndef Arduino_h +#define Arduino_h + +#include +#include +#include +#include +#include + +typedef bool boolean; +typedef uint8_t byte; +typedef uint16_t word; + +// some libraries and sketches depend on this AVR stuff, +// assuming Arduino.h or WProgram.h automatically includes it... +// +#include "avr/pgmspace.h" +#include "avr/interrupt.h" +#include "avr/io.h" + +#include "binary.h" +#include "itoa.h" + +#ifdef __cplusplus + extern "C"{ +#endif // __cplusplus + +// Include Atmel headers +#include "sam.h" + +#include "wiring_constants.h" + +#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L ) +#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) ) +#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) ) + +void yield( void ) ; + +/* system functions */ +int main( void ); +void init( void ); + +/* sketch */ +void setup( void ) ; +void loop( void ) ; + +#include "WVariant.h" + +#ifdef __cplusplus +} // extern "C" +#endif + +// The following headers are for C++ only compilation +#ifdef __cplusplus + #include "WCharacter.h" + #include "WString.h" + #include "Tone.h" + #include "WMath.h" + #include "HardwareSerial.h" + #include "pulse.h" + #include +#endif + +#include "delay.h" + +#ifdef __cplusplus + #include "Uart.h" +#endif + +// Include board variant +#include "variant.h" +#include "wiring.h" +#include "wiring_digital.h" +#include "wiring_analog.h" +#include "wiring_shift.h" +#include "WInterrupts.h" + +#ifndef __cplusplus + // undefine stdlib's abs if encountered + #ifdef abs + #undef abs + #endif // abs + + #define min(a,b) ((a)<(b)?(a):(b)) + #define max(a,b) ((a)>(b)?(a):(b)) + #define abs(x) ((x)>0?(x):-(x)) + #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) + +#else + //using std::min; + //using std::max; + template + auto min(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (b < a) ? b : a; + } + + template + auto max(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (a < b) ? b : a; + } +#endif + +#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) +#define radians(deg) ((deg)*DEG_TO_RAD) +#define degrees(rad) ((rad)*RAD_TO_DEG) +#define sq(x) ((x)*(x)) + +#define interrupts() __enable_irq() +#define noInterrupts() __disable_irq() + +#define lowByte(w) ((uint8_t) ((w) & 0xff)) +#define highByte(w) ((uint8_t) ((w) >> 8)) + +#define bitRead(value, bit) (((value) >> (bit)) & 0x01) +#define bitSet(value, bit) ((value) |= (1UL << (bit))) +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) +#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) +#define bit(b) (1UL << (b)) + +#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606) + // Interrupts + #define digitalPinToInterrupt(P) ( P ) +#endif + +// Allows publishing the Beta core under samd-beta / arduino organization +#ifndef ARDUINO_ARCH_SAMD +#define ARDUINO_ARCH_SAMD +#endif + +// USB Device +#include "USB/USBDesc.h" +#include "USB/USBCore.h" +#include "USB/USBAPI.h" +#include "USB/USB_host.h" + +#ifdef __cplusplus + #include "USB/CDC.h" +#endif + +#endif // Arduino_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.8/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.8/platform.txt new file mode 100644 index 0000000..abcb1ed --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.8/platform.txt @@ -0,0 +1,248 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Arduino SAMD (32-bits ARM Cortex-M0+) Boards +version=1.8.8 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +# EXPERIMENTAL feature: optimization flags +# - this is alpha and may be subject to change without notice +compiler.optimization_flags=-Os +compiler.optimization_flags.release=-Os +compiler.optimization_flags.debug=-Og -g3 + +compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags={compiler.optimization_flags} -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + +# Upload/Debug tools +# ------------------ + +# +# AVRDUDE +# +tools.avrdude.path={runtime.tools.avrdude.path} +tools.avrdude.cmd={path}/bin/avrdude +tools.avrdude.config.path={path}/etc/avrdude.conf + +tools.avrdude.upload.params.verbose=-v -v +tools.avrdude.upload.params.quiet=-q -q +tools.avrdude.upload.params.noverify=-V +tools.avrdude.upload.pattern="{cmd}" "-C{config.path}" {upload.verbose} -p{build.emu.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} "-Uflash:w:{build.path}/{build.project_name}.hex:i" + +tools.avrdude_remote.upload.pattern="openocd --version 2>&1 | grep 2016 && if opkg update; then opkg upgrade openocd; exit 1; else echo 'Please connect your board to the Internet in order to upgrade tools' >&2; exit 1; fi || /usr/bin/run-avrdude /tmp/sketch.hex" + +tools.avrdude.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.avrdude.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +arduinoota.extraflags= +tools.bossac.network_cmd={runtime.tools.arduinoOTA-1.3.0.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b {arduinoota.extraflags} + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.hex} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# GDB (Debugger) +# +# EXPERIMENTAL feature: debug.pattern +# - this is alpha and may be subject to change without notice +tools.gdb-openocd.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +tools.gdb-openocd.cmd=arm-none-eabi-gdb +tools.gdb-openocd.cmd.windows=arm-none-eabi-gdb.exe +tools.gdb-openocd.interpreter=console +tools.gdb-openocd.debug.pattern="{path}/{cmd}" --interpreter={interpreter} -ex "set remotetimeout 5" -ex "set pagination off" -ex 'target extended-remote | "{tools.openocd.path}/{tools.openocd.cmd}" -s "{tools.openocd.path}/share/openocd/scripts/" --file "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "gdb_port pipe" -c "telnet_port 0"' "{build.path}/{build.project_name}.elf" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.9/cores/arduino/Arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.9/cores/arduino/Arduino.h new file mode 100644 index 0000000..4c47b5c --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.9/cores/arduino/Arduino.h @@ -0,0 +1,165 @@ +/* + Arduino.h - Main include file for the Arduino SDK + Copyright (c) 2014 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// KH, This is the fix according to https://github.com/arduino/ArduinoCore-samd/pull/399 +// to avoid notorious compiler error while uing STL (min and max macro error) +// It's terrible Arduino has just released new core and still don't merge the PR + +#ifndef Arduino_h +#define Arduino_h + +#include +#include +#include +#include +#include + +typedef bool boolean; +typedef uint8_t byte; +typedef uint16_t word; + +// some libraries and sketches depend on this AVR stuff, +// assuming Arduino.h or WProgram.h automatically includes it... +// +#include "avr/pgmspace.h" +#include "avr/interrupt.h" +#include "avr/io.h" + +#include "binary.h" +#include "itoa.h" + +#ifdef __cplusplus + extern "C"{ +#endif // __cplusplus + +// Include Atmel headers +#include "sam.h" + +#include "wiring_constants.h" + +#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L ) +#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) ) +#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) ) + +void yield( void ) ; + +/* system functions */ +int main( void ); +void init( void ); + +/* sketch */ +void setup( void ) ; +void loop( void ) ; + +#include "WVariant.h" + +#ifdef __cplusplus +} // extern "C" +#endif + +// The following headers are for C++ only compilation +#ifdef __cplusplus + #include "WCharacter.h" + #include "WString.h" + #include "Tone.h" + #include "WMath.h" + #include "HardwareSerial.h" + #include "pulse.h" + #include +#endif + +#include "delay.h" + +#ifdef __cplusplus + #include "Uart.h" +#endif + +// Include board variant +#include "variant.h" +#include "wiring.h" +#include "wiring_digital.h" +#include "wiring_analog.h" +#include "wiring_shift.h" +#include "WInterrupts.h" + +#ifndef __cplusplus + // undefine stdlib's abs if encountered + #ifdef abs + #undef abs + #endif // abs + + #define min(a,b) ((a)<(b)?(a):(b)) + #define max(a,b) ((a)>(b)?(a):(b)) + #define abs(x) ((x)>0?(x):-(x)) + #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) + +#else + //using std::min; + //using std::max; + template + auto min(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (b < a) ? b : a; + } + + template + auto max(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (a < b) ? b : a; + } +#endif + +#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) +#define radians(deg) ((deg)*DEG_TO_RAD) +#define degrees(rad) ((rad)*RAD_TO_DEG) +#define sq(x) ((x)*(x)) + +#define interrupts() __enable_irq() +#define noInterrupts() __disable_irq() + +#define lowByte(w) ((uint8_t) ((w) & 0xff)) +#define highByte(w) ((uint8_t) ((w) >> 8)) + +#define bitRead(value, bit) (((value) >> (bit)) & 0x01) +#define bitSet(value, bit) ((value) |= (1UL << (bit))) +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) +#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) +#define bit(b) (1UL << (b)) + +#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606) + // Interrupts + #define digitalPinToInterrupt(P) ( P ) +#endif + +// Allows publishing the Beta core under samd-beta / arduino organization +#ifndef ARDUINO_ARCH_SAMD +#define ARDUINO_ARCH_SAMD +#endif + +// USB Device +#include "USB/USBDesc.h" +#include "USB/USBCore.h" +#include "USB/USBAPI.h" +#include "USB/USB_host.h" + +#ifdef __cplusplus + #include "USB/CDC.h" +#endif + +#endif // Arduino_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.9/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.9/platform.txt new file mode 100644 index 0000000..9aa0320 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/arduino/hardware/samd/1.8.9/platform.txt @@ -0,0 +1,242 @@ +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Arduino SAMD Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Arduino SAMD (32-bits ARM Cortex-M0+) Boards +version=1.8.9 + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined + +# EXPERIMENTAL feature: optimization flags +# - this is alpha and may be subject to change without notice +compiler.optimization_flags=-Os +compiler.optimization_flags.release=-Os +compiler.optimization_flags.debug=-Og -g3 + +compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags={compiler.optimization_flags} -Wl,--gc-sections -save-temps +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +#compiler.c.elf.extra_flags=-v +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math + +compiler.libraries.ldflags= + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DBOARD_NAME="{build.board}" -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} -lm "{build.path}/{archive_file}" -Wl,--end-group + +## Create output (bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" + +## Create output (hex file) +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" + +build.preferred_out_format=bin + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* + +# Upload/Debug tools +# ------------------ + +# +# AVRDUDE +# +tools.avrdude.path={runtime.tools.avrdude.path} +tools.avrdude.cmd={path}/bin/avrdude +tools.avrdude.config.path={path}/etc/avrdude.conf + +tools.avrdude.upload.params.verbose=-v -v +tools.avrdude.upload.params.quiet=-q -q +tools.avrdude.upload.params.noverify=-V +tools.avrdude.upload.pattern="{cmd}" "-C{config.path}" {upload.verbose} -p{build.emu.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} "-Uflash:w:{build.path}/{build.project_name}.hex:i" + +tools.avrdude_remote.upload.pattern="openocd --version 2>&1 | grep 2016 && if opkg update; then opkg upgrade openocd; exit 1; else echo 'Please connect your board to the Internet in order to upgrade tools' >&2; exit 1; fi || /usr/bin/run-avrdude /tmp/sketch.hex" + +tools.avrdude.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.avrdude.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +# +# BOSSA +# +tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe + +tools.bossac.upload.params.verbose=-i -d +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R + +tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +arduinoota.extraflags= +tools.bossac.network_cmd={runtime.tools.arduinoOTA-1.3.0.path}/bin/arduinoOTA +tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b {arduinoota.extraflags} + +# +# BOSSA (ignore binary size) +# +tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path} +tools.bossacI.cmd=bossac +tools.bossacI.cmd.windows=bossac.exe + +tools.bossacI.upload.params.verbose=-i -d +tools.bossacI.upload.params.quiet= +tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R + +tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R + +tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + + +# +# OpenOCD sketch upload +# + +tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.cmd=bin/openocd +tools.openocd.cmd.windows=bin/openocd.exe + +tools.openocd.upload.params.verbose=-d2 +tools.openocd.upload.params.quiet=-d0 +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" + +tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b + +tools.openocd.program.params.verbose=-d2 +tools.openocd.program.params.quiet=-d0 +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.hex} verify reset; shutdown" + +tools.openocd.erase.params.verbose=-d3 +tools.openocd.erase.params.quiet=-d0 +tools.openocd.erase.pattern= + +tools.openocd.bootloader.params.verbose=-d2 +tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# OpenOCD sketch upload - version with configurable bootloader size +# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences +# + +tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.cmd=bin/openocd +tools.openocd-withbootsize.cmd.windows=bin/openocd.exe + +tools.openocd-withbootsize.upload.params.verbose=-d2 +tools.openocd-withbootsize.upload.params.quiet=-d0 +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" + +# Program flashes the binary at 0x0000, so use the linker script without_bootloader +tools.openocd-withbootsize.program.params.verbose=-d2 +tools.openocd-withbootsize.program.params.quiet=-d0 +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" + +tools.openocd-withbootsize.erase.params.verbose=-d3 +tools.openocd-withbootsize.erase.params.quiet=-d0 +tools.openocd-withbootsize.erase.pattern= + +tools.openocd-withbootsize.bootloader.params.verbose=-d2 +tools.openocd-withbootsize.bootloader.params.quiet=-d0 +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# +# GDB (Debugger) +# +# EXPERIMENTAL feature: debug.pattern +# - this is alpha and may be subject to change without notice +tools.gdb-openocd.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +tools.gdb-openocd.cmd=arm-none-eabi-gdb +tools.gdb-openocd.cmd.windows=arm-none-eabi-gdb.exe +tools.gdb-openocd.interpreter=console +tools.gdb-openocd.debug.pattern="{path}/{cmd}" --interpreter={interpreter} -ex "set remotetimeout 5" -ex "set pagination off" -ex 'target extended-remote | "{tools.openocd.path}/{tools.openocd.cmd}" -s "{tools.openocd.path}/share/openocd/scripts/" --file "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "gdb_port pipe" -c "telnet_port 0"' "{build.path}/{build.project_name}.elf" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/boards.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/boards.txt new file mode 100644 index 0000000..693927f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/boards.txt @@ -0,0 +1,1798 @@ +menu.usb=USB Type +menu.speed=CPU Speed +menu.opt=Optimize +menu.keys=Keyboard Layout + + +# TODO: consider whether these compiler warnings are worthwhile +# -Wno-error=unused-function +# -Wno-error=unused-but-set-variable +# -Wno-error=unused-variable +# -Wno-unused-parameter +# -Wno-unused-but-set-parameter +# -Wno-sign-compare + + +teensy41.name=Teensy 4.1 +#teensy41.upload.maximum_size=8126464 +teensy41.build.board=TEENSY41 +teensy41.build.flags.ld=-Wl,--gc-sections,--relax "-T{build.core.path}/imxrt1062_t41.ld" +#teensy41.upload.maximum_data_size=524288 +teensy41.upload.tool=teensyloader +teensy41.upload.protocol=halfkay +teensy41.build.core=teensy4 +teensy41.build.mcu=imxrt1062 +teensy41.build.warn_data_percentage=99 +teensy41.build.toolchain=arm/bin/ +teensy41.build.command.gcc=arm-none-eabi-gcc +teensy41.build.command.g++=arm-none-eabi-g++ +teensy41.build.command.ar=arm-none-eabi-gcc-ar +teensy41.build.command.objcopy=arm-none-eabi-objcopy +teensy41.build.command.objdump=arm-none-eabi-objdump +teensy41.build.command.linker=arm-none-eabi-gcc +teensy41.build.command.size=arm-none-eabi-size +teensy41.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib +teensy41.build.flags.dep=-MMD +teensy41.build.flags.optimize=-Os +teensy41.build.flags.cpu=-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 +teensy41.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=156 +teensy41.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing +teensy41.build.flags.c= +teensy41.build.flags.S=-x assembler-with-cpp +teensy41.build.flags.libs=-larm_cortexM7lfsp_math -lm -lstdc++ +teensy41.serial.restart_cmd=false +teensy41.menu.usb.serial=Serial +teensy41.menu.usb.serial.build.usbtype=USB_SERIAL +teensy41.menu.usb.serial2=Dual Serial +teensy41.menu.usb.serial2.build.usbtype=USB_DUAL_SERIAL +teensy41.menu.usb.serial3=Triple Serial +teensy41.menu.usb.serial3.build.usbtype=USB_TRIPLE_SERIAL +teensy41.menu.usb.keyboard=Keyboard +teensy41.menu.usb.keyboard.build.usbtype=USB_KEYBOARDONLY +teensy41.menu.usb.keyboard.fake_serial=teensy_gateway +teensy41.menu.usb.touch=Keyboard + Touch Screen +teensy41.menu.usb.touch.build.usbtype=USB_TOUCHSCREEN +teensy41.menu.usb.touch.fake_serial=teensy_gateway +teensy41.menu.usb.hidtouch=Keyboard + Mouse + Touch Screen +teensy41.menu.usb.hidtouch.build.usbtype=USB_HID_TOUCHSCREEN +teensy41.menu.usb.hidtouch.fake_serial=teensy_gateway +teensy41.menu.usb.hid=Keyboard + Mouse + Joystick +teensy41.menu.usb.hid.build.usbtype=USB_HID +teensy41.menu.usb.hid.fake_serial=teensy_gateway +teensy41.menu.usb.serialhid=Serial + Keyboard + Mouse + Joystick +teensy41.menu.usb.serialhid.build.usbtype=USB_SERIAL_HID +teensy41.menu.usb.midi=MIDI +teensy41.menu.usb.midi.build.usbtype=USB_MIDI +teensy41.menu.usb.midi.fake_serial=teensy_gateway +teensy41.menu.usb.midi4=MIDIx4 +teensy41.menu.usb.midi4.build.usbtype=USB_MIDI4 +teensy41.menu.usb.midi4.fake_serial=teensy_gateway +teensy41.menu.usb.midi16=MIDIx16 +teensy41.menu.usb.midi16.build.usbtype=USB_MIDI16 +teensy41.menu.usb.midi16.fake_serial=teensy_gateway +teensy41.menu.usb.serialmidi=Serial + MIDI +teensy41.menu.usb.serialmidi.build.usbtype=USB_MIDI_SERIAL +teensy41.menu.usb.serialmidi4=Serial + MIDIx4 +teensy41.menu.usb.serialmidi4.build.usbtype=USB_MIDI4_SERIAL +teensy41.menu.usb.serialmidi16=Serial + MIDIx16 +teensy41.menu.usb.serialmidi16.build.usbtype=USB_MIDI16_SERIAL +teensy41.menu.usb.audio=Audio +teensy41.menu.usb.audio.build.usbtype=USB_AUDIO +teensy41.menu.usb.audio.fake_serial=teensy_gateway +teensy41.menu.usb.serialmidiaudio=Serial + MIDI + Audio +teensy41.menu.usb.serialmidiaudio.build.usbtype=USB_MIDI_AUDIO_SERIAL +teensy41.menu.usb.serialmidi16audio=Serial + MIDIx16 + Audio +teensy41.menu.usb.serialmidi16audio.build.usbtype=USB_MIDI16_AUDIO_SERIAL +teensy41.menu.usb.mtp=MTP Disk (Experimental) +teensy41.menu.usb.mtp.build.usbtype=USB_MTPDISK +teensy41.menu.usb.mtp.fake_serial=teensy_gateway +teensy41.menu.usb.rawhid=Raw HID +teensy41.menu.usb.rawhid.build.usbtype=USB_RAWHID +teensy41.menu.usb.rawhid.fake_serial=teensy_gateway +teensy41.menu.usb.flightsim=Flight Sim Controls +teensy41.menu.usb.flightsim.build.usbtype=USB_FLIGHTSIM +teensy41.menu.usb.flightsim.fake_serial=teensy_gateway +teensy41.menu.usb.flightsimjoystick=Flight Sim Controls + Joystick +teensy41.menu.usb.flightsimjoystick.build.usbtype=USB_FLIGHTSIM_JOYSTICK +teensy41.menu.usb.flightsimjoystick.fake_serial=teensy_gateway +#teensy41.menu.usb.disable=No USB +#teensy41.menu.usb.disable.build.usbtype=USB_DISABLED + +teensy41.menu.speed.600=600 MHz +teensy41.menu.speed.528=528 MHz +teensy41.menu.speed.450=450 MHz +teensy41.menu.speed.396=396 MHz +teensy41.menu.speed.150=150 MHz +teensy41.menu.speed.24=24 MHz +teensy41.menu.speed.720=720 MHz (overclock) +teensy41.menu.speed.816=816 MHz (overclock) +teensy41.menu.speed.912=912 MHz (overclock, cooling req'd) +teensy41.menu.speed.960=960 MHz (overclock, cooling req'd) +teensy41.menu.speed.1008=1.008 GHz (overclock, cooling req'd) +teensy41.menu.speed.1008.build.fcpu=1008000000 +teensy41.menu.speed.960.build.fcpu=960000000 +teensy41.menu.speed.912.build.fcpu=912000000 +teensy41.menu.speed.816.build.fcpu=816000000 +teensy41.menu.speed.720.build.fcpu=720000000 +teensy41.menu.speed.600.build.fcpu=600000000 +teensy41.menu.speed.528.build.fcpu=528000000 +teensy41.menu.speed.450.build.fcpu=450000000 +teensy41.menu.speed.396.build.fcpu=396000000 +teensy41.menu.speed.150.build.fcpu=150000000 +teensy41.menu.speed.24.build.fcpu=24000000 + +teensy41.menu.opt.o2std=Faster +teensy41.menu.opt.o2std.build.flags.optimize=-O2 +teensy41.menu.opt.o2std.build.flags.ldspecs= +#teensy41.menu.opt.o2lto=Faster with LTO +#teensy41.menu.opt.o2lto.build.flags.optimize=-O2 -flto -fno-fat-lto-objects +#teensy41.menu.opt.o2lto.build.flags.ldspecs=-fuse-linker-plugin +teensy41.menu.opt.o1std=Fast +teensy41.menu.opt.o1std.build.flags.optimize=-O1 +teensy41.menu.opt.o1std.build.flags.ldspecs= +#teensy41.menu.opt.o1lto=Fast with LTO +#teensy41.menu.opt.o1lto.build.flags.optimize=-O1 -flto -fno-fat-lto-objects +#teensy41.menu.opt.o1lto.build.flags.ldspecs=-fuse-linker-plugin +teensy41.menu.opt.o3std=Fastest +teensy41.menu.opt.o3std.build.flags.optimize=-O3 +teensy41.menu.opt.o3std.build.flags.ldspecs= +#teensy41.menu.opt.o3purestd=Fastest + pure-code +#teensy41.menu.opt.o3purestd.build.flags.optimize=-O3 -mpure-code -D__PURE_CODE__ +#teensy41.menu.opt.o3purestd.build.flags.ldspecs= +#teensy41.menu.opt.o3lto=Fastest with LTO +#teensy41.menu.opt.o3lto.build.flags.optimize=-O3 -flto -fno-fat-lto-objects +#teensy41.menu.opt.o3lto.build.flags.ldspecs=-fuse-linker-plugin +#teensy41.menu.opt.o3purelto=Fastest + pure-code with LTO +#teensy41.menu.opt.o3purelto.build.flags.optimize=-O3 -mpure-code -D__PURE_CODE__ -flto -fno-fat-lto-objects +#teensy41.menu.opt.o3purelto.build.flags.ldspecs=-fuse-linker-plugin +teensy41.menu.opt.ogstd=Debug +teensy41.menu.opt.ogstd.build.flags.optimize=-Og +teensy41.menu.opt.ogstd.build.flags.ldspecs= +#teensy41.menu.opt.oglto=Debug with LTO +#teensy41.menu.opt.oglto.build.flags.optimize=-Og -flto -fno-fat-lto-objects +#teensy41.menu.opt.oglto.build.flags.ldspecs=-fuse-linker-plugin +teensy41.menu.opt.osstd=Smallest Code +teensy41.menu.opt.osstd.build.flags.optimize=-Os --specs=nano.specs +teensy41.menu.opt.osstd.build.flags.ldspecs= +#teensy41.menu.opt.oslto=Smallest Code with LTO +#teensy41.menu.opt.oslto.build.flags.optimize=-Os -flto -fno-fat-lto-objects --specs=nano.specs +#teensy41.menu.opt.oslto.build.flags.ldspecs=-fuse-linker-plugin + +teensy41.menu.keys.en-us=US English +teensy41.menu.keys.en-us.build.keylayout=US_ENGLISH +teensy41.menu.keys.fr-ca=Canadian French +teensy41.menu.keys.fr-ca.build.keylayout=CANADIAN_FRENCH +teensy41.menu.keys.xx-ca=Canadian Multilingual +teensy41.menu.keys.xx-ca.build.keylayout=CANADIAN_MULTILINGUAL +teensy41.menu.keys.cz-cz=Czech +teensy41.menu.keys.cz-cz.build.keylayout=CZECH +teensy41.menu.keys.da-da=Danish +teensy41.menu.keys.da-da.build.keylayout=DANISH +teensy41.menu.keys.fi-fi=Finnish +teensy41.menu.keys.fi-fi.build.keylayout=FINNISH +teensy41.menu.keys.fr-fr=French +teensy41.menu.keys.fr-fr.build.keylayout=FRENCH +teensy41.menu.keys.fr-be=French Belgian +teensy41.menu.keys.fr-be.build.keylayout=FRENCH_BELGIAN +teensy41.menu.keys.fr-ch=French Swiss +teensy41.menu.keys.fr-ch.build.keylayout=FRENCH_SWISS +teensy41.menu.keys.de-de=German +teensy41.menu.keys.de-de.build.keylayout=GERMAN +teensy41.menu.keys.de-dm=German (Mac) +teensy41.menu.keys.de-dm.build.keylayout=GERMAN_MAC +teensy41.menu.keys.de-ch=German Swiss +teensy41.menu.keys.de-ch.build.keylayout=GERMAN_SWISS +teensy41.menu.keys.is-is=Icelandic +teensy41.menu.keys.is-is.build.keylayout=ICELANDIC +teensy41.menu.keys.en-ie=Irish +teensy41.menu.keys.en-ie.build.keylayout=IRISH +teensy41.menu.keys.it-it=Italian +teensy41.menu.keys.it-it.build.keylayout=ITALIAN +teensy41.menu.keys.no-no=Norwegian +teensy41.menu.keys.no-no.build.keylayout=NORWEGIAN +teensy41.menu.keys.pt-pt=Portuguese +teensy41.menu.keys.pt-pt.build.keylayout=PORTUGUESE +teensy41.menu.keys.pt-br=Portuguese Brazilian +teensy41.menu.keys.pt-br.build.keylayout=PORTUGUESE_BRAZILIAN +teensy41.menu.keys.rs-rs=Serbian (Latin Only) +teensy41.menu.keys.rs-rs.build.keylayout=SERBIAN_LATIN_ONLY +teensy41.menu.keys.es-es=Spanish +teensy41.menu.keys.es-es.build.keylayout=SPANISH +teensy41.menu.keys.es-mx=Spanish Latin America +teensy41.menu.keys.es-mx.build.keylayout=SPANISH_LATIN_AMERICA +teensy41.menu.keys.sv-se=Swedish +teensy41.menu.keys.sv-se.build.keylayout=SWEDISH +teensy41.menu.keys.tr-tr=Turkish (partial) +teensy41.menu.keys.tr-tr.build.keylayout=TURKISH +teensy41.menu.keys.en-gb=United Kingdom +teensy41.menu.keys.en-gb.build.keylayout=UNITED_KINGDOM +teensy41.menu.keys.usint=US International +teensy41.menu.keys.usint.build.keylayout=US_INTERNATIONAL + + + + +teensyMM.name=Teensy MicroMod +#teensyMM.upload.maximum_size=16515072 +teensyMM.build.board=TEENSY_MICROMOD +teensyMM.build.flags.ld=-Wl,--gc-sections,--relax "-T{build.core.path}/imxrt1062_mm.ld" +#teensyMM.upload.maximum_data_size=524288 +#teensyMM.upload.maximum_data_size=1048576 +teensyMM.upload.tool=teensyloader +teensyMM.upload.protocol=halfkay +teensyMM.build.core=teensy4 +teensyMM.build.mcu=imxrt1062 +teensyMM.build.warn_data_percentage=99 +teensyMM.build.toolchain=arm/bin/ +teensyMM.build.command.gcc=arm-none-eabi-gcc +teensyMM.build.command.g++=arm-none-eabi-g++ +teensyMM.build.command.ar=arm-none-eabi-gcc-ar +teensyMM.build.command.objcopy=arm-none-eabi-objcopy +teensyMM.build.command.objdump=arm-none-eabi-objdump +teensyMM.build.command.linker=arm-none-eabi-gcc +teensyMM.build.command.size=arm-none-eabi-size +teensyMM.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib +teensyMM.build.flags.dep=-MMD +teensyMM.build.flags.optimize=-Os +teensyMM.build.flags.cpu=-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 +teensyMM.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=156 +teensyMM.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing +teensyMM.build.flags.c= +teensyMM.build.flags.S=-x assembler-with-cpp +teensyMM.build.flags.libs=-larm_cortexM7lfsp_math -lm -lstdc++ +teensyMM.serial.restart_cmd=false +teensyMM.menu.usb.serial=Serial +teensyMM.menu.usb.serial.build.usbtype=USB_SERIAL +teensyMM.menu.usb.serial2=Dual Serial +teensyMM.menu.usb.serial2.build.usbtype=USB_DUAL_SERIAL +teensyMM.menu.usb.serial3=Triple Serial +teensyMM.menu.usb.serial3.build.usbtype=USB_TRIPLE_SERIAL +teensyMM.menu.usb.keyboard=Keyboard +teensyMM.menu.usb.keyboard.build.usbtype=USB_KEYBOARDONLY +teensyMM.menu.usb.keyboard.fake_serial=teensy_gateway +teensyMM.menu.usb.touch=Keyboard + Touch Screen +teensyMM.menu.usb.touch.build.usbtype=USB_TOUCHSCREEN +teensyMM.menu.usb.touch.fake_serial=teensy_gateway +teensyMM.menu.usb.hidtouch=Keyboard + Mouse + Touch Screen +teensyMM.menu.usb.hidtouch.build.usbtype=USB_HID_TOUCHSCREEN +teensyMM.menu.usb.hidtouch.fake_serial=teensy_gateway +teensyMM.menu.usb.hid=Keyboard + Mouse + Joystick +teensyMM.menu.usb.hid.build.usbtype=USB_HID +teensyMM.menu.usb.hid.fake_serial=teensy_gateway +teensyMM.menu.usb.serialhid=Serial + Keyboard + Mouse + Joystick +teensyMM.menu.usb.serialhid.build.usbtype=USB_SERIAL_HID +teensyMM.menu.usb.midi=MIDI +teensyMM.menu.usb.midi.build.usbtype=USB_MIDI +teensyMM.menu.usb.midi.fake_serial=teensy_gateway +teensyMM.menu.usb.midi4=MIDIx4 +teensyMM.menu.usb.midi4.build.usbtype=USB_MIDI4 +teensyMM.menu.usb.midi4.fake_serial=teensy_gateway +teensyMM.menu.usb.midi16=MIDIx16 +teensyMM.menu.usb.midi16.build.usbtype=USB_MIDI16 +teensyMM.menu.usb.midi16.fake_serial=teensy_gateway +teensyMM.menu.usb.serialmidi=Serial + MIDI +teensyMM.menu.usb.serialmidi.build.usbtype=USB_MIDI_SERIAL +teensyMM.menu.usb.serialmidi4=Serial + MIDIx4 +teensyMM.menu.usb.serialmidi4.build.usbtype=USB_MIDI4_SERIAL +teensyMM.menu.usb.serialmidi16=Serial + MIDIx16 +teensyMM.menu.usb.serialmidi16.build.usbtype=USB_MIDI16_SERIAL +teensyMM.menu.usb.audio=Audio +teensyMM.menu.usb.audio.build.usbtype=USB_AUDIO +teensyMM.menu.usb.audio.fake_serial=teensy_gateway +teensyMM.menu.usb.serialmidiaudio=Serial + MIDI + Audio +teensyMM.menu.usb.serialmidiaudio.build.usbtype=USB_MIDI_AUDIO_SERIAL +teensyMM.menu.usb.serialmidi16audio=Serial + MIDIx16 + Audio +teensyMM.menu.usb.serialmidi16audio.build.usbtype=USB_MIDI16_AUDIO_SERIAL +teensyMM.menu.usb.mtp=MTP Disk (Experimental) +teensyMM.menu.usb.mtp.build.usbtype=USB_MTPDISK +teensyMM.menu.usb.mtp.fake_serial=teensy_gateway +teensyMM.menu.usb.rawhid=Raw HID +teensyMM.menu.usb.rawhid.build.usbtype=USB_RAWHID +teensyMM.menu.usb.rawhid.fake_serial=teensy_gateway +teensyMM.menu.usb.flightsim=Flight Sim Controls +teensyMM.menu.usb.flightsim.build.usbtype=USB_FLIGHTSIM +teensyMM.menu.usb.flightsim.fake_serial=teensy_gateway +teensyMM.menu.usb.flightsimjoystick=Flight Sim Controls + Joystick +teensyMM.menu.usb.flightsimjoystick.build.usbtype=USB_FLIGHTSIM_JOYSTICK +teensyMM.menu.usb.flightsimjoystick.fake_serial=teensy_gateway +#teensyMM.menu.usb.disable=No USB +#teensyMM.menu.usb.disable.build.usbtype=USB_DISABLED + +teensyMM.menu.speed.600=600 MHz +teensyMM.menu.speed.528=528 MHz +teensyMM.menu.speed.450=450 MHz +teensyMM.menu.speed.396=396 MHz +teensyMM.menu.speed.150=150 MHz +teensyMM.menu.speed.24=24 MHz +teensyMM.menu.speed.720=720 MHz (overclock) +teensyMM.menu.speed.816=816 MHz (overclock) +teensyMM.menu.speed.912=912 MHz (overclock, cooling req'd) +teensyMM.menu.speed.960=960 MHz (overclock, cooling req'd) +teensyMM.menu.speed.1008=1.008 GHz (overclock, cooling req'd) +teensyMM.menu.speed.1008.build.fcpu=1008000000 +teensyMM.menu.speed.960.build.fcpu=960000000 +teensyMM.menu.speed.912.build.fcpu=912000000 +teensyMM.menu.speed.816.build.fcpu=816000000 +teensyMM.menu.speed.720.build.fcpu=720000000 +teensyMM.menu.speed.600.build.fcpu=600000000 +teensyMM.menu.speed.528.build.fcpu=528000000 +teensyMM.menu.speed.450.build.fcpu=450000000 +teensyMM.menu.speed.396.build.fcpu=396000000 +teensyMM.menu.speed.150.build.fcpu=150000000 +teensyMM.menu.speed.24.build.fcpu=24000000 + +teensyMM.menu.opt.o2std=Faster +teensyMM.menu.opt.o2std.build.flags.optimize=-O2 +teensyMM.menu.opt.o2std.build.flags.ldspecs= +#teensyMM.menu.opt.o2lto=Faster with LTO +#teensyMM.menu.opt.o2lto.build.flags.optimize=-O2 -flto -fno-fat-lto-objects +#teensyMM.menu.opt.o2lto.build.flags.ldspecs=-fuse-linker-plugin +teensyMM.menu.opt.o1std=Fast +teensyMM.menu.opt.o1std.build.flags.optimize=-O1 +teensyMM.menu.opt.o1std.build.flags.ldspecs= +#teensyMM.menu.opt.o1lto=Fast with LTO +#teensyMM.menu.opt.o1lto.build.flags.optimize=-O1 -flto -fno-fat-lto-objects +#teensyMM.menu.opt.o1lto.build.flags.ldspecs=-fuse-linker-plugin +teensyMM.menu.opt.o3std=Fastest +teensyMM.menu.opt.o3std.build.flags.optimize=-O3 +teensyMM.menu.opt.o3std.build.flags.ldspecs= +#teensyMM.menu.opt.o3purestd=Fastest + pure-code +#teensyMM.menu.opt.o3purestd.build.flags.optimize=-O3 -mpure-code -D__PURE_CODE__ +#teensyMM.menu.opt.o3purestd.build.flags.ldspecs= +#teensyMM.menu.opt.o3lto=Fastest with LTO +#teensyMM.menu.opt.o3lto.build.flags.optimize=-O3 -flto -fno-fat-lto-objects +#teensyMM.menu.opt.o3lto.build.flags.ldspecs=-fuse-linker-plugin +#teensyMM.menu.opt.o3purelto=Fastest + pure-code with LTO +#teensyMM.menu.opt.o3purelto.build.flags.optimize=-O3 -mpure-code -D__PURE_CODE__ -flto -fno-fat-lto-objects +#teensyMM.menu.opt.o3purelto.build.flags.ldspecs=-fuse-linker-plugin +teensyMM.menu.opt.ogstd=Debug +teensyMM.menu.opt.ogstd.build.flags.optimize=-Og +teensyMM.menu.opt.ogstd.build.flags.ldspecs= +#teensyMM.menu.opt.oglto=Debug with LTO +#teensyMM.menu.opt.oglto.build.flags.optimize=-Og -flto -fno-fat-lto-objects +#teensyMM.menu.opt.oglto.build.flags.ldspecs=-fuse-linker-plugin +teensyMM.menu.opt.osstd=Smallest Code +teensyMM.menu.opt.osstd.build.flags.optimize=-Os --specs=nano.specs +teensyMM.menu.opt.osstd.build.flags.ldspecs= +#teensyMM.menu.opt.oslto=Smallest Code with LTO +#teensyMM.menu.opt.oslto.build.flags.optimize=-Os -flto -fno-fat-lto-objects --specs=nano.specs +#teensyMM.menu.opt.oslto.build.flags.ldspecs=-fuse-linker-plugin + +teensyMM.menu.keys.en-us=US English +teensyMM.menu.keys.en-us.build.keylayout=US_ENGLISH +teensyMM.menu.keys.fr-ca=Canadian French +teensyMM.menu.keys.fr-ca.build.keylayout=CANADIAN_FRENCH +teensyMM.menu.keys.xx-ca=Canadian Multilingual +teensyMM.menu.keys.xx-ca.build.keylayout=CANADIAN_MULTILINGUAL +teensyMM.menu.keys.cz-cz=Czech +teensyMM.menu.keys.cz-cz.build.keylayout=CZECH +teensyMM.menu.keys.da-da=Danish +teensyMM.menu.keys.da-da.build.keylayout=DANISH +teensyMM.menu.keys.fi-fi=Finnish +teensyMM.menu.keys.fi-fi.build.keylayout=FINNISH +teensyMM.menu.keys.fr-fr=French +teensyMM.menu.keys.fr-fr.build.keylayout=FRENCH +teensyMM.menu.keys.fr-be=French Belgian +teensyMM.menu.keys.fr-be.build.keylayout=FRENCH_BELGIAN +teensyMM.menu.keys.fr-ch=French Swiss +teensyMM.menu.keys.fr-ch.build.keylayout=FRENCH_SWISS +teensyMM.menu.keys.de-de=German +teensyMM.menu.keys.de-de.build.keylayout=GERMAN +teensyMM.menu.keys.de-dm=German (Mac) +teensyMM.menu.keys.de-dm.build.keylayout=GERMAN_MAC +teensyMM.menu.keys.de-ch=German Swiss +teensyMM.menu.keys.de-ch.build.keylayout=GERMAN_SWISS +teensyMM.menu.keys.is-is=Icelandic +teensyMM.menu.keys.is-is.build.keylayout=ICELANDIC +teensyMM.menu.keys.en-ie=Irish +teensyMM.menu.keys.en-ie.build.keylayout=IRISH +teensyMM.menu.keys.it-it=Italian +teensyMM.menu.keys.it-it.build.keylayout=ITALIAN +teensyMM.menu.keys.no-no=Norwegian +teensyMM.menu.keys.no-no.build.keylayout=NORWEGIAN +teensyMM.menu.keys.pt-pt=Portuguese +teensyMM.menu.keys.pt-pt.build.keylayout=PORTUGUESE +teensyMM.menu.keys.pt-br=Portuguese Brazilian +teensyMM.menu.keys.pt-br.build.keylayout=PORTUGUESE_BRAZILIAN +teensyMM.menu.keys.rs-rs=Serbian (Latin Only) +teensyMM.menu.keys.rs-rs.build.keylayout=SERBIAN_LATIN_ONLY +teensyMM.menu.keys.es-es=Spanish +teensyMM.menu.keys.es-es.build.keylayout=SPANISH +teensyMM.menu.keys.es-mx=Spanish Latin America +teensyMM.menu.keys.es-mx.build.keylayout=SPANISH_LATIN_AMERICA +teensyMM.menu.keys.sv-se=Swedish +teensyMM.menu.keys.sv-se.build.keylayout=SWEDISH +teensyMM.menu.keys.tr-tr=Turkish (partial) +teensyMM.menu.keys.tr-tr.build.keylayout=TURKISH +teensyMM.menu.keys.en-gb=United Kingdom +teensyMM.menu.keys.en-gb.build.keylayout=UNITED_KINGDOM +teensyMM.menu.keys.usint=US International +teensyMM.menu.keys.usint.build.keylayout=US_INTERNATIONAL + + + + +teensy40.name=Teensy 4.0 +#teensy40.upload.maximum_size=2031616 +teensy40.build.board=TEENSY40 +teensy40.build.flags.ld=-Wl,--gc-sections,--relax "-T{build.core.path}/imxrt1062.ld" +#teensy40.upload.maximum_data_size=524288 +#teensy40.upload.maximum_data_size=1048576 +teensy40.upload.tool=teensyloader +teensy40.upload.protocol=halfkay +teensy40.build.core=teensy4 +teensy40.build.mcu=imxrt1062 +teensy40.build.warn_data_percentage=99 +teensy40.build.toolchain=arm/bin/ +teensy40.build.command.gcc=arm-none-eabi-gcc +teensy40.build.command.g++=arm-none-eabi-g++ +teensy40.build.command.ar=arm-none-eabi-gcc-ar +teensy40.build.command.objcopy=arm-none-eabi-objcopy +teensy40.build.command.objdump=arm-none-eabi-objdump +teensy40.build.command.linker=arm-none-eabi-gcc +teensy40.build.command.size=arm-none-eabi-size +teensy40.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib +teensy40.build.flags.dep=-MMD +teensy40.build.flags.optimize=-Os +teensy40.build.flags.cpu=-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 +teensy40.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=156 +teensy40.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing +teensy40.build.flags.c= +teensy40.build.flags.S=-x assembler-with-cpp +teensy40.build.flags.libs=-larm_cortexM7lfsp_math -lm -lstdc++ +teensy40.serial.restart_cmd=false +teensy40.menu.usb.serial=Serial +teensy40.menu.usb.serial.build.usbtype=USB_SERIAL +teensy40.menu.usb.serial2=Dual Serial +teensy40.menu.usb.serial2.build.usbtype=USB_DUAL_SERIAL +teensy40.menu.usb.serial3=Triple Serial +teensy40.menu.usb.serial3.build.usbtype=USB_TRIPLE_SERIAL +teensy40.menu.usb.keyboard=Keyboard +teensy40.menu.usb.keyboard.build.usbtype=USB_KEYBOARDONLY +teensy40.menu.usb.keyboard.fake_serial=teensy_gateway +teensy40.menu.usb.touch=Keyboard + Touch Screen +teensy40.menu.usb.touch.build.usbtype=USB_TOUCHSCREEN +teensy40.menu.usb.touch.fake_serial=teensy_gateway +teensy40.menu.usb.hidtouch=Keyboard + Mouse + Touch Screen +teensy40.menu.usb.hidtouch.build.usbtype=USB_HID_TOUCHSCREEN +teensy40.menu.usb.hidtouch.fake_serial=teensy_gateway +teensy40.menu.usb.hid=Keyboard + Mouse + Joystick +teensy40.menu.usb.hid.build.usbtype=USB_HID +teensy40.menu.usb.hid.fake_serial=teensy_gateway +teensy40.menu.usb.serialhid=Serial + Keyboard + Mouse + Joystick +teensy40.menu.usb.serialhid.build.usbtype=USB_SERIAL_HID +teensy40.menu.usb.midi=MIDI +teensy40.menu.usb.midi.build.usbtype=USB_MIDI +teensy40.menu.usb.midi.fake_serial=teensy_gateway +teensy40.menu.usb.midi4=MIDIx4 +teensy40.menu.usb.midi4.build.usbtype=USB_MIDI4 +teensy40.menu.usb.midi4.fake_serial=teensy_gateway +teensy40.menu.usb.midi16=MIDIx16 +teensy40.menu.usb.midi16.build.usbtype=USB_MIDI16 +teensy40.menu.usb.midi16.fake_serial=teensy_gateway +teensy40.menu.usb.serialmidi=Serial + MIDI +teensy40.menu.usb.serialmidi.build.usbtype=USB_MIDI_SERIAL +teensy40.menu.usb.serialmidi4=Serial + MIDIx4 +teensy40.menu.usb.serialmidi4.build.usbtype=USB_MIDI4_SERIAL +teensy40.menu.usb.serialmidi16=Serial + MIDIx16 +teensy40.menu.usb.serialmidi16.build.usbtype=USB_MIDI16_SERIAL +teensy40.menu.usb.audio=Audio +teensy40.menu.usb.audio.build.usbtype=USB_AUDIO +teensy40.menu.usb.audio.fake_serial=teensy_gateway +teensy40.menu.usb.serialmidiaudio=Serial + MIDI + Audio +teensy40.menu.usb.serialmidiaudio.build.usbtype=USB_MIDI_AUDIO_SERIAL +teensy40.menu.usb.serialmidi16audio=Serial + MIDIx16 + Audio +teensy40.menu.usb.serialmidi16audio.build.usbtype=USB_MIDI16_AUDIO_SERIAL +teensy40.menu.usb.mtp=MTP Disk (Experimental) +teensy40.menu.usb.mtp.build.usbtype=USB_MTPDISK +teensy40.menu.usb.mtp.fake_serial=teensy_gateway +teensy40.menu.usb.rawhid=Raw HID +teensy40.menu.usb.rawhid.build.usbtype=USB_RAWHID +teensy40.menu.usb.rawhid.fake_serial=teensy_gateway +teensy40.menu.usb.flightsim=Flight Sim Controls +teensy40.menu.usb.flightsim.build.usbtype=USB_FLIGHTSIM +teensy40.menu.usb.flightsim.fake_serial=teensy_gateway +teensy40.menu.usb.flightsimjoystick=Flight Sim Controls + Joystick +teensy40.menu.usb.flightsimjoystick.build.usbtype=USB_FLIGHTSIM_JOYSTICK +teensy40.menu.usb.flightsimjoystick.fake_serial=teensy_gateway +#teensy40.menu.usb.disable=No USB +#teensy40.menu.usb.disable.build.usbtype=USB_DISABLED + +teensy40.menu.speed.600=600 MHz +teensy40.menu.speed.528=528 MHz +teensy40.menu.speed.450=450 MHz +teensy40.menu.speed.396=396 MHz +teensy40.menu.speed.150=150 MHz +teensy40.menu.speed.24=24 MHz +teensy40.menu.speed.720=720 MHz (overclock) +teensy40.menu.speed.816=816 MHz (overclock) +teensy40.menu.speed.912=912 MHz (overclock, cooling req'd) +teensy40.menu.speed.960=960 MHz (overclock, cooling req'd) +teensy40.menu.speed.1008=1.008 GHz (overclock, cooling req'd) +teensy40.menu.speed.1008.build.fcpu=1008000000 +teensy40.menu.speed.960.build.fcpu=960000000 +teensy40.menu.speed.912.build.fcpu=912000000 +teensy40.menu.speed.816.build.fcpu=816000000 +teensy40.menu.speed.720.build.fcpu=720000000 +teensy40.menu.speed.600.build.fcpu=600000000 +teensy40.menu.speed.528.build.fcpu=528000000 +teensy40.menu.speed.450.build.fcpu=450000000 +teensy40.menu.speed.396.build.fcpu=396000000 +teensy40.menu.speed.150.build.fcpu=150000000 +teensy40.menu.speed.24.build.fcpu=24000000 + +teensy40.menu.opt.o2std=Faster +teensy40.menu.opt.o2std.build.flags.optimize=-O2 +teensy40.menu.opt.o2std.build.flags.ldspecs= +#teensy40.menu.opt.o2lto=Faster with LTO +#teensy40.menu.opt.o2lto.build.flags.optimize=-O2 -flto -fno-fat-lto-objects +#teensy40.menu.opt.o2lto.build.flags.ldspecs=-fuse-linker-plugin +teensy40.menu.opt.o1std=Fast +teensy40.menu.opt.o1std.build.flags.optimize=-O1 +teensy40.menu.opt.o1std.build.flags.ldspecs= +#teensy40.menu.opt.o1lto=Fast with LTO +#teensy40.menu.opt.o1lto.build.flags.optimize=-O1 -flto -fno-fat-lto-objects +#teensy40.menu.opt.o1lto.build.flags.ldspecs=-fuse-linker-plugin +teensy40.menu.opt.o3std=Fastest +teensy40.menu.opt.o3std.build.flags.optimize=-O3 +teensy40.menu.opt.o3std.build.flags.ldspecs= +#teensy40.menu.opt.o3purestd=Fastest + pure-code +#teensy40.menu.opt.o3purestd.build.flags.optimize=-O3 -mpure-code -D__PURE_CODE__ +#teensy40.menu.opt.o3purestd.build.flags.ldspecs= +#teensy40.menu.opt.o3lto=Fastest with LTO +#teensy40.menu.opt.o3lto.build.flags.optimize=-O3 -flto -fno-fat-lto-objects +#teensy40.menu.opt.o3lto.build.flags.ldspecs=-fuse-linker-plugin +#teensy40.menu.opt.o3purelto=Fastest + pure-code with LTO +#teensy40.menu.opt.o3purelto.build.flags.optimize=-O3 -mpure-code -D__PURE_CODE__ -flto -fno-fat-lto-objects +#teensy40.menu.opt.o3purelto.build.flags.ldspecs=-fuse-linker-plugin +teensy40.menu.opt.ogstd=Debug +teensy40.menu.opt.ogstd.build.flags.optimize=-Og +teensy40.menu.opt.ogstd.build.flags.ldspecs= +#teensy40.menu.opt.oglto=Debug with LTO +#teensy40.menu.opt.oglto.build.flags.optimize=-Og -flto -fno-fat-lto-objects +#teensy40.menu.opt.oglto.build.flags.ldspecs=-fuse-linker-plugin +teensy40.menu.opt.osstd=Smallest Code +teensy40.menu.opt.osstd.build.flags.optimize=-Os --specs=nano.specs +teensy40.menu.opt.osstd.build.flags.ldspecs= +#teensy40.menu.opt.oslto=Smallest Code with LTO +#teensy40.menu.opt.oslto.build.flags.optimize=-Os -flto -fno-fat-lto-objects --specs=nano.specs +#teensy40.menu.opt.oslto.build.flags.ldspecs=-fuse-linker-plugin + +teensy40.menu.keys.en-us=US English +teensy40.menu.keys.en-us.build.keylayout=US_ENGLISH +teensy40.menu.keys.fr-ca=Canadian French +teensy40.menu.keys.fr-ca.build.keylayout=CANADIAN_FRENCH +teensy40.menu.keys.xx-ca=Canadian Multilingual +teensy40.menu.keys.xx-ca.build.keylayout=CANADIAN_MULTILINGUAL +teensy40.menu.keys.cz-cz=Czech +teensy40.menu.keys.cz-cz.build.keylayout=CZECH +teensy40.menu.keys.da-da=Danish +teensy40.menu.keys.da-da.build.keylayout=DANISH +teensy40.menu.keys.fi-fi=Finnish +teensy40.menu.keys.fi-fi.build.keylayout=FINNISH +teensy40.menu.keys.fr-fr=French +teensy40.menu.keys.fr-fr.build.keylayout=FRENCH +teensy40.menu.keys.fr-be=French Belgian +teensy40.menu.keys.fr-be.build.keylayout=FRENCH_BELGIAN +teensy40.menu.keys.fr-ch=French Swiss +teensy40.menu.keys.fr-ch.build.keylayout=FRENCH_SWISS +teensy40.menu.keys.de-de=German +teensy40.menu.keys.de-de.build.keylayout=GERMAN +teensy40.menu.keys.de-dm=German (Mac) +teensy40.menu.keys.de-dm.build.keylayout=GERMAN_MAC +teensy40.menu.keys.de-ch=German Swiss +teensy40.menu.keys.de-ch.build.keylayout=GERMAN_SWISS +teensy40.menu.keys.is-is=Icelandic +teensy40.menu.keys.is-is.build.keylayout=ICELANDIC +teensy40.menu.keys.en-ie=Irish +teensy40.menu.keys.en-ie.build.keylayout=IRISH +teensy40.menu.keys.it-it=Italian +teensy40.menu.keys.it-it.build.keylayout=ITALIAN +teensy40.menu.keys.no-no=Norwegian +teensy40.menu.keys.no-no.build.keylayout=NORWEGIAN +teensy40.menu.keys.pt-pt=Portuguese +teensy40.menu.keys.pt-pt.build.keylayout=PORTUGUESE +teensy40.menu.keys.pt-br=Portuguese Brazilian +teensy40.menu.keys.pt-br.build.keylayout=PORTUGUESE_BRAZILIAN +teensy40.menu.keys.rs-rs=Serbian (Latin Only) +teensy40.menu.keys.rs-rs.build.keylayout=SERBIAN_LATIN_ONLY +teensy40.menu.keys.es-es=Spanish +teensy40.menu.keys.es-es.build.keylayout=SPANISH +teensy40.menu.keys.es-mx=Spanish Latin America +teensy40.menu.keys.es-mx.build.keylayout=SPANISH_LATIN_AMERICA +teensy40.menu.keys.sv-se=Swedish +teensy40.menu.keys.sv-se.build.keylayout=SWEDISH +teensy40.menu.keys.tr-tr=Turkish (partial) +teensy40.menu.keys.tr-tr.build.keylayout=TURKISH +teensy40.menu.keys.en-gb=United Kingdom +teensy40.menu.keys.en-gb.build.keylayout=UNITED_KINGDOM +teensy40.menu.keys.usint=US International +teensy40.menu.keys.usint.build.keylayout=US_INTERNATIONAL + + +teensy36.name=Teensy 3.6 +teensy36.upload.maximum_size=1048576 +teensy36.upload.maximum_data_size=262144 +teensy36.upload.tool=teensyloader +teensy36.upload.protocol=halfkay +teensy36.build.board=TEENSY36 +teensy36.build.core=teensy3 +teensy36.build.mcu=mk66fx1m0 +teensy36.build.warn_data_percentage=99 +teensy36.build.toolchain=arm/bin/ +teensy36.build.command.gcc=arm-none-eabi-gcc +teensy36.build.command.g++=arm-none-eabi-g++ +teensy36.build.command.ar=arm-none-eabi-gcc-ar +teensy36.build.command.objcopy=arm-none-eabi-objcopy +teensy36.build.command.objdump=arm-none-eabi-objdump + +# KH, Fix linker error when using STL library +#teensy36.build.command.linker=arm-none-eabi-gcc +teensy36.build.command.linker=arm-none-eabi-g++ + +teensy36.build.command.size=arm-none-eabi-size +teensy36.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib -mno-unaligned-access +teensy36.build.flags.dep=-MMD +teensy36.build.flags.optimize=-Os +teensy36.build.flags.cpu=-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant +teensy36.build.flags.defs=-D__MK66FX1M0__ -DTEENSYDUINO=156 +teensy36.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti +teensy36.build.flags.c= +teensy36.build.flags.S=-x assembler-with-cpp +teensy36.build.flags.ld=-Wl,--gc-sections,--relax,--defsym=__rtc_localtime={extra.time.local} "-T{build.core.path}/mk66fx1m0.ld" +teensy36.build.flags.libs=-larm_cortexM4lf_math -lm -lstdc++ +teensy36.serial.restart_cmd=false +teensy36.menu.usb.serial=Serial +teensy36.menu.usb.serial.build.usbtype=USB_SERIAL +teensy36.menu.usb.serial2=Dual Serial +teensy36.menu.usb.serial2.build.usbtype=USB_DUAL_SERIAL +teensy36.menu.usb.serial3=Triple Serial +teensy36.menu.usb.serial3.build.usbtype=USB_TRIPLE_SERIAL +teensy36.menu.usb.keyboard=Keyboard +teensy36.menu.usb.keyboard.build.usbtype=USB_KEYBOARDONLY +teensy36.menu.usb.keyboard.fake_serial=teensy_gateway +teensy36.menu.usb.touch=Keyboard + Touch Screen +teensy36.menu.usb.touch.build.usbtype=USB_TOUCHSCREEN +teensy36.menu.usb.touch.fake_serial=teensy_gateway +teensy36.menu.usb.hidtouch=Keyboard + Mouse + Touch Screen +teensy36.menu.usb.hidtouch.build.usbtype=USB_HID_TOUCHSCREEN +teensy36.menu.usb.hidtouch.fake_serial=teensy_gateway +teensy36.menu.usb.hid=Keyboard + Mouse + Joystick +teensy36.menu.usb.hid.build.usbtype=USB_HID +teensy36.menu.usb.hid.fake_serial=teensy_gateway +teensy36.menu.usb.serialhid=Serial + Keyboard + Mouse + Joystick +teensy36.menu.usb.serialhid.build.usbtype=USB_SERIAL_HID +teensy36.menu.usb.midi=MIDI +teensy36.menu.usb.midi.build.usbtype=USB_MIDI +teensy36.menu.usb.midi.fake_serial=teensy_gateway +teensy36.menu.usb.midi4=MIDIx4 +teensy36.menu.usb.midi4.build.usbtype=USB_MIDI4 +teensy36.menu.usb.midi4.fake_serial=teensy_gateway +teensy36.menu.usb.midi16=MIDIx16 +teensy36.menu.usb.midi16.build.usbtype=USB_MIDI16 +teensy36.menu.usb.midi16.fake_serial=teensy_gateway +teensy36.menu.usb.serialmidi=Serial + MIDI +teensy36.menu.usb.serialmidi.build.usbtype=USB_MIDI_SERIAL +teensy36.menu.usb.serialmidi4=Serial + MIDIx4 +teensy36.menu.usb.serialmidi4.build.usbtype=USB_MIDI4_SERIAL +teensy36.menu.usb.serialmidi16=Serial + MIDIx16 +teensy36.menu.usb.serialmidi16.build.usbtype=USB_MIDI16_SERIAL +teensy36.menu.usb.audio=Audio +teensy36.menu.usb.audio.build.usbtype=USB_AUDIO +teensy36.menu.usb.audio.fake_serial=teensy_gateway +teensy36.menu.usb.serialmidiaudio=Serial + MIDI + Audio +teensy36.menu.usb.serialmidiaudio.build.usbtype=USB_MIDI_AUDIO_SERIAL +teensy36.menu.usb.serialmidi16audio=Serial + MIDIx16 + Audio +teensy36.menu.usb.serialmidi16audio.build.usbtype=USB_MIDI16_AUDIO_SERIAL +teensy36.menu.usb.mtp=MTP Disk (Experimental) +teensy36.menu.usb.mtp.build.usbtype=USB_MTPDISK +teensy36.menu.usb.mtp.fake_serial=teensy_gateway +teensy36.menu.usb.rawhid=Raw HID +teensy36.menu.usb.rawhid.build.usbtype=USB_RAWHID +teensy36.menu.usb.rawhid.fake_serial=teensy_gateway +teensy36.menu.usb.flightsim=Flight Sim Controls +teensy36.menu.usb.flightsim.build.usbtype=USB_FLIGHTSIM +teensy36.menu.usb.flightsim.fake_serial=teensy_gateway +teensy36.menu.usb.flightsimjoystick=Flight Sim Controls + Joystick +teensy36.menu.usb.flightsimjoystick.build.usbtype=USB_FLIGHTSIM_JOYSTICK +teensy36.menu.usb.flightsimjoystick.fake_serial=teensy_gateway +teensy36.menu.usb.everything=All of the Above +teensy36.menu.usb.everything.build.usbtype=USB_EVERYTHING +teensy36.menu.usb.disable=No USB +teensy36.menu.usb.disable.build.usbtype=USB_DISABLED + +teensy36.menu.speed.180=180 MHz +teensy36.menu.speed.168=168 MHz +teensy36.menu.speed.144=144 MHz +teensy36.menu.speed.120=120 MHz +teensy36.menu.speed.96=96 MHz +teensy36.menu.speed.72=72 MHz +teensy36.menu.speed.48=48 MHz +teensy36.menu.speed.24=24 MHz +teensy36.menu.speed.16=16 MHz (No USB) +teensy36.menu.speed.8=8 MHz (No USB) +teensy36.menu.speed.4=4 MHz (No USB) +teensy36.menu.speed.2=2 MHz (No USB) +teensy36.menu.speed.192=192 MHz (overclock) +teensy36.menu.speed.216=216 MHz (overclock) +teensy36.menu.speed.240=240 MHz (overclock) +teensy36.menu.speed.256=256 MHz (overclock) +teensy36.menu.speed.256.build.fcpu=256000000 +teensy36.menu.speed.240.build.fcpu=240000000 +teensy36.menu.speed.216.build.fcpu=216000000 +teensy36.menu.speed.192.build.fcpu=192000000 +teensy36.menu.speed.180.build.fcpu=180000000 +teensy36.menu.speed.168.build.fcpu=168000000 +teensy36.menu.speed.144.build.fcpu=144000000 +teensy36.menu.speed.120.build.fcpu=120000000 +teensy36.menu.speed.96.build.fcpu=96000000 +teensy36.menu.speed.72.build.fcpu=72000000 +teensy36.menu.speed.48.build.fcpu=48000000 +teensy36.menu.speed.24.build.fcpu=24000000 +teensy36.menu.speed.16.build.fcpu=16000000 +teensy36.menu.speed.8.build.fcpu=8000000 +teensy36.menu.speed.4.build.fcpu=4000000 +teensy36.menu.speed.2.build.fcpu=2000000 + +teensy36.menu.opt.o2std=Faster +teensy36.menu.opt.o2std.build.flags.optimize=-O2 +teensy36.menu.opt.o2std.build.flags.ldspecs= +teensy36.menu.opt.o2lto=Faster with LTO +teensy36.menu.opt.o2lto.build.flags.optimize=-O2 -flto -fno-fat-lto-objects +teensy36.menu.opt.o2lto.build.flags.ldspecs=-fuse-linker-plugin +teensy36.menu.opt.o1std=Fast +teensy36.menu.opt.o1std.build.flags.optimize=-O1 +teensy36.menu.opt.o1std.build.flags.ldspecs= +teensy36.menu.opt.o1lto=Fast with LTO +teensy36.menu.opt.o1lto.build.flags.optimize=-O1 -flto -fno-fat-lto-objects +teensy36.menu.opt.o1lto.build.flags.ldspecs=-fuse-linker-plugin +teensy36.menu.opt.o3std=Fastest +teensy36.menu.opt.o3std.build.flags.optimize=-O3 +teensy36.menu.opt.o3std.build.flags.ldspecs= +teensy36.menu.opt.o3purestd=Fastest + pure-code +teensy36.menu.opt.o3purestd.build.flags.optimize=-O3 -mpure-code -D__PURE_CODE__ +teensy36.menu.opt.o3purestd.build.flags.ldspecs= +teensy36.menu.opt.o3lto=Fastest with LTO +teensy36.menu.opt.o3lto.build.flags.optimize=-O3 -flto -fno-fat-lto-objects +teensy36.menu.opt.o3lto.build.flags.ldspecs=-fuse-linker-plugin +teensy36.menu.opt.o3purelto=Fastest + pure-code with LTO +teensy36.menu.opt.o3purelto.build.flags.optimize=-O3 -mpure-code -D__PURE_CODE__ -flto -fno-fat-lto-objects +teensy36.menu.opt.o3purelto.build.flags.ldspecs=-fuse-linker-plugin +teensy36.menu.opt.ogstd=Debug +teensy36.menu.opt.ogstd.build.flags.optimize=-Og +teensy36.menu.opt.ogstd.build.flags.ldspecs= +teensy36.menu.opt.oglto=Debug with LTO +teensy36.menu.opt.oglto.build.flags.optimize=-Og -flto -fno-fat-lto-objects +teensy36.menu.opt.oglto.build.flags.ldspecs=-fuse-linker-plugin +teensy36.menu.opt.osstd=Smallest Code +teensy36.menu.opt.osstd.build.flags.optimize=-Os --specs=nano.specs +teensy36.menu.opt.osstd.build.flags.ldspecs= +teensy36.menu.opt.oslto=Smallest Code with LTO +teensy36.menu.opt.oslto.build.flags.optimize=-Os -flto -fno-fat-lto-objects --specs=nano.specs +teensy36.menu.opt.oslto.build.flags.ldspecs=-fuse-linker-plugin + +teensy36.menu.keys.en-us=US English +teensy36.menu.keys.en-us.build.keylayout=US_ENGLISH +teensy36.menu.keys.fr-ca=Canadian French +teensy36.menu.keys.fr-ca.build.keylayout=CANADIAN_FRENCH +teensy36.menu.keys.xx-ca=Canadian Multilingual +teensy36.menu.keys.xx-ca.build.keylayout=CANADIAN_MULTILINGUAL +teensy36.menu.keys.cz-cz=Czech +teensy36.menu.keys.cz-cz.build.keylayout=CZECH +teensy36.menu.keys.da-da=Danish +teensy36.menu.keys.da-da.build.keylayout=DANISH +teensy36.menu.keys.fi-fi=Finnish +teensy36.menu.keys.fi-fi.build.keylayout=FINNISH +teensy36.menu.keys.fr-fr=French +teensy36.menu.keys.fr-fr.build.keylayout=FRENCH +teensy36.menu.keys.fr-be=French Belgian +teensy36.menu.keys.fr-be.build.keylayout=FRENCH_BELGIAN +teensy36.menu.keys.fr-ch=French Swiss +teensy36.menu.keys.fr-ch.build.keylayout=FRENCH_SWISS +teensy36.menu.keys.de-de=German +teensy36.menu.keys.de-de.build.keylayout=GERMAN +teensy36.menu.keys.de-dm=German (Mac) +teensy36.menu.keys.de-dm.build.keylayout=GERMAN_MAC +teensy36.menu.keys.de-ch=German Swiss +teensy36.menu.keys.de-ch.build.keylayout=GERMAN_SWISS +teensy36.menu.keys.is-is=Icelandic +teensy36.menu.keys.is-is.build.keylayout=ICELANDIC +teensy36.menu.keys.en-ie=Irish +teensy36.menu.keys.en-ie.build.keylayout=IRISH +teensy36.menu.keys.it-it=Italian +teensy36.menu.keys.it-it.build.keylayout=ITALIAN +teensy36.menu.keys.no-no=Norwegian +teensy36.menu.keys.no-no.build.keylayout=NORWEGIAN +teensy36.menu.keys.pt-pt=Portuguese +teensy36.menu.keys.pt-pt.build.keylayout=PORTUGUESE +teensy36.menu.keys.pt-br=Portuguese Brazilian +teensy36.menu.keys.pt-br.build.keylayout=PORTUGUESE_BRAZILIAN +teensy36.menu.keys.rs-rs=Serbian (Latin Only) +teensy36.menu.keys.rs-rs.build.keylayout=SERBIAN_LATIN_ONLY +teensy36.menu.keys.es-es=Spanish +teensy36.menu.keys.es-es.build.keylayout=SPANISH +teensy36.menu.keys.es-mx=Spanish Latin America +teensy36.menu.keys.es-mx.build.keylayout=SPANISH_LATIN_AMERICA +teensy36.menu.keys.sv-se=Swedish +teensy36.menu.keys.sv-se.build.keylayout=SWEDISH +teensy36.menu.keys.tr-tr=Turkish (partial) +teensy36.menu.keys.tr-tr.build.keylayout=TURKISH +teensy36.menu.keys.en-gb=United Kingdom +teensy36.menu.keys.en-gb.build.keylayout=UNITED_KINGDOM +teensy36.menu.keys.usint=US International +teensy36.menu.keys.usint.build.keylayout=US_INTERNATIONAL + + +teensy35.name=Teensy 3.5 +teensy35.upload.maximum_size=524288 +teensy35.upload.maximum_data_size=262136 +teensy35.upload.tool=teensyloader +teensy35.upload.protocol=halfkay +teensy35.build.board=TEENSY35 +teensy35.build.core=teensy3 +teensy35.build.mcu=mk64fx512 +teensy35.build.warn_data_percentage=98 +teensy35.build.toolchain=arm/bin/ +teensy35.build.command.gcc=arm-none-eabi-gcc +teensy35.build.command.g++=arm-none-eabi-g++ +teensy35.build.command.ar=arm-none-eabi-gcc-ar +teensy35.build.command.objcopy=arm-none-eabi-objcopy +teensy35.build.command.objdump=arm-none-eabi-objdump + +# KH, Fix linker error when using STL library +#teensy35.build.command.linker=arm-none-eabi-gcc +teensy35.build.command.linker=arm-none-eabi-g++ + +teensy35.build.command.size=arm-none-eabi-size +teensy35.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib -mno-unaligned-access +teensy35.build.flags.dep=-MMD +teensy35.build.flags.optimize=-Os +teensy35.build.flags.cpu=-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant +teensy35.build.flags.defs=-D__MK64FX512__ -DTEENSYDUINO=156 +teensy35.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti +teensy35.build.flags.c= +teensy35.build.flags.S=-x assembler-with-cpp +teensy35.build.flags.ld=-Wl,--gc-sections,--relax,--defsym=__rtc_localtime={extra.time.local} "-T{build.core.path}/mk64fx512.ld" +teensy35.build.flags.libs=-larm_cortexM4lf_math -lm -lstdc++ +teensy35.serial.restart_cmd=false +teensy35.menu.usb.serial=Serial +teensy35.menu.usb.serial.build.usbtype=USB_SERIAL +teensy35.menu.usb.serial2=Dual Serial +teensy35.menu.usb.serial2.build.usbtype=USB_DUAL_SERIAL +teensy35.menu.usb.serial3=Triple Serial +teensy35.menu.usb.serial3.build.usbtype=USB_TRIPLE_SERIAL +teensy35.menu.usb.keyboard=Keyboard +teensy35.menu.usb.keyboard.build.usbtype=USB_KEYBOARDONLY +teensy35.menu.usb.keyboard.fake_serial=teensy_gateway +teensy35.menu.usb.touch=Keyboard + Touch Screen +teensy35.menu.usb.touch.build.usbtype=USB_TOUCHSCREEN +teensy35.menu.usb.touch.fake_serial=teensy_gateway +teensy35.menu.usb.hidtouch=Keyboard + Mouse + Touch Screen +teensy35.menu.usb.hidtouch.build.usbtype=USB_HID_TOUCHSCREEN +teensy35.menu.usb.hidtouch.fake_serial=teensy_gateway +teensy35.menu.usb.hid=Keyboard + Mouse + Joystick +teensy35.menu.usb.hid.build.usbtype=USB_HID +teensy35.menu.usb.hid.fake_serial=teensy_gateway +teensy35.menu.usb.serialhid=Serial + Keyboard + Mouse + Joystick +teensy35.menu.usb.serialhid.build.usbtype=USB_SERIAL_HID +teensy35.menu.usb.midi=MIDI +teensy35.menu.usb.midi.build.usbtype=USB_MIDI +teensy35.menu.usb.midi.fake_serial=teensy_gateway +teensy35.menu.usb.midi4=MIDIx4 +teensy35.menu.usb.midi4.build.usbtype=USB_MIDI4 +teensy35.menu.usb.midi4.fake_serial=teensy_gateway +teensy35.menu.usb.midi16=MIDIx16 +teensy35.menu.usb.midi16.build.usbtype=USB_MIDI16 +teensy35.menu.usb.midi16.fake_serial=teensy_gateway +teensy35.menu.usb.serialmidi=Serial + MIDI +teensy35.menu.usb.serialmidi.build.usbtype=USB_MIDI_SERIAL +teensy35.menu.usb.serialmidi4=Serial + MIDIx4 +teensy35.menu.usb.serialmidi4.build.usbtype=USB_MIDI4_SERIAL +teensy35.menu.usb.serialmidi16=Serial + MIDIx16 +teensy35.menu.usb.serialmidi16.build.usbtype=USB_MIDI16_SERIAL +teensy35.menu.usb.audio=Audio +teensy35.menu.usb.audio.build.usbtype=USB_AUDIO +teensy35.menu.usb.audio.fake_serial=teensy_gateway +teensy35.menu.usb.serialmidiaudio=Serial + MIDI + Audio +teensy35.menu.usb.serialmidiaudio.build.usbtype=USB_MIDI_AUDIO_SERIAL +teensy35.menu.usb.serialmidi16audio=Serial + MIDIx16 + Audio +teensy35.menu.usb.serialmidi16audio.build.usbtype=USB_MIDI16_AUDIO_SERIAL +teensy35.menu.usb.mtp=MTP Disk (Experimental) +teensy35.menu.usb.mtp.build.usbtype=USB_MTPDISK +teensy35.menu.usb.mtp.fake_serial=teensy_gateway +teensy35.menu.usb.rawhid=Raw HID +teensy35.menu.usb.rawhid.build.usbtype=USB_RAWHID +teensy35.menu.usb.rawhid.fake_serial=teensy_gateway +teensy35.menu.usb.flightsim=Flight Sim Controls +teensy35.menu.usb.flightsim.build.usbtype=USB_FLIGHTSIM +teensy35.menu.usb.flightsim.fake_serial=teensy_gateway +teensy35.menu.usb.flightsimjoystick=Flight Sim Controls + Joystick +teensy35.menu.usb.flightsimjoystick.build.usbtype=USB_FLIGHTSIM_JOYSTICK +teensy35.menu.usb.flightsimjoystick.fake_serial=teensy_gateway +teensy35.menu.usb.everything=All of the Above +teensy35.menu.usb.everything.build.usbtype=USB_EVERYTHING +teensy35.menu.usb.disable=No USB +teensy35.menu.usb.disable.build.usbtype=USB_DISABLED + +teensy35.menu.speed.120=120 MHz +teensy35.menu.speed.96=96 MHz +teensy35.menu.speed.72=72 MHz +teensy35.menu.speed.48=48 MHz +teensy35.menu.speed.24=24 MHz +teensy35.menu.speed.16=16 MHz (No USB) +teensy35.menu.speed.8=8 MHz (No USB) +teensy35.menu.speed.4=4 MHz (No USB) +teensy35.menu.speed.2=2 MHz (No USB) +teensy35.menu.speed.144=144 MHz (overclock) +teensy35.menu.speed.168=168 MHz (overclock) +teensy35.menu.speed.168.build.fcpu=168000000 +teensy35.menu.speed.144.build.fcpu=144000000 +teensy35.menu.speed.120.build.fcpu=120000000 +teensy35.menu.speed.96.build.fcpu=96000000 +teensy35.menu.speed.72.build.fcpu=72000000 +teensy35.menu.speed.48.build.fcpu=48000000 +teensy35.menu.speed.24.build.fcpu=24000000 +teensy35.menu.speed.16.build.fcpu=16000000 +teensy35.menu.speed.8.build.fcpu=8000000 +teensy35.menu.speed.4.build.fcpu=4000000 +teensy35.menu.speed.2.build.fcpu=2000000 + +teensy35.menu.opt.o2std=Faster +teensy35.menu.opt.o2std.build.flags.optimize=-O2 +teensy35.menu.opt.o2std.build.flags.ldspecs= +teensy35.menu.opt.o2lto=Faster with LTO +teensy35.menu.opt.o2lto.build.flags.optimize=-O2 -flto -fno-fat-lto-objects +teensy35.menu.opt.o2lto.build.flags.ldspecs=-fuse-linker-plugin +teensy35.menu.opt.o1std=Fast +teensy35.menu.opt.o1std.build.flags.optimize=-O1 +teensy35.menu.opt.o1std.build.flags.ldspecs= +teensy35.menu.opt.o1lto=Fast with LTO +teensy35.menu.opt.o1lto.build.flags.optimize=-O1 -flto -fno-fat-lto-objects +teensy35.menu.opt.o1lto.build.flags.ldspecs=-fuse-linker-plugin +teensy35.menu.opt.o3std=Fastest +teensy35.menu.opt.o3std.build.flags.optimize=-O3 +teensy35.menu.opt.o3std.build.flags.ldspecs= +teensy35.menu.opt.o3purestd=Fastest + pure-code +teensy35.menu.opt.o3purestd.build.flags.optimize=-O3 -mpure-code -D__PURE_CODE__ +teensy35.menu.opt.o3purestd.build.flags.ldspecs= +teensy35.menu.opt.o3lto=Fastest with LTO +teensy35.menu.opt.o3lto.build.flags.optimize=-O3 -flto -fno-fat-lto-objects +teensy35.menu.opt.o3lto.build.flags.ldspecs=-fuse-linker-plugin +teensy35.menu.opt.o3purelto=Fastest + pure-code with LTO +teensy35.menu.opt.o3purelto.build.flags.optimize=-O3 -mpure-code -D__PURE_CODE__ -flto -fno-fat-lto-objects +teensy35.menu.opt.o3purelto.build.flags.ldspecs=-fuse-linker-plugin +teensy35.menu.opt.ogstd=Debug +teensy35.menu.opt.ogstd.build.flags.optimize=-Og +teensy35.menu.opt.ogstd.build.flags.ldspecs= +teensy35.menu.opt.oglto=Debug with LTO +teensy35.menu.opt.oglto.build.flags.optimize=-Og -flto -fno-fat-lto-objects +teensy35.menu.opt.oglto.build.flags.ldspecs=-fuse-linker-plugin +teensy35.menu.opt.osstd=Smallest Code +teensy35.menu.opt.osstd.build.flags.optimize=-Os --specs=nano.specs +teensy35.menu.opt.osstd.build.flags.ldspecs= +teensy35.menu.opt.oslto=Smallest Code with LTO +teensy35.menu.opt.oslto.build.flags.optimize=-Os -flto -fno-fat-lto-objects --specs=nano.specs +teensy35.menu.opt.oslto.build.flags.ldspecs=-fuse-linker-plugin + +teensy35.menu.keys.en-us=US English +teensy35.menu.keys.en-us.build.keylayout=US_ENGLISH +teensy35.menu.keys.fr-ca=Canadian French +teensy35.menu.keys.fr-ca.build.keylayout=CANADIAN_FRENCH +teensy35.menu.keys.xx-ca=Canadian Multilingual +teensy35.menu.keys.xx-ca.build.keylayout=CANADIAN_MULTILINGUAL +teensy35.menu.keys.cz-cz=Czech +teensy35.menu.keys.cz-cz.build.keylayout=CZECH +teensy35.menu.keys.da-da=Danish +teensy35.menu.keys.da-da.build.keylayout=DANISH +teensy35.menu.keys.fi-fi=Finnish +teensy35.menu.keys.fi-fi.build.keylayout=FINNISH +teensy35.menu.keys.fr-fr=French +teensy35.menu.keys.fr-fr.build.keylayout=FRENCH +teensy35.menu.keys.fr-be=French Belgian +teensy35.menu.keys.fr-be.build.keylayout=FRENCH_BELGIAN +teensy35.menu.keys.fr-ch=French Swiss +teensy35.menu.keys.fr-ch.build.keylayout=FRENCH_SWISS +teensy35.menu.keys.de-de=German +teensy35.menu.keys.de-de.build.keylayout=GERMAN +teensy35.menu.keys.de-dm=German (Mac) +teensy35.menu.keys.de-dm.build.keylayout=GERMAN_MAC +teensy35.menu.keys.de-ch=German Swiss +teensy35.menu.keys.de-ch.build.keylayout=GERMAN_SWISS +teensy35.menu.keys.is-is=Icelandic +teensy35.menu.keys.is-is.build.keylayout=ICELANDIC +teensy35.menu.keys.en-ie=Irish +teensy35.menu.keys.en-ie.build.keylayout=IRISH +teensy35.menu.keys.it-it=Italian +teensy35.menu.keys.it-it.build.keylayout=ITALIAN +teensy35.menu.keys.no-no=Norwegian +teensy35.menu.keys.no-no.build.keylayout=NORWEGIAN +teensy35.menu.keys.pt-pt=Portuguese +teensy35.menu.keys.pt-pt.build.keylayout=PORTUGUESE +teensy35.menu.keys.pt-br=Portuguese Brazilian +teensy35.menu.keys.pt-br.build.keylayout=PORTUGUESE_BRAZILIAN +teensy35.menu.keys.rs-rs=Serbian (Latin Only) +teensy35.menu.keys.rs-rs.build.keylayout=SERBIAN_LATIN_ONLY +teensy35.menu.keys.es-es=Spanish +teensy35.menu.keys.es-es.build.keylayout=SPANISH +teensy35.menu.keys.es-mx=Spanish Latin America +teensy35.menu.keys.es-mx.build.keylayout=SPANISH_LATIN_AMERICA +teensy35.menu.keys.sv-se=Swedish +teensy35.menu.keys.sv-se.build.keylayout=SWEDISH +teensy35.menu.keys.tr-tr=Turkish (partial) +teensy35.menu.keys.tr-tr.build.keylayout=TURKISH +teensy35.menu.keys.en-gb=United Kingdom +teensy35.menu.keys.en-gb.build.keylayout=UNITED_KINGDOM +teensy35.menu.keys.usint=US International +teensy35.menu.keys.usint.build.keylayout=US_INTERNATIONAL + + +teensy31.name=Teensy 3.2 / 3.1 +teensy31.upload.maximum_size=262144 +teensy31.upload.maximum_data_size=65536 +teensy31.upload.tool=teensyloader +teensy31.upload.protocol=halfkay +teensy31.build.board=TEENSY32 +teensy31.build.core=teensy3 +teensy31.build.mcu=mk20dx256 +teensy31.build.warn_data_percentage=97 +teensy31.build.toolchain=arm/bin/ +teensy31.build.command.gcc=arm-none-eabi-gcc +teensy31.build.command.g++=arm-none-eabi-g++ +teensy31.build.command.ar=arm-none-eabi-gcc-ar +teensy31.build.command.objcopy=arm-none-eabi-objcopy +teensy31.build.command.objdump=arm-none-eabi-objdump + +# KH, Fix linker error when using STL library +#teensy31.build.command.linker=arm-none-eabi-gcc +teensy31.build.command.linker=arm-none-eabi-g++ + +teensy31.build.command.size=arm-none-eabi-size +teensy31.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib -mno-unaligned-access +teensy31.build.flags.dep=-MMD +teensy31.build.flags.optimize=-Os +teensy31.build.flags.cpu=-mthumb -mcpu=cortex-m4 -fsingle-precision-constant +teensy31.build.flags.defs=-D__MK20DX256__ -DTEENSYDUINO=156 +teensy31.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti +teensy31.build.flags.c= +teensy31.build.flags.S=-x assembler-with-cpp +teensy31.build.flags.ld=-Wl,--gc-sections,--relax,--defsym=__rtc_localtime={extra.time.local} "-T{build.core.path}/mk20dx256.ld" +teensy31.build.flags.libs=-larm_cortexM4l_math -lm -lstdc++ +teensy31.serial.restart_cmd=false +teensy31.menu.usb.serial=Serial +teensy31.menu.usb.serial.build.usbtype=USB_SERIAL +teensy31.menu.usb.serial2=Dual Serial +teensy31.menu.usb.serial2.build.usbtype=USB_DUAL_SERIAL +teensy31.menu.usb.serial3=Triple Serial +teensy31.menu.usb.serial3.build.usbtype=USB_TRIPLE_SERIAL +teensy31.menu.usb.keyboard=Keyboard +teensy31.menu.usb.keyboard.build.usbtype=USB_KEYBOARDONLY +teensy31.menu.usb.keyboard.fake_serial=teensy_gateway +teensy31.menu.usb.touch=Keyboard + Touch Screen +teensy31.menu.usb.touch.build.usbtype=USB_TOUCHSCREEN +teensy31.menu.usb.touch.fake_serial=teensy_gateway +teensy31.menu.usb.hidtouch=Keyboard + Mouse + Touch Screen +teensy31.menu.usb.hidtouch.build.usbtype=USB_HID_TOUCHSCREEN +teensy31.menu.usb.hidtouch.fake_serial=teensy_gateway +teensy31.menu.usb.hid=Keyboard + Mouse + Joystick +teensy31.menu.usb.hid.build.usbtype=USB_HID +teensy31.menu.usb.hid.fake_serial=teensy_gateway +teensy31.menu.usb.serialhid=Serial + Keyboard + Mouse + Joystick +teensy31.menu.usb.serialhid.build.usbtype=USB_SERIAL_HID +teensy31.menu.usb.midi=MIDI +teensy31.menu.usb.midi.build.usbtype=USB_MIDI +teensy31.menu.usb.midi.fake_serial=teensy_gateway +teensy31.menu.usb.midi4=MIDIx4 +teensy31.menu.usb.midi4.build.usbtype=USB_MIDI4 +teensy31.menu.usb.midi4.fake_serial=teensy_gateway +teensy31.menu.usb.midi16=MIDIx16 +teensy31.menu.usb.midi16.build.usbtype=USB_MIDI16 +teensy31.menu.usb.midi16.fake_serial=teensy_gateway +teensy31.menu.usb.serialmidi=Serial + MIDI +teensy31.menu.usb.serialmidi.build.usbtype=USB_MIDI_SERIAL +teensy31.menu.usb.serialmidi4=Serial + MIDIx4 +teensy31.menu.usb.serialmidi4.build.usbtype=USB_MIDI4_SERIAL +teensy31.menu.usb.serialmidi16=Serial + MIDIx16 +teensy31.menu.usb.serialmidi16.build.usbtype=USB_MIDI16_SERIAL +teensy31.menu.usb.audio=Audio +teensy31.menu.usb.audio.build.usbtype=USB_AUDIO +teensy31.menu.usb.audio.fake_serial=teensy_gateway +teensy31.menu.usb.serialmidiaudio=Serial + MIDI + Audio +teensy31.menu.usb.serialmidiaudio.build.usbtype=USB_MIDI_AUDIO_SERIAL +teensy31.menu.usb.serialmidi16audio=Serial + MIDIx16 + Audio +teensy31.menu.usb.serialmidi16audio.build.usbtype=USB_MIDI16_AUDIO_SERIAL +teensy31.menu.usb.mtp=MTP Disk (Experimental) +teensy31.menu.usb.mtp.build.usbtype=USB_MTPDISK +teensy31.menu.usb.mtp.fake_serial=teensy_gateway +teensy31.menu.usb.rawhid=Raw HID +teensy31.menu.usb.rawhid.build.usbtype=USB_RAWHID +teensy31.menu.usb.rawhid.fake_serial=teensy_gateway +teensy31.menu.usb.flightsim=Flight Sim Controls +teensy31.menu.usb.flightsim.build.usbtype=USB_FLIGHTSIM +teensy31.menu.usb.flightsim.fake_serial=teensy_gateway +teensy31.menu.usb.flightsimjoystick=Flight Sim Controls + Joystick +teensy31.menu.usb.flightsimjoystick.build.usbtype=USB_FLIGHTSIM_JOYSTICK +teensy31.menu.usb.flightsimjoystick.fake_serial=teensy_gateway +teensy31.menu.usb.everything=All of the Above +teensy31.menu.usb.everything.build.usbtype=USB_EVERYTHING +teensy31.menu.usb.disable=No USB +teensy31.menu.usb.disable.build.usbtype=USB_DISABLED + +teensy31.menu.speed.96=96 MHz (overclock) +teensy31.menu.speed.72=72 MHz +teensy31.menu.speed.48=48 MHz +teensy31.menu.speed.24=24 MHz +teensy31.menu.speed.16=16 MHz (No USB) +teensy31.menu.speed.8=8 MHz (No USB) +teensy31.menu.speed.4=4 MHz (No USB) +teensy31.menu.speed.2=2 MHz (No USB) +teensy31.menu.speed.120=120 MHz (overclock) +#uncomment these if you want to try faster overclocking +#teensy31.menu.speed.144=144 MHz (overclock) +#teensy31.menu.speed.168=168 MHz (overclock) +teensy31.menu.speed.168.build.fcpu=168000000 +teensy31.menu.speed.144.build.fcpu=144000000 +teensy31.menu.speed.120.build.fcpu=120000000 +teensy31.menu.speed.96.build.fcpu=96000000 +teensy31.menu.speed.72.build.fcpu=72000000 +teensy31.menu.speed.48.build.fcpu=48000000 +teensy31.menu.speed.24.build.fcpu=24000000 +teensy31.menu.speed.16.build.fcpu=16000000 +teensy31.menu.speed.8.build.fcpu=8000000 +teensy31.menu.speed.4.build.fcpu=4000000 +teensy31.menu.speed.2.build.fcpu=2000000 + +teensy31.menu.opt.o2std=Faster +teensy31.menu.opt.o2std.build.flags.optimize=-O2 +teensy31.menu.opt.o2std.build.flags.ldspecs= +teensy31.menu.opt.o2lto=Faster with LTO +teensy31.menu.opt.o2lto.build.flags.optimize=-O2 -flto -fno-fat-lto-objects +teensy31.menu.opt.o2lto.build.flags.ldspecs=-fuse-linker-plugin +teensy31.menu.opt.o1std=Fast +teensy31.menu.opt.o1std.build.flags.optimize=-O1 +teensy31.menu.opt.o1std.build.flags.ldspecs= +teensy31.menu.opt.o1lto=Fast with LTO +teensy31.menu.opt.o1lto.build.flags.optimize=-O1 -flto -fno-fat-lto-objects +teensy31.menu.opt.o1lto.build.flags.ldspecs=-fuse-linker-plugin +teensy31.menu.opt.o3std=Fastest +teensy31.menu.opt.o3std.build.flags.optimize=-O3 +teensy31.menu.opt.o3std.build.flags.ldspecs= +teensy31.menu.opt.o3purestd=Fastest + pure-code +teensy31.menu.opt.o3purestd.build.flags.optimize=-O3 -mpure-code -D__PURE_CODE__ +teensy31.menu.opt.o3purestd.build.flags.ldspecs= +teensy31.menu.opt.o3lto=Fastest with LTO +teensy31.menu.opt.o3lto.build.flags.optimize=-O3 -flto -fno-fat-lto-objects +teensy31.menu.opt.o3lto.build.flags.ldspecs=-fuse-linker-plugin +teensy31.menu.opt.o3purelto=Fastest + pure-code with LTO +teensy31.menu.opt.o3purelto.build.flags.optimize=-O3 -mpure-code -D__PURE_CODE__ -flto -fno-fat-lto-objects +teensy31.menu.opt.o3purelto.build.flags.ldspecs=-fuse-linker-plugin +teensy31.menu.opt.ogstd=Debug +teensy31.menu.opt.ogstd.build.flags.optimize=-Og +teensy31.menu.opt.ogstd.build.flags.ldspecs= +teensy31.menu.opt.oglto=Debug with LTO +teensy31.menu.opt.oglto.build.flags.optimize=-Og -flto -fno-fat-lto-objects +teensy31.menu.opt.oglto.build.flags.ldspecs=-fuse-linker-plugin +teensy31.menu.opt.osstd=Smallest Code +teensy31.menu.opt.osstd.build.flags.optimize=-Os --specs=nano.specs +teensy31.menu.opt.osstd.build.flags.ldspecs= +teensy31.menu.opt.oslto=Smallest Code with LTO +teensy31.menu.opt.oslto.build.flags.optimize=-Os -flto -fno-fat-lto-objects --specs=nano.specs +teensy31.menu.opt.oslto.build.flags.ldspecs=-fuse-linker-plugin + +teensy31.menu.keys.en-us=US English +teensy31.menu.keys.en-us.build.keylayout=US_ENGLISH +teensy31.menu.keys.fr-ca=Canadian French +teensy31.menu.keys.fr-ca.build.keylayout=CANADIAN_FRENCH +teensy31.menu.keys.xx-ca=Canadian Multilingual +teensy31.menu.keys.xx-ca.build.keylayout=CANADIAN_MULTILINGUAL +teensy31.menu.keys.cz-cz=Czech +teensy31.menu.keys.cz-cz.build.keylayout=CZECH +teensy31.menu.keys.da-da=Danish +teensy31.menu.keys.da-da.build.keylayout=DANISH +teensy31.menu.keys.fi-fi=Finnish +teensy31.menu.keys.fi-fi.build.keylayout=FINNISH +teensy31.menu.keys.fr-fr=French +teensy31.menu.keys.fr-fr.build.keylayout=FRENCH +teensy31.menu.keys.fr-be=French Belgian +teensy31.menu.keys.fr-be.build.keylayout=FRENCH_BELGIAN +teensy31.menu.keys.fr-ch=French Swiss +teensy31.menu.keys.fr-ch.build.keylayout=FRENCH_SWISS +teensy31.menu.keys.de-de=German +teensy31.menu.keys.de-de.build.keylayout=GERMAN +teensy31.menu.keys.de-dm=German (Mac) +teensy31.menu.keys.de-dm.build.keylayout=GERMAN_MAC +teensy31.menu.keys.de-ch=German Swiss +teensy31.menu.keys.de-ch.build.keylayout=GERMAN_SWISS +teensy31.menu.keys.is-is=Icelandic +teensy31.menu.keys.is-is.build.keylayout=ICELANDIC +teensy31.menu.keys.en-ie=Irish +teensy31.menu.keys.en-ie.build.keylayout=IRISH +teensy31.menu.keys.it-it=Italian +teensy31.menu.keys.it-it.build.keylayout=ITALIAN +teensy31.menu.keys.no-no=Norwegian +teensy31.menu.keys.no-no.build.keylayout=NORWEGIAN +teensy31.menu.keys.pt-pt=Portuguese +teensy31.menu.keys.pt-pt.build.keylayout=PORTUGUESE +teensy31.menu.keys.pt-br=Portuguese Brazilian +teensy31.menu.keys.pt-br.build.keylayout=PORTUGUESE_BRAZILIAN +teensy31.menu.keys.rs-rs=Serbian (Latin Only) +teensy31.menu.keys.rs-rs.build.keylayout=SERBIAN_LATIN_ONLY +teensy31.menu.keys.es-es=Spanish +teensy31.menu.keys.es-es.build.keylayout=SPANISH +teensy31.menu.keys.es-mx=Spanish Latin America +teensy31.menu.keys.es-mx.build.keylayout=SPANISH_LATIN_AMERICA +teensy31.menu.keys.sv-se=Swedish +teensy31.menu.keys.sv-se.build.keylayout=SWEDISH +teensy31.menu.keys.tr-tr=Turkish (partial) +teensy31.menu.keys.tr-tr.build.keylayout=TURKISH +teensy31.menu.keys.en-gb=United Kingdom +teensy31.menu.keys.en-gb.build.keylayout=UNITED_KINGDOM +teensy31.menu.keys.usint=US International +teensy31.menu.keys.usint.build.keylayout=US_INTERNATIONAL + +teensy31.vid.0=0x16C0 +teensy31.vid.1=0x16C0 +teensy31.vid.2=0x16C0 +teensy31.vid.3=0x16C0 +teensy31.vid.4=0x16C0 +teensy31.pid.0=0x0483 +teensy31.pid.1=0x0487 +teensy31.pid.2=0x0489 +teensy31.pid.3=0x048A +teensy31.pid.4=0x0476 + +teensy30.name=Teensy 3.0 +teensy30.upload.maximum_size=131072 +teensy30.upload.maximum_data_size=16384 +teensy30.upload.tool=teensyloader +teensy30.upload.protocol=halfkay +teensy30.build.board=TEENSY30 +teensy30.build.core=teensy3 +teensy30.build.mcu=mk20dx128 +teensy30.build.warn_data_percentage=94 +teensy30.build.toolchain=arm/bin/ +teensy30.build.command.gcc=arm-none-eabi-gcc +teensy30.build.command.g++=arm-none-eabi-g++ +teensy30.build.command.ar=arm-none-eabi-gcc-ar +teensy30.build.command.objcopy=arm-none-eabi-objcopy +teensy30.build.command.objdump=arm-none-eabi-objdump + +# KH, Fix linker error when using STL library +#teensy30.build.command.linker=arm-none-eabi-gcc +teensy30.build.command.linker=arm-none-eabi-g++ + +teensy30.build.command.size=arm-none-eabi-size +teensy30.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib -mno-unaligned-access +teensy30.build.flags.dep=-MMD +teensy30.build.flags.optimize=-Os +teensy30.build.flags.cpu=-mthumb -mcpu=cortex-m4 -fsingle-precision-constant +teensy30.build.flags.defs=-D__MK20DX128__ -DTEENSYDUINO=156 +teensy30.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti +teensy30.build.flags.c= +teensy30.build.flags.S=-x assembler-with-cpp +teensy30.build.flags.ld=-Wl,--gc-sections,--relax,--defsym=__rtc_localtime={extra.time.local} "-T{build.core.path}/mk20dx128.ld" +teensy30.build.flags.ldspecs=--specs=nano.specs +teensy30.build.flags.libs=-larm_cortexM4l_math -lm -lstdc++ +teensy30.serial.restart_cmd=false + +teensy30.menu.usb.serial=Serial +teensy30.menu.usb.serial.build.usbtype=USB_SERIAL +teensy30.menu.usb.keyboard=Keyboard +teensy30.menu.usb.keyboard.build.usbtype=USB_KEYBOARDONLY +teensy30.menu.usb.keyboard.fake_serial=teensy_gateway +teensy30.menu.usb.hid=Keyboard + Mouse + Joystick +teensy30.menu.usb.hid.build.usbtype=USB_HID +teensy30.menu.usb.hid.fake_serial=teensy_gateway +teensy30.menu.usb.serialhid=Serial + Keyboard + Mouse + Joystick +teensy30.menu.usb.serialhid.build.usbtype=USB_SERIAL_HID +teensy30.menu.usb.touch=Keyboard + Touch Screen +teensy30.menu.usb.touch.build.usbtype=USB_TOUCHSCREEN +teensy30.menu.usb.touch.fake_serial=teensy_gateway +teensy30.menu.usb.midi=MIDI +teensy30.menu.usb.midi.build.usbtype=USB_MIDI +teensy30.menu.usb.midi.fake_serial=teensy_gateway +teensy30.menu.usb.midi4=MIDIx4 +teensy30.menu.usb.midi4.build.usbtype=USB_MIDI4 +teensy30.menu.usb.midi4.fake_serial=teensy_gateway +teensy30.menu.usb.serialmidi=Serial + MIDI +teensy30.menu.usb.serialmidi.build.usbtype=USB_MIDI_SERIAL +teensy30.menu.usb.serialmidi4=Serial + MIDIx4 +teensy30.menu.usb.serialmidi4.build.usbtype=USB_MIDI4_SERIAL +teensy30.menu.usb.audio=Audio +teensy30.menu.usb.audio.build.usbtype=USB_AUDIO +teensy30.menu.usb.audio.fake_serial=teensy_gateway +teensy30.menu.usb.serialmidiaudio=Serial + MIDI + Audio +teensy30.menu.usb.serialmidiaudio.build.usbtype=USB_MIDI_AUDIO_SERIAL +teensy30.menu.usb.mtp=MTP Disk (Experimental) +teensy30.menu.usb.mtp.build.usbtype=USB_MTPDISK +teensy30.menu.usb.mtp.fake_serial=teensy_gateway +teensy30.menu.usb.rawhid=Raw HID +teensy30.menu.usb.rawhid.build.usbtype=USB_RAWHID +teensy30.menu.usb.rawhid.fake_serial=teensy_gateway +teensy30.menu.usb.flightsim=Flight Sim Controls +teensy30.menu.usb.flightsim.build.usbtype=USB_FLIGHTSIM +teensy30.menu.usb.flightsim.fake_serial=teensy_gateway +teensy30.menu.usb.disable=No USB +teensy30.menu.usb.disable.build.usbtype=USB_DISABLED + +teensy30.menu.speed.96=96 MHz (overclock) +teensy30.menu.speed.48=48 MHz +teensy30.menu.speed.24=24 MHz +teensy30.menu.speed.96.build.fcpu=96000000 +teensy30.menu.speed.48.build.fcpu=48000000 +teensy30.menu.speed.24.build.fcpu=24000000 + +teensy30.menu.opt.o2std=Faster +teensy30.menu.opt.o2std.build.flags.optimize=-O2 +teensy30.menu.opt.o2std.build.flags.ldspecs= +teensy30.menu.opt.o2lto=Faster with LTO +teensy30.menu.opt.o2lto.build.flags.optimize=-O2 -flto -fno-fat-lto-objects +teensy30.menu.opt.o2lto.build.flags.ldspecs=-fuse-linker-plugin +teensy30.menu.opt.o1std=Fast +teensy30.menu.opt.o1std.build.flags.optimize=-O1 +teensy30.menu.opt.o1std.build.flags.ldspecs= +teensy30.menu.opt.o1lto=Fast with LTO +teensy30.menu.opt.o1lto.build.flags.optimize=-O1 -flto -fno-fat-lto-objects +teensy30.menu.opt.o1lto.build.flags.ldspecs=-fuse-linker-plugin +teensy30.menu.opt.o3std=Fastest +teensy30.menu.opt.o3std.build.flags.optimize=-O3 +teensy30.menu.opt.o3std.build.flags.ldspecs= +teensy30.menu.opt.o3lto=Fastest with LTO +teensy30.menu.opt.o3lto.build.flags.optimize=-O3 -flto -fno-fat-lto-objects +teensy30.menu.opt.o3lto.build.flags.ldspecs=-fuse-linker-plugin +teensy30.menu.opt.ogstd=Debug +teensy30.menu.opt.ogstd.build.flags.optimize=-Og +teensy30.menu.opt.ogstd.build.flags.ldspecs= +teensy30.menu.opt.oglto=Debug with LTO +teensy30.menu.opt.oglto.build.flags.optimize=-Og -flto -fno-fat-lto-objects +teensy30.menu.opt.oglto.build.flags.ldspecs=-fuse-linker-plugin +teensy30.menu.opt.osstd=Smallest Code +teensy30.menu.opt.osstd.build.flags.optimize=-Os --specs=nano.specs +teensy30.menu.opt.osstd.build.flags.ldspecs= +teensy30.menu.opt.oslto=Smallest Code with LTO +teensy30.menu.opt.oslto.build.flags.optimize=-Os -flto -fno-fat-lto-objects --specs=nano.specs +teensy30.menu.opt.oslto.build.flags.ldspecs=-fuse-linker-plugin + +teensy30.menu.keys.en-us=US English +teensy30.menu.keys.en-us.build.keylayout=US_ENGLISH +teensy30.menu.keys.fr-ca=Canadian French +teensy30.menu.keys.fr-ca.build.keylayout=CANADIAN_FRENCH +teensy30.menu.keys.xx-ca=Canadian Multilingual +teensy30.menu.keys.xx-ca.build.keylayout=CANADIAN_MULTILINGUAL +teensy30.menu.keys.cz-cz=Czech +teensy30.menu.keys.cz-cz.build.keylayout=CZECH +teensy30.menu.keys.da-da=Danish +teensy30.menu.keys.da-da.build.keylayout=DANISH +teensy30.menu.keys.fi-fi=Finnish +teensy30.menu.keys.fi-fi.build.keylayout=FINNISH +teensy30.menu.keys.fr-fr=French +teensy30.menu.keys.fr-fr.build.keylayout=FRENCH +teensy30.menu.keys.fr-be=French Belgian +teensy30.menu.keys.fr-be.build.keylayout=FRENCH_BELGIAN +teensy30.menu.keys.fr-ch=French Swiss +teensy30.menu.keys.fr-ch.build.keylayout=FRENCH_SWISS +teensy30.menu.keys.de-de=German +teensy30.menu.keys.de-de.build.keylayout=GERMAN +teensy30.menu.keys.de-dm=German (Mac) +teensy30.menu.keys.de-dm.build.keylayout=GERMAN_MAC +teensy30.menu.keys.de-ch=German Swiss +teensy30.menu.keys.de-ch.build.keylayout=GERMAN_SWISS +teensy30.menu.keys.is-is=Icelandic +teensy30.menu.keys.is-is.build.keylayout=ICELANDIC +teensy30.menu.keys.en-ie=Irish +teensy30.menu.keys.en-ie.build.keylayout=IRISH +teensy30.menu.keys.it-it=Italian +teensy30.menu.keys.it-it.build.keylayout=ITALIAN +teensy30.menu.keys.no-no=Norwegian +teensy30.menu.keys.no-no.build.keylayout=NORWEGIAN +teensy30.menu.keys.pt-pt=Portuguese +teensy30.menu.keys.pt-pt.build.keylayout=PORTUGUESE +teensy30.menu.keys.pt-br=Portuguese Brazilian +teensy30.menu.keys.pt-br.build.keylayout=PORTUGUESE_BRAZILIAN +teensy30.menu.keys.rs-rs=Serbian (Latin Only) +teensy30.menu.keys.rs-rs.build.keylayout=SERBIAN_LATIN_ONLY +teensy30.menu.keys.es-es=Spanish +teensy30.menu.keys.es-es.build.keylayout=SPANISH +teensy30.menu.keys.es-mx=Spanish Latin America +teensy30.menu.keys.es-mx.build.keylayout=SPANISH_LATIN_AMERICA +teensy30.menu.keys.sv-se=Swedish +teensy30.menu.keys.sv-se.build.keylayout=SWEDISH +teensy30.menu.keys.tr-tr=Turkish (partial) +teensy30.menu.keys.tr-tr.build.keylayout=TURKISH +teensy30.menu.keys.en-gb=United Kingdom +teensy30.menu.keys.en-gb.build.keylayout=UNITED_KINGDOM +teensy30.menu.keys.usint=US International +teensy30.menu.keys.usint.build.keylayout=US_INTERNATIONAL + + +teensyLC.name=Teensy LC +teensyLC.upload.maximum_size=63488 +teensyLC.upload.maximum_data_size=8192 +teensyLC.upload.tool=teensyloader +teensyLC.upload.protocol=halfkay +teensyLC.build.board=TEENSYLC +teensyLC.build.core=teensy3 +teensyLC.build.mcu=mkl26z64 +teensyLC.build.warn_data_percentage=88 +teensyLC.build.toolchain=arm/bin/ +teensyLC.build.command.gcc=arm-none-eabi-gcc +teensyLC.build.command.g++=arm-none-eabi-g++ +teensyLC.build.command.ar=arm-none-eabi-gcc-ar +teensyLC.build.command.objcopy=arm-none-eabi-objcopy +teensyLC.build.command.objdump=arm-none-eabi-objdump + +# KH, Fix linker error when using STL library +#teensyLC.build.command.linker=arm-none-eabi-gcc +teensyLC.build.command.linker=arm-none-eabi-g++ + +teensyLC.build.command.size=arm-none-eabi-size +teensyLC.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib -mno-unaligned-access +teensyLC.build.flags.dep=-MMD +teensyLC.build.flags.cpu=-mthumb -mcpu=cortex-m0plus -fsingle-precision-constant +teensyLC.build.flags.defs=-D__MKL26Z64__ -DTEENSYDUINO=156 +teensyLC.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti +teensyLC.build.flags.c= +teensyLC.build.flags.S=-x assembler-with-cpp +teensyLC.build.flags.ld=-Wl,--gc-sections,--relax,--defsym=__rtc_localtime={extra.time.local} "-T{build.core.path}/mkl26z64.ld" +teensyLC.build.flags.libs=-larm_cortexM0l_math -lm -lstdc++ +teensyLC.serial.restart_cmd=false +teensyLC.menu.usb.serial=Serial +teensyLC.menu.usb.serial.build.usbtype=USB_SERIAL +teensyLC.menu.usb.serial2=Dual Serial +teensyLC.menu.usb.serial2.build.usbtype=USB_DUAL_SERIAL +teensyLC.menu.usb.serial3=Triple Serial +teensyLC.menu.usb.serial3.build.usbtype=USB_TRIPLE_SERIAL +teensyLC.menu.usb.keyboard=Keyboard +teensyLC.menu.usb.keyboard.build.usbtype=USB_KEYBOARDONLY +teensyLC.menu.usb.keyboard.fake_serial=teensy_gateway +teensyLC.menu.usb.hid=Keyboard + Mouse + Joystick +teensyLC.menu.usb.hid.build.usbtype=USB_HID +teensyLC.menu.usb.hid.fake_serial=teensy_gateway +teensyLC.menu.usb.serialhid=Serial + Keyboard + Mouse + Joystick +teensyLC.menu.usb.serialhid.build.usbtype=USB_SERIAL_HID +teensyLC.menu.usb.touch=Keyboard + Touch Screen +teensyLC.menu.usb.touch.build.usbtype=USB_TOUCHSCREEN +teensyLC.menu.usb.touch.fake_serial=teensy_gateway +teensyLC.menu.usb.midi=MIDI +teensyLC.menu.usb.midi.build.usbtype=USB_MIDI +teensyLC.menu.usb.midi.fake_serial=teensy_gateway +teensyLC.menu.usb.midi4=MIDIx4 +teensyLC.menu.usb.midi4.build.usbtype=USB_MIDI4 +teensyLC.menu.usb.midi4.fake_serial=teensy_gateway +teensyLC.menu.usb.serialmidi=Serial + MIDI +teensyLC.menu.usb.serialmidi.build.usbtype=USB_MIDI_SERIAL +teensyLC.menu.usb.serialmidi4=Serial + MIDIx4 +teensyLC.menu.usb.serialmidi4.build.usbtype=USB_MIDI4_SERIAL +teensyLC.menu.usb.mtp=MTP Disk (Experimental) +teensyLC.menu.usb.mtp.build.usbtype=USB_MTPDISK +teensyLC.menu.usb.mtp.fake_serial=teensy_gateway +teensyLC.menu.usb.rawhid=Raw HID +teensyLC.menu.usb.rawhid.build.usbtype=USB_RAWHID +teensyLC.menu.usb.rawhid.fake_serial=teensy_gateway +teensyLC.menu.usb.flightsim=Flight Sim Controls +teensyLC.menu.usb.flightsim.build.usbtype=USB_FLIGHTSIM +teensyLC.menu.usb.flightsim.fake_serial=teensy_gateway +teensyLC.menu.usb.disable=No USB +teensyLC.menu.usb.disable.build.usbtype=USB_DISABLED + +teensyLC.menu.speed.48=48 MHz +teensyLC.menu.speed.24=24 MHz +teensyLC.menu.speed.48.build.fcpu=48000000 +teensyLC.menu.speed.24.build.fcpu=24000000 + +teensyLC.menu.opt.osstd=Smallest Code +teensyLC.menu.opt.osstd.build.flags.optimize=-Os --specs=nano.specs +teensyLC.menu.opt.osstd.build.flags.ldspecs= +teensyLC.menu.opt.oslto=Smallest Code with LTO +teensyLC.menu.opt.oslto.build.flags.optimize=-Os -flto -fno-fat-lto-objects --specs=nano.specs +teensyLC.menu.opt.oslto.build.flags.ldspecs=-fuse-linker-plugin +teensyLC.menu.opt.ogstd=Debug +teensyLC.menu.opt.ogstd.build.flags.optimize=-Og +teensyLC.menu.opt.ogstd.build.flags.ldspecs= +teensyLC.menu.opt.oglto=Debug with LTO +teensyLC.menu.opt.oglto.build.flags.optimize=-Og -flto -fno-fat-lto-objects +teensyLC.menu.opt.oglto.build.flags.ldspecs=-fuse-linker-plugin +teensyLC.menu.opt.o3std=Fastest +teensyLC.menu.opt.o3std.build.flags.optimize=-O3 +teensyLC.menu.opt.o3std.build.flags.ldspecs= +teensyLC.menu.opt.o3lto=Fastest with LTO +teensyLC.menu.opt.o3lto.build.flags.optimize=-O3 -flto -fno-fat-lto-objects +teensyLC.menu.opt.o3lto.build.flags.ldspecs=-fuse-linker-plugin +teensyLC.menu.opt.o2std=Faster +teensyLC.menu.opt.o2std.build.flags.optimize=-O2 +teensyLC.menu.opt.o2std.build.flags.ldspecs= +teensyLC.menu.opt.o2lto=Faster with LTO +teensyLC.menu.opt.o2lto.build.flags.optimize=-O2 -flto -fno-fat-lto-objects +teensyLC.menu.opt.o2lto.build.flags.ldspecs=-fuse-linker-plugin +teensyLC.menu.opt.o1std=Fast +teensyLC.menu.opt.o1std.build.flags.optimize=-O1 +teensyLC.menu.opt.o1std.build.flags.ldspecs= +teensyLC.menu.opt.o1lto=Fast with LTO +teensyLC.menu.opt.o1lto.build.flags.optimize=-O1 -flto -fno-fat-lto-objects +teensyLC.menu.opt.o1lto.build.flags.ldspecs=-fuse-linker-plugin + +teensyLC.menu.keys.en-us=US English +teensyLC.menu.keys.en-us.build.keylayout=US_ENGLISH +teensyLC.menu.keys.fr-ca=Canadian French +teensyLC.menu.keys.fr-ca.build.keylayout=CANADIAN_FRENCH +teensyLC.menu.keys.xx-ca=Canadian Multilingual +teensyLC.menu.keys.xx-ca.build.keylayout=CANADIAN_MULTILINGUAL +teensyLC.menu.keys.cz-cz=Czech +teensyLC.menu.keys.cz-cz.build.keylayout=CZECH +teensyLC.menu.keys.da-da=Danish +teensyLC.menu.keys.da-da.build.keylayout=DANISH +teensyLC.menu.keys.fi-fi=Finnish +teensyLC.menu.keys.fi-fi.build.keylayout=FINNISH +teensyLC.menu.keys.fr-fr=French +teensyLC.menu.keys.fr-fr.build.keylayout=FRENCH +teensyLC.menu.keys.fr-be=French Belgian +teensyLC.menu.keys.fr-be.build.keylayout=FRENCH_BELGIAN +teensyLC.menu.keys.fr-ch=French Swiss +teensyLC.menu.keys.fr-ch.build.keylayout=FRENCH_SWISS +teensyLC.menu.keys.de-de=German +teensyLC.menu.keys.de-de.build.keylayout=GERMAN +teensyLC.menu.keys.de-dm=German (Mac) +teensyLC.menu.keys.de-dm.build.keylayout=GERMAN_MAC +teensyLC.menu.keys.de-ch=German Swiss +teensyLC.menu.keys.de-ch.build.keylayout=GERMAN_SWISS +teensyLC.menu.keys.is-is=Icelandic +teensyLC.menu.keys.is-is.build.keylayout=ICELANDIC +teensyLC.menu.keys.en-ie=Irish +teensyLC.menu.keys.en-ie.build.keylayout=IRISH +teensyLC.menu.keys.it-it=Italian +teensyLC.menu.keys.it-it.build.keylayout=ITALIAN +teensyLC.menu.keys.no-no=Norwegian +teensyLC.menu.keys.no-no.build.keylayout=NORWEGIAN +teensyLC.menu.keys.pt-pt=Portuguese +teensyLC.menu.keys.pt-pt.build.keylayout=PORTUGUESE +teensyLC.menu.keys.pt-br=Portuguese Brazilian +teensyLC.menu.keys.pt-br.build.keylayout=PORTUGUESE_BRAZILIAN +teensyLC.menu.keys.rs-rs=Serbian (Latin Only) +teensyLC.menu.keys.rs-rs.build.keylayout=SERBIAN_LATIN_ONLY +teensyLC.menu.keys.es-es=Spanish +teensyLC.menu.keys.es-es.build.keylayout=SPANISH +teensyLC.menu.keys.es-mx=Spanish Latin America +teensyLC.menu.keys.es-mx.build.keylayout=SPANISH_LATIN_AMERICA +teensyLC.menu.keys.sv-se=Swedish +teensyLC.menu.keys.sv-se.build.keylayout=SWEDISH +teensyLC.menu.keys.tr-tr=Turkish (partial) +teensyLC.menu.keys.tr-tr.build.keylayout=TURKISH +teensyLC.menu.keys.en-gb=United Kingdom +teensyLC.menu.keys.en-gb.build.keylayout=UNITED_KINGDOM +teensyLC.menu.keys.usint=US International +teensyLC.menu.keys.usint.build.keylayout=US_INTERNATIONAL + + +teensypp2.name=Teensy++ 2.0 +teensypp2.upload.maximum_size=130048 +teensypp2.upload.maximum_data_size=8192 +teensypp2.upload.tool=teensyloader +teensypp2.upload.protocol=halfkay +teensypp2.build.board=TEENSY2PP +teensypp2.build.core=teensy +teensypp2.build.mcu=at90usb1286 +teensypp2.build.warn_data_percentage=94 +teensypp2.build.toolchain=avr/bin/ +teensypp2.build.command.gcc=avr-gcc +teensypp2.build.command.g++=avr-g++ +teensypp2.build.command.ar=avr-ar +teensypp2.build.command.objcopy=avr-objcopy +teensypp2.build.command.objdump=avr-objdump +teensypp2.build.command.linker=avr-gcc +teensypp2.build.command.size=avr-size +teensypp2.build.flags.common=-g -Wall -ffunction-sections -fdata-sections +teensypp2.build.flags.dep=-MMD +teensypp2.build.flags.optimize=-Os +teensypp2.build.flags.cpu=-mmcu=at90usb1286 +teensypp2.build.flags.defs=-DTEENSYDUINO=156 -DARDUINO_ARCH_AVR +teensypp2.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++11 +teensypp2.build.flags.c= +teensypp2.build.flags.S=-x assembler-with-cpp +teensypp2.build.flags.ld=-Wl,--gc-sections,--relax +teensypp2.build.flags.ldspecs= +teensypp2.build.flags.libs=-lm +teensypp2.build.serial_number=true +teensypp2.serial.restart_cmd=true + +teensypp2.menu.usb.serial=Serial +teensypp2.menu.usb.serial.build.usbtype=USB_SERIAL +teensypp2.menu.usb.hid=Keyboard + Mouse + Joystick +teensypp2.menu.usb.hid.build.usbtype=USB_HID +teensypp2.menu.usb.hid.fake_serial=teensy_gateway +teensypp2.menu.usb.serialhid=Serial + Keyboard + Mouse + Joystick +teensypp2.menu.usb.serialhid.build.usbtype=USB_SERIAL_HID +teensypp2.menu.usb.int_disk=Disk(Internal) + Keyboard +teensypp2.menu.usb.int_disk.build.usbtype=USB_DISK +teensypp2.menu.usb.int_disk.fake_serial=teensy_gateway +teensypp2.menu.usb.int_disk.build.elfpatch=mktinyfat +teensypp2.menu.usb.sd_disk=Disk(SD Card) + Keyboard +teensypp2.menu.usb.sd_disk.build.usbtype=USB_DISK_SDFLASH +teensypp2.menu.usb.sd_disk.fake_serial=teensy_gateway +teensypp2.menu.usb.midi=MIDI +teensypp2.menu.usb.midi.build.usbtype=USB_MIDI +teensypp2.menu.usb.midi.fake_serial=teensy_gateway +teensypp2.menu.usb.rawhid=Raw HID +teensypp2.menu.usb.rawhid.build.usbtype=USB_RAWHID +teensypp2.menu.usb.rawhid.fake_serial=teensy_gateway +teensypp2.menu.usb.flightsim=Flight Sim Controls +teensypp2.menu.usb.flightsim.build.usbtype=USB_FLIGHTSIM +teensypp2.menu.usb.flightsim.fake_serial=teensy_gateway +teensypp2.menu.speed.16=16 MHz +teensypp2.menu.speed.8=8 MHz +teensypp2.menu.speed.4=4 MHz +teensypp2.menu.speed.2=2 MHz +teensypp2.menu.speed.1=1 MHz +teensypp2.menu.speed.16.build.fcpu=16000000L +teensypp2.menu.speed.8.build.fcpu=8000000L +teensypp2.menu.speed.4.build.fcpu=4000000L +teensypp2.menu.speed.2.build.fcpu=2000000L +teensypp2.menu.speed.1.build.fcpu=1000000L + +teensypp2.menu.keys.en-us=US English +teensypp2.menu.keys.en-us.build.keylayout=US_ENGLISH +teensypp2.menu.keys.fr-ca=Canadian French +teensypp2.menu.keys.fr-ca.build.keylayout=CANADIAN_FRENCH +teensypp2.menu.keys.xx-ca=Canadian Multilingual +teensypp2.menu.keys.xx-ca.build.keylayout=CANADIAN_MULTILINGUAL +teensypp2.menu.keys.cz-cz=Czech +teensypp2.menu.keys.cz-cz.build.keylayout=CZECH +teensypp2.menu.keys.da-da=Danish +teensypp2.menu.keys.da-da.build.keylayout=DANISH +teensypp2.menu.keys.fi-fi=Finnish +teensypp2.menu.keys.fi-fi.build.keylayout=FINNISH +teensypp2.menu.keys.fr-fr=French +teensypp2.menu.keys.fr-fr.build.keylayout=FRENCH +teensypp2.menu.keys.fr-be=French Belgian +teensypp2.menu.keys.fr-be.build.keylayout=FRENCH_BELGIAN +teensypp2.menu.keys.fr-ch=French Swiss +teensypp2.menu.keys.fr-ch.build.keylayout=FRENCH_SWISS +teensypp2.menu.keys.de-de=German +teensypp2.menu.keys.de-de.build.keylayout=GERMAN +teensypp2.menu.keys.de-dm=German (Mac) +teensypp2.menu.keys.de-dm.build.keylayout=GERMAN_MAC +teensypp2.menu.keys.de-ch=German Swiss +teensypp2.menu.keys.de-ch.build.keylayout=GERMAN_SWISS +teensypp2.menu.keys.is-is=Icelandic +teensypp2.menu.keys.is-is.build.keylayout=ICELANDIC +teensypp2.menu.keys.en-ie=Irish +teensypp2.menu.keys.en-ie.build.keylayout=IRISH +teensypp2.menu.keys.it-it=Italian +teensypp2.menu.keys.it-it.build.keylayout=ITALIAN +teensypp2.menu.keys.no-no=Norwegian +teensypp2.menu.keys.no-no.build.keylayout=NORWEGIAN +teensypp2.menu.keys.pt-pt=Portuguese +teensypp2.menu.keys.pt-pt.build.keylayout=PORTUGUESE +teensypp2.menu.keys.pt-br=Portuguese Brazilian +teensypp2.menu.keys.pt-br.build.keylayout=PORTUGUESE_BRAZILIAN +teensypp2.menu.keys.rs-rs=Serbian (Latin Only) +teensypp2.menu.keys.rs-rs.build.keylayout=SERBIAN_LATIN_ONLY +teensypp2.menu.keys.es-es=Spanish +teensypp2.menu.keys.es-es.build.keylayout=SPANISH +teensypp2.menu.keys.es-mx=Spanish Latin America +teensypp2.menu.keys.es-mx.build.keylayout=SPANISH_LATIN_AMERICA +teensypp2.menu.keys.sv-se=Swedish +teensypp2.menu.keys.sv-se.build.keylayout=SWEDISH +teensypp2.menu.keys.tr-tr=Turkish (partial) +teensypp2.menu.keys.tr-tr.build.keylayout=TURKISH +teensypp2.menu.keys.en-gb=United Kingdom +teensypp2.menu.keys.en-gb.build.keylayout=UNITED_KINGDOM +teensypp2.menu.keys.usint=US International +teensypp2.menu.keys.usint.build.keylayout=US_INTERNATIONAL + + +teensy2.name=Teensy 2.0 +teensy2.upload.maximum_size=32256 +teensy2.upload.maximum_data_size=2560 +teensy2.upload.tool=teensyloader +teensy2.upload.protocol=halfkay +teensy2.build.board=TEENSY2 +teensy2.build.core=teensy +teensy2.build.mcu=atmega32u4 +teensy2.build.warn_data_percentage=80 +teensy2.build.toolchain=avr/bin/ +teensy2.build.command.gcc=avr-gcc +teensy2.build.command.g++=avr-g++ +teensy2.build.command.ar=avr-ar +teensy2.build.command.objcopy=avr-objcopy +teensy2.build.command.objdump=avr-objdump +teensy2.build.command.linker=avr-gcc +teensy2.build.command.size=avr-size +teensy2.build.flags.common=-g -Wall -ffunction-sections -fdata-sections +teensy2.build.flags.dep=-MMD +teensy2.build.flags.optimize=-Os +teensy2.build.flags.cpu=-mmcu=atmega32u4 +teensy2.build.flags.defs=-DTEENSYDUINO=156 -DARDUINO_ARCH_AVR +teensy2.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++11 +teensy2.build.flags.c= +teensy2.build.flags.S=-x assembler-with-cpp +teensy2.build.flags.ld=-Wl,--gc-sections,--relax +teensy2.build.flags.ldspecs= +teensy2.build.flags.libs=-lm +teensy2.build.serial_number=true +teensy2.serial.restart_cmd=true + +teensy2.menu.usb.serial=Serial +teensy2.menu.usb.serial.build.usbtype=USB_SERIAL +teensy2.menu.usb.hid=Keyboard + Mouse + Joystick +teensy2.menu.usb.hid.build.usbtype=USB_HID +teensy2.menu.usb.hid.fake_serial=teensy_gateway +teensy2.menu.usb.serialhid=Serial + Keyboard + Mouse + Joystick +teensy2.menu.usb.serialhid.build.usbtype=USB_SERIAL_HID +teensy2.menu.usb.int_disk=Disk(Internal) + Keyboard +teensy2.menu.usb.int_disk.build.usbtype=USB_DISK +teensy2.menu.usb.int_disk.fake_serial=teensy_gateway +teensy2.menu.usb.int_disk.build.elfpatch=mktinyfat +teensy2.menu.usb.sd_disk=Disk(SD Card) + Keyboard +teensy2.menu.usb.sd_disk.build.usbtype=USB_DISK_SDFLASH +teensy2.menu.usb.sd_disk.fake_serial=teensy_gateway +teensy2.menu.usb.midi=MIDI +teensy2.menu.usb.midi.build.usbtype=USB_MIDI +teensy2.menu.usb.midi.fake_serial=teensy_gateway +teensy2.menu.usb.rawhid=Raw HID +teensy2.menu.usb.rawhid.build.usbtype=USB_RAWHID +teensy2.menu.usb.rawhid.fake_serial=teensy_gateway +teensy2.menu.usb.flightsim=Flight Sim Controls +teensy2.menu.usb.flightsim.build.usbtype=USB_FLIGHTSIM +teensy2.menu.usb.flightsim.fake_serial=teensy_gateway +teensy2.menu.speed.16=16 MHz +teensy2.menu.speed.8=8 MHz +teensy2.menu.speed.4=4 MHz +teensy2.menu.speed.2=2 MHz +teensy2.menu.speed.1=1 MHz +teensy2.menu.speed.16.build.fcpu=16000000L +teensy2.menu.speed.8.build.fcpu=8000000L +teensy2.menu.speed.4.build.fcpu=4000000L +teensy2.menu.speed.2.build.fcpu=2000000L +teensy2.menu.speed.1.build.fcpu=1000000L + +teensy2.menu.keys.en-us=US English +teensy2.menu.keys.en-us.build.keylayout=US_ENGLISH +teensy2.menu.keys.fr-ca=Canadian French +teensy2.menu.keys.fr-ca.build.keylayout=CANADIAN_FRENCH +teensy2.menu.keys.xx-ca=Canadian Multilingual +teensy2.menu.keys.xx-ca.build.keylayout=CANADIAN_MULTILINGUAL +teensy2.menu.keys.cz-cz=Czech +teensy2.menu.keys.cz-cz.build.keylayout=CZECH +teensy2.menu.keys.da-da=Danish +teensy2.menu.keys.da-da.build.keylayout=DANISH +teensy2.menu.keys.fi-fi=Finnish +teensy2.menu.keys.fi-fi.build.keylayout=FINNISH +teensy2.menu.keys.fr-fr=French +teensy2.menu.keys.fr-fr.build.keylayout=FRENCH +teensy2.menu.keys.fr-be=French Belgian +teensy2.menu.keys.fr-be.build.keylayout=FRENCH_BELGIAN +teensy2.menu.keys.fr-ch=French Swiss +teensy2.menu.keys.fr-ch.build.keylayout=FRENCH_SWISS +teensy2.menu.keys.de-de=German +teensy2.menu.keys.de-de.build.keylayout=GERMAN +teensy2.menu.keys.de-dm=German (Mac) +teensy2.menu.keys.de-dm.build.keylayout=GERMAN_MAC +teensy2.menu.keys.de-ch=German Swiss +teensy2.menu.keys.de-ch.build.keylayout=GERMAN_SWISS +teensy2.menu.keys.is-is=Icelandic +teensy2.menu.keys.is-is.build.keylayout=ICELANDIC +teensy2.menu.keys.en-ie=Irish +teensy2.menu.keys.en-ie.build.keylayout=IRISH +teensy2.menu.keys.it-it=Italian +teensy2.menu.keys.it-it.build.keylayout=ITALIAN +teensy2.menu.keys.no-no=Norwegian +teensy2.menu.keys.no-no.build.keylayout=NORWEGIAN +teensy2.menu.keys.pt-pt=Portuguese +teensy2.menu.keys.pt-pt.build.keylayout=PORTUGUESE +teensy2.menu.keys.pt-br=Portuguese Brazilian +teensy2.menu.keys.pt-br.build.keylayout=PORTUGUESE_BRAZILIAN +teensy2.menu.keys.rs-rs=Serbian (Latin Only) +teensy2.menu.keys.rs-rs.build.keylayout=SERBIAN_LATIN_ONLY +teensy2.menu.keys.es-es=Spanish +teensy2.menu.keys.es-es.build.keylayout=SPANISH +teensy2.menu.keys.es-mx=Spanish Latin America +teensy2.menu.keys.es-mx.build.keylayout=SPANISH_LATIN_AMERICA +teensy2.menu.keys.sv-se=Swedish +teensy2.menu.keys.sv-se.build.keylayout=SWEDISH +teensy2.menu.keys.tr-tr=Turkish (partial) +teensy2.menu.keys.tr-tr.build.keylayout=TURKISH +teensy2.menu.keys.en-gb=United Kingdom +teensy2.menu.keys.en-gb.build.keylayout=UNITED_KINGDOM +teensy2.menu.keys.usint=US International +teensy2.menu.keys.usint.build.keylayout=US_INTERNATIONAL + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/cores/teensy/Stream.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/cores/teensy/Stream.cpp new file mode 100644 index 0000000..6c78ed5 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/cores/teensy/Stream.cpp @@ -0,0 +1,446 @@ +/* + Stream.cpp - adds parsing methods to Stream class + Copyright (c) 2008 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Created July 2011 + parsing functions based on TextFinder library by Michael Margolis + */ + +#include + +#define PARSE_TIMEOUT 1000 // default number of milli-seconds to wait +#define NO_SKIP_CHAR 1 // a magic char not found in a valid ASCII numeric field + +// private method to read stream with timeout +int Stream::timedRead() +{ + int c; + unsigned long startMillis = millis(); + + do + { + c = read(); + + if (c >= 0) + return c; + + yield(); + } while (millis() - startMillis < _timeout); + + Serial.print(("timedRead timeout = ")); + Serial.println(_timeout); + + return -1; // -1 indicates timeout +} + +// private method to peek stream with timeout +int Stream::timedPeek() +{ + int c; + unsigned long startMillis = millis(); + + do + { + c = peek(); + + if (c >= 0) + return c; + + yield(); + } while (millis() - startMillis < _timeout); + + return -1; // -1 indicates timeout +} + +// returns peek of the next digit in the stream or -1 if timeout +// discards non-numeric characters +int Stream::peekNextDigit() +{ + int c; + + while (1) + { + c = timedPeek(); + + if (c < 0) + return c; // timeout + + if (c == '-') + return c; + + if (c >= '0' && c <= '9') + return c; + + read(); // discard non-numeric + } +} + +// Public Methods +////////////////////////////////////////////////////////////// + +void Stream::setTimeout(unsigned long timeout) // sets the maximum number of milliseconds to wait +{ + _timeout = timeout; +} + +// find returns true if the target string is found +bool Stream::find(const char *target) +{ + return findUntil(target, NULL); +} + +// reads data from the stream until the target string of given length is found +// returns true if target string is found, false if timed out +bool Stream::find(const char *target, size_t length) +{ + return findUntil(target, length, NULL, 0); +} + +// as find but search ends if the terminator string is found +bool Stream::findUntil(const char *target, const char *terminator) +{ + if (target == nullptr) + return true; + + size_t tlen = (terminator == nullptr) ? 0 : strlen(terminator); + + return findUntil(target, strlen(target), terminator, tlen); +} + +// reads data from the stream until the target string of the given length is found +// search terminated if the terminator string is found +// returns true if target string is found, false if terminated or timed out +bool Stream::findUntil(const char *target, size_t targetLen, const char *terminator, size_t termLen) +{ + size_t index = 0; // maximum target string length is 64k bytes! + size_t termIndex = 0; + int c; + + if ( target == nullptr) + return true; + + if ( *target == 0) + return true; // return true if target is a null string + + if (terminator == nullptr) + termLen = 0; + + while ( (c = timedRead()) > 0) + { + if ( c == target[index]) + { + //////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1); + if (++index >= targetLen) + { + // return true if all chars in the target match + return true; + } + } + else + { + index = 0; // reset index if any char does not match + } + + if (termLen > 0 && c == terminator[termIndex]) + { + if (++termIndex >= termLen) + return false; // return false if terminate string found before target string + } + else + termIndex = 0; + } + + return false; +} + + +// returns the first valid (long) integer value from the current position. +// initial characters that are not digits (or the minus sign) are skipped +// function is terminated by the first character that is not a digit. +long Stream::parseInt() +{ + return parseInt(NO_SKIP_CHAR); // terminate on first non-digit character (or timeout) +} + +// as above but a given skipChar is ignored +// this allows format characters (typically commas) in values to be ignored +long Stream::parseInt(char skipChar) +{ + boolean isNegative = false; + long value = 0; + int c; + + c = peekNextDigit(); + + // ignore non numeric leading characters + if (c < 0) + return 0; // zero returned if timeout + + do + { + if (c == skipChar) + ; // ignore this charactor + else if (c == '-') + isNegative = true; + else if (c >= '0' && c <= '9') // is c a digit? + value = value * 10 + c - '0'; + + read(); // consume the character we got with peek + c = timedPeek(); + } + while ( (c >= '0' && c <= '9') || c == skipChar ); + + if (isNegative) + value = -value; + + return value; +} + + +// as parseInt but returns a floating point value +float Stream::parseFloat() +{ + return parseFloat(NO_SKIP_CHAR); +} + +// as above but the given skipChar is ignored +// this allows format characters (typically commas) in values to be ignored +float Stream::parseFloat(char skipChar) +{ + boolean isNegative = false; + boolean isFraction = false; + long value = 0; + int c; + float fraction = 1.0; + + c = peekNextDigit(); + + // ignore non numeric leading characters + if (c < 0) + return 0; // zero returned if timeout + + do + { + if (c == skipChar) + ; // ignore + else if (c == '-') + isNegative = true; + else if (c == '.') + isFraction = true; + else if (c >= '0' && c <= '9') + { + // is c a digit? + value = value * 10 + c - '0'; + + if (isFraction) + fraction *= 0.1f; + } + + read(); // consume the character we got with peek + c = timedPeek(); + } + while ( (c >= '0' && c <= '9') || c == '.' || c == skipChar ); + + if (isNegative) + value = -value; + + if (isFraction) + return value * fraction; + else + return value; +} + +// read characters from stream into buffer +// terminates if length characters have been read, or timeout (see setTimeout) +// returns the number of characters placed in the buffer +// the buffer is NOT null terminated. +// +size_t Stream::readBytes(char *buffer, size_t length) +{ + if (buffer == nullptr) + return 0; + + size_t count = 0; + + while (count < length) + { + int c = timedRead(); + + if (c < 0) + { + setReadError(); + break; + } + + *buffer++ = (char)c; + count++; + } + + return count; +} + + +// as readBytes with terminator character +// terminates if length characters have been read, timeout, or if the terminator character detected +// returns the number of characters placed in the buffer (0 means no valid data found) + +size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length) +{ + if (buffer == nullptr) + return 0; + + if (length < 1) + return 0; + + length--; + size_t index = 0; + + while (index < length) + { + int c = timedRead(); + + if (c == terminator) + break; + + if (c < 0) + { + setReadError(); + break; + } + + *buffer++ = (char)c; + index++; + } + + *buffer = 0; + return index; // return number of characters, not including null terminator +} + +#if 1 +// From nRF52 + +String Stream::readString(size_t max) +{ + String ret; + int c = timedRead(); + + while (c >= 0) + { + ret += (char)c; + c = timedRead(); + } + + return ret; +} + +char readStringBuffer[2048]; + +char* Stream::readCharsUntil(char terminator, size_t max) +{ + uint16_t offset = 0; + + int c = timedRead(); + + readStringBuffer[offset++] = c; + + while (c >= 0 && c != terminator) + { + c = timedRead(); + + readStringBuffer[offset++] = c; + } + + readStringBuffer[offset] = 0; + + return readStringBuffer; +} + +String Stream::readStringUntil(char terminator, size_t max) +{ + String ret; + uint16_t offset = 0; + + int c = timedRead(); + + readStringBuffer[offset++] = c; + + while (c >= 0 && c != terminator) + { + c = timedRead(); + + readStringBuffer[offset++] = c; + } + + readStringBuffer[offset] = 0; + + ret = String(readStringBuffer); + + return String(readStringBuffer); +} + +#else + +String Stream::readString(size_t max) +{ + String str; + size_t length = 0; + + while (length < max) + { + int c = timedRead(); + + if (c < 0) + { + setReadError(); + break; // timeout + } + + if (c == 0) + break; + + str += (char)c; + length++; + } + + return str; +} + +String Stream::readStringUntil(char terminator, size_t max) +{ + String str; + size_t length = 0; + + while (length < max) + { + int c = timedRead(); + + if (c < 0) + { + setReadError(); + break; // timeout + } + + if (c == 0 || c == terminator) + break; + + str += (char)c; + length++; + } + + return str; +} +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/cores/teensy/Stream.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/cores/teensy/Stream.h new file mode 100644 index 0000000..e63330a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/cores/teensy/Stream.h @@ -0,0 +1,149 @@ +/* + Stream.h - base class for character-based streams. + Copyright (c) 2010 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef Stream_h +#define Stream_h + +#include +#include "Print.h" + +class Stream : public Print +{ + public: + constexpr Stream() : _timeout(1000), read_error(0) {} + virtual int available() = 0; + virtual int read() = 0; + virtual int peek() = 0; + + void setTimeout(unsigned long timeout); + bool find(const char *target); + + bool find(const uint8_t *target) + { + return find ((const char *)target); + } + + bool find(const String &target) + { + return find(target.c_str()); + } + + bool find(const char *target, size_t length); + + bool find(const uint8_t *target, size_t length) + { + return find ((const char *)target, length); + } + + bool find(const String &target, size_t length) + { + return find(target.c_str(), length); + } + + bool findUntil(const char *target, const char *terminator); + + bool findUntil(const uint8_t *target, const char *terminator) + { + return findUntil((const char *)target, terminator); + } + + bool findUntil(const String &target, const char *terminator) + { + return findUntil(target.c_str(), terminator); + } + + bool findUntil(const char *target, const String &terminator) + { + return findUntil(target, terminator.c_str()); + } + + bool findUntil(const String &target, const String &terminator) + { + return findUntil(target.c_str(), terminator.c_str()); + } + + bool findUntil(const char *target, size_t targetLen, const char *terminate, size_t termLen); + + bool findUntil(const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen) + { + return findUntil((const char *)target, targetLen, terminate, termLen); + } + + bool findUntil(const String &target, size_t targetLen, const char *terminate, size_t termLen); + bool findUntil(const char *target, size_t targetLen, const String &terminate, size_t termLen); + bool findUntil(const String &target, size_t targetLen, const String &terminate, size_t termLen); + + long parseInt(); + long parseInt(char skipChar); + + float parseFloat(); + float parseFloat(char skipChar); + + size_t readBytes(char *buffer, size_t length); + + size_t readBytes(uint8_t *buffer, size_t length) + { + return readBytes((char *)buffer, length); + } + + size_t readBytesUntil(char terminator, char *buffer, size_t length); + + size_t readBytesUntil(char terminator, uint8_t *buffer, size_t length) + { + return readBytesUntil(terminator, (char *)buffer, length); + } + + //////////////////////////////////////////////////////////// + String readString(size_t max = 512); + String readStringUntil(char terminator, size_t max = 512); + + // KH, to not use String + char* readCharsUntil(char terminator, size_t max = 512); + //////////////////////////////////////////////////////////// + + int getReadError() + { + return read_error; + } + + void clearReadError() + { + setReadError(0); + } + + protected: + void setReadError(int err = 1) + { + read_error = err; + } + + unsigned long _timeout; + + // KH + int timedRead(); + int timedPeek(); + int peekNextDigit(); + ////// + + private: + char read_error; +}; + +#endif + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/cores/teensy3/Stream.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/cores/teensy3/Stream.cpp new file mode 100644 index 0000000..6c78ed5 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/cores/teensy3/Stream.cpp @@ -0,0 +1,446 @@ +/* + Stream.cpp - adds parsing methods to Stream class + Copyright (c) 2008 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Created July 2011 + parsing functions based on TextFinder library by Michael Margolis + */ + +#include + +#define PARSE_TIMEOUT 1000 // default number of milli-seconds to wait +#define NO_SKIP_CHAR 1 // a magic char not found in a valid ASCII numeric field + +// private method to read stream with timeout +int Stream::timedRead() +{ + int c; + unsigned long startMillis = millis(); + + do + { + c = read(); + + if (c >= 0) + return c; + + yield(); + } while (millis() - startMillis < _timeout); + + Serial.print(("timedRead timeout = ")); + Serial.println(_timeout); + + return -1; // -1 indicates timeout +} + +// private method to peek stream with timeout +int Stream::timedPeek() +{ + int c; + unsigned long startMillis = millis(); + + do + { + c = peek(); + + if (c >= 0) + return c; + + yield(); + } while (millis() - startMillis < _timeout); + + return -1; // -1 indicates timeout +} + +// returns peek of the next digit in the stream or -1 if timeout +// discards non-numeric characters +int Stream::peekNextDigit() +{ + int c; + + while (1) + { + c = timedPeek(); + + if (c < 0) + return c; // timeout + + if (c == '-') + return c; + + if (c >= '0' && c <= '9') + return c; + + read(); // discard non-numeric + } +} + +// Public Methods +////////////////////////////////////////////////////////////// + +void Stream::setTimeout(unsigned long timeout) // sets the maximum number of milliseconds to wait +{ + _timeout = timeout; +} + +// find returns true if the target string is found +bool Stream::find(const char *target) +{ + return findUntil(target, NULL); +} + +// reads data from the stream until the target string of given length is found +// returns true if target string is found, false if timed out +bool Stream::find(const char *target, size_t length) +{ + return findUntil(target, length, NULL, 0); +} + +// as find but search ends if the terminator string is found +bool Stream::findUntil(const char *target, const char *terminator) +{ + if (target == nullptr) + return true; + + size_t tlen = (terminator == nullptr) ? 0 : strlen(terminator); + + return findUntil(target, strlen(target), terminator, tlen); +} + +// reads data from the stream until the target string of the given length is found +// search terminated if the terminator string is found +// returns true if target string is found, false if terminated or timed out +bool Stream::findUntil(const char *target, size_t targetLen, const char *terminator, size_t termLen) +{ + size_t index = 0; // maximum target string length is 64k bytes! + size_t termIndex = 0; + int c; + + if ( target == nullptr) + return true; + + if ( *target == 0) + return true; // return true if target is a null string + + if (terminator == nullptr) + termLen = 0; + + while ( (c = timedRead()) > 0) + { + if ( c == target[index]) + { + //////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1); + if (++index >= targetLen) + { + // return true if all chars in the target match + return true; + } + } + else + { + index = 0; // reset index if any char does not match + } + + if (termLen > 0 && c == terminator[termIndex]) + { + if (++termIndex >= termLen) + return false; // return false if terminate string found before target string + } + else + termIndex = 0; + } + + return false; +} + + +// returns the first valid (long) integer value from the current position. +// initial characters that are not digits (or the minus sign) are skipped +// function is terminated by the first character that is not a digit. +long Stream::parseInt() +{ + return parseInt(NO_SKIP_CHAR); // terminate on first non-digit character (or timeout) +} + +// as above but a given skipChar is ignored +// this allows format characters (typically commas) in values to be ignored +long Stream::parseInt(char skipChar) +{ + boolean isNegative = false; + long value = 0; + int c; + + c = peekNextDigit(); + + // ignore non numeric leading characters + if (c < 0) + return 0; // zero returned if timeout + + do + { + if (c == skipChar) + ; // ignore this charactor + else if (c == '-') + isNegative = true; + else if (c >= '0' && c <= '9') // is c a digit? + value = value * 10 + c - '0'; + + read(); // consume the character we got with peek + c = timedPeek(); + } + while ( (c >= '0' && c <= '9') || c == skipChar ); + + if (isNegative) + value = -value; + + return value; +} + + +// as parseInt but returns a floating point value +float Stream::parseFloat() +{ + return parseFloat(NO_SKIP_CHAR); +} + +// as above but the given skipChar is ignored +// this allows format characters (typically commas) in values to be ignored +float Stream::parseFloat(char skipChar) +{ + boolean isNegative = false; + boolean isFraction = false; + long value = 0; + int c; + float fraction = 1.0; + + c = peekNextDigit(); + + // ignore non numeric leading characters + if (c < 0) + return 0; // zero returned if timeout + + do + { + if (c == skipChar) + ; // ignore + else if (c == '-') + isNegative = true; + else if (c == '.') + isFraction = true; + else if (c >= '0' && c <= '9') + { + // is c a digit? + value = value * 10 + c - '0'; + + if (isFraction) + fraction *= 0.1f; + } + + read(); // consume the character we got with peek + c = timedPeek(); + } + while ( (c >= '0' && c <= '9') || c == '.' || c == skipChar ); + + if (isNegative) + value = -value; + + if (isFraction) + return value * fraction; + else + return value; +} + +// read characters from stream into buffer +// terminates if length characters have been read, or timeout (see setTimeout) +// returns the number of characters placed in the buffer +// the buffer is NOT null terminated. +// +size_t Stream::readBytes(char *buffer, size_t length) +{ + if (buffer == nullptr) + return 0; + + size_t count = 0; + + while (count < length) + { + int c = timedRead(); + + if (c < 0) + { + setReadError(); + break; + } + + *buffer++ = (char)c; + count++; + } + + return count; +} + + +// as readBytes with terminator character +// terminates if length characters have been read, timeout, or if the terminator character detected +// returns the number of characters placed in the buffer (0 means no valid data found) + +size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length) +{ + if (buffer == nullptr) + return 0; + + if (length < 1) + return 0; + + length--; + size_t index = 0; + + while (index < length) + { + int c = timedRead(); + + if (c == terminator) + break; + + if (c < 0) + { + setReadError(); + break; + } + + *buffer++ = (char)c; + index++; + } + + *buffer = 0; + return index; // return number of characters, not including null terminator +} + +#if 1 +// From nRF52 + +String Stream::readString(size_t max) +{ + String ret; + int c = timedRead(); + + while (c >= 0) + { + ret += (char)c; + c = timedRead(); + } + + return ret; +} + +char readStringBuffer[2048]; + +char* Stream::readCharsUntil(char terminator, size_t max) +{ + uint16_t offset = 0; + + int c = timedRead(); + + readStringBuffer[offset++] = c; + + while (c >= 0 && c != terminator) + { + c = timedRead(); + + readStringBuffer[offset++] = c; + } + + readStringBuffer[offset] = 0; + + return readStringBuffer; +} + +String Stream::readStringUntil(char terminator, size_t max) +{ + String ret; + uint16_t offset = 0; + + int c = timedRead(); + + readStringBuffer[offset++] = c; + + while (c >= 0 && c != terminator) + { + c = timedRead(); + + readStringBuffer[offset++] = c; + } + + readStringBuffer[offset] = 0; + + ret = String(readStringBuffer); + + return String(readStringBuffer); +} + +#else + +String Stream::readString(size_t max) +{ + String str; + size_t length = 0; + + while (length < max) + { + int c = timedRead(); + + if (c < 0) + { + setReadError(); + break; // timeout + } + + if (c == 0) + break; + + str += (char)c; + length++; + } + + return str; +} + +String Stream::readStringUntil(char terminator, size_t max) +{ + String str; + size_t length = 0; + + while (length < max) + { + int c = timedRead(); + + if (c < 0) + { + setReadError(); + break; // timeout + } + + if (c == 0 || c == terminator) + break; + + str += (char)c; + length++; + } + + return str; +} +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/cores/teensy3/Stream.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/cores/teensy3/Stream.h new file mode 100644 index 0000000..e63330a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/cores/teensy3/Stream.h @@ -0,0 +1,149 @@ +/* + Stream.h - base class for character-based streams. + Copyright (c) 2010 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef Stream_h +#define Stream_h + +#include +#include "Print.h" + +class Stream : public Print +{ + public: + constexpr Stream() : _timeout(1000), read_error(0) {} + virtual int available() = 0; + virtual int read() = 0; + virtual int peek() = 0; + + void setTimeout(unsigned long timeout); + bool find(const char *target); + + bool find(const uint8_t *target) + { + return find ((const char *)target); + } + + bool find(const String &target) + { + return find(target.c_str()); + } + + bool find(const char *target, size_t length); + + bool find(const uint8_t *target, size_t length) + { + return find ((const char *)target, length); + } + + bool find(const String &target, size_t length) + { + return find(target.c_str(), length); + } + + bool findUntil(const char *target, const char *terminator); + + bool findUntil(const uint8_t *target, const char *terminator) + { + return findUntil((const char *)target, terminator); + } + + bool findUntil(const String &target, const char *terminator) + { + return findUntil(target.c_str(), terminator); + } + + bool findUntil(const char *target, const String &terminator) + { + return findUntil(target, terminator.c_str()); + } + + bool findUntil(const String &target, const String &terminator) + { + return findUntil(target.c_str(), terminator.c_str()); + } + + bool findUntil(const char *target, size_t targetLen, const char *terminate, size_t termLen); + + bool findUntil(const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen) + { + return findUntil((const char *)target, targetLen, terminate, termLen); + } + + bool findUntil(const String &target, size_t targetLen, const char *terminate, size_t termLen); + bool findUntil(const char *target, size_t targetLen, const String &terminate, size_t termLen); + bool findUntil(const String &target, size_t targetLen, const String &terminate, size_t termLen); + + long parseInt(); + long parseInt(char skipChar); + + float parseFloat(); + float parseFloat(char skipChar); + + size_t readBytes(char *buffer, size_t length); + + size_t readBytes(uint8_t *buffer, size_t length) + { + return readBytes((char *)buffer, length); + } + + size_t readBytesUntil(char terminator, char *buffer, size_t length); + + size_t readBytesUntil(char terminator, uint8_t *buffer, size_t length) + { + return readBytesUntil(terminator, (char *)buffer, length); + } + + //////////////////////////////////////////////////////////// + String readString(size_t max = 512); + String readStringUntil(char terminator, size_t max = 512); + + // KH, to not use String + char* readCharsUntil(char terminator, size_t max = 512); + //////////////////////////////////////////////////////////// + + int getReadError() + { + return read_error; + } + + void clearReadError() + { + setReadError(0); + } + + protected: + void setReadError(int err = 1) + { + read_error = err; + } + + unsigned long _timeout; + + // KH + int timedRead(); + int timedPeek(); + int peekNextDigit(); + ////// + + private: + char read_error; +}; + +#endif + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/cores/teensy4/Stream.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/cores/teensy4/Stream.cpp new file mode 100644 index 0000000..6c78ed5 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/cores/teensy4/Stream.cpp @@ -0,0 +1,446 @@ +/* + Stream.cpp - adds parsing methods to Stream class + Copyright (c) 2008 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Created July 2011 + parsing functions based on TextFinder library by Michael Margolis + */ + +#include + +#define PARSE_TIMEOUT 1000 // default number of milli-seconds to wait +#define NO_SKIP_CHAR 1 // a magic char not found in a valid ASCII numeric field + +// private method to read stream with timeout +int Stream::timedRead() +{ + int c; + unsigned long startMillis = millis(); + + do + { + c = read(); + + if (c >= 0) + return c; + + yield(); + } while (millis() - startMillis < _timeout); + + Serial.print(("timedRead timeout = ")); + Serial.println(_timeout); + + return -1; // -1 indicates timeout +} + +// private method to peek stream with timeout +int Stream::timedPeek() +{ + int c; + unsigned long startMillis = millis(); + + do + { + c = peek(); + + if (c >= 0) + return c; + + yield(); + } while (millis() - startMillis < _timeout); + + return -1; // -1 indicates timeout +} + +// returns peek of the next digit in the stream or -1 if timeout +// discards non-numeric characters +int Stream::peekNextDigit() +{ + int c; + + while (1) + { + c = timedPeek(); + + if (c < 0) + return c; // timeout + + if (c == '-') + return c; + + if (c >= '0' && c <= '9') + return c; + + read(); // discard non-numeric + } +} + +// Public Methods +////////////////////////////////////////////////////////////// + +void Stream::setTimeout(unsigned long timeout) // sets the maximum number of milliseconds to wait +{ + _timeout = timeout; +} + +// find returns true if the target string is found +bool Stream::find(const char *target) +{ + return findUntil(target, NULL); +} + +// reads data from the stream until the target string of given length is found +// returns true if target string is found, false if timed out +bool Stream::find(const char *target, size_t length) +{ + return findUntil(target, length, NULL, 0); +} + +// as find but search ends if the terminator string is found +bool Stream::findUntil(const char *target, const char *terminator) +{ + if (target == nullptr) + return true; + + size_t tlen = (terminator == nullptr) ? 0 : strlen(terminator); + + return findUntil(target, strlen(target), terminator, tlen); +} + +// reads data from the stream until the target string of the given length is found +// search terminated if the terminator string is found +// returns true if target string is found, false if terminated or timed out +bool Stream::findUntil(const char *target, size_t targetLen, const char *terminator, size_t termLen) +{ + size_t index = 0; // maximum target string length is 64k bytes! + size_t termIndex = 0; + int c; + + if ( target == nullptr) + return true; + + if ( *target == 0) + return true; // return true if target is a null string + + if (terminator == nullptr) + termLen = 0; + + while ( (c = timedRead()) > 0) + { + if ( c == target[index]) + { + //////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1); + if (++index >= targetLen) + { + // return true if all chars in the target match + return true; + } + } + else + { + index = 0; // reset index if any char does not match + } + + if (termLen > 0 && c == terminator[termIndex]) + { + if (++termIndex >= termLen) + return false; // return false if terminate string found before target string + } + else + termIndex = 0; + } + + return false; +} + + +// returns the first valid (long) integer value from the current position. +// initial characters that are not digits (or the minus sign) are skipped +// function is terminated by the first character that is not a digit. +long Stream::parseInt() +{ + return parseInt(NO_SKIP_CHAR); // terminate on first non-digit character (or timeout) +} + +// as above but a given skipChar is ignored +// this allows format characters (typically commas) in values to be ignored +long Stream::parseInt(char skipChar) +{ + boolean isNegative = false; + long value = 0; + int c; + + c = peekNextDigit(); + + // ignore non numeric leading characters + if (c < 0) + return 0; // zero returned if timeout + + do + { + if (c == skipChar) + ; // ignore this charactor + else if (c == '-') + isNegative = true; + else if (c >= '0' && c <= '9') // is c a digit? + value = value * 10 + c - '0'; + + read(); // consume the character we got with peek + c = timedPeek(); + } + while ( (c >= '0' && c <= '9') || c == skipChar ); + + if (isNegative) + value = -value; + + return value; +} + + +// as parseInt but returns a floating point value +float Stream::parseFloat() +{ + return parseFloat(NO_SKIP_CHAR); +} + +// as above but the given skipChar is ignored +// this allows format characters (typically commas) in values to be ignored +float Stream::parseFloat(char skipChar) +{ + boolean isNegative = false; + boolean isFraction = false; + long value = 0; + int c; + float fraction = 1.0; + + c = peekNextDigit(); + + // ignore non numeric leading characters + if (c < 0) + return 0; // zero returned if timeout + + do + { + if (c == skipChar) + ; // ignore + else if (c == '-') + isNegative = true; + else if (c == '.') + isFraction = true; + else if (c >= '0' && c <= '9') + { + // is c a digit? + value = value * 10 + c - '0'; + + if (isFraction) + fraction *= 0.1f; + } + + read(); // consume the character we got with peek + c = timedPeek(); + } + while ( (c >= '0' && c <= '9') || c == '.' || c == skipChar ); + + if (isNegative) + value = -value; + + if (isFraction) + return value * fraction; + else + return value; +} + +// read characters from stream into buffer +// terminates if length characters have been read, or timeout (see setTimeout) +// returns the number of characters placed in the buffer +// the buffer is NOT null terminated. +// +size_t Stream::readBytes(char *buffer, size_t length) +{ + if (buffer == nullptr) + return 0; + + size_t count = 0; + + while (count < length) + { + int c = timedRead(); + + if (c < 0) + { + setReadError(); + break; + } + + *buffer++ = (char)c; + count++; + } + + return count; +} + + +// as readBytes with terminator character +// terminates if length characters have been read, timeout, or if the terminator character detected +// returns the number of characters placed in the buffer (0 means no valid data found) + +size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length) +{ + if (buffer == nullptr) + return 0; + + if (length < 1) + return 0; + + length--; + size_t index = 0; + + while (index < length) + { + int c = timedRead(); + + if (c == terminator) + break; + + if (c < 0) + { + setReadError(); + break; + } + + *buffer++ = (char)c; + index++; + } + + *buffer = 0; + return index; // return number of characters, not including null terminator +} + +#if 1 +// From nRF52 + +String Stream::readString(size_t max) +{ + String ret; + int c = timedRead(); + + while (c >= 0) + { + ret += (char)c; + c = timedRead(); + } + + return ret; +} + +char readStringBuffer[2048]; + +char* Stream::readCharsUntil(char terminator, size_t max) +{ + uint16_t offset = 0; + + int c = timedRead(); + + readStringBuffer[offset++] = c; + + while (c >= 0 && c != terminator) + { + c = timedRead(); + + readStringBuffer[offset++] = c; + } + + readStringBuffer[offset] = 0; + + return readStringBuffer; +} + +String Stream::readStringUntil(char terminator, size_t max) +{ + String ret; + uint16_t offset = 0; + + int c = timedRead(); + + readStringBuffer[offset++] = c; + + while (c >= 0 && c != terminator) + { + c = timedRead(); + + readStringBuffer[offset++] = c; + } + + readStringBuffer[offset] = 0; + + ret = String(readStringBuffer); + + return String(readStringBuffer); +} + +#else + +String Stream::readString(size_t max) +{ + String str; + size_t length = 0; + + while (length < max) + { + int c = timedRead(); + + if (c < 0) + { + setReadError(); + break; // timeout + } + + if (c == 0) + break; + + str += (char)c; + length++; + } + + return str; +} + +String Stream::readStringUntil(char terminator, size_t max) +{ + String str; + size_t length = 0; + + while (length < max) + { + int c = timedRead(); + + if (c < 0) + { + setReadError(); + break; // timeout + } + + if (c == 0 || c == terminator) + break; + + str += (char)c; + length++; + } + + return str; +} +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/cores/teensy4/Stream.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/cores/teensy4/Stream.h new file mode 100644 index 0000000..e63330a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/hardware/teensy/avr/cores/teensy4/Stream.h @@ -0,0 +1,149 @@ +/* + Stream.h - base class for character-based streams. + Copyright (c) 2010 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef Stream_h +#define Stream_h + +#include +#include "Print.h" + +class Stream : public Print +{ + public: + constexpr Stream() : _timeout(1000), read_error(0) {} + virtual int available() = 0; + virtual int read() = 0; + virtual int peek() = 0; + + void setTimeout(unsigned long timeout); + bool find(const char *target); + + bool find(const uint8_t *target) + { + return find ((const char *)target); + } + + bool find(const String &target) + { + return find(target.c_str()); + } + + bool find(const char *target, size_t length); + + bool find(const uint8_t *target, size_t length) + { + return find ((const char *)target, length); + } + + bool find(const String &target, size_t length) + { + return find(target.c_str(), length); + } + + bool findUntil(const char *target, const char *terminator); + + bool findUntil(const uint8_t *target, const char *terminator) + { + return findUntil((const char *)target, terminator); + } + + bool findUntil(const String &target, const char *terminator) + { + return findUntil(target.c_str(), terminator); + } + + bool findUntil(const char *target, const String &terminator) + { + return findUntil(target, terminator.c_str()); + } + + bool findUntil(const String &target, const String &terminator) + { + return findUntil(target.c_str(), terminator.c_str()); + } + + bool findUntil(const char *target, size_t targetLen, const char *terminate, size_t termLen); + + bool findUntil(const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen) + { + return findUntil((const char *)target, targetLen, terminate, termLen); + } + + bool findUntil(const String &target, size_t targetLen, const char *terminate, size_t termLen); + bool findUntil(const char *target, size_t targetLen, const String &terminate, size_t termLen); + bool findUntil(const String &target, size_t targetLen, const String &terminate, size_t termLen); + + long parseInt(); + long parseInt(char skipChar); + + float parseFloat(); + float parseFloat(char skipChar); + + size_t readBytes(char *buffer, size_t length); + + size_t readBytes(uint8_t *buffer, size_t length) + { + return readBytes((char *)buffer, length); + } + + size_t readBytesUntil(char terminator, char *buffer, size_t length); + + size_t readBytesUntil(char terminator, uint8_t *buffer, size_t length) + { + return readBytesUntil(terminator, (char *)buffer, length); + } + + //////////////////////////////////////////////////////////// + String readString(size_t max = 512); + String readStringUntil(char terminator, size_t max = 512); + + // KH, to not use String + char* readCharsUntil(char terminator, size_t max = 512); + //////////////////////////////////////////////////////////// + + int getReadError() + { + return read_error; + } + + void clearReadError() + { + setReadError(0); + } + + protected: + void setReadError(int err = 1) + { + read_error = err; + } + + unsigned long _timeout; + + // KH + int timedRead(); + int timedPeek(); + int peekNextDigit(); + ////// + + private: + char read_error; +}; + +#endif + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/industrialshields/hardware/avr/1.1.36/cores/industrialshields/Udp.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/industrialshields/hardware/avr/1.1.36/cores/industrialshields/Udp.h new file mode 100644 index 0000000..d052446 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/industrialshields/hardware/avr/1.1.36/cores/industrialshields/Udp.h @@ -0,0 +1,89 @@ +/* + * Udp.cpp: Library to send/receive UDP packets. + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + */ + +#ifndef udp_h +#define udp_h + +#include +#include + +class UDP : public Stream { + +public: + virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + virtual void stop() =0; // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port) =0; + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port) =0; + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket() =0; + // Write a single byte into the packet + virtual size_t write(uint8_t) =0; + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size) =0; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket() =0; + // Number of bytes remaining in the current packet + virtual int available() =0; + // Read a single byte from the current packet + virtual int read() =0; + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len) =0; + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) =0; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek() =0; + virtual void flush() =0; // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() =0; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() =0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/industrialshields/hardware/avr/1.1.37/cores/industrialshields/Udp.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/industrialshields/hardware/avr/1.1.37/cores/industrialshields/Udp.h new file mode 100644 index 0000000..d052446 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/industrialshields/hardware/avr/1.1.37/cores/industrialshields/Udp.h @@ -0,0 +1,89 @@ +/* + * Udp.cpp: Library to send/receive UDP packets. + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + */ + +#ifndef udp_h +#define udp_h + +#include +#include + +class UDP : public Stream { + +public: + virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + virtual void stop() =0; // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port) =0; + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port) =0; + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket() =0; + // Write a single byte into the packet + virtual size_t write(uint8_t) =0; + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size) =0; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket() =0; + // Number of bytes remaining in the current packet + virtual int available() =0; + // Read a single byte from the current packet + virtual int read() =0; + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len) =0; + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) =0; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek() =0; + virtual void flush() =0; // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() =0; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() =0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/realtek/hardware/AmebaD/3.0.10/cores/arduino/avr/pgmspace.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/realtek/hardware/AmebaD/3.0.10/cores/arduino/avr/pgmspace.h new file mode 100644 index 0000000..bf87a94 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/realtek/hardware/AmebaD/3.0.10/cores/arduino/avr/pgmspace.h @@ -0,0 +1,122 @@ +/* + pgmspace.h - Definitions for compatibility with AVR pgmspace macros + + Copyright (c) 2015 Arduino LLC + + Based on work of Paul Stoffregen on Teensy 3 (http://pjrc.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE +*/ + +#ifndef __PGMSPACE_H_ +#define __PGMSPACE_H_ 1 + +#include + +#define PROGMEM +#define PGM_P const char * +#define PSTR(str) (str) + +#define _SFR_BYTE(n) (n) + +typedef void prog_void; +typedef char prog_char; +typedef unsigned char prog_uchar; +typedef int8_t prog_int8_t; +typedef uint8_t prog_uint8_t; +typedef int16_t prog_int16_t; +typedef uint16_t prog_uint16_t; +typedef int32_t prog_int32_t; +typedef uint32_t prog_uint32_t; +typedef int64_t prog_int64_t; +typedef uint64_t prog_uint64_t; + +typedef const void* int_farptr_t; +typedef const void* uint_farptr_t; + +#define memchr_P(s, c, n) memchr((s), (c), (n)) +#define memcmp_P(s1, s2, n) memcmp((s1), (s2), (n)) +#define memccpy_P(dest, src, c, n) memccpy((dest), (src), (c), (n)) +#define memcpy_P(dest, src, n) memcpy((dest), (src), (n)) +#define memmem_P(haystack, haystacklen, needle, needlelen) memmem((haystack), (haystacklen), (needle), (needlelen)) +#define memrchr_P(s, c, n) memrchr((s), (c), (n)) +#define strcat_P(dest, src) strcat((dest), (src)) +#define strchr_P(s, c) strchr((s), (c)) +#define strchrnul_P(s, c) strchrnul((s), (c)) +#define strcmp_P(a, b) strcmp((a), (b)) +#define strcpy_P(dest, src) strcpy((dest), (src)) +#define strcasecmp_P(s1, s2) strcasecmp((s1), (s2)) +#define strcasestr_P(haystack, needle) strcasestr((haystack), (needle)) +#define strcspn_P(s, accept) strcspn((s), (accept)) +#define strlcat_P(s1, s2, n) strlcat((s1), (s2), (n)) +#define strlcpy_P(s1, s2, n) strlcpy((s1), (s2), (n)) +#define strlen_P(a) strlen((a)) +#define strnlen_P(s, n) strnlen((s), (n)) +#define strncmp_P(s1, s2, n) strncmp((s1), (s2), (n)) +#define strncasecmp_P(s1, s2, n) strncasecmp((s1), (s2), (n)) +#define strncat_P(s1, s2, n) strncat((s1), (s2), (n)) +#define strncpy_P(s1, s2, n) strncpy((s1), (s2), (n)) +#define strpbrk_P(s, accept) strpbrk((s), (accept)) +#define strrchr_P(s, c) strrchr((s), (c)) +#define strsep_P(sp, delim) strsep((sp), (delim)) +#define strspn_P(s, accept) strspn((s), (accept)) +#define strstr_P(a, b) strstr((a), (b)) +#define strtok_P(s, delim) strtok((s), (delim)) +#define strtok_rP(s, delim, last) strtok((s), (delim), (last)) + +#define strlen_PF(a) strlen((a)) +#define strnlen_PF(src, len) strnlen((src), (len)) +#define memcpy_PF(dest, src, len) memcpy((dest), (src), (len)) +#define strcpy_PF(dest, src) strcpy((dest), (src)) +#define strncpy_PF(dest, src, len) strncpy((dest), (src), (len)) +#define strcat_PF(dest, src) strcat((dest), (src)) +#define strlcat_PF(dest, src, len) strlcat((dest), (src), (len)) +#define strncat_PF(dest, src, len) strncat((dest), (src), (len)) +#define strcmp_PF(s1, s2) strcmp((s1), (s2)) +#define strncmp_PF(s1, s2, n) strncmp((s1), (s2), (n)) +#define strcasecmp_PF(s1, s2) strcasecmp((s1), (s2)) +#define strncasecmp_PF(s1, s2, n) strncasecmp((s1), (s2), (n)) +#define strstr_PF(s1, s2) strstr((s1), (s2)) +#define strlcpy_PF(dest, src, n) strlcpy((dest), (src), (n)) +#define memcmp_PF(s1, s2, n) memcmp((s1), (s2), (n)) + +#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__) +#define snprintf_P(s, f, ...) snprintf((s), (f), __VA_ARGS__) + +#define pgm_read_byte(addr) (*(const unsigned char *)(addr)) +#define pgm_read_word(addr) (*(const unsigned short *)(addr)) +#define pgm_read_dword(addr) (*(const unsigned long *)(addr)) +#define pgm_read_float(addr) (*(const float *)(addr)) +#define pgm_read_ptr(addr) (*(const void **)(addr)) + +#define pgm_read_byte_near(addr) pgm_read_byte(addr) +#define pgm_read_word_near(addr) pgm_read_word(addr) +#define pgm_read_dword_near(addr) pgm_read_dword(addr) +#define pgm_read_float_near(addr) pgm_read_float(addr) +#define pgm_read_ptr_near(addr) pgm_read_ptr(addr) + +#define pgm_read_byte_far(addr) pgm_read_byte(addr) +#define pgm_read_word_far(addr) pgm_read_word(addr) +#define pgm_read_dword_far(addr) pgm_read_dword(addr) +#define pgm_read_float_far(addr) pgm_read_float(addr) +#define pgm_read_ptr_far(addr) pgm_read_ptr(addr) + +#define pgm_get_far_address(addr) (&(addr)) + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/realtek/hardware/AmebaD/3.0.8/cores/arduino/avr/pgmspace.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/realtek/hardware/AmebaD/3.0.8/cores/arduino/avr/pgmspace.h new file mode 100644 index 0000000..bf87a94 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/realtek/hardware/AmebaD/3.0.8/cores/arduino/avr/pgmspace.h @@ -0,0 +1,122 @@ +/* + pgmspace.h - Definitions for compatibility with AVR pgmspace macros + + Copyright (c) 2015 Arduino LLC + + Based on work of Paul Stoffregen on Teensy 3 (http://pjrc.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE +*/ + +#ifndef __PGMSPACE_H_ +#define __PGMSPACE_H_ 1 + +#include + +#define PROGMEM +#define PGM_P const char * +#define PSTR(str) (str) + +#define _SFR_BYTE(n) (n) + +typedef void prog_void; +typedef char prog_char; +typedef unsigned char prog_uchar; +typedef int8_t prog_int8_t; +typedef uint8_t prog_uint8_t; +typedef int16_t prog_int16_t; +typedef uint16_t prog_uint16_t; +typedef int32_t prog_int32_t; +typedef uint32_t prog_uint32_t; +typedef int64_t prog_int64_t; +typedef uint64_t prog_uint64_t; + +typedef const void* int_farptr_t; +typedef const void* uint_farptr_t; + +#define memchr_P(s, c, n) memchr((s), (c), (n)) +#define memcmp_P(s1, s2, n) memcmp((s1), (s2), (n)) +#define memccpy_P(dest, src, c, n) memccpy((dest), (src), (c), (n)) +#define memcpy_P(dest, src, n) memcpy((dest), (src), (n)) +#define memmem_P(haystack, haystacklen, needle, needlelen) memmem((haystack), (haystacklen), (needle), (needlelen)) +#define memrchr_P(s, c, n) memrchr((s), (c), (n)) +#define strcat_P(dest, src) strcat((dest), (src)) +#define strchr_P(s, c) strchr((s), (c)) +#define strchrnul_P(s, c) strchrnul((s), (c)) +#define strcmp_P(a, b) strcmp((a), (b)) +#define strcpy_P(dest, src) strcpy((dest), (src)) +#define strcasecmp_P(s1, s2) strcasecmp((s1), (s2)) +#define strcasestr_P(haystack, needle) strcasestr((haystack), (needle)) +#define strcspn_P(s, accept) strcspn((s), (accept)) +#define strlcat_P(s1, s2, n) strlcat((s1), (s2), (n)) +#define strlcpy_P(s1, s2, n) strlcpy((s1), (s2), (n)) +#define strlen_P(a) strlen((a)) +#define strnlen_P(s, n) strnlen((s), (n)) +#define strncmp_P(s1, s2, n) strncmp((s1), (s2), (n)) +#define strncasecmp_P(s1, s2, n) strncasecmp((s1), (s2), (n)) +#define strncat_P(s1, s2, n) strncat((s1), (s2), (n)) +#define strncpy_P(s1, s2, n) strncpy((s1), (s2), (n)) +#define strpbrk_P(s, accept) strpbrk((s), (accept)) +#define strrchr_P(s, c) strrchr((s), (c)) +#define strsep_P(sp, delim) strsep((sp), (delim)) +#define strspn_P(s, accept) strspn((s), (accept)) +#define strstr_P(a, b) strstr((a), (b)) +#define strtok_P(s, delim) strtok((s), (delim)) +#define strtok_rP(s, delim, last) strtok((s), (delim), (last)) + +#define strlen_PF(a) strlen((a)) +#define strnlen_PF(src, len) strnlen((src), (len)) +#define memcpy_PF(dest, src, len) memcpy((dest), (src), (len)) +#define strcpy_PF(dest, src) strcpy((dest), (src)) +#define strncpy_PF(dest, src, len) strncpy((dest), (src), (len)) +#define strcat_PF(dest, src) strcat((dest), (src)) +#define strlcat_PF(dest, src, len) strlcat((dest), (src), (len)) +#define strncat_PF(dest, src, len) strncat((dest), (src), (len)) +#define strcmp_PF(s1, s2) strcmp((s1), (s2)) +#define strncmp_PF(s1, s2, n) strncmp((s1), (s2), (n)) +#define strcasecmp_PF(s1, s2) strcasecmp((s1), (s2)) +#define strncasecmp_PF(s1, s2, n) strncasecmp((s1), (s2), (n)) +#define strstr_PF(s1, s2) strstr((s1), (s2)) +#define strlcpy_PF(dest, src, n) strlcpy((dest), (src), (n)) +#define memcmp_PF(s1, s2, n) memcmp((s1), (s2), (n)) + +#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__) +#define snprintf_P(s, f, ...) snprintf((s), (f), __VA_ARGS__) + +#define pgm_read_byte(addr) (*(const unsigned char *)(addr)) +#define pgm_read_word(addr) (*(const unsigned short *)(addr)) +#define pgm_read_dword(addr) (*(const unsigned long *)(addr)) +#define pgm_read_float(addr) (*(const float *)(addr)) +#define pgm_read_ptr(addr) (*(const void **)(addr)) + +#define pgm_read_byte_near(addr) pgm_read_byte(addr) +#define pgm_read_word_near(addr) pgm_read_word(addr) +#define pgm_read_dword_near(addr) pgm_read_dword(addr) +#define pgm_read_float_near(addr) pgm_read_float(addr) +#define pgm_read_ptr_near(addr) pgm_read_ptr(addr) + +#define pgm_read_byte_far(addr) pgm_read_byte(addr) +#define pgm_read_word_far(addr) pgm_read_word(addr) +#define pgm_read_dword_far(addr) pgm_read_dword(addr) +#define pgm_read_float_far(addr) pgm_read_float(addr) +#define pgm_read_ptr_far(addr) pgm_read_ptr(addr) + +#define pgm_get_far_address(addr) (&(addr)) + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/realtek/hardware/AmebaD/3.1.0/cores/arduino/avr/pgmspace.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/realtek/hardware/AmebaD/3.1.0/cores/arduino/avr/pgmspace.h new file mode 100644 index 0000000..bf87a94 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/realtek/hardware/AmebaD/3.1.0/cores/arduino/avr/pgmspace.h @@ -0,0 +1,122 @@ +/* + pgmspace.h - Definitions for compatibility with AVR pgmspace macros + + Copyright (c) 2015 Arduino LLC + + Based on work of Paul Stoffregen on Teensy 3 (http://pjrc.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE +*/ + +#ifndef __PGMSPACE_H_ +#define __PGMSPACE_H_ 1 + +#include + +#define PROGMEM +#define PGM_P const char * +#define PSTR(str) (str) + +#define _SFR_BYTE(n) (n) + +typedef void prog_void; +typedef char prog_char; +typedef unsigned char prog_uchar; +typedef int8_t prog_int8_t; +typedef uint8_t prog_uint8_t; +typedef int16_t prog_int16_t; +typedef uint16_t prog_uint16_t; +typedef int32_t prog_int32_t; +typedef uint32_t prog_uint32_t; +typedef int64_t prog_int64_t; +typedef uint64_t prog_uint64_t; + +typedef const void* int_farptr_t; +typedef const void* uint_farptr_t; + +#define memchr_P(s, c, n) memchr((s), (c), (n)) +#define memcmp_P(s1, s2, n) memcmp((s1), (s2), (n)) +#define memccpy_P(dest, src, c, n) memccpy((dest), (src), (c), (n)) +#define memcpy_P(dest, src, n) memcpy((dest), (src), (n)) +#define memmem_P(haystack, haystacklen, needle, needlelen) memmem((haystack), (haystacklen), (needle), (needlelen)) +#define memrchr_P(s, c, n) memrchr((s), (c), (n)) +#define strcat_P(dest, src) strcat((dest), (src)) +#define strchr_P(s, c) strchr((s), (c)) +#define strchrnul_P(s, c) strchrnul((s), (c)) +#define strcmp_P(a, b) strcmp((a), (b)) +#define strcpy_P(dest, src) strcpy((dest), (src)) +#define strcasecmp_P(s1, s2) strcasecmp((s1), (s2)) +#define strcasestr_P(haystack, needle) strcasestr((haystack), (needle)) +#define strcspn_P(s, accept) strcspn((s), (accept)) +#define strlcat_P(s1, s2, n) strlcat((s1), (s2), (n)) +#define strlcpy_P(s1, s2, n) strlcpy((s1), (s2), (n)) +#define strlen_P(a) strlen((a)) +#define strnlen_P(s, n) strnlen((s), (n)) +#define strncmp_P(s1, s2, n) strncmp((s1), (s2), (n)) +#define strncasecmp_P(s1, s2, n) strncasecmp((s1), (s2), (n)) +#define strncat_P(s1, s2, n) strncat((s1), (s2), (n)) +#define strncpy_P(s1, s2, n) strncpy((s1), (s2), (n)) +#define strpbrk_P(s, accept) strpbrk((s), (accept)) +#define strrchr_P(s, c) strrchr((s), (c)) +#define strsep_P(sp, delim) strsep((sp), (delim)) +#define strspn_P(s, accept) strspn((s), (accept)) +#define strstr_P(a, b) strstr((a), (b)) +#define strtok_P(s, delim) strtok((s), (delim)) +#define strtok_rP(s, delim, last) strtok((s), (delim), (last)) + +#define strlen_PF(a) strlen((a)) +#define strnlen_PF(src, len) strnlen((src), (len)) +#define memcpy_PF(dest, src, len) memcpy((dest), (src), (len)) +#define strcpy_PF(dest, src) strcpy((dest), (src)) +#define strncpy_PF(dest, src, len) strncpy((dest), (src), (len)) +#define strcat_PF(dest, src) strcat((dest), (src)) +#define strlcat_PF(dest, src, len) strlcat((dest), (src), (len)) +#define strncat_PF(dest, src, len) strncat((dest), (src), (len)) +#define strcmp_PF(s1, s2) strcmp((s1), (s2)) +#define strncmp_PF(s1, s2, n) strncmp((s1), (s2), (n)) +#define strcasecmp_PF(s1, s2) strcasecmp((s1), (s2)) +#define strncasecmp_PF(s1, s2, n) strncasecmp((s1), (s2), (n)) +#define strstr_PF(s1, s2) strstr((s1), (s2)) +#define strlcpy_PF(dest, src, n) strlcpy((dest), (src), (n)) +#define memcmp_PF(s1, s2, n) memcmp((s1), (s2), (n)) + +#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__) +#define snprintf_P(s, f, ...) snprintf((s), (f), __VA_ARGS__) + +#define pgm_read_byte(addr) (*(const unsigned char *)(addr)) +#define pgm_read_word(addr) (*(const unsigned short *)(addr)) +#define pgm_read_dword(addr) (*(const unsigned long *)(addr)) +#define pgm_read_float(addr) (*(const float *)(addr)) +#define pgm_read_ptr(addr) (*(const void **)(addr)) + +#define pgm_read_byte_near(addr) pgm_read_byte(addr) +#define pgm_read_word_near(addr) pgm_read_word(addr) +#define pgm_read_dword_near(addr) pgm_read_dword(addr) +#define pgm_read_float_near(addr) pgm_read_float(addr) +#define pgm_read_ptr_near(addr) pgm_read_ptr(addr) + +#define pgm_read_byte_far(addr) pgm_read_byte(addr) +#define pgm_read_word_far(addr) pgm_read_word(addr) +#define pgm_read_dword_far(addr) pgm_read_dword(addr) +#define pgm_read_float_far(addr) pgm_read_float(addr) +#define pgm_read_ptr_far(addr) pgm_read_ptr(addr) + +#define pgm_get_far_address(addr) (&(addr)) + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/realtek/hardware/AmebaD/3.1.1/cores/arduino/avr/pgmspace.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/realtek/hardware/AmebaD/3.1.1/cores/arduino/avr/pgmspace.h new file mode 100644 index 0000000..bf87a94 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/realtek/hardware/AmebaD/3.1.1/cores/arduino/avr/pgmspace.h @@ -0,0 +1,122 @@ +/* + pgmspace.h - Definitions for compatibility with AVR pgmspace macros + + Copyright (c) 2015 Arduino LLC + + Based on work of Paul Stoffregen on Teensy 3 (http://pjrc.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE +*/ + +#ifndef __PGMSPACE_H_ +#define __PGMSPACE_H_ 1 + +#include + +#define PROGMEM +#define PGM_P const char * +#define PSTR(str) (str) + +#define _SFR_BYTE(n) (n) + +typedef void prog_void; +typedef char prog_char; +typedef unsigned char prog_uchar; +typedef int8_t prog_int8_t; +typedef uint8_t prog_uint8_t; +typedef int16_t prog_int16_t; +typedef uint16_t prog_uint16_t; +typedef int32_t prog_int32_t; +typedef uint32_t prog_uint32_t; +typedef int64_t prog_int64_t; +typedef uint64_t prog_uint64_t; + +typedef const void* int_farptr_t; +typedef const void* uint_farptr_t; + +#define memchr_P(s, c, n) memchr((s), (c), (n)) +#define memcmp_P(s1, s2, n) memcmp((s1), (s2), (n)) +#define memccpy_P(dest, src, c, n) memccpy((dest), (src), (c), (n)) +#define memcpy_P(dest, src, n) memcpy((dest), (src), (n)) +#define memmem_P(haystack, haystacklen, needle, needlelen) memmem((haystack), (haystacklen), (needle), (needlelen)) +#define memrchr_P(s, c, n) memrchr((s), (c), (n)) +#define strcat_P(dest, src) strcat((dest), (src)) +#define strchr_P(s, c) strchr((s), (c)) +#define strchrnul_P(s, c) strchrnul((s), (c)) +#define strcmp_P(a, b) strcmp((a), (b)) +#define strcpy_P(dest, src) strcpy((dest), (src)) +#define strcasecmp_P(s1, s2) strcasecmp((s1), (s2)) +#define strcasestr_P(haystack, needle) strcasestr((haystack), (needle)) +#define strcspn_P(s, accept) strcspn((s), (accept)) +#define strlcat_P(s1, s2, n) strlcat((s1), (s2), (n)) +#define strlcpy_P(s1, s2, n) strlcpy((s1), (s2), (n)) +#define strlen_P(a) strlen((a)) +#define strnlen_P(s, n) strnlen((s), (n)) +#define strncmp_P(s1, s2, n) strncmp((s1), (s2), (n)) +#define strncasecmp_P(s1, s2, n) strncasecmp((s1), (s2), (n)) +#define strncat_P(s1, s2, n) strncat((s1), (s2), (n)) +#define strncpy_P(s1, s2, n) strncpy((s1), (s2), (n)) +#define strpbrk_P(s, accept) strpbrk((s), (accept)) +#define strrchr_P(s, c) strrchr((s), (c)) +#define strsep_P(sp, delim) strsep((sp), (delim)) +#define strspn_P(s, accept) strspn((s), (accept)) +#define strstr_P(a, b) strstr((a), (b)) +#define strtok_P(s, delim) strtok((s), (delim)) +#define strtok_rP(s, delim, last) strtok((s), (delim), (last)) + +#define strlen_PF(a) strlen((a)) +#define strnlen_PF(src, len) strnlen((src), (len)) +#define memcpy_PF(dest, src, len) memcpy((dest), (src), (len)) +#define strcpy_PF(dest, src) strcpy((dest), (src)) +#define strncpy_PF(dest, src, len) strncpy((dest), (src), (len)) +#define strcat_PF(dest, src) strcat((dest), (src)) +#define strlcat_PF(dest, src, len) strlcat((dest), (src), (len)) +#define strncat_PF(dest, src, len) strncat((dest), (src), (len)) +#define strcmp_PF(s1, s2) strcmp((s1), (s2)) +#define strncmp_PF(s1, s2, n) strncmp((s1), (s2), (n)) +#define strcasecmp_PF(s1, s2) strcasecmp((s1), (s2)) +#define strncasecmp_PF(s1, s2, n) strncasecmp((s1), (s2), (n)) +#define strstr_PF(s1, s2) strstr((s1), (s2)) +#define strlcpy_PF(dest, src, n) strlcpy((dest), (src), (n)) +#define memcmp_PF(s1, s2, n) memcmp((s1), (s2), (n)) + +#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__) +#define snprintf_P(s, f, ...) snprintf((s), (f), __VA_ARGS__) + +#define pgm_read_byte(addr) (*(const unsigned char *)(addr)) +#define pgm_read_word(addr) (*(const unsigned short *)(addr)) +#define pgm_read_dword(addr) (*(const unsigned long *)(addr)) +#define pgm_read_float(addr) (*(const float *)(addr)) +#define pgm_read_ptr(addr) (*(const void **)(addr)) + +#define pgm_read_byte_near(addr) pgm_read_byte(addr) +#define pgm_read_word_near(addr) pgm_read_word(addr) +#define pgm_read_dword_near(addr) pgm_read_dword(addr) +#define pgm_read_float_near(addr) pgm_read_float(addr) +#define pgm_read_ptr_near(addr) pgm_read_ptr(addr) + +#define pgm_read_byte_far(addr) pgm_read_byte(addr) +#define pgm_read_word_far(addr) pgm_read_word(addr) +#define pgm_read_dword_far(addr) pgm_read_dword(addr) +#define pgm_read_float_far(addr) pgm_read_float(addr) +#define pgm_read_ptr_far(addr) pgm_read_ptr(addr) + +#define pgm_get_far_address(addr) (&(addr)) + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/realtek/hardware/AmebaD/3.1.2/cores/arduino/avr/pgmspace.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/realtek/hardware/AmebaD/3.1.2/cores/arduino/avr/pgmspace.h new file mode 100644 index 0000000..bf87a94 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/realtek/hardware/AmebaD/3.1.2/cores/arduino/avr/pgmspace.h @@ -0,0 +1,122 @@ +/* + pgmspace.h - Definitions for compatibility with AVR pgmspace macros + + Copyright (c) 2015 Arduino LLC + + Based on work of Paul Stoffregen on Teensy 3 (http://pjrc.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE +*/ + +#ifndef __PGMSPACE_H_ +#define __PGMSPACE_H_ 1 + +#include + +#define PROGMEM +#define PGM_P const char * +#define PSTR(str) (str) + +#define _SFR_BYTE(n) (n) + +typedef void prog_void; +typedef char prog_char; +typedef unsigned char prog_uchar; +typedef int8_t prog_int8_t; +typedef uint8_t prog_uint8_t; +typedef int16_t prog_int16_t; +typedef uint16_t prog_uint16_t; +typedef int32_t prog_int32_t; +typedef uint32_t prog_uint32_t; +typedef int64_t prog_int64_t; +typedef uint64_t prog_uint64_t; + +typedef const void* int_farptr_t; +typedef const void* uint_farptr_t; + +#define memchr_P(s, c, n) memchr((s), (c), (n)) +#define memcmp_P(s1, s2, n) memcmp((s1), (s2), (n)) +#define memccpy_P(dest, src, c, n) memccpy((dest), (src), (c), (n)) +#define memcpy_P(dest, src, n) memcpy((dest), (src), (n)) +#define memmem_P(haystack, haystacklen, needle, needlelen) memmem((haystack), (haystacklen), (needle), (needlelen)) +#define memrchr_P(s, c, n) memrchr((s), (c), (n)) +#define strcat_P(dest, src) strcat((dest), (src)) +#define strchr_P(s, c) strchr((s), (c)) +#define strchrnul_P(s, c) strchrnul((s), (c)) +#define strcmp_P(a, b) strcmp((a), (b)) +#define strcpy_P(dest, src) strcpy((dest), (src)) +#define strcasecmp_P(s1, s2) strcasecmp((s1), (s2)) +#define strcasestr_P(haystack, needle) strcasestr((haystack), (needle)) +#define strcspn_P(s, accept) strcspn((s), (accept)) +#define strlcat_P(s1, s2, n) strlcat((s1), (s2), (n)) +#define strlcpy_P(s1, s2, n) strlcpy((s1), (s2), (n)) +#define strlen_P(a) strlen((a)) +#define strnlen_P(s, n) strnlen((s), (n)) +#define strncmp_P(s1, s2, n) strncmp((s1), (s2), (n)) +#define strncasecmp_P(s1, s2, n) strncasecmp((s1), (s2), (n)) +#define strncat_P(s1, s2, n) strncat((s1), (s2), (n)) +#define strncpy_P(s1, s2, n) strncpy((s1), (s2), (n)) +#define strpbrk_P(s, accept) strpbrk((s), (accept)) +#define strrchr_P(s, c) strrchr((s), (c)) +#define strsep_P(sp, delim) strsep((sp), (delim)) +#define strspn_P(s, accept) strspn((s), (accept)) +#define strstr_P(a, b) strstr((a), (b)) +#define strtok_P(s, delim) strtok((s), (delim)) +#define strtok_rP(s, delim, last) strtok((s), (delim), (last)) + +#define strlen_PF(a) strlen((a)) +#define strnlen_PF(src, len) strnlen((src), (len)) +#define memcpy_PF(dest, src, len) memcpy((dest), (src), (len)) +#define strcpy_PF(dest, src) strcpy((dest), (src)) +#define strncpy_PF(dest, src, len) strncpy((dest), (src), (len)) +#define strcat_PF(dest, src) strcat((dest), (src)) +#define strlcat_PF(dest, src, len) strlcat((dest), (src), (len)) +#define strncat_PF(dest, src, len) strncat((dest), (src), (len)) +#define strcmp_PF(s1, s2) strcmp((s1), (s2)) +#define strncmp_PF(s1, s2, n) strncmp((s1), (s2), (n)) +#define strcasecmp_PF(s1, s2) strcasecmp((s1), (s2)) +#define strncasecmp_PF(s1, s2, n) strncasecmp((s1), (s2), (n)) +#define strstr_PF(s1, s2) strstr((s1), (s2)) +#define strlcpy_PF(dest, src, n) strlcpy((dest), (src), (n)) +#define memcmp_PF(s1, s2, n) memcmp((s1), (s2), (n)) + +#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__) +#define snprintf_P(s, f, ...) snprintf((s), (f), __VA_ARGS__) + +#define pgm_read_byte(addr) (*(const unsigned char *)(addr)) +#define pgm_read_word(addr) (*(const unsigned short *)(addr)) +#define pgm_read_dword(addr) (*(const unsigned long *)(addr)) +#define pgm_read_float(addr) (*(const float *)(addr)) +#define pgm_read_ptr(addr) (*(const void **)(addr)) + +#define pgm_read_byte_near(addr) pgm_read_byte(addr) +#define pgm_read_word_near(addr) pgm_read_word(addr) +#define pgm_read_dword_near(addr) pgm_read_dword(addr) +#define pgm_read_float_near(addr) pgm_read_float(addr) +#define pgm_read_ptr_near(addr) pgm_read_ptr(addr) + +#define pgm_read_byte_far(addr) pgm_read_byte(addr) +#define pgm_read_word_far(addr) pgm_read_word(addr) +#define pgm_read_dword_far(addr) pgm_read_dword(addr) +#define pgm_read_float_far(addr) pgm_read_float(addr) +#define pgm_read_ptr_far(addr) pgm_read_ptr(addr) + +#define pgm_get_far_address(addr) (&(addr)) + +#endif diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.2.1/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.2.1/platform.txt new file mode 100644 index 0000000..ab6423a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.2.1/platform.txt @@ -0,0 +1,146 @@ +# Copyright (c) 2021 Earle F. Philhower, III +# +# Raspberry Pi RP2040 Core platform file +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Raspberry Pi RP2040 Boards(1.2.1) +version=1.2.1 + + + + + + +compiler.path={runtime.tools.pqt-gcc.path}/bin/ + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra + +compiler.defines={build.led} +compiler.includes="-I{runtime.platform.path}/pico_base/" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/pico_unique_id/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/pico_platform/include/" "-I{runtime.platform.path}/pico-sdk/src/common/pico_base/include/" "-I{runtime.platform.path}/pico-sdk/src/rp2040/hardware_regs/include/" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_timer/include/" "-I{runtime.platform.path}/pico-sdk/src/common/pico_stdlib/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_gpio/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_i2c/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_flash/include" "-I{runtime.platform.path}/pico-sdk/src/common/pico_base/include" "-I{runtime.platform.path}/pico-examples/build/generated/pico_base" "-I{runtime.platform.path}/pico-sdk/src/boards/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/pico_platform/include" "-I{runtime.platform.path}/pico-sdk/src/rp2040/hardware_regs/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_base/include" "-I{runtime.platform.path}/pico-sdk/src/rp2040/hardware_structs/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_claim/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_sync/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_uart/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_divider/include" "-I{runtime.platform.path}/pico-sdk/src/common/pico_time/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_timer/include" "-I{runtime.platform.path}/pico-sdk/src/common/pico_sync/include" "-I{runtime.platform.path}/pico-sdk/src/common/pico_util/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/pico_runtime/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_clocks/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_resets/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_watchdog/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_xosc/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_pll/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_vreg/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_irq/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/pico_printf/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/pico_bootrom/include" "-I{runtime.platform.path}/pico-sdk/src/common/pico_bit_ops/include" "-I{runtime.platform.path}/pico-sdk/src/common/pico_divider/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/pico_double/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/pico_int64_ops/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/pico_float/include" "-I{runtime.platform.path}/pico-sdk/src/common/pico_binary_info/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_pio/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/pico_stdio/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_dma/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/pico_stdio_uart/include" "-I{runtime.platform.path}/pico-sdk/src/rp2040/hardware_regs/include/" "-I{runtime.platform.path}/pico-sdk/lib/tinyusb/src/" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/pico_stdio_usb/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_spi/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_pwm/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/hardware_adc/include" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/pico_multicore/include" "-I{runtime.platform.path}/cores/rp2040/api/deprecated-avr-comp/" "-I{runtime.platform.path}/pico-sdk/src/rp2_common/pico_multicore/include" "-I{runtime.platform.path}/pico-extras/src/rp2_common/pico_audio_i2s/include" "-I{runtime.platform.path}/pico-extras/src/common/pico_audio/include" "-I{runtime.platform.path}/pico-extras/src/common/pico_util_buffer/include" +compiler.flags=-Os -march=armv6-m -mcpu=cortex-m0plus -mthumb -ffunction-sections -fdata-sections +compiler.wrap=-Wl,--wrap=acos -Wl,--wrap=acosf -Wl,--wrap=acosh -Wl,--wrap=acoshf -Wl,--wrap=__aeabi_cdcmpeq -Wl,--wrap=__aeabi_cdcmple -Wl,--wrap=__aeabi_cdrcmple -Wl,--wrap=__aeabi_cfcmpeq -Wl,--wrap=__aeabi_cfcmple -Wl,--wrap=__aeabi_cfrcmple -Wl,--wrap=__aeabi_d2f -Wl,--wrap=__aeabi_d2iz -Wl,--wrap=__aeabi_d2lz -Wl,--wrap=__aeabi_d2uiz -Wl,--wrap=__aeabi_d2ulz -Wl,--wrap=__aeabi_dadd -Wl,--wrap=__aeabi_dcmpeq -Wl,--wrap=__aeabi_dcmpge -Wl,--wrap=__aeabi_dcmpgt -Wl,--wrap=__aeabi_dcmple -Wl,--wrap=__aeabi_dcmplt -Wl,--wrap=__aeabi_dcmpun -Wl,--wrap=__aeabi_ddiv -Wl,--wrap=__aeabi_dmul -Wl,--wrap=__aeabi_drsub -Wl,--wrap=__aeabi_dsub -Wl,--wrap=__aeabi_f2d -Wl,--wrap=__aeabi_f2iz -Wl,--wrap=__aeabi_f2lz -Wl,--wrap=__aeabi_f2uiz -Wl,--wrap=__aeabi_f2ulz -Wl,--wrap=__aeabi_fadd -Wl,--wrap=__aeabi_fcmpeq -Wl,--wrap=__aeabi_fcmpge -Wl,--wrap=__aeabi_fcmpgt -Wl,--wrap=__aeabi_fcmple -Wl,--wrap=__aeabi_fcmplt -Wl,--wrap=__aeabi_fcmpun -Wl,--wrap=__aeabi_fdiv -Wl,--wrap=__aeabi_fmul -Wl,--wrap=__aeabi_frsub -Wl,--wrap=__aeabi_fsub -Wl,--wrap=__aeabi_i2d -Wl,--wrap=__aeabi_i2f -Wl,--wrap=__aeabi_idiv -Wl,--wrap=__aeabi_idivmod -Wl,--wrap=__aeabi_l2d -Wl,--wrap=__aeabi_l2f -Wl,--wrap=__aeabi_ldivmod -Wl,--wrap=__aeabi_lmul -Wl,--wrap=__aeabi_memcpy -Wl,--wrap=__aeabi_memcpy4 -Wl,--wrap=__aeabi_memcpy8 -Wl,--wrap=__aeabi_memset -Wl,--wrap=__aeabi_memset4 -Wl,--wrap=__aeabi_memset8 -Wl,--wrap=__aeabi_ui2d -Wl,--wrap=__aeabi_ui2f -Wl,--wrap=__aeabi_uidiv -Wl,--wrap=__aeabi_uidivmod -Wl,--wrap=__aeabi_ul2d -Wl,--wrap=__aeabi_ul2f -Wl,--wrap=__aeabi_uldivmod -Wl,--wrap=asin -Wl,--wrap=asinf -Wl,--wrap=asinh -Wl,--wrap=asinhf -Wl,--wrap=atan -Wl,--wrap=atan2 -Wl,--wrap=atan2f -Wl,--wrap=atanf -Wl,--wrap=atanh -Wl,--wrap=atanhf -Wl,--wrap=calloc -Wl,--wrap=cbrt -Wl,--wrap=cbrtf -Wl,--wrap=ceil -Wl,--wrap=ceilf -Wl,--wrap=__clz -Wl,--wrap=__clzdi2 -Wl,--wrap=__clzl -Wl,--wrap=__clzll -Wl,--wrap=__clzsi2 -Wl,--wrap=copysign -Wl,--wrap=copysignf -Wl,--wrap=cos -Wl,--wrap=cosf -Wl,--wrap=cosh -Wl,--wrap=coshf -Wl,--wrap=__ctzdi2 -Wl,--wrap=__ctzsi2 -Wl,--wrap=drem -Wl,--wrap=dremf -Wl,--wrap=exp -Wl,--wrap=exp10 -Wl,--wrap=exp10f -Wl,--wrap=exp2 -Wl,--wrap=exp2f -Wl,--wrap=expf -Wl,--wrap=expm1 -Wl,--wrap=expm1f -Wl,--wrap=floor -Wl,--wrap=floorf -Wl,--wrap=fma -Wl,--wrap=fmaf -Wl,--wrap=fmod -Wl,--wrap=fmodf -Wl,--wrap=free -Wl,--wrap=hypot -Wl,--wrap=hypotf -Wl,--wrap=ldexp -Wl,--wrap=ldexpf -Wl,--wrap=log -Wl,--wrap=log10 -Wl,--wrap=log10f -Wl,--wrap=log1p -Wl,--wrap=log1pf -Wl,--wrap=log2 -Wl,--wrap=log2f -Wl,--wrap=logf -Wl,--wrap=malloc -Wl,--wrap=memcpy -Wl,--wrap=memset -Wl,--wrap=__popcountdi2 -Wl,--wrap=__popcountsi2 -Wl,--wrap=pow -Wl,--wrap=powf -Wl,--wrap=powint -Wl,--wrap=powintf -Wl,--wrap=remainder -Wl,--wrap=remainderf -Wl,--wrap=remquo -Wl,--wrap=remquof -Wl,--wrap=round -Wl,--wrap=roundf -Wl,--wrap=sin -Wl,--wrap=sincos -Wl,--wrap=sincosf -Wl,--wrap=sinf -Wl,--wrap=sinh -Wl,--wrap=sinhf -Wl,--wrap=sqrt -Wl,--wrap=sqrtf -Wl,--wrap=tan -Wl,--wrap=tanf -Wl,--wrap=tanh -Wl,--wrap=tanhf -Wl,--wrap=trunc -Wl,--wrap=truncf + +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-c {compiler.defines} {compiler.flags} {compiler.includes} -std=gnu17 -g +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags={compiler.defines} {compiler.flags} -Wl,--gc-sections -u _printf_float -u _scanf_float +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD {compiler.includes} -g +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-c {compiler.defines} {compiler.flags} {compiler.includes} -std=gnu++17 -g + + +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags={compiler.wrap} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +# Board configuration, set in boards.txt. Present here to ensure substitution works +build.flash_length= +build.eeprom_start= +build.fs_start= +build.fs_end= + +build.boot2=boot2_generic_03h_4_padded_checksum + +# Allow Pico boards do be auto-discovered by the IDE +discovery.rp2040.pattern="{runtime.tools.pqt-python3.path}/python3" "{runtime.platform.path}/tools/discovery.py" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} {build.usbpid} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {build.usbpid} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} {build.usbpid} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.hooks.linking.prelink.1.pattern="{runtime.tools.pqt-python3.path}/python3" "{runtime.platform.path}/tools/simplesub.py" --input "{runtime.platform.path}/lib/memmap_default.ld" --out "{build.path}/memmap_default.ld" --sub __FLASH_LENGTH__ {build.flash_length} --sub __EEPROM_START__ {build.eeprom_start} --sub __FS_START__ {build.fs_start} --sub __FS_END__ {build.fs_end} +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-Wl,--script={build.path}/memmap_default.ld" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nosys.specs -Wl,--start-group {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "{runtime.platform.path}/lib/libpico.a" -lm "-I{runtime.platform.path}/pico-sdk/src/rp2040/hardware_regs/include/" "-I{runtime.platform.path}/pico-sdk/src/common/pico_binary_info/include" "{runtime.platform.path}/assembly/{build.boot2}.S" -lc -lstdc++ -Wl,--end-group + +## Create output (UF2 file) +recipe.objcopy.uf2.pattern="{runtime.tools.pqt-elf2uf2.path}/elf2uf2" "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.uf2" + +build.preferred_out_format=uf2 + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.boot2|\.text|\.rodata|\.ARM\.extab|\.ARM\.exidx)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss|\.ram_vector_table|\.uninitialized_data)\s+([0-9]+).* + +tools.uf2conv.path= +# Because the variable expansion doesn't allow one tool to find another, the following lines +# will point to "{runtime.platform.path}/tools/python3/python3" in GIT and +# "{runtime.tools.pqt-python3.path}/python3" for JSON board manager releases. +tools.uf2conv.cmd={runtime.tools.pqt-python3.path}/python3 + +tools.uf2conv.upload.protocol=uf2 +tools.uf2conv.upload.params.verbose= +tools.uf2conv.upload.params.quiet= +tools.uf2conv.upload.pattern="{cmd}" "{runtime.platform.path}/tools/uf2conv.py" --serial "{serial.port}" --family RP2040 --deploy "{build.path}/{build.project_name}.uf2" + + +tools.picoprobe.cmd={runtime.tools.pqt-openocd.path} + +tools.picoprobe.upload.protocol=picoprobe +tools.picoprobe.upload.params.verbose= +tools.picoprobe.upload.params.quiet= +tools.picoprobe.upload.pattern="{cmd}/bin/openocd" -f "interface/picoprobe.cfg" -f "target/rp2040.cfg" -s "{cmd}/share/openocd/scripts" -c "program {build.path}/{build.project_name}.elf verify reset exit" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.2.2/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.2.2/platform.txt new file mode 100644 index 0000000..0327aa0 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.2.2/platform.txt @@ -0,0 +1,145 @@ +# Copyright (c) 2021 Earle F. Philhower, III +# +# Raspberry Pi RP2040 Core platform file +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Raspberry Pi RP2040 Boards(1.2.2) +version=1.2.2 + + + + + + +compiler.path={runtime.tools.pqt-gcc.path}/bin/ + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra + +compiler.defines={build.led} +compiler.includes="-iprefix{runtime.platform.path}/" "@{runtime.platform.path}/lib/platform_inc.txt" +compiler.flags=-Os -march=armv6-m -mcpu=cortex-m0plus -mthumb -ffunction-sections -fdata-sections -fno-exceptions +compiler.wrap="@{runtime.platform.path}/lib/platform_wrap.txt" + +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-c {compiler.defines} {compiler.flags} {compiler.includes} -std=gnu17 -g +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags={compiler.defines} {compiler.flags} -Wl,--gc-sections -u _printf_float -u _scanf_float +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD {compiler.includes} -g +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-c {compiler.defines} {compiler.flags} {compiler.includes} -fno-rtti -std=gnu++17 -g + +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags={compiler.wrap} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +# Board configuration, set in boards.txt. Present here to ensure substitution works +build.flash_length= +build.eeprom_start= +build.fs_start= +build.fs_end= + +build.boot2=boot2_generic_03h_4_padded_checksum + +# Allow Pico boards do be auto-discovered by the IDE +discovery.rp2040.pattern="{runtime.tools.pqt-python3.path}/python3" "{runtime.platform.path}/tools/discovery.py" + + +# Compile patterns +# ---------------- + +## Compile c files +## KH Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} {build.usbpid} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## KH Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {build.usbpid} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## KH Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} {build.usbpid} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.hooks.linking.prelink.1.pattern="{runtime.tools.pqt-python3.path}/python3" "{runtime.platform.path}/tools/simplesub.py" --input "{runtime.platform.path}/lib/memmap_default.ld" --out "{build.path}/memmap_default.ld" --sub __FLASH_LENGTH__ {build.flash_length} --sub __EEPROM_START__ {build.eeprom_start} --sub __FS_START__ {build.fs_start} --sub __FS_END__ {build.fs_end} +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-Wl,--script={build.path}/memmap_default.ld" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nosys.specs -Wl,--start-group {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "{runtime.platform.path}/lib/libpico.a" -lm "-I{runtime.platform.path}/pico-sdk/src/rp2040/hardware_regs/include/" "-I{runtime.platform.path}/pico-sdk/src/common/pico_binary_info/include" "{runtime.platform.path}/assembly/{build.boot2}.S" -lc -lstdc++ -Wl,--end-group + +## Create output (UF2 file) +recipe.objcopy.uf2.pattern="{runtime.tools.pqt-elf2uf2.path}/elf2uf2" "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.uf2" + +build.preferred_out_format=uf2 + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.boot2|\.text|\.rodata|\.ARM\.extab|\.ARM\.exidx)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss|\.ram_vector_table|\.uninitialized_data)\s+([0-9]+).* + +tools.uf2conv.path= +# Because the variable expansion doesn't allow one tool to find another, the following lines +# will point to "{runtime.platform.path}/tools/python3/python3" in GIT and +# "{runtime.tools.pqt-python3.path}/python3" for JSON board manager releases. +tools.uf2conv.cmd={runtime.tools.pqt-python3.path}/python3 + +tools.uf2conv.upload.protocol=uf2 +tools.uf2conv.upload.params.verbose= +tools.uf2conv.upload.params.quiet= +tools.uf2conv.upload.pattern="{cmd}" "{runtime.platform.path}/tools/uf2conv.py" --serial "{serial.port}" --family RP2040 --deploy "{build.path}/{build.project_name}.uf2" + + +tools.picoprobe.cmd={runtime.tools.pqt-openocd.path} + +tools.picoprobe.upload.protocol=picoprobe +tools.picoprobe.upload.params.verbose= +tools.picoprobe.upload.params.quiet= +tools.picoprobe.upload.pattern="{cmd}/bin/openocd" -f "interface/picoprobe.cfg" -f "target/rp2040.cfg" -s "{cmd}/share/openocd/scripts" -c "program {build.path}/{build.project_name}.elf verify reset exit" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.3.0/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.3.0/platform.txt new file mode 100644 index 0000000..1629e8a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.3.0/platform.txt @@ -0,0 +1,145 @@ +# Copyright (c) 2021 Earle F. Philhower, III +# +# Raspberry Pi RP2040 Core platform file +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Raspberry Pi RP2040 Boards(1.3.0) +version=1.3.0 + + + + + + +compiler.path={runtime.tools.pqt-gcc.path}/bin/ + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra + +compiler.defines={build.led} +compiler.includes="-iprefix{runtime.platform.path}/" "@{runtime.platform.path}/lib/platform_inc.txt" +compiler.flags=-Os -march=armv6-m -mcpu=cortex-m0plus -mthumb -ffunction-sections -fdata-sections -fno-exceptions +compiler.wrap="@{runtime.platform.path}/lib/platform_wrap.txt" + +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-c {compiler.defines} {compiler.flags} {compiler.includes} -std=gnu17 -g +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags={compiler.defines} {compiler.flags} -Wl,--gc-sections -u _printf_float -u _scanf_float +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD {compiler.includes} -g +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-c {compiler.defines} {compiler.flags} {compiler.includes} -fno-rtti -std=gnu++17 -g + +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags={compiler.wrap} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +# Board configuration, set in boards.txt. Present here to ensure substitution works +build.flash_length= +build.eeprom_start= +build.fs_start= +build.fs_end= + +build.boot2=boot2_generic_03h_4_padded_checksum + +# Allow Pico boards do be auto-discovered by the IDE +discovery.rp2040.pattern="{runtime.tools.pqt-python3.path}/python3" "{runtime.platform.path}/tools/discovery.py" + + +# Compile patterns +# ---------------- + +## Compile c files +## Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} {build.usbpid} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {build.usbpid} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} {build.usbpid} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.hooks.linking.prelink.1.pattern="{runtime.tools.pqt-python3.path}/python3" "{runtime.platform.path}/tools/simplesub.py" --input "{runtime.platform.path}/lib/memmap_default.ld" --out "{build.path}/memmap_default.ld" --sub __FLASH_LENGTH__ {build.flash_length} --sub __EEPROM_START__ {build.eeprom_start} --sub __FS_START__ {build.fs_start} --sub __FS_END__ {build.fs_end} +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-Wl,--script={build.path}/memmap_default.ld" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nosys.specs -Wl,--start-group {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "{runtime.platform.path}/lib/libpico.a" -lm "-I{runtime.platform.path}/pico-sdk/src/rp2040/hardware_regs/include/" "-I{runtime.platform.path}/pico-sdk/src/common/pico_binary_info/include" "{runtime.platform.path}/assembly/{build.boot2}.S" -lc -lstdc++ -Wl,--end-group + +## Create output (UF2 file) +recipe.objcopy.uf2.pattern="{runtime.tools.pqt-elf2uf2.path}/elf2uf2" "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.uf2" + +build.preferred_out_format=uf2 + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.boot2|\.text|\.rodata|\.ARM\.extab|\.ARM\.exidx)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss|\.ram_vector_table|\.uninitialized_data)\s+([0-9]+).* + +tools.uf2conv.path= +# Because the variable expansion doesn't allow one tool to find another, the following lines +# will point to "{runtime.platform.path}/tools/python3/python3" in GIT and +# "{runtime.tools.pqt-python3.path}/python3" for JSON board manager releases. +tools.uf2conv.cmd={runtime.tools.pqt-python3.path}/python3 + +tools.uf2conv.upload.protocol=uf2 +tools.uf2conv.upload.params.verbose= +tools.uf2conv.upload.params.quiet= +tools.uf2conv.upload.pattern="{cmd}" "{runtime.platform.path}/tools/uf2conv.py" --serial "{serial.port}" --family RP2040 --deploy "{build.path}/{build.project_name}.uf2" + + +tools.picoprobe.cmd={runtime.tools.pqt-openocd.path} + +tools.picoprobe.upload.protocol=picoprobe +tools.picoprobe.upload.params.verbose= +tools.picoprobe.upload.params.quiet= +tools.picoprobe.upload.pattern="{cmd}/bin/openocd" -f "interface/picoprobe.cfg" -f "target/rp2040.cfg" -s "{cmd}/share/openocd/scripts" -c "program {build.path}/{build.project_name}.elf verify reset exit" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.3.1/cores/rp2040/Arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.3.1/cores/rp2040/Arduino.h new file mode 100644 index 0000000..99c1eb8 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.3.1/cores/rp2040/Arduino.h @@ -0,0 +1,115 @@ +/* + * Arduino header for the Raspberry Pi Pico RP2040 + * + * Copyright (c) 2021 Earle F. Philhower, III + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef Arduino_h +#define Arduino_h + +#include +#include +#include +// Wacky deprecated AVR compatibilty functions +#include "stdlib_noniso.h" + +#include "api/ArduinoAPI.h" +#include + + +// Required for the port*Register macros +#include "hardware/gpio.h" + +#include "debug_internal.h" + +#ifdef __cplusplus +extern "C"{ +#endif // __cplusplus + +// For compatibility to many platforms and libraries +#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L ) +#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() ) +#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() ) + +// Disable/reenable all interrupts. Safely handles nested disables +void interrupts(); +void noInterrupts(); + +// GPIO change/value interrupts +void attachInterrupt(pin_size_t pin, voidFuncPtr callback, PinStatus mode); +void detachInterrupt(pin_size_t pin); + +// AVR compatibilty macros...naughty and accesses the HW directly +#define digitalPinToPort(pin) (0) +#define digitalPinToBitMask(pin) (1UL << (pin)) +#define digitalPinToTimer(pin) (0) +#define digitalPinToInterrupt(pin) (pin) +#define NOT_AN_INTERRUPT (-1) +#define portOutputRegister(port) ((volatile uint32_t*) sio_hw->gpio_out) +#define portInputRegister(port) ((volatile uint32_t*) sio_hw->gpio_in) +#define portModeRegister(port) ((volatile uint32_t*) sio_hw->gpio_oe) + +// IO config +void pinMode(pin_size_t pinNumber, PinMode pinMode); + +// SIO (GPIO) +void digitalWrite(pin_size_t pinNumber, PinStatus status); +PinStatus digitalRead(pin_size_t pinNumber); + +// ADC +int analogRead(pin_size_t pinNumber); +float analogReadTemp(); // Returns core temp in Centigrade + +// PWM +void analogWrite(pin_size_t pinNumber, int value); +void analogWriteFreq(uint32_t freq); +void analogWriteRange(uint32_t range); +void analogWriteResolution(int res); + +// Timing +void delay(unsigned long); +void delayMicroseconds(unsigned int us); +unsigned long millis(); + +#ifdef __cplusplus +} // extern "C" +#endif + +// Ancient AVR defines +#define HAVE_HWSERIAL0 +#define HAVE_HWSERIAL1 +#define HAVE_HWSERIAL2 + +#ifdef __cplusplus +#include "SerialUSB.h" +#include "SerialUART.h" +#include "RP2040.h" +#include "Bootsel.h" + +// Template which will evaluate at *compile time* to a single 32b number +// with the specified bits set. +template +constexpr uint32_t __bitset(const int (&a)[N], size_t i = 0U) { + return i < N ? (1L << a[i]) | __bitset(a, i+1) : 0; +} +#endif + + +// ARM toolchain doesn't provide itoa etc, provide them +#include "api/itoa.h" + +#endif // Arduino_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.3.1/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.3.1/platform.txt new file mode 100644 index 0000000..e451260 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.3.1/platform.txt @@ -0,0 +1,145 @@ +# Copyright (c) 2021 Earle F. Philhower, III +# +# Raspberry Pi RP2040 Core platform file +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Raspberry Pi RP2040 Boards(1.3.1) +version=1.3.1 + + + + + + +compiler.path={runtime.tools.pqt-gcc.path}/bin/ + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra + +compiler.defines={build.led} +compiler.includes="-iprefix{runtime.platform.path}/" "@{runtime.platform.path}/lib/platform_inc.txt" +compiler.flags=-Os -march=armv6-m -mcpu=cortex-m0plus -mthumb -ffunction-sections -fdata-sections -fno-exceptions +compiler.wrap="@{runtime.platform.path}/lib/platform_wrap.txt" + +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-c {compiler.defines} {compiler.flags} {compiler.includes} -std=gnu17 -g +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags={compiler.defines} {compiler.flags} -Wl,--gc-sections -u _printf_float -u _scanf_float +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD {compiler.includes} -g +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-c {compiler.defines} {compiler.flags} {compiler.includes} -fno-rtti -std=gnu++17 -g + +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags={compiler.wrap} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +# Board configuration, set in boards.txt. Present here to ensure substitution works +build.flash_length= +build.eeprom_start= +build.fs_start= +build.fs_end= + +build.boot2=boot2_generic_03h_4_padded_checksum + +# Allow Pico boards do be auto-discovered by the IDE +discovery.rp2040.pattern="{runtime.tools.pqt-python3.path}/python3" "{runtime.platform.path}/tools/discovery.py" + + +# Compile patterns +# ---------------- + +## Compile c files +## Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} {build.usbpid} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {build.usbpid} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} {build.usbpid} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.hooks.linking.prelink.1.pattern="{runtime.tools.pqt-python3.path}/python3" "{runtime.platform.path}/tools/simplesub.py" --input "{runtime.platform.path}/lib/memmap_default.ld" --out "{build.path}/memmap_default.ld" --sub __FLASH_LENGTH__ {build.flash_length} --sub __EEPROM_START__ {build.eeprom_start} --sub __FS_START__ {build.fs_start} --sub __FS_END__ {build.fs_end} +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-Wl,--script={build.path}/memmap_default.ld" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nosys.specs -Wl,--start-group {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "{runtime.platform.path}/lib/libpico.a" -lm "-I{runtime.platform.path}/pico-sdk/src/rp2040/hardware_regs/include/" "-I{runtime.platform.path}/pico-sdk/src/common/pico_binary_info/include" "{runtime.platform.path}/assembly/{build.boot2}.S" -lc -lstdc++ -Wl,--end-group + +## Create output (UF2 file) +recipe.objcopy.uf2.pattern="{runtime.tools.pqt-elf2uf2.path}/elf2uf2" "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.uf2" + +build.preferred_out_format=uf2 + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.boot2|\.text|\.rodata|\.ARM\.extab|\.ARM\.exidx)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss|\.ram_vector_table|\.uninitialized_data)\s+([0-9]+).* + +tools.uf2conv.path= +# Because the variable expansion doesn't allow one tool to find another, the following lines +# will point to "{runtime.platform.path}/tools/python3/python3" in GIT and +# "{runtime.tools.pqt-python3.path}/python3" for JSON board manager releases. +tools.uf2conv.cmd={runtime.tools.pqt-python3.path}/python3 + +tools.uf2conv.upload.protocol=uf2 +tools.uf2conv.upload.params.verbose= +tools.uf2conv.upload.params.quiet= +tools.uf2conv.upload.pattern="{cmd}" "{runtime.platform.path}/tools/uf2conv.py" --serial "{serial.port}" --family RP2040 --deploy "{build.path}/{build.project_name}.uf2" + + +tools.picoprobe.cmd={runtime.tools.pqt-openocd.path} + +tools.picoprobe.upload.protocol=picoprobe +tools.picoprobe.upload.params.verbose= +tools.picoprobe.upload.params.quiet= +tools.picoprobe.upload.pattern="{cmd}/bin/openocd" -f "interface/picoprobe.cfg" -f "target/rp2040.cfg" -s "{cmd}/share/openocd/scripts" -c "program {build.path}/{build.project_name}.elf verify reset exit" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.4.0/cores/rp2040/Arduino.h b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.4.0/cores/rp2040/Arduino.h new file mode 100644 index 0000000..99c1eb8 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.4.0/cores/rp2040/Arduino.h @@ -0,0 +1,115 @@ +/* + * Arduino header for the Raspberry Pi Pico RP2040 + * + * Copyright (c) 2021 Earle F. Philhower, III + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef Arduino_h +#define Arduino_h + +#include +#include +#include +// Wacky deprecated AVR compatibilty functions +#include "stdlib_noniso.h" + +#include "api/ArduinoAPI.h" +#include + + +// Required for the port*Register macros +#include "hardware/gpio.h" + +#include "debug_internal.h" + +#ifdef __cplusplus +extern "C"{ +#endif // __cplusplus + +// For compatibility to many platforms and libraries +#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L ) +#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() ) +#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() ) + +// Disable/reenable all interrupts. Safely handles nested disables +void interrupts(); +void noInterrupts(); + +// GPIO change/value interrupts +void attachInterrupt(pin_size_t pin, voidFuncPtr callback, PinStatus mode); +void detachInterrupt(pin_size_t pin); + +// AVR compatibilty macros...naughty and accesses the HW directly +#define digitalPinToPort(pin) (0) +#define digitalPinToBitMask(pin) (1UL << (pin)) +#define digitalPinToTimer(pin) (0) +#define digitalPinToInterrupt(pin) (pin) +#define NOT_AN_INTERRUPT (-1) +#define portOutputRegister(port) ((volatile uint32_t*) sio_hw->gpio_out) +#define portInputRegister(port) ((volatile uint32_t*) sio_hw->gpio_in) +#define portModeRegister(port) ((volatile uint32_t*) sio_hw->gpio_oe) + +// IO config +void pinMode(pin_size_t pinNumber, PinMode pinMode); + +// SIO (GPIO) +void digitalWrite(pin_size_t pinNumber, PinStatus status); +PinStatus digitalRead(pin_size_t pinNumber); + +// ADC +int analogRead(pin_size_t pinNumber); +float analogReadTemp(); // Returns core temp in Centigrade + +// PWM +void analogWrite(pin_size_t pinNumber, int value); +void analogWriteFreq(uint32_t freq); +void analogWriteRange(uint32_t range); +void analogWriteResolution(int res); + +// Timing +void delay(unsigned long); +void delayMicroseconds(unsigned int us); +unsigned long millis(); + +#ifdef __cplusplus +} // extern "C" +#endif + +// Ancient AVR defines +#define HAVE_HWSERIAL0 +#define HAVE_HWSERIAL1 +#define HAVE_HWSERIAL2 + +#ifdef __cplusplus +#include "SerialUSB.h" +#include "SerialUART.h" +#include "RP2040.h" +#include "Bootsel.h" + +// Template which will evaluate at *compile time* to a single 32b number +// with the specified bits set. +template +constexpr uint32_t __bitset(const int (&a)[N], size_t i = 0U) { + return i < N ? (1L << a[i]) | __bitset(a, i+1) : 0; +} +#endif + + +// ARM toolchain doesn't provide itoa etc, provide them +#include "api/itoa.h" + +#endif // Arduino_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.4.0/platform.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.4.0/platform.txt new file mode 100644 index 0000000..1ea19c3 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/Packages_Patches/rp2040/hardware/rp2040/1.4.0/platform.txt @@ -0,0 +1,145 @@ +# Copyright (c) 2021 Earle F. Philhower, III +# +# Raspberry Pi RP2040 Core platform file +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Raspberry Pi RP2040 Boards(1.4.0) +version=1.4.0 + + + + + + +compiler.path={runtime.tools.pqt-gcc.path}/bin/ + +# Compile variables +# ----------------- + +compiler.warning_flags=-w +compiler.warning_flags.none=-w +compiler.warning_flags.default= +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra + +compiler.defines={build.led} +compiler.includes="-iprefix{runtime.platform.path}/" "@{runtime.platform.path}/lib/platform_inc.txt" +compiler.flags=-Os -march=armv6-m -mcpu=cortex-m0plus -mthumb -ffunction-sections -fdata-sections -fno-exceptions +compiler.wrap="@{runtime.platform.path}/lib/platform_wrap.txt" + +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-c {compiler.defines} {compiler.flags} {compiler.includes} -std=gnu17 -g +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags={compiler.defines} {compiler.flags} -Wl,--gc-sections -u _printf_float -u _scanf_float +compiler.S.cmd=arm-none-eabi-gcc +compiler.S.flags=-c -g -x assembler-with-cpp -MMD {compiler.includes} -g +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-c {compiler.defines} {compiler.flags} {compiler.includes} -fno-rtti -std=gnu++17 -g + +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 +compiler.elf2hex.bin.flags=-O binary +compiler.elf2hex.hex.flags=-O ihex -R .eeprom +compiler.elf2hex.cmd=arm-none-eabi-objcopy +compiler.ldflags={compiler.wrap} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +compiler.readelf.cmd=arm-none-eabi-readelf + +# this can be overriden in boards.txt +build.extra_flags= + +# These can be overridden in platform.local.txt +compiler.c.extra_flags= +compiler.c.elf.extra_flags= +compiler.cpp.extra_flags= +compiler.S.extra_flags= +compiler.ar.extra_flags= +compiler.elf2hex.extra_flags= + +# Board configuration, set in boards.txt. Present here to ensure substitution works +build.flash_length= +build.eeprom_start= +build.fs_start= +build.fs_end= + +build.boot2=boot2_generic_03h_4_padded_checksum + +# Allow Pico boards do be auto-discovered by the IDE +discovery.rp2040.pattern="{runtime.tools.pqt-python3.path}/python3" "{runtime.platform.path}/tools/discovery.py" + + +# Compile patterns +# ---------------- + +## Compile c files +## Add -DBOARD_NAME="{build.board}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} {build.usbpid} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +## Add -DBOARD_NAME="{build.board}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {build.usbpid} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}" + +## Compile S files +## Add -DBOARD_NAME="{build.board}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} {build.usbpid} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}" + +## Create archives +# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value +archive_file_path={build.path}/{archive_file} +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.hooks.linking.prelink.1.pattern="{runtime.tools.pqt-python3.path}/python3" "{runtime.platform.path}/tools/simplesub.py" --input "{runtime.platform.path}/lib/memmap_default.ld" --out "{build.path}/memmap_default.ld" --sub __FLASH_LENGTH__ {build.flash_length} --sub __EEPROM_START__ {build.eeprom_start} --sub __FS_START__ {build.fs_start} --sub __FS_END__ {build.fs_end} +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-Wl,--script={build.path}/memmap_default.ld" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nosys.specs -Wl,--as-needed -Wl,--start-group {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" -Wl,--whole-archive "{runtime.platform.path}/lib/libpico.a" -Wl,--no-whole-archive -lm "-I{runtime.platform.path}/pico-sdk/src/rp2040/hardware_regs/include/" "-I{runtime.platform.path}/pico-sdk/src/common/pico_binary_info/include" "{runtime.platform.path}/assembly/{build.boot2}.S" -lc -lstdc++ -Wl,--end-group + +## Create output (UF2 file) +recipe.objcopy.uf2.pattern="{runtime.tools.pqt-elf2uf2.path}/elf2uf2" "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.uf2" + +build.preferred_out_format=uf2 + +## Save hex +recipe.output.tmp_file={build.project_name}.{build.preferred_out_format} +recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format} + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=^(?:\.boot2|\.text|\.rodata|\.ARM\.extab|\.ARM\.exidx)\s+([0-9]+).* +recipe.size.regex.data=^(?:\.data|\.bss|\.ram_vector_table|\.uninitialized_data)\s+([0-9]+).* + +tools.uf2conv.path= +# Because the variable expansion doesn't allow one tool to find another, the following lines +# will point to "{runtime.platform.path}/tools/python3/python3" in GIT and +# "{runtime.tools.pqt-python3.path}/python3" for JSON board manager releases. +tools.uf2conv.cmd={runtime.tools.pqt-python3.path}/python3 + +tools.uf2conv.upload.protocol=uf2 +tools.uf2conv.upload.params.verbose= +tools.uf2conv.upload.params.quiet= +tools.uf2conv.upload.pattern="{cmd}" "{runtime.platform.path}/tools/uf2conv.py" --serial "{serial.port}" --family RP2040 --deploy "{build.path}/{build.project_name}.uf2" + + +tools.picoprobe.cmd={runtime.tools.pqt-openocd.path} + +tools.picoprobe.upload.protocol=picoprobe +tools.picoprobe.upload.params.verbose= +tools.picoprobe.upload.params.quiet= +tools.picoprobe.upload.pattern="{cmd}/bin/openocd" -f "interface/picoprobe.cfg" -f "target/rp2040.cfg" -s "{cmd}/share/openocd/scripts" -c "program {build.path}/{build.project_name}.elf verify reset exit" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/README.md b/libraries/MySQL_MariaDB_Generic-1.7.2/README.md new file mode 100644 index 0000000..2d60f29 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/README.md @@ -0,0 +1,1966 @@ +## MySQL_MariaDB_Generic + +[![arduino-library-badge](https://www.ardu-badge.com/badge/MySQL_MariaDB_Generic.svg?)](https://www.ardu-badge.com/MySQL_MariaDB_Generic) +[![GitHub release](https://img.shields.io/github/release/khoih-prog/MySQL_MariaDB_Generic.svg)](https://github.com/khoih-prog/MySQL_MariaDB_Generic/releases) +[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/MySQL_MariaDB_Generic/blob/master/LICENSE) +[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing) +[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/MySQL_MariaDB_Generic.svg)](http://github.com/khoih-prog/MySQL_MariaDB_Generic/issues) + +Donate to my libraries using BuyMeACoffee + + +--- +--- + +## Table of Contents + +* [Important Change from v1.7.0](#Important-Change-from-v170) +* [Why do we need this MySQL_MariaDB_Generic library](#why-do-we-need-this-mysql_mariadb_generic-library) + * [Features](#features) + * [Currently supported Boards](#currently-supported-boards) + * [Currently supported WiFi shields/modules](#currently-supported-wifi-shieldsmodules) + * [Currently supported Ethernet shields/modules](#currently-supported-ethernet-shieldsmodules) +* [Changelog](changelog.md) +* [Prerequisites](#prerequisites) +* [Installation](#installation) + * [Use Arduino Library Manager](#use-arduino-library-manager) + * [Manual Install](#manual-install) + * [VS Code & PlatformIO](#vs-code--platformio) +* [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error) +* [Packages' Patches](#packages-patches) + * [1. For Adafruit nRF52840 and nRF52832 boards](#1-for-adafruit-nRF52840-and-nRF52832-boards) + * [2. For Teensy boards](#2-for-teensy-boards) + * [3. For Arduino SAM DUE boards](#3-for-arduino-sam-due-boards) + * [4. For Arduino SAMD boards](#4-for-arduino-samd-boards) + * [For core version v1.8.10+](#for-core-version-v1810) + * [For core version v1.8.9-](#for-core-version-v189-) + * [5. For Adafruit SAMD boards](#5-for-adafruit-samd-boards) + * [6. For Seeeduino SAMD boards](#6-for-seeeduino-samd-boards) + * [7. For STM32 boards](#7-for-stm32-boards) + * [7.1. For STM32 boards to use LAN8720](#71-for-stm32-boards-to-use-lan8720) + * [7.2. For STM32 boards to use Serial1](#72-for-stm32-boards-to-use-serial1) + * [8. For RP2040-based boards using Earle Philhower arduino-pico core](#8-for-rp2040-based-boards-using-earle-philhower-arduino-pico-core) + * [8.1. To use BOARD_NAME](#81-to-use-board_name) + * [8.2. To avoid compile error relating to microsecondsToClockCycles](#82-to-avoid-compile-error-relating-to-microsecondstoclockcycles) + * [9. For Portenta_H7 boards using Arduino IDE in Linux](#9-for-portenta_h7-boards-using-arduino-ide-in-linux) + * [10. For RTL8720DN boards using AmebaD core](#10-for-rtl8720dn-boards-using-amebad-core) + * [11. For SAMD21 and SAMD51 boards using ArduinoCore-fab-sam core](#11-For-SAMD21-and-SAMD51-boards-using-ArduinoCore-fab-sam-core) + * [12. For Seeeduino RP2040 boards](#12-For-Seeeduino-RP2040-boards) +* [Libraries' Patches](#libraries-patches) + * [1. For application requiring 2K+ HTML page](#1-for-application-requiring-2k-html-page) + * [2. For Ethernet library](#2-for-ethernet-library) + * [3. For EthernetLarge library](#3-for-ethernetlarge-library) + * [4. For Etherne2 library](#4-for-ethernet2-library) + * [5. For Ethernet3 library](#5-for-ethernet3-library) + * [6. For UIPEthernet library](#6-for-uipethernet-library) + * [7. For fixing ESP32 compile error](#7-for-fixing-esp32-compile-error) + * [8. For fixing ESP8266 compile error](#8-for-fixing-esp8266-compile-error) +* [HOWTO Use analogRead() with ESP32 running WiFi and/or BlueTooth (BT/BLE)](#howto-use-analogread-with-esp32-running-wifi-andor-bluetooth-btble) + * [1. ESP32 has 2 ADCs, named ADC1 and ADC2](#1--esp32-has-2-adcs-named-adc1-and-adc2) + * [2. ESP32 ADCs functions](#2-esp32-adcs-functions) + * [3. ESP32 WiFi uses ADC2 for WiFi functions](#3-esp32-wifi-uses-adc2-for-wifi-functions) +* [Important Notes](#important-notes) +* [Basic Usage](#basic-usage) + * [ 1. To use Ethernet module/shield](#1-to-use-ethernet-moduleshield) + * [ 2. To use WiFi module/shield](#2-to-use-wifi-moduleshield) + * [ 3. To use WiFiNINA module/shield](#3-to-use-wifinina-moduleshield) +* [Examples](#examples) + * [For Ethernet module/shield](#for-ethernet-moduleshield) + * [For WiFi module/shield](#for-wifi-moduleshield) + * [For WiFiNINA module/shield](#for-wifinina-moduleshield) + * [For WT32_ETH01](#for-wt32_eth01) + * [For Teensy 4.1 NativeEthernet](#for-teensy-41-nativeethernet) + * [For Teensy 4.1 QNEthernet](#for-teensy-41-qnethernet) + * [For Portenta_H7 Ethernet](#For-Portenta_H7-Ethernet) + * [For Portenta_H7 WiFi](#For-Portenta_H7-WiFi) +* [Example Basic_Select](#example-Basic_Select) + * [1. File Basic_Select.ino](#1-file-Basic_Selectino) + * [2. File defines.h](#2-file-definesh) +* [Debug Terminal Output Samples](#debug-terminal-output-samples) + * [ 1. Query_Progmem on NRF52840_FEATHER using W5x00/Ethernet_Generic Library](#1-query_progmem-on-nrf52840_feather-using-w5x00Ethernet_Generic-library) + * [ 2. Complex_Select on NUCLEO_F767ZI using LAN8742A/STM32Ethernet Library](#2-complex_select-on-nucleo_f767zi-using-lan8742astm32ethernet-library) + * [ 3. Query_Results_WiFi on ITSYBITSY_M4](#3-query_results_wifi-on-itsybitsy_m4) + * [ 4. Basic_Select_WiFi on SEEED_XIAO_M0](#4-basic_select_wifi-on-seeed_xiao_m0) + * [ 5. Query_Results_WiFiNINA on SAMD_NANO_33_IOT](#5-query_results_wifinina-on-samd_nano_33_iot) + * [ 6. Connect_By_Hostname on SAM DUE using W5x00/Ethernet_Generic Library](#6-connect_by_hostname-on-sam-due-using-w5x00Ethernet_Generic-library) + * [ 7. Complex_Select on NRF52840_FEATHER using ENC28J60/UIPEthernet Library](#7-complex_select-on-nrf52840_feather-using-enc28j60uipethernet-library) + * [ 8. Complex_Select on NRF52840_FEATHER using ENC28J60/EthernetENC Library](#8-complex_select-on-nrf52840_feather-using-enc28j60ethernetenc-library) + * [ 9. Query_Progmem on NRF52840_FEATHER using ENC28J60/EthernetENC Library](#9-query_progmem-on-nrf52840_feather-using-enc28j60ethernetenc-library) + * [10. Basic_Insert_ESP on ESP8266_NODEMCU_ESP12E](#10-basic_insert_esp-on-esp8266_nodemcu_esp12e) + * [11. Basic_Insert_ESP on ESP32S2_DEV](#11-basic_insert_esp-on-esp32s2_dev) + * [12. Basic_Select_WiFiNINA on MBED NANO_RP2040_CONNECT](#12-basic_select_wifinina-on-mbed-nano_rp2040_connect) + * [13. Complex_Select on MBED RASPBERRY_PI_PICO using W5x00/Ethernet_Generic Library](#13-complex_select-on-mbed-raspberry_pi_pico-using-w5x00Ethernet_Generic-library) + * [14. Complex_Select on RASPBERRY_PI_PICO using W5x00/Ethernet_Generic Library](#14-complex_select-on-raspberry_pi_pico-using-w5x00Ethernet_Generic-library) + * [15. Complex_Select_WT32_ETH01 on WT32-ETH01](#15-complex_select_wt32_eth01-on-wt32-eth01) + * [16. Complex_Select on Teensy 4.1 with NativeEthernet](#16-complex_select-on-teensy-41-with-nativeethernet) + * [17. Complex_Select on Teensy 4.1 with QNEthernet](#17-complex_select-on-teensy-41-with-qnethernet) + * [18. Complex_Insert on PORTENTA_H7_M7 using Portenta_Ethernet](#18-Complex_Insert-on-PORTENTA_H7_M7-using-Portenta_Ethernet) + * [19. Complex_Select_WiFi on PORTENTA_H7_M7](#19-Complex_Select_WiFi-on-PORTENTA_H7_M7) +* [Debug](#debug) +* [Troubleshooting](#troubleshooting) +* [Issues](#issues) +* [TO DO](#to-do) +* [DONE](#done) +* [Contributions and Thanks](#contributions-and-thanks) +* [Contributing](#contributing) +* [License](#license) +* [Copyright](#copyright) + +--- +--- + +### Important Change from v1.7.0 + +Please have a look at [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error) + + +--- +--- + +### Why do we need this [MySQL_MariaDB_Generic library](https://github.com/khoih-prog/MySQL_MariaDB_Generic) + +#### Features + +Have you ever wanted to connect your Arduino project to a database to either store the data you've collected or retrieve data saved to trigger events in your sketch? + +Well, now you can connect your Arduino project directly to a **MySQL / MariaDB server** without using an intermediate computer or a web-based or cloud-based service. Having direct access to a **MySQL / MariaDB database server** means you can store data acquired from your project as well as check values stored in tables on the server. + +This also means you can setup your own, local MySQL server to store your data further removing the need for Internet connectivity. If that is not an issue, you can still connect to and store data on a MySQL server via your network, Internet, or even in the cloud! + +This [**MySQL_MariaDB_Generic library**](https://github.com/khoih-prog/MySQL_MariaDB_Generic) will let you to do exactly that and more! + +This [**MySQL_MariaDB_Generic library**](https://github.com/khoih-prog/MySQL_MariaDB_Generic) is based on and modified from [**Dr. Charles Bell's MySQL_Connector_Arduino Library**](https://github.com/ChuckBell/MySQL_Connector_Arduino), to provide support to many more boards and shields, such as **Arduino SAMD21, Adafruit SAMD21/SAMD51, Seeeduino SAMD21/SAMD51, nRF52, STM32F/L/H/G/WB/MP1, Teensy, SAM DUE, AVR Mega, RP2040-based (Nano RP2040 Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040), Portenta_H7, etc. boards**. Those supported boards can be used with **ESP8266/ESP32’s WiFi, WiFiNINA, W5x00/ENC28J60/LAN8742A Ethernet, ESP8266/ESP32-AT, NativeEthernet/QNEthernet modules/shields, Portenta_H7 WiFi/Ethernet.** + +--- + +#### Currently supported Boards + +This [**MySQL_MariaDB_Generic** library](https://github.com/khoih-prog/MySQL_MariaDB_Generic) currently supports these following boards: + + 1. **nRF52 boards**, such as **AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.** + + 2. **SAMD21** + - Arduino SAMD21: ZERO, MKRs, NANO_33_IOT, etc. + - Adafruit SAMD21 (M0): ItsyBitsy M0, Feather M0, Feather M0 Express, Metro M0 Express, Circuit Playground Express, Trinket M0, PIRkey, Hallowing M0, Crickit M0, etc. + - Seeeduino: LoRaWAN, Zero, Femto M0, XIAO M0, Wio GPS Board, etc. + + 3. **SAMD51** + - Adafruit SAMD51 (M4): Metro M4, Grand Central M4, ItsyBitsy M4, Feather M4 Express, Trellis M4, Metro M4 AirLift Lite, MONSTER M4SK Express, Hallowing M4, etc. + - Seeeduino: Wio Terminal, Grove UI Wireless + + 4. **SAM DUE** + 5. **Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0)** using either Ethernet, WiFi, or for Teensy 4.1 NativeEthernet/QNEthernet + 6. **STM32F/L/H/G/WB/MP1 boards (with 32+K Flash)** + - Nucleo-144 + - Nucleo-64 + - Discovery + - Generic STM32F0, STM32F1, STM32F2, STM32F3, STM32F4, STM32F7 (with 64+K Flash): x8 and up + - STM32L0, STM32L1, STM32L4, STM32L5 + - STM32G0, STM32G4 + - STM32H7 + - STM32WB + - STM32MP1 + - LoRa boards + - 3-D printer boards + - Generic Flight Controllers + - Midatronics boards + + 7. **ESP32** + 8. **ESP8266** + + 9. RP2040-based boards, such as **Nano_RP2040_Connect**, using [**Arduino mbed OS for Nano boards**](https://github.com/arduino/ArduinoCore-mbed). + +10. RP2040-based boards, such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, using [**Arduino-mbed RP2040** core](https://github.com/arduino/ArduinoCore-mbed) or [**Earle Philhower's arduino-pico** core](https://github.com/earlephilhower/arduino-pico). + +11. RP2040-based boards, such as **Seeed XIAO RP2040**, using **Seeeduino RP2040** core + +12. **WT32_ETH01 (ESP32 + LAN8720A)** + +13. **Portenta_H7** using either `Murata WiFi` or `Vision-shield Ethernet` + +--- + +#### Currently supported WiFi shields/modules + +1. WiFiNINA using [`WiFiNINA_Generic library`](https://github.com/khoih-prog/WiFiNINA_Generic) +2. WiFi101 using [`WiFi101 library`](https://github.com/arduino-libraries/WiFi101) +3. u-blox W101, W102 using [`WiFiNINA_Generic library`](https://github.com/khoih-prog/WiFiNINA_Generic) +4. ESP8266-AT command using [`WiFiEspAT library`](https://github.com/jandrassy/WiFiEspAT) +5. ESP8266/ESP32-AT command using [`ESP_AT_Lib library`](https://github.com/khoih-prog/ESP_AT_Lib) +6. **Portenta_H7 built-in Murata WiFi** + + +--- + +#### Currently supported Ethernet shields/modules + +1. W5x00 using [`Ethernet_Generic`](https://github.com/khoih-prog/Ethernet_Generic) library +2. W5x00 using [`Ethernet`](https://www.arduino.cc/en/Reference/Ethernet), [`EthernetLarge`](https://github.com/OPEnSLab-OSU/EthernetLarge), [`Ethernet2`](https://github.com/adafruit/Ethernet2) or [`Ethernet3`](https://github.com/sstaub/Ethernet3) library +3. ENC28J60 using [`EthernetENC`](https://github.com/jandrassy/EthernetENC) or [`UIPEthernet`](https://github.com/UIPEthernet/UIPEthernet) library +4. Teensy 4.1 built-in Ethernet using [`NativeEthernet`](https://github.com/vjmuzik/NativeEthernet) library +5. Teensy 4.1 built-in Ethernet using [`QNEthernet`](https://github.com/ssilverman/QNEthernet) library +6. Portenta_H7 Ethernet using [`Portenta_Ethernet`](https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/Ethernet) library + +

+ +

+ + +--- +--- + + +## Prerequisites + + 1. [`Arduino IDE 1.8.19+` for Arduino](https://github.com/arduino/Arduino). [![GitHub release](https://img.shields.io/github/release/arduino/Arduino.svg)](https://github.com/arduino/Arduino/releases/latest) + 2. [`ESP32 Core 2.0.2+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards. [![Latest release](https://img.shields.io/github/release/espressif/arduino-esp32.svg)](https://github.com/espressif/arduino-esp32/releases/latest/) + 3. [`ESP8266 Core 3.0.2+`](https://github.com/esp8266/Arduino) for ESP8266-based boards. [![Latest release](https://img.shields.io/github/release/esp8266/Arduino.svg)](https://github.com/esp8266/Arduino/releases/latest/). + 4. [`Arduino AVR core 1.8.5+`](https://github.com/arduino/ArduinoCore-avr) for Arduino (Use Arduino Board Manager) for AVR boards. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-avr.svg)](https://github.com/arduino/ArduinoCore-avr/releases/latest) + 5. [`Teensy core v1.56+`](https://www.pjrc.com/teensy/td_download.html) for Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0) boards. + 6. [`Arduino SAM DUE core v1.6.12+`](https://github.com/arduino/ArduinoCore-sam) for SAM DUE ARM Cortex-M3 boards. + 7. [`Arduino SAMD core 1.8.13+`](https://github.com/arduino/ArduinoCore-samd) for SAMD ARM Cortex-M0+ boards. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-samd.svg)](https://github.com/arduino/ArduinoCore-samd/releases/latest) + 8. [`Adafruit SAMD core 1.7.10+`](https://github.com/adafruit/ArduinoCore-samd) for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.). [![GitHub release](https://img.shields.io/github/release/adafruit/ArduinoCore-samd.svg)](https://github.com/adafruit/ArduinoCore-samd/releases/latest) + 9. [`Fab_SAM_Arduino core v1.16.18-alpha2+`](https://github.com/qbolsee/ArduinoCore-fab-sam) for SAMD21/SAMD51 boards. [![GitHub release](https://img.shields.io/github/release/qbolsee/ArduinoCore-fab-sam.svg)](https://github.com/qbolsee/ArduinoCore-fab-sam/releases/latest) +10. [`Seeeduino SAMD core 1.8.2+`](https://github.com/Seeed-Studio/ArduinoCore-samd) for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.). [![Latest release](https://img.shields.io/github/release/Seeed-Studio/ArduinoCore-samd.svg)](https://github.com/Seeed-Studio/ArduinoCore-samd/releases/latest/) +11. [`Seeeduino RP2040 core 2.7.2+`](https://github.com/Seeed-Studio) for XIAO RP2040 boards. +12. [`Adafruit nRF52 v1.3.0+`](https://github.com/adafruit/Adafruit_nRF52_Arduino) for nRF52 boards such as Adafruit NRF52840_FEATHER, NRF52832_FEATHER, NRF52840_FEATHER_SENSE, NRF52840_ITSYBITSY, NRF52840_CIRCUITPLAY, NRF52840_CLUE, NRF52840_METRO, NRF52840_PCA10056, PARTICLE_XENON, **NINA_B302_ublox**, etc. [![GitHub release](https://img.shields.io/github/release/adafruit/Adafruit_nRF52_Arduino.svg)](https://github.com/adafruit/Adafruit_nRF52_Arduino/releases/latest) +13. [`Arduino Core for STM32 v2.2.0+`](https://github.com/stm32duino/Arduino_Core_STM32) for STM32F/L/H/G/WB/MP1 boards. [![GitHub release](https://img.shields.io/github/release/stm32duino/Arduino_Core_STM32.svg)](https://github.com/stm32duino/Arduino_Core_STM32/releases/latest) +14. [`Earle Philhower's arduino-pico core v1.13.1+`](https://github.com/earlephilhower/arduino-pico) for RP2040-based boards such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, etc. [![GitHub release](https://img.shields.io/github/release/earlephilhower/arduino-pico.svg)](https://github.com/earlephilhower/arduino-pico/releases/latest) +15. [`Arduino mbed_rp2040 core 3.0.1+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino (Use Arduino Board Manager) RP2040-based boards, such as RASPBERRY_PI_PICO. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest) + + +16. [`WiFiNINA_Generic library v1.8.14-3+`](https://github.com/khoih-prog/WiFiNINA_Generic) for WiFiNINA. To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/WiFiNINA_Generic.svg?)](https://www.ardu-badge.com/WiFiNINA_Generic). + +17. Depending on which Ethernet module/shield you're using : + - [`Ethernet_Generic library v2.0.1+`](https://github.com/khoih-prog/Ethernet_Generic) for W5100, W5200 and W5500/WIZ550io/WIZ850io/USR-ES1 with Wiznet W5500 chip. [![GitHub release](https://img.shields.io/github/release/khoih-prog/Ethernet_Generic.svg)](https://github.com/khoih-prog/Ethernet_Generic/releases/latest) + - [`EthernetENC library v2.0.2+`](https://github.com/jandrassy/EthernetENC) for ENC28J60. [![GitHub release](https://img.shields.io/github/release/jandrassy/EthernetENC.svg)](https://github.com/jandrassy/EthernetENC/releases/latest). **New and Better** + - [`UIPEthernet library v2.0.11+`](https://github.com/UIPEthernet/UIPEthernet) for ENC28J60. [![GitHub release](https://img.shields.io/github/release/UIPEthernet/UIPEthernet.svg)](https://github.com/UIPEthernet/UIPEthernet/releases/latest) + - [`STM32Ethernet library v1.2.0+`](https://github.com/stm32duino/STM32Ethernet) for built-in LAN8742A Ethernet on (Nucleo-144, Discovery). [![GitHub release](https://img.shields.io/github/release/stm32duino/STM32Ethernet.svg)](https://github.com/stm32duino/STM32Ethernet/releases/latest). To be used with [`LwIP library v2.1.2+`](https://github.com/stm32duino/LwIP). [![GitHub release](https://img.shields.io/github/release/stm32duino/LwIP.svg)](https://github.com/stm32duino/LwIP/releases/latest) + - [`NativeEthernetLarge library stable111+`](https://github.com/vjmuzik/NativeEthernet) for Teensy 4.1 built-in Ethernet. + - [`QNEthernet Library version v0.14.0+`](https://github.com/ssilverman/QNEthernet) for Teensy 4.1 built-in Ethernet. **New** + +18. [`WiFiEspAT library v1.3.2+`](https://github.com/jandrassy/WiFiEspAT) if necessary to use ESP8288/ESP32-AT shields. To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/WiFiEspAT.svg?)](https://www.ardu-badge.com/WiFiEspAT). +19. [`ESP8266_AT_WebServer library v1.5.3+`](https://github.com/khoih-prog/ESP8266_AT_WebServer) if necessary to use ESP8288/ESP32-AT shields. To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/ESP8266_AT_WebServer.svg?)](https://www.ardu-badge.com/ESP8266_AT_WebServer). +20. [`ESP_AT_Lib library v1.4.1+`](https://github.com/khoih-prog/ESP_AT_Lib) if necessary to use ESP8288/ESP32-AT shields. To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/ESP_AT_Lib.svg?)](https://www.ardu-badge.com/ESP_AT_Lib). +21. [`WebServer_WT32_ETH01 library v1.4.1+`](https://github.com/khoih-prog/WebServer_WT32_ETH01) to use WT32_ETH01 (ESP32 + LAN8720). To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/WebServer_WT32_ETH01.svg?)](https://www.ardu-badge.com/WebServer_WT32_ETH01). + +--- +--- + +## Installation + +### Use Arduino Library Manager +The best and easiest way is to use `Arduino Library Manager`. Search for `MySQL_MariaDB_Generic`, then select / install the latest version. +You can also use this link [![arduino-library-badge](https://www.ardu-badge.com/badge/MySQL_MariaDB_Generic.svg?)](https://www.ardu-badge.com/MySQL_MariaDB_Generic) for more detailed instructions. + +### Manual Install + +Another way to install is to: + +1. Navigate to [**MySQL_MariaDB_Generic**](https://github.com/khoih-prog/MySQL_MariaDB_Generic) page. +2. Download the latest release `MySQL_MariaDB_Generic-master.zip`. +3. Extract the zip file to `MySQL_MariaDB_Generic-master` directory +4. Copy whole `MySQL_MariaDB_Generic-master` folder to Arduino libraries' directory such as `~/Arduino/libraries/`. + +### VS Code & PlatformIO: + +1. Install [VS Code](https://code.visualstudio.com/) +2. Install [PlatformIO](https://platformio.org/platformio-ide) +3. Install [**MySQL_MariaDB_Generic** library](https://registry.platformio.org/libraries/khoih-prog/MySQL_MariaDB_Generic) by using [Library Manager](https://registry.platformio.org/libraries/khoih-prog/MySQL_MariaDB_Generic/installation). Search for **MySQL_MariaDB_Generic** in [Platform.io Author's Libraries](https://platformio.org/lib/search?query=author:%22Khoi%20Hoang%22) +4. Use included [platformio.ini](platformio/platformio.ini) file from examples to ensure that all dependent libraries will installed automatically. Please visit documentation for the other options and examples at [Project Configuration File](https://docs.platformio.org/page/projectconf.html) + + +--- +--- + +### HOWTO Fix `Multiple Definitions` Linker Error + +The current library implementation, using `xyz-Impl.h` instead of standard `xyz.cpp`, possibly creates certain `Multiple Definitions` Linker error in certain use cases. + +You can include this `.hpp` file + +``` +// Can be included as many times as necessary, without `Multiple Definitions` Linker Error +#include "MySQL_Generic.hpp" //https://github.com/khoih-prog/MySQL_Generic +``` + +in many files. But be sure to use the following `.h` file **in just 1 `.h`, `.cpp` or `.ino` file**, which must **not be included in any other file**, to avoid `Multiple Definitions` Linker Error + +``` +// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error +#include "MySQL_Generic.h" //https://github.com/khoih-prog/MySQL_Generic +``` + +Check the new [**multiFileProject_Ethernet** example](examples/Ethernet/multiFileProject_Ethernet) for a `HOWTO` demo. + +Have a look at the discussion in [Different behaviour using the src_cpp or src_h lib #80](https://github.com/khoih-prog/ESPAsync_WiFiManager/discussions/80) + + + +--- +--- + +### Packages' Patches + +#### 1. For Adafruit nRF52840 and nRF52832 boards + +**To be able to compile, run and automatically detect and display BOARD_NAME on nRF52840/nRF52832 boards**, you have to copy the whole [nRF52 Packages_Patches](Packages_Patches/adafruit/hardware/nrf52/1.3.0) directory into Adafruit nRF52 directory (~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0). + +Supposing the Adafruit nRF52 version is 1.3.0. These files must be copied into the directory: +- `~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/platform.txt` +- `~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/boards.txt` +- `~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Udp.h` +- `~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.h` +- `~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.cpp` +- `~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.h` +- `~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.cpp` +- `~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.h` +- `~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.cpp` +- **`~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Udp.h`** + +Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z +These files must be copied into the directory: + +- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/platform.txt` +- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/boards.txt` +- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Udp.h` +- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Print.h` +- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Print.cpp` +- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B302_ublox/variant.h` +- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B302_ublox/variant.cpp` +- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.h` +- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.cpp` +- **`~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Udp.h`** + +#### 2. For Teensy boards + + **To be able to compile and run on Teensy boards**, you have to copy the files in [**Packages_Patches for Teensy directory**](Packages_Patches/hardware/teensy/avr) into Teensy hardware directory (./arduino-1.8.19/hardware/teensy/avr/boards.txt). + +Supposing the Arduino version is 1.8.19. These files must be copied into the directory: + +- `./arduino-1.8.19/hardware/teensy/avr/boards.txt` +- `./arduino-1.8.19/hardware/teensy/avr/cores/teensy/Stream.h` +- `./arduino-1.8.19/hardware/teensy/avr/cores/teensy3/Stream.h` +- `./arduino-1.8.19/hardware/teensy/avr/cores/teensy4/Stream.h` + +Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz +These files must be copied into the directory: + +- `./arduino-x.yy.zz/hardware/teensy/avr/boards.txt` +- `./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy/Stream.h` +- `./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy3/Stream.h` +- `./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy4/Stream.h` + +#### 3. For Arduino SAM DUE boards + + **To be able to compile and run on SAM DUE boards**, you have to copy the whole [SAM DUE](Packages_Patches/arduino/hardware/sam/1.6.12) directory into Arduino sam directory (~/.arduino15/packages/arduino/hardware/sam/1.6.12). + +Supposing the Arduino SAM core version is 1.6.12. This file must be copied into the directory: + +- `~/.arduino15/packages/arduino/hardware/sam/1.6.12/platform.txt` + +Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz +This file must be copied into the directory: + +- `~/.arduino15/packages/arduino/hardware/sam/x.yy.zz/platform.txt` + +#### 4. For Arduino SAMD boards + + ***To be able to compile, run and automatically detect and display BOARD_NAME on Arduino SAMD (Nano-33-IoT, etc) boards***, you have to copy the whole [Arduino SAMD Packages_Patches](Packages_Patches/arduino/hardware/samd/1.8.13) directory into Arduino SAMD directory (~/.arduino15/packages/arduino/hardware/samd/1.8.13). + +#### For core version v1.8.10+ + +Supposing the Arduino SAMD version is 1.8.13. Now only one file must be copied into the directory: + +- `~/.arduino15/packages/arduino/hardware/samd/1.8.13/platform.txt` + +Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz + +This file must be copied into the directory: + +- `~/.arduino15/packages/arduino/hardware/samd/x.yy.zz/platform.txt` + +#### For core version v1.8.9- + +Supposing the Arduino SAMD version is 1.8.9. These files must be copied into the directory: + +- `~/.arduino15/packages/arduino/hardware/samd/1.8.9/platform.txt` +- ***`~/.arduino15/packages/arduino/hardware/samd/1.8.9/cores/arduino/Arduino.h`*** + +Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z + +These files must be copied into the directory: + +- `~/.arduino15/packages/arduino/hardware/samd/x.yy.z/platform.txt` +- ***`~/.arduino15/packages/arduino/hardware/samd/x.yy.z/cores/arduino/Arduino.h`*** + + This is mandatory to fix the ***notorious Arduino SAMD compiler error***. See [Improve Arduino compatibility with the STL (min and max macro)](https://github.com/arduino/ArduinoCore-samd/pull/399) + +``` + ...\arm-none-eabi\include\c++\7.2.1\bits\stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2 + min(const _Tp& __a, const _Tp& __b, _Compare __comp) +``` + +Whenever the above-mentioned compiler error issue is fixed with the new Arduino SAMD release, you don't need to copy the `Arduino.h` file anymore. + +#### 5. For Adafruit SAMD boards + + ***To be able to compile, run and automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards***, you have to copy the whole [Adafruit SAMD Packages_Patches](Packages_Patches/adafruit/hardware/samd/1.7.9) directory into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.7.9). + +Supposing the Adafruit SAMD core version is 1.7.9. This file must be copied into the directory: + +- `~/.arduino15/packages/adafruit/hardware/samd/1.7.9/platform.txt` +- `~/.arduino15/packages/adafruit/hardware/samd/1.7.9/cores/arduino/Print.h` +- `~/.arduino15/packages/adafruit/hardware/samd/1.7.9/cores/arduino/Print.cpp` + +Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz +This file must be copied into the directory: + +- `~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/platform.txt` +- `~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/cores/arduino/Print.h` +- `~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/cores/arduino/Print.cpp` + +#### 6. For Seeeduino SAMD boards + + ***To be able to compile, run and automatically detect and display BOARD_NAME on Seeeduino SAMD (XIAO M0, Wio Terminal, etc) boards***, you have to copy the whole [Seeeduino SAMD Packages_Patches](Packages_Patches/Seeeduino/hardware/samd/1.8.2) directory into Seeeduino samd directory (~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2). + +Supposing the Seeeduino SAMD core version is 1.8.2. This file must be copied into the directory: + +- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2/platform.txt` +- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2/cores/arduino/Arduino.h` +- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2/cores/arduino/Print.h` +- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2/cores/arduino/Print.cpp` + +Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz +This file must be copied into the directory: + +- `~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/platform.txt` +- `~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/cores/arduino/Arduino.h` +- `~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/cores/arduino/Print.h` +- `~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/cores/arduino/Print.cpp` + +#### 7. For STM32 boards + +#### 7.1 For STM32 boards to use LAN8720 + +To use LAN8720 on some STM32 boards + +- **Nucleo-144 (F429ZI, NUCLEO_F746NG, NUCLEO_F746ZG, NUCLEO_F756ZG)** +- **Discovery (DISCO_F746NG)** +- **STM32F4 boards (BLACK_F407VE, BLACK_F407VG, BLACK_F407ZE, BLACK_F407ZG, BLACK_F407VE_Mini, DIYMORE_F407VGT, FK407M1)** + +you have to copy the files [stm32f4xx_hal_conf_default.h](Packages_Patches/STM32/hardware/stm32/2.2.0/system/STM32F4xx) and [stm32f7xx_hal_conf_default.h](Packages_Patches/STM32/hardware/stm32/2.2.0/system/STM32F7xx) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system) to overwrite the old files. + +Supposing the STM32 stm32 core version is 2.2.0. These files must be copied into the directory: + +- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h` for STM32F4. +- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h` for Nucleo-144 STM32F7. + +Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz, +theses files must be copied into the corresponding directory: + +- `~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/system/STM32F4xx/stm32f4xx_hal_conf_default.h` +- `~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/system/STM32F7xx/stm32f7xx_hal_conf_default.h + + +#### 7.2 For STM32 boards to use Serial1 + +**To use Serial1 on some STM32 boards without Serial1 definition (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.) boards**, you have to copy the files [STM32 variant.h](Packages_Patches/STM32/hardware/stm32/2.2.0) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.2.0). You have to modify the files corresponding to your boards, this is just an illustration how to do. + +Supposing the STM32 stm32 core version is 2.2.0. These files must be copied into the directory: + +- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/NUCLEO_F767ZI/variant.h` for Nucleo-144 NUCLEO_F767ZI. +- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/NUCLEO_L053R8/variant.h` for Nucleo-64 NUCLEO_L053R8. + +Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz, +theses files must be copied into the corresponding directory: + +- `~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/NUCLEO_F767ZI/variant.h` +- `~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/NUCLEO_L053R8/variant.h` + +#### 8. For RP2040-based boards using [Earle Philhower arduino-pico core](https://github.com/earlephilhower/arduino-pico) + +#### 8.1 To use BOARD_NAME + + **To be able to automatically detect and display BOARD_NAME on RP2040-based boards (RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, GENERIC_RP2040, etc) boards**, you have to copy the file [RP2040 platform.txt](Packages_Patches/rp2040/hardware/rp2040/1.4.0) into rp2040 directory (~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0). + +Supposing the rp2040 core version is 1.4.0. This file must be copied into the directory: + +- `~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0/platform.txt` + +Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz +This file must be copied into the directory: + +- `~/.arduino15/packages/rp2040/hardware/rp2040/x.yy.zz/platform.txt` + +With core after v1.5.0, this step is not necessary anymore thanks to the PR [Add -DBOARD_NAME="{build.board}" #136](https://github.com/earlephilhower/arduino-pico/pull/136). + +#### 8.2 To avoid compile error relating to microsecondsToClockCycles + +Some libraries, such as [Adafruit DHT-sensor-library](https://github.com/adafruit/DHT-sensor-library), require the definition of microsecondsToClockCycles(). **To be able to compile and run on RP2040-based boards**, you have to copy the files in [**RP2040 Arduino.h**](Packages_Patches/rp2040/hardware/rp2040/1.4.0/cores/rp2040/Arduino.h) into rp2040 directory (~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0). + +Supposing the rp2040 core version is 1.4.0. This file must be copied to replace: + +- `~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0/cores/rp2040/Arduino.h` + +Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz +This file must be copied to replace: + +- `~/.arduino15/packages/rp2040/hardware/rp2040/x.yy.zz/cores/rp2040/Arduino.h` + +With core after v1.5.0, this step is not necessary anymore thanks to the PR [Add defs for compatibility #142](https://github.com/earlephilhower/arduino-pico/pull/142). + + +#### 9. For Portenta_H7 boards using Arduino IDE in Linux + + **To be able to upload firmware to Portenta_H7 using Arduino IDE in Linux (Ubuntu, etc.)**, you have to copy the file [portenta_post_install.sh](Packages_Patches/arduino/hardware/mbed_portenta/3.0.0/portenta_post_install.sh) into mbed_portenta directory (~/.arduino15/packages/arduino/hardware/mbed_portenta/3.0.0/portenta_post_install.sh). + + Then run the following command using `sudo` + +``` +$ cd ~/.arduino15/packages/arduino/hardware/mbed_portenta/3.0.0 +$ chmod 755 portenta_post_install.sh +$ sudo ./portenta_post_install.sh +``` + +This will create the file `/etc/udev/rules.d/49-portenta_h7.rules` as follows: + +``` +# Portenta H7 bootloader mode UDEV rules + +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="035b", GROUP="plugdev", MODE="0666" +``` + +Supposing the ArduinoCore-mbed core version is 3.0.0. Now only one file must be copied into the directory: + +- `~/.arduino15/packages/arduino/hardware/mbed_portenta/3.0.0/portenta_post_install.sh` + +Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz + +This file must be copied into the directory: + +- `~/.arduino15/packages/arduino/hardware/mbed_portenta/x.yy.zz/portenta_post_install.sh` + + +#### 10. For RTL8720DN boards using AmebaD core + + To avoid compile error relating to PROGMEM, you have to copy the file [Realtek AmebaD core pgmspace.h](Packages_Patches/realtek/hardware/AmebaD/3.1.2/cores/arduino/avr/pgmspace.h) into Realtek AmebaD directory (~/.arduino15/packages/realtek/hardware/AmebaD/3.1.2/cores/arduino/avr/pgmspace.h). + +Supposing the Realtek AmebaD core version is 3.1.2. This file must be copied into the directory: + +- `~/.arduino15/packages/realtek/hardware/AmebaD/3.1.2/cores/arduino/avr/pgmspace.h` + +Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz +This file must be copied into the directory: + +- `~/.arduino15/packages/realtek/hardware/AmebaD/x.yy.zz/cores/arduino/avr/pgmspace.h` + + +#### 11. For SAMD21 and SAMD51 boards using ArduinoCore-fab-sam core + + To avoid compile error relating to SAMD21/SAMD51, you have to copy the file [ArduinoCore-fab-sam core pgmspace.h](Packages_Patches/Fab_SAM_Arduino/hardware/samd/1.6.18-alpha2/boards.txt) into `ArduinoCore-fab-sam` samd directory (~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/1.6.18-alpha2/boards.txt). + +Supposing the `ArduinoCore-fab-sam` samd core version is 1.6.18-alpha2. This file must be copied into the directory: + +- `~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/1.6.18-alpha2/boards.txt` + +Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz +This file must be copied into the directory: + +- `~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/x.yy.zz/boards.txt` + + +#### 12. For Seeeduino RP2040 boards + + ***To be able to compile, run and automatically detect and display BOARD_NAME on Seeeduino RP2040 (XIAO RP2040, Wio RP2040 Mini) boards***, you have to copy the whole [Seeeduino RP2040 Packages_Patches](Packages_Patches/Seeeduino/hardware/rp2040/2.7.2) directory into Seeeduino samd directory (~/.arduino15/packages/Seeeduino/hardware/rp2040/2.7.2). + +Supposing the Seeeduino SAMD core version is 2.7.2. This file must be copied into the directory: + +- `~/.arduino15/packages/Seeeduino/hardware/rp2040/2.7.2/boards.txt` +- `~/.arduino15/packages/Seeeduino/hardware/rp2040/2.7.2/variants/Seeed_XIAO_RP2040/pins_arduino.h` + +Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz +This file must be copied into the directory: + +- `~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/boards.txt` +- `~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/variants/Seeed_XIAO_RP2040/pins_arduino.h` + + +--- +--- + +### Libraries' Patches + +#### 1. For application requiring 2K+ HTML page + +If your application requires 2K+ HTML page, the current [`Ethernet library`](https://www.arduino.cc/en/Reference/Ethernet) must be modified if you are using W5200/W5500 Ethernet shields. W5100 is not supported for 2K+ buffer. If you use boards requiring different CS/SS pin for W5x00 Ethernet shield, for example ESP32, ESP8266, nRF52, etc., you also have to modify the following libraries to be able to specify the CS/SS pin correctly. + +#### 2. For Ethernet library + +To fix [`Ethernet library`](https://www.arduino.cc/en/Reference/Ethernet), just copy these following files into the [`Ethernet library`](https://www.arduino.cc/en/Reference/Ethernet) directory to overwrite the old files: +- [Ethernet.h](LibraryPatches/Ethernet/src/Ethernet.h) +- [Ethernet.cpp](LibraryPatches/Ethernet/src/Ethernet.cpp) +- [EthernetServer.cpp](LibraryPatches/Ethernet/src/EthernetServer.cpp) +- [w5100.h](LibraryPatches/Ethernet/src/utility/w5100.h) +- [w5100.cpp](LibraryPatches/Ethernet/src/utility/w5100.cpp) + +#### 3. For EthernetLarge library + +To fix [`EthernetLarge library`](https://github.com/OPEnSLab-OSU/EthernetLarge), just copy these following files into the [`EthernetLarge library`](https://github.com/OPEnSLab-OSU/EthernetLarge) directory to overwrite the old files: +- [EthernetLarge.h](LibraryPatches/EthernetLarge/src/EthernetLarge.h) +- [EthernetLarge.cpp](LibraryPatches/EthernetLarge/src/EthernetLarge.cpp) +- [EthernetServer.cpp](LibraryPatches/EthernetLarge/src/EthernetServer.cpp) +- [w5100.h](LibraryPatches/EthernetLarge/src/utility/w5100.h) +- [w5100.cpp](LibraryPatches/EthernetLarge/src/utility/w5100.cpp) + + +#### 4. For Ethernet2 library + +To fix [`Ethernet2 library`](https://github.com/khoih-prog/Ethernet2), just copy these following files into the [`Ethernet2 library`](https://github.com/khoih-prog/Ethernet2) directory to overwrite the old files: + +- [Ethernet2.h](LibraryPatches/Ethernet2/src/Ethernet2.h) +- [Ethernet2.cpp](LibraryPatches/Ethernet2/src/Ethernet2.cpp) + +To add UDP Multicast support, necessary for the [**UPnP_Generic library**](https://github.com/khoih-prog/UPnP_Generic): + +- [EthernetUdp2.h](LibraryPatches/Ethernet2/src/EthernetUdp2.h) +- [EthernetUdp2.cpp](LibraryPatches/Ethernet2/src/EthernetUdp2.cpp) + +#### 5. For Ethernet3 library + +5. To fix [`Ethernet3 library`](https://github.com/sstaub/Ethernet3), just copy these following files into the [`Ethernet3 library`](https://github.com/sstaub/Ethernet3) directory to overwrite the old files: +- [Ethernet3.h](LibraryPatches/Ethernet3/src/Ethernet3.h) +- [Ethernet3.cpp](LibraryPatches/Ethernet3/src/Ethernet3.cpp) + +#### 6. For UIPEthernet library + +***To be able to compile and run on nRF52 boards with ENC28J60 using UIPEthernet library***, you have to copy these following files into the UIPEthernet `utility` directory to overwrite the old files: + +- [UIPEthernet.h](LibraryPatches/UIPEthernet/UIPEthernet.h) +- [UIPEthernet.cpp](LibraryPatches/UIPEthernet/UIPEthernet.cpp) +- [Enc28J60Network.h](LibraryPatches/UIPEthernet/utility/Enc28J60Network.h) +- [Enc28J60Network.cpp](LibraryPatches/UIPEthernet/utility/Enc28J60Network.cpp) + +#### 7. For fixing ESP32 compile error + +To fix [`ESP32 compile error`](https://github.com/espressif/arduino-esp32), just copy the following file into the [`ESP32`](https://github.com/espressif/arduino-esp32) cores/esp32 directory (e.g. ./arduino-1.8.12/hardware/espressif/cores/esp32) to overwrite the old file: +- [Server.h](LibraryPatches/esp32/cores/esp32/Server.h) + +#### 8. For fixing ESP8266 compile error + +To fix `ESP8266 compile error` such as + +``` +error: 'class EthernetClass' has no member named 'init' +Ethernet.init (USE_THIS_SS_PIN); +``` + +just rename the following file in ./arduino-1.8.13/hardware/esp8266com/esp8266/libraries/Ethernet directory + +- From `Ethernet.h` to `Ethernet_ESP8266.h` + +--- +--- + + +### HOWTO Use analogRead() with ESP32 running WiFi and/or BlueTooth (BT/BLE) + +Please have a look at [**ESP_WiFiManager Issue 39: Not able to read analog port when using the autoconnect example**](https://github.com/khoih-prog/ESP_WiFiManager/issues/39) to have more detailed description and solution of the issue. + +#### 1. ESP32 has 2 ADCs, named ADC1 and ADC2 + +#### 2. ESP32 ADCs functions + +- ADC1 controls ADC function for pins **GPIO32-GPIO39** +- ADC2 controls ADC function for pins **GPIO0, 2, 4, 12-15, 25-27** + +#### 3.. ESP32 WiFi uses ADC2 for WiFi functions + +Look in file [**adc_common.c**](https://github.com/espressif/esp-idf/blob/master/components/driver/adc_common.c#L61) + +> In ADC2, there're two locks used for different cases: +> 1. lock shared with app and Wi-Fi: +> ESP32: +> When Wi-Fi using the ADC2, we assume it will never stop, so app checks the lock and returns immediately if failed. +> ESP32S2: +> The controller's control over the ADC is determined by the arbiter. There is no need to control by lock. +> +> 2. lock shared between tasks: +> when several tasks sharing the ADC2, we want to guarantee +> all the requests will be handled. +> Since conversions are short (about 31us), app returns the lock very soon, +> we use a spinlock to stand there waiting to do conversions one by one. +> +> adc2_spinlock should be acquired first, then adc2_wifi_lock or rtc_spinlock. + + +- In order to use ADC2 for other functions, we have to **acquire complicated firmware locks and very difficult to do** +- So, it's not advisable to use ADC2 with WiFi/BlueTooth (BT/BLE). +- Use ADC1, and pins GPIO32-GPIO39 +- If somehow it's a must to use those pins serviced by ADC2 (**GPIO0, 2, 4, 12, 13, 14, 15, 25, 26 and 27**), use the **fix mentioned at the end** of [**ESP_WiFiManager Issue 39: Not able to read analog port when using the autoconnect example**](https://github.com/khoih-prog/ESP_WiFiManager/issues/39) to work with ESP32 WiFi/BlueTooth (BT/BLE). + + +--- +--- + +### Important Notes + +1. From v1.0.0, code is restructured to provide flexibility to make it easy to support many more **WiFi/Ethernet** modules/shields in the future. Please delete the *.cpp files, replaced by *.hpp files, in the src directory, if *.cpp files still exist after installing new version. + +2. For **Adafruit nRF52**, use the SPI's pins as follows: + + - SS/CS = 10 + - SPI_MOSI = MO(SI) + - SPI_MISO = MI(SO) + - SPI_SCK = SCK + +3. For **Adafruit SAMD21/SAMD51**, use the SPI's CS/SS pin as follows: + + - Itsy-Bitsy M0/M4, Feather M0 (Express), Hallowing M0 Express, Zero, Metro M0 => use CS = 16 = pin A2 + - Feather M4 (SAMD51) => use SS/CS = 9 + - Grand Central M4 => use SS/CS = 53 + - Hallowing M4 => use SS/CS = 10 + - Metro M4 AirLift => use SS/CS = 36 + +To know the default CS/SS pins of not listed boards, check the related `variant.h` files in + +`~/.arduino15/packages/adafruit/hardware/samd/x.y.zz/variants/board_name/variant.h` + +4. For **Arduino SAM DUE**, use the SPI's pins as follows: + + - SS/CS = 10 + - SPI_MOSI = 75 ( pin 4 @ [ICSP connector](pics/ICSP_connector.jpg) ) + - SPI_MISO = 74 ( pin 1 @ [ICSP connector](pics/ICSP_connector.jpg) ) + - SPI_SCK = 76 ( pin 3 @ [ICSP connector](pics/ICSP_connector.jpg) ) + +

+ +

+ +5. For **RP2040**, use the SPI's pins as follows: + + - SS/CS = GP17 default or GP5 by modifying `defines.h` + - MOSI = GP19 + - MISO = GP16 + - SCK = GP18 + +

+ +

+ + +--- +--- + +## Basic Usage + +Please see [Dr. Charles Bell's wiki documentation](https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki), especially [Examples section](https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki/Examples) for the best and detailed explanation. + +There are many modifications to facilitate the usage of [**MySQL_MariaDB_Generic Library**](https://github.com/khoih-prog/MySQL_MariaDB_Generic). Please have a look at the examples to see the differences. + +--- + +### 1. To use Ethernet module/shield + +#### Just select an Ethernet module/shield and the corresponding library to use in defines.h: + +```c++ +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false +``` + +#### In the sketch: + +```c++ +#include "defines.h" + +#include + +... + +MySQL_Connection conn((Client *)&client); +MySQL_Query sql_query = MySQL_Query(&conn); +``` + +--- + +### 2. To use WiFi module/shield + +#### For ESP8266 or ESP32, don't need to select any WiFi module/shield in defines.h. + +#### For remaining boards, just select a WiFi module/shield and the corresponding library to use in defines.h: + +```c++ +// Select only one of these libraries, only for boards other than ESP8266/ESP32 +#define USING_WIFI_ESP_AT false // Using ESP8266_AT_WebServer lib (https://github.com/khoih-prog/ESP8266_AT_WebServer) +#define USING_WIFININA_GENERIC false // Using WiFiNINA_Generic library (https://github.com/khoih-prog/WiFiNINA_Generic) +#define USING_WIFININA false // Using WiFiNINA library +#define USING_WIFIESPAT_LIB true // Using WiFiEspAT library (https://github.com/jandrassy/WiFiEspAT) +#define USING_WIFI_CUSTOM false +``` + +#### In the sketch: + +```c++ +#include "defines.h" +#include "Credentials.h" + +#include + +... + +MySQL_Connection conn((Client *)&client); +MySQL_Query sql_query = MySQL_Query(&conn); +``` + +--- + +### 3. To use WiFiNINA module/shield + +#### Can't use WiFiNINA for ESP8266 or ESP32. + +#### For remaining boards, just select a library to use in defines.h: + +```c++ +// Select only one of these libraries, only for boards other than ESP8266/ESP32 +#define USING_WIFININA_GENERIC true +#define USING_WIFININA false +``` + +#### In the sketch: + +```c++ +#include "defines.h" +#include "Credentials.h" + +#include + +... + +MySQL_Connection conn((Client *)&client); +MySQL_Query sql_query = MySQL_Query(&conn); +``` + +--- +--- + +### Examples + +#### For Ethernet module/shield + + 1. [Basic_Insert](examples/Ethernet/Basic_Insert) + 2. [Basic_Select](examples/Ethernet/Basic_Select) + 3. [Complex_Insert](examples/Ethernet/Complex_Insert) + 4. [Complex_Select](examples/Ethernet/Complex_Select) + 5. [Connect](examples/Ethernet/Connect) + 6. [Connect_By_Hostname](examples/Ethernet/Connect_By_Hostname) + 7. [Connect_Default_Database](examples/Ethernet/Connect_Default_Database) + 8. [Connect_Disconnect](examples/Ethernet/Connect_Disconnect) + 9. [Query_Progmem](examples/Ethernet/Query_Progmem) +10. [Query_Results](examples/Ethernet/Query_Results) +11. [multiFileProject_Ethernet](examples/Ethernet/multiFileProject_Ethernet) **New** + +#### For WiFi module/shield + + 1. [Basic_Insert_ESP](examples/WiFi/Basic_Insert_ESP) + 2. [Basic_Insert_WiFi](examples/WiFi/Basic_Insert_WiFi) + 3. [Basic_Select_WiFi](examples/WiFi/Basic_Select_WiFi) + 4. [Complex_Insert_WiFi](examples/WiFi/Complex_Insert_WiFi) + 5. [Complex_Select_WiFi](examples/WiFi/Complex_Select_WiFi) + 6. [Connect_WiFi](examples/WiFi/Connect_WiFi) + 7. [Connect_Default_Database_WiFi](examples/WiFi/Connect_Default_Database_WiFi) + 8. [Connect_Disconnect_WiFi](examples/WiFi/Connect_Disconnect_WiFi) + 9. [Query_Progmem_WiFi](examples/WiFi/Query_Progmem_WiFi) +10. [Query_Results_WiFi](examples/WiFi/Query_Results_WiFi) +11. [Reboot_WiFi](examples/WiFi/Reboot_WiFi) +12. [multiFileProject_WiFi](examples/WiFi/multiFileProject_WiFi) **New** + +#### For WiFiNINA module/shield + + 1. [Basic_Insert_WiFiNINA](examples/WiFiNINA/Basic_Insert_WiFiNINA) + 2. [Basic_Select_WiFiNINA](examples/WiFiNINA/Basic_Select_WiFiNINA) + 3. [Complex_Insert_WiFiNINA](examples/WiFiNINA/Complex_Insert_WiFiNINA) + 4. [Complex_Select_WiFiNINA](examples/WiFiNINA/Complex_Select_WiFiNINA) + 5. [Connect_WiFiNINA](examples/WiFiNINA/Connect_WiFiNINA) + 6. [Connect_Default_Database_WiFiNINA](examples/WiFiNINA/Connect_Default_Database_WiFiNINA) + 7. [Connect_Disconnect_WiFiNINA](examples/WiFiNINA/Connect_Disconnect_WiFiNINA) + 8. [Query_Progmem_WiFiNINA](examples/WiFiNINA/Query_Progmem_WiFiNINA) + 9. [Query_Results_WiFiNINA](examples/WiFiNINA/Query_Results_WiFiNINA) +10. [Reboot_WiFiNINA](examples/WiFiNINA/Reboot_WiFiNINA) +11. [multiFileProject_WiFiNINA](examples/WiFiNINA/multiFileProject_WiFiNINA) **New** + +#### For WT32_ETH01 + + 1. [Basic_Insert_WT32_ETH01](examples/WT32_ETH01/Basic_Insert_WT32_ETH01) + 2. [Basic_Select_WT32_ETH01](examples/WT32_ETH01/Basic_Select_WT32_ETH01) + 3. [Complex_Insert_WT32_ETH01](examples/WT32_ETH01/Complex_Insert_WT32_ETH01) + 4. [Complex_Select_WT32_ETH01](examples/WT32_ETH01/Complex_Select_WT32_ETH01) + 5. [Connect_WT32_ETH01](examples/WT32_ETH01/Connect_WT32_ETH01) + 6. [Connect_Default_Database_WT32_ETH01](examples/WT32_ETH01/Connect_Default_Database_WT32_ETH01) + 7. [Connect_Disconnect_WT32_ETH01](examples/WT32_ETH01/Connect_Disconnect_WT32_ETH01) + 8. [Query_Progmem_WT32_ETH01](examples/WT32_ETH01/Query_Progmem_WT32_ETH01) + 9. [Query_Results_WT32_ETH01](examples/WT32_ETH01/Query_Results_WT32_ETH01) +10. [Reboot_WT32_ETH01](examples/WT32_ETH01/Reboot_WT32_ETH01) +11. [multiFileProject_WT32_ETH01](examples/WT32_ETH01/multiFileProject_WT32_ETH01) **New** + +#### For Teensy 4.1 NativeEthernet + + 1. [Basic_Insert](examples/NativeEthernet/Basic_Insert) + 2. [Basic_Select](examples/NativeEthernet/Basic_Select) + 3. [Complex_Insert](examples/NativeEthernet/Complex_Insert) + 4. [Complex_Select](examples/NativeEthernet/Complex_Select) + 5. [Connect](examples/NativeEthernet/Connect) + 6. [Connect_By_Hostname](examples/NativeEthernet/Connect_By_Hostname) + 7. [Connect_Default_Database](examples/NativeEthernet/Connect_Default_Database) + 8. [Connect_Disconnect](examples/NativeEthernet/Connect_Disconnect) + 9. [Query_Progmem](examples/NativeEthernet/Query_Progmem) +10. [Query_Results](examples/NativeEthernet/Query_Results) +11. [multiFileProject_NativeEthernet](examples/NativeEthernet/multiFileProject_NativeEthernet) **New** + +#### For Teensy 4.1 QNEthernet + + 1. [Basic_Insert](examples/QNEthernet/Basic_Insert) + 2. [Basic_Select](examples/QNEthernet/Basic_Select) + 3. [Complex_Insert](examples/QNEthernet/Complex_Insert) + 4. [Complex_Select](examples/QNEthernet/Complex_Select) + 5. [Connect](examples/QNEthernet/Connect) + 6. [Connect_By_Hostname](examples/QNEthernet/Connect_By_Hostname) + 7. [Connect_Default_Database](examples/QNEthernet/Connect_Default_Database) + 8. [Connect_Disconnect](examples/QNEthernet/Connect_Disconnect) + 9. [Query_Progmem](examples/QNEthernet/Query_Progmem) +10. [Query_Results](examples/QNEthernet/Query_Results) +11. [multiFileProject_QNEthernet](examples/QNEthernet/multiFileProject_QNEthernet) **New** + +#### For Portenta_H7 Ethernet + + 1. [Basic_Insert](examples/Portenta_H7/Ethernet/Basic_Insert) + 2. [Basic_Select](examples/Portenta_H7/Ethernet/Basic_Select) + 3. [Complex_Insert](examples/Portenta_H7/Ethernet/Complex_Insert) + 4. [Connect](examples/Portenta_H7/Ethernet/Connect) + 5. [Connect_By_Hostname](examples/Portenta_H7/Ethernet/Connect_By_Hostname) + 6. [Connect_Default_Database](examples/Portenta_H7/Ethernet/Connect_Default_Database) + 7. [multiFileProject_Portenta_H7_Ethernet](examples/Portenta_H7/Ethernet/multiFileProject_Portenta_H7_Ethernet) **New** + + +#### For Portenta_H7 WiFi + + 1. [Basic_Insert_WiFi](examples/Portenta_H7/WiFi/Basic_Insert_WiFi) + 2. [Basic_Select_WiFi](examples/Portenta_H7/WiFi/Basic_Select_WiFi) + 3. [Complex_Insert_WiFi](examples/Portenta_H7/WiFi/Complex_Insert_WiFi) + 4. [Complex_Select_WiFi](examples/Portenta_H7/WiFi/Complex_Select_WiFi) + 5. [Connect_WiFi](examples/Portenta_H7/WiFi/Connect_WiFi) + 6. [Connect_Default_Database_WiFi](examples/Portenta_H7/WiFi/Connect_Default_Database_WiFi) + 7. [Connect_Disconnect_WiFi](examples/Portenta_H7/WiFi/Connect_Disconnect_WiFi) + 8. [Reboot_WiFi](examples/Portenta_H7/WiFi/Reboot_WiFi) + 9. [multiFileProject_Portenta_H7_WiFi](examples/Portenta_H7/WiFi/multiFileProject_Portenta_H7_WiFi) **New** + + + +--- +--- + +### Example [Basic_Select](examples/Ethernet/Basic_Select) + +Please take a look at other examples, as well. + +#### 1. File [Basic_Select.ino](examples/Ethernet/Basic_Select/Basic_Select.ino) + +https://github.com/khoih-prog/MySQL_MariaDB_Generic/blob/78ff2dbda8caaa10266eb93acd286641aba7dd27/examples/Ethernet/Basic_Select/Basic_Select.ino#L50-L326 + + + +#### 2. File [defines.h](examples/Ethernet/Basic_Select/defines.h) + +https://github.com/khoih-prog/MySQL_MariaDB_Generic/blob/78ff2dbda8caaa10266eb93acd286641aba7dd27/examples/Ethernet/Basic_Select/defines.h#L16-L463 + + +--- +--- + +### Debug Terminal Output Samples + +#### 1. Query_Progmem on NRF52840_FEATHER using W5x00/Ethernet_Generic Library + +This is terminal debug output when running [Query_Progmem](examples/Ethernet/Query_Progmem) on nRF52 **Adafruit NRF52840_FEATHER using W5500 Ethernet module and Ethernet_Generic library** connecting to MariaDB Server. + +``` +Starting Query_Progmem on NRF52840_FEATHER using W5x00/Ethernet_Generic Library +MySQL_MariaDB_Generic v1.7.2 +Ethernet_Generic W5500 init, using SPI_CS = 10, number of sockets = 4 +Using mac index = 10 +Connected! IP address: 192.168.2.145 +Connecting to SQL Server @ your_account.ddns.net, Port = 5698 +User = invited-guest, PW = the-invited-guest +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.34-MariaDB-0+deb10u1 + +Running SELECT from PROGMEM and printing results + +SELECT * FROM world.city LIMIT 12 +ID,Name,CountryCode,District,Population +1,Kabul,AFG,Kabol,1780000 +2,Qandahar,AFG,Qandahar,237500 +3,Herat,AFG,Herat,186800 +4,Mazar-e-Sharif,AFG,Balkh,127800 +5,Amsterdam,NLD,Noord-Holland,731200 +6,Rotterdam,NLD,Zuid-Holland,593321 +7,Haag,NLD,Zuid-Holland,440900 +8,Utrecht,NLD,Utrecht,234323 +9,Eindhoven,NLD,Noord-Brabant,201843 +10,Tilburg,NLD,Noord-Brabant,193238 +11,Groningen,NLD,Groningen,172701 +12,Breda,NLD,Noord-Brabant,160398 +12 rows in result. +``` + +--- + +#### 2. Complex_Select on NUCLEO_F767ZI using LAN8742A/STM32Ethernet Library + +This is terminal debug output when running [Complex_Select](examples/Ethernet/Complex_Select) on STM32F7 **Nucleo-144 NUCLEO_F767ZI using LAN8742A built-in Ethernet and STM32Ethernet library** connecting to MariaDB Server. + +``` +Starting Complex_Select on NUCLEO_F767ZI using LAN8742A/STM32Ethernet Library +MySQL_MariaDB_Generic v1.7.2 +Using mac index = 0 +Connected! IP address: 192.168.2.165 +Connecting to SQL Server @ your_account.ddns.net, Port = 5698 +User = invited-guest, PW = the-invited-guest, DB = world +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.34-MariaDB-0+deb10u1 +==================================================== +> Running SELECT with dynamically supplied parameter +SELECT name, population FROM world.city WHERE population < 857880 ORDER BY population DESC LIMIT 12; +name,population +Naucalpan de Ju⸮rez,857511 +Pikine,855287 +Lubumbashi,851381 +Monrovia,850000 +Freetown,850000 +Zaporizzja,848000 +Handan,840000 +S⸮o Lu⸮s,837588 +Wuxi,830000 +Ouagadougou,824000 +Ciudad de Guatemala,823301 +Coimbatore,816321 +[SQL] Disconnected + +Sleeping... +================================================ +Connecting... +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.34-MariaDB-0+deb10u1 +==================================================== +> Running SELECT with dynamically supplied parameter +SELECT name, population FROM world.city WHERE population < 972170 ORDER BY population DESC LIMIT 12; +name,population +Mekka,965700 +K⸮ln,962507 +Managua,959000 +Detroit,951270 +Shenzhen,950500 +Haora (Howrah),950435 +Campinas,950043 +Brazzaville,950000 +Khartum,947483 +Karaj,940968 +Taichung,940589 +Santa Cruz de la Sierra,935361 +[SQL] Disconnected + +Sleeping... +================================================ + +``` + +--- + +#### 3. Query_Results_WiFi on ITSYBITSY_M4 + +This is terminal debug output when running [Query_Results_WiFi](examples/WiFi/Query_Results_WiFi) on SAMD51 **Adafruit ITSYBITSY_M4 using ESP8266-AT WiFi shield and WiFiEspAT library** connecting to MySQL Server. + +``` +Starting Query_Results_WiFi on ITSYBITSY_M4 +MySQL_MariaDB_Generic v1.7.2 +Using WiFiEspAT Library +WiFi shield init done +Connecting to HueNet1 +Connected to network. My IP address is: 192.168.2.32 +Connecting to SQL Server @ your_account.ddns.net, Port = 5698 +User = invited-guest, PW = the-invited-guest +Connecting... +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.34-MariaDB-0+deb10u1 + +Running SELECT and printing results + +SELECT * FROM world.city LIMIT 6 +ID, Name, CountryCode, District, Population +1, Kabul, AFG, Kabol, 1780000 +2, Qandahar, AFG, Qandahar, 237500 +3, Herat, AFG, Herat, 186800 +4, Mazar-e-Sharif, AFG, Balkh, 127800 +5, Amsterdam, NLD, Noord-Holland, 731200 +6, Rotterdam, NLD, Zuid-Holland, 593321 +[SQL] Disconnected + +Sleeping... +================================================ +``` + +--- + +#### 4. Basic_Select_WiFi on SEEED_XIAO_M0 + +This is terminal debug output when running [Basic_Select_WiFi](examples/WiFi/Basic_Select_WiFi) on SAMD21 **Seeeduino SEEED_XIAO_M0 using ESP8266-AT WiFi shield and WiFiEspAT library** connecting to MariaDB Server. + + +``` +Starting Basic_Select_WiFi on SEEED_XIAO_M0 +MySQL_MariaDB_Generic v1.7.2 +Using WiFiEspAT Library +WiFi shield init done +Connecting to HueNet1 +Connected to network. My IP address is: 192.168.2.32 +Connecting to SQL Server @ your_account.ddns.net, Port = 5698 +User = invited-guest, PW = the-invited-guest, DB = world +Connecting... +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.34-MariaDB-0+deb10u1 +1) Demonstrating using a dynamically allocated query. +SELECT population FROM world.city WHERE name = 'Toronto' + Toronto pop = 688275 +2) Demonstrating using a local, global query. +SELECT population FROM world.city WHERE name = 'Toronto' + Toronto pop = 688275 + Toronto pop increased by 11725 = 700000 +[SQL] Disconnected + +Sleeping... +================================================ + +``` + +--- + +#### 5. Query_Results_WiFiNINA on SAMD_NANO_33_IOT + +This is terminal debug output when running [Query_Results_WiFiNINA](examples/WiFiNINA/Query_Results_WiFiNINA) on SAMD21 **Arduino SAMD_NANO_33_IOT using built-in WiFiNINA and WiFiNINA_Generic library** connecting to MariaDB Server. + + +``` +Starting Query_Results_WiFiNINA on SAMD_NANO_33_IOT +MySQL_MariaDB_Generic v1.7.2 +Attempting to connect to SSID: HueNet1 +SSID: HueNet1 +IP Address: 192.168.2.118 +signal strength (RSSI):-40 dBm +Connecting to SQL Server @ your_account.ddns.net, Port = 5698 +User = invited-guest, PW = the-invited-guest +Connecting... +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.34-MariaDB-0+deb10u1 + +Running SELECT and printing results + +SELECT * FROM world.city LIMIT 12 +ID, Name, CountryCode, District, Population +1, Kabul, AFG, Kabol, 1780000 +2, Qandahar, AFG, Qandahar, 237500 +3, Herat, AFG, Herat, 186800 +4, Mazar-e-Sharif, AFG, Balkh, 127800 +5, Amsterdam, NLD, Noord-Holland, 731200 +6, Rotterdam, NLD, Zuid-Holland, 593321 +7, Haag, NLD, Zuid-Holland, 440900 +8, Utrecht, NLD, Utrecht, 234323 +9, Eindhoven, NLD, Noord-Brabant, 201843 +10, Tilburg, NLD, Noord-Brabant, 193238 +11, Groningen, NLD, Groningen, 172701 +12, Breda, NLD, Noord-Brabant, 160398 +[SQL] Disconnected + +Sleeping... +================================================ + +``` + +--- + +#### 6. Connect_By_Hostname on SAM DUE using W5x00/Ethernet_Generic Library + +This is terminal debug output when running [Connect_By_Hostname](examples/Ethernet/Connect_By_Hostname) on **Arduino SAM DUE using W5100 Ethernet shield and Ethernet_Generic library** connecting to MariaDB Server. + + +``` +Starting Connect_By_Hostname on SAM DUE using W5x00/Ethernet_Generic Library +MySQL_MariaDB_Generic v1.7.2 +_pinCS = 0 +W5100 init, using SS_PIN_DEFAULT = 10, new ss_pin = 10, W5100Class::ss_pin = 10 +W5100::init: W5100, SSIZE =4096 +Using mac index = 2 +Connected! IP address: 192.168.2.177 +Connecting to SQL Server @ your_account.ddns.net, Port = 5698 +User = invited-guest, PW = the-invited-guest +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.34-MariaDB-0+deb10u1 +[SQL] Disconnected +``` + +--- + +#### 7. Complex_Select on NRF52840_FEATHER using ENC28J60/UIPEthernet Library + +This is terminal debug output when running [Complex_Select](examples/Ethernet/Complex_Select) on **NRF52840_FEATHER using ENC28J60 Ethernet shield and UIPEthernet library** connecting to MariaDB Server. + + +``` +Starting Complex_Select on NRF52840_FEATHER using ENC28J60/UIPEthernet Library +MySQL_MariaDB_Generic v1.7.2 +ENC28J60_CONTROL_CS =10 +SS =5 +SPI_MOSI =25 +SPI_MISO =24 +SPI_SCK =26 +Using mac index = 5 +Connected! IP address: 192.168.2.161 +Connecting to SQL Server @ your_account.ddns.net, Port = 5698 +User = invited-guest, PW = the-invited-guest, DB = world +Connecting... +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.34-MariaDB-0+deb10u1 +==================================================== +> Running SELECT with dynamically supplied parameter +SELECT name, population FROM world.city WHERE population < 885240 ORDER BY population DESC LIMIT 12; +name,population +Port-au-Prince,884472 +Mosul,879000 +Barquisimeto,877239 +Krasnojarsk,875500 +Saratov,874000 +Shubra al-Khayma,870716 +S⸮o Gon⸮alo,869254 +Songnam,869094 +Chiba,863930 +Nova Igua⸮u,862225 +Naucalpan de Ju⸮rez,857511 +Pikine,855287 +[SQL] Disconnected + +Sleeping... +================================================ +Connecting... +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.34-MariaDB-0+deb10u1 +==================================================== +> Running SELECT with dynamically supplied parameter +SELECT name, population FROM world.city WHERE population < 1015280 ORDER BY population DESC LIMIT 12; +name,population +Kalyan,1014557 +Birmingham,1013000 +Rostov-na-Donu,1012700 +Odesa,1011000 +Perm,1009700 +Napoli,1002619 +Zapopan,1002239 +Amman,1000000 +Mogadishu,997000 +Volgograd,993400 +Sendai,989975 +Peshawar,988005 +[SQL] Disconnected + +Sleeping... +================================================ +Connecting... +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.34-MariaDB-0+deb10u1 +==================================================== +> Running SELECT with dynamically supplied parameter +SELECT name, population FROM world.city WHERE population < 1193330 ORDER BY population DESC LIMIT 12; +name,population +Tabriz,1191043 +Dallas,1188580 +Bel⸮m,1186926 +Multan,1182441 +Praha,1181126 +Kalookan,1177604 +Nanning,1161800 +C⸮rdoba,1157507 +Samara,1156100 +Hyderabad,1151274 +Omsk,1148900 +Davao,1147116 +[SQL] Disconnected + +Sleeping... +================================================ + +``` + +--- + +#### 8. Complex_Select on NRF52840_FEATHER using ENC28J60/EthernetENC Library + +This is terminal debug output when running [Complex_Select](examples/Ethernet/Complex_Select) on **NRF52840_FEATHER using ENC28J60 Ethernet shield and EthernetENC library** connecting to MariaDB Server. + +``` +Starting Complex_Select on NRF52840_FEATHER, with ENC28J60 using EthernetENC Library +MySQL_MariaDB_Generic v1.7.2 +[SQL] ========================================= +[SQL] Default SPI pinout: +[SQL] MOSI: 25 +[SQL] MISO: 24 +[SQL] SCK: 26 +[SQL] SS: 5 +[SQL] ========================================= +[SQL] Board : NRF52840_FEATHER , setCsPin: 10 +[SQL] ========================================= +[SQL] Currently Used SPI pinout: +[SQL] MOSI: 25 +[SQL] MISO: 24 +[SQL] SCK: 26 +[SQL] SS: 5 +[SQL] ========================================= +Using mac index = 15 +Connected! IP address: 192.168.2.98 +Connecting to SQL Server @ your_account.ddns.net, Port = 5698 +User = invited-guest, PW = the-invited-guest, DB = world +Connecting... +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.34-MariaDB-0+deb10u1 +==================================================== +> Running SELECT with dynamically supplied parameter +SELECT name, population FROM world.city WHERE population < 831690 ORDER BY population DESC LIMIT 12; +name,population +Wuxi,830000 +Ouagadougou,824000 +Ciudad de Guatemala,823301 +Coimbatore,816321 +Tegucigalpa,813900 +Xuzhou,810000 +Bamako,809552 +Mbuji-Mayi,806475 +Cartagena,805757 +Ahvaz,804980 +Bengasi,804000 +Thane (Thana),803389 +[SQL] Disconnected + +Sleeping... +================================================ +``` + +--- + +#### 9. Query_Progmem on NRF52840_FEATHER using ENC28J60/EthernetENC Library + +This is terminal debug output when running [Query_Progmem](examples/Ethernet/Query_Progmem) on **NRF52840_FEATHER using ENC28J60 Ethernet shield and EthernetENC library** connecting to MariaDB Server. + + +``` +Starting Query_Progmem on NRF52840_FEATHER, with ENC28J60 using EthernetENC Library +MySQL_MariaDB_Generic v1.7.2 +[SQL] ========================================= +[SQL] Default SPI pinout: +[SQL] MOSI: 25 +[SQL] MISO: 24 +[SQL] SCK: 26 +[SQL] SS: 5 +[SQL] ========================================= +[SQL] Board : NRF52840_FEATHER , setCsPin: 10 +[SQL] ========================================= +[SQL] Currently Used SPI pinout: +[SQL] MOSI: 25 +[SQL] MISO: 24 +[SQL] SCK: 26 +[SQL] SS: 5 +[SQL] ========================================= +Using mac index = 13 +Connected! IP address: 192.168.2.106 +Connecting to SQL Server @ your_account.ddns.net, Port = 5698 +User = invited-guest, PW = the-invited-guest +Connecting... +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.34-MariaDB-0+deb10u1 + +Running SELECT from PROGMEM and printing results + +SELECT * FROM test_arduino.hello_arduino LIMIT 6 +num,message,recorded +351,Hello, Arduino!,2020-08-18 13:52:35 +352,Hello, Arduino!,2020-08-18 13:53:42 +353,Hello, Arduino!,2020-08-18 13:54:57 +354,Hello, Arduino!,2020-08-18 13:56:03 +355,Hello, Arduino!,2020-08-18 22:37:21 +356,Hello, Arduino!,2020-08-18 22:38:28 +6 rows in result. +[SQL] Disconnected + +Sleeping... +================================================ +``` + +--- + +#### 10. Basic_Insert_ESP on ESP8266_NODEMCU_ESP12E + +This is terminal debug output when running [Basic_Insert_ESP](examples/WiFi/Basic_Insert_ESP) on **ESP8266_NODEMCU_ESP12E using ESP8266 core v3.0.0** connecting to MariaDB Server. + + +``` +Starting Basic_Insert_ESP on ESP8266_NODEMCU_ESP12E +MySQL_MariaDB_Generic v1.7.2 +Connecting to HueNet1 +...........Connected to network. My IP address is: 192.168.2.135 +Connecting to SQL Server @ your_account.ddns.net , Port = 5698 +User = invited-guest , PW = the-invited-guest , DB = test_arduino +Connecting... +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.27-MariaDB-0+deb10u1 +INSERT INTO test_arduino.hello_arduino (message) VALUES ('Hello, Arduino!') +Data Inserted. +[SQL] Disconnected + +Sleeping... +================================================ +``` + +--- + +#### 11. Basic_Insert_ESP on ESP32S2_DEV + +This is terminal debug output when running [Basic_Insert_ESP](examples/WiFi/Basic_Insert_ESP) on **ESP32S2_DEV using ESP32 core v1.0.6** connecting to MariaDB Server. + + +``` +Starting Basic_Insert_ESP on ESP32S2_DEV +MySQL_MariaDB_Generic v1.7.2 +Connecting to HueNet1 +.......Connected to network. My IP address is: 192.168.2.190 +Connecting to SQL Server @ your_account.ddns.net , Port = 5698 +User = invited-guest , PW = the-invited-guest , DB = test_arduino +Connecting... +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.27-MariaDB-0+deb10u1 +INSERT INTO test_arduino.hello_arduino (message) VALUES ('Hello, Arduino!') +Data Inserted. +[SQL] Disconnected + +Sleeping... +================================================ +``` + +--- + +#### 12. Basic_Select_WiFiNINA on MBED NANO_RP2040_CONNECT + +This is terminal debug output when running [Basic_Select_WiFiNINA](examples/WiFiNINA/Basic_Select_WiFiNINA) on **MBED NANO_RP2040_CONNECT** connecting to MariaDB Server. + + +``` +Starting Basic_Select_WiFiNINA on MBED NANO_RP2040_CONNECT +MySQL_MariaDB_Generic v1.7.2 +Attempting to connect to SSID: HueNet1 +SSID: HueNet1 +IP Address: 192.168.2.153 +signal strength (RSSI):-44 dBm +Connecting to SQL Server @ your_account.ddns.net, Port = 5698 +User = invited-guest, PW = the-invited-guest, DB = world +Connecting... +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.27-MariaDB-0+deb10u1 +1) Demonstrating using a dynamically allocated query. +SELECT population FROM world.city WHERE name = 'Toronto' + Toronto pop = 688275 +2) Demonstrating using a local, global query. +SELECT population FROM world.city WHERE name = 'Toronto' + Toronto pop = 688275 + Toronto pop increased by 11725 = 700000 +[SQL] Disconnected + +Sleeping... +================================================ +``` + +--- + +#### 13. Complex_Select on MBED RASPBERRY_PI_PICO using W5x00/Ethernet_Generic Library + +This is terminal debug output when running [Complex_Select](examples/Ethernet/Complex_Select) on **MBED RASPBERRY_PI_PICO, with W5x00 using Ethernet_Generic Library** connecting to MariaDB Server, using [ArduinoCore-mbed mbed_rp2040 core](https://github.com/arduino/ArduinoCore-mbed) + + +``` +Starting Complex_Select on MBED RASPBERRY_PI_PICO , with W5x00 using Ethernet_Generic Library on SPI0/SPI +MySQL_MariaDB_Generic v1.7.2 +[SQL] ========================================= +[SQL] Default SPI pinout: +[SQL] MOSI: 19 +[SQL] MISO: 16 +[SQL] SCK: 18 +[SQL] SS: 17 +[SQL] ========================================= +[SQL] RPIPICO setCsPin: 17 +[SQL] Currently Used SPI pinout: +[SQL] MOSI: 19 +[SQL] MISO: 16 +[SQL] SCK: 18 +[SQL] SS: 17 +[SQL] ========================= +Using mac index = 2 +Connected! IP address: 192.168.2.92 +Connecting to SQL Server @ 192.168.2.112 , Port = 5698 +User = invited-guest , PW = the-invited-guest , DB = world +Connecting... +[SQL] Connecting to Server: 192.168.2.112 , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.34-MariaDB-0+deb10u1 +==================================================== +> Running SELECT with dynamically supplied parameter +SELECT name, population FROM world.city WHERE population < 827440 ORDER BY population DESC LIMIT 12; +name,population +Ouagadougou,824000 +Ciudad de Guatemala,823301 +Coimbatore,816321 +Tegucigalpa,813900 +Xuzhou,810000 +Bamako,809552 +Mbuji-Mayi,806475 +Cartagena,805757 +Ahvaz,804980 +Bengasi,804000 +Thane (Thana),803389 +L⸮dz,800110 +[SQL] Disconnected + +Sleeping... +================================================ +Connecting... +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.27-MariaDB-0+deb10u1 +==================================================== +> Running SELECT with dynamically supplied parameter +SELECT name, population FROM world.city WHERE population < 934480 ORDER BY population DESC LIMIT 12; +name,population +Varanasi (Benares),929270 +Patna,917243 +Hohhot,916700 +Rosario,907718 +Voronez,907700 +Soweto,904165 +Torino,903705 +San Jose,894943 +Srinagar,892506 +Agra,891790 +Kampala,890800 +Mandalay,885300 +[SQL] Disconnected + +Sleeping... +================================================ +``` + +--- + +#### 14. Complex_Select on RASPBERRY_PI_PICO using W5x00/Ethernet_Generic Library + +This is terminal debug output when running [Complex_Select](examples/Ethernet/Complex_Select) on **RASPBERRY_PI_PICO, with W5x00 using Ethernet_Generic Library** connecting to MariaDB Server, using [arduino-pico rp2040 core](https://github.com/earlephilhower/arduino-pico) + + +``` +Starting Complex_Select on RASPBERRY_PI_PICO , with W5x00 using Ethernet_Generic Library on SPI1 +MySQL_MariaDB_Generic v1.7.2 +[SQL] ========================================= +[SQL] Default SPI pinout: +[SQL] MOSI: 19 +[SQL] MISO: 16 +[SQL] SCK: 18 +[SQL] SS: 17 +[SQL] ========================================= +[SQL] RPIPICO setCsPin: 13 +[SQL] Currently Used SPI pinout: +[SQL] MOSI: 15 +[SQL] MISO: 12 +[SQL] SCK: 14 +[SQL] SS: 13 +[SQL] ========================= +Using mac index = 0 +Connected! IP address: 192.168.2.172 +Connecting to SQL Server @ 192.168.2.112 , Port = 5698 +User = invited-guest , PW = the-invited-guest , DB = world +Connecting... +[SQL] Connecting to Server: 192.168.2.112 , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.34-MariaDB-0+deb10u1 +==================================================== +> Running SELECT with dynamically supplied parameter +SELECT name, population FROM world.city WHERE population < 900290 ORDER BY population DESC LIMIT 12; +name,population +San Jose,894943 +Srinagar,892506 +Agra,891790 +Kampala,890800 +Mandalay,885300 +Port-au-Prince,884472 +Mosul,879000 +Barquisimeto,877239 +Krasnojarsk,875500 +Saratov,874000 +Shubra al-Khayma,870716 +S⸮o Gon⸮alo,869254 +[SQL] Disconnected + +Sleeping... +================================================ +``` + +--- + +#### 15. Complex_Select_WT32_ETH01 on WT32-ETH01 + +This is terminal debug output when running [Complex_Select_WT32_ETH01](examples/WT32_ETH01/Complex_Select_WT32_ETH01) on **WT32_ETH01** connecting to MariaDB Server. + +``` +Starting Complex_Select_WT32_ETH01 on WT32-ETH01 +WebServer_WT32_ETH01 v1.4.1 +MySQL_MariaDB_Generic v1.7.2 +ETH MAC: A8:03:2A:A1:61:73, IPv4: 192.168.2.232 +FULL_DUPLEX, 100Mbps +Connected to network. My IP address is: 192.168.2.232 +Connecting to SQL Server @ your_account.ddns.net , Port = 5698 +User = invited-guest , PW = the-invited-guest , DB = world +Connecting... +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.27-MariaDB-0+deb10u1 +==================================================== +> Running SELECT with dynamically supplied parameter +SELECT name, population FROM world.city WHERE population < 848510 ORDER BY population DESC LIMIT 6; +name,population +Zaporizzja,848000 +Handan,840000 +S⸮o Lu⸮s,837588 +Wuxi,830000 +Ouagadougou,824000 +Ciudad de Guatemala,823301 +[SQL] Disconnected + +Sleeping... +================================================ +Connecting... +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.27-MariaDB-0+deb10u1 +==================================================== +> Running SELECT with dynamically supplied parameter +SELECT name, population FROM world.city WHERE population < 962720 ORDER BY population DESC LIMIT 6; +name,population +K⸮ln,962507 +Managua,959000 +Detroit,951270 +Shenzhen,950500 +Haora (Howrah),950435 +Campinas,950043 +[SQL] Disconnected + +Sleeping... +================================================ +``` + +--- + + +#### 16. Complex_Select on Teensy 4.1 with NativeEthernet + +This is terminal debug output when running [Complex_Select](examples/NativeEthernet/Complex_Select) on **Teensy 4.1 with NativeEthernet** connecting to MariaDB Server. + +``` +Starting Complex_Select on Teensy 4.1 , with NativeEthernet +MySQL_MariaDB_Generic v1.7.2 +Using mac index = 2 +Connected! IP address: 192.168.2.86 +Connecting to SQL Server @ your_account.ddns.net , Port = 5698 +User = invited-guest , PW = the-invited-guest , DB = world +Connecting... +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.29-MariaDB-0+deb10u1 +==================================================== +> Running SELECT with dynamically supplied parameter +SELECT name, population FROM world.city WHERE population < 940450 ORDER BY population DESC LIMIT 12; +name,population +Santa Cruz de la Sierra,935361 +Varanasi (Benares),929270 +Patna,917243 +Hohhot,916700 +Rosario,907718 +Voronez,907700 +Soweto,904165 +Torino,903705 +San Jose,894943 +Srinagar,892506 +Agra,891790 +Kampala,890800 +[SQL] Disconnected + +Sleeping... +================================================ +Connecting... +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.29-MariaDB-0+deb10u1 +==================================================== +> Running SELECT with dynamically supplied parameter +SELECT name, population FROM world.city WHERE population < 1054490 ORDER BY population DESC LIMIT 12; +name,population +Shiraz,1053025 +Donetsk,1050000 +Ludhiana,1042740 +Jilin,1040000 +Tangshan,1040000 +Vadodara (Baroda),1031346 +Maputo,1018938 +Montr�al,1016376 +Kitakyushu,1016264 +Kalyan,1014557 +Birmingham,1013000 +Rostov-na-Donu,1012700 +[SQL] Disconnected + +Sleeping... +``` + +--- + + +#### 17. Complex_Select on Teensy 4.1 with QNEthernet + +This is terminal debug output when running [Complex_Select](examples/NativeEthernet/Complex_Select) on **Teensy 4.1 using QNEthernet** connecting to MariaDB Server. + +``` +Starting Complex_Select on TEENSY 4.1 using QNEthernet +MySQL_MariaDB_Generic v1.7.2 +=========== USE_QN_ETHERNET =========== +Initialize Ethernet using static IP => Connected! IP address: 192.168.2.222 +Connecting to SQL Server @ your_account.ddns.net , Port = 5698 +User = invited-guest , PW = the-invited-guest , DB = world +Connecting... +[SQL] Connecting to Server: your_account.ddns.net , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.29-MariaDB-0+deb10u1 +==================================================== +> Running SELECT with dynamically supplied parameter +SELECT name, population FROM world.city WHERE population < 837930 ORDER BY population DESC LIMIT 12; +name,population +S�o Lu�s,837588 +Wuxi,830000 +Ouagadougou,824000 +Ciudad de Guatemala,823301 +Coimbatore,816321 +Tegucigalpa,813900 +Xuzhou,810000 +Bamako,809552 +Mbuji-Mayi,806475 +Cartagena,805757 +Ahvaz,804980 +Bengasi,804000 +[SQL] Disconnected + +Sleeping... +================================================ +``` + +--- + + +#### 18. Complex_Insert on PORTENTA_H7_M7 using Portenta_Ethernet + +This is terminal debug output when running [Complex_Insert](examples/Portenta_H7/Ethernet/Complex_Insert) on **PORTENTA_H7_M7 using Portenta_Ethernet** connecting to MariaDB Server. + +``` +Starting Complex_Insert on PORTENTA_H7_M7 , with Ethernet using Portenta_Ethernet Library +MySQL_MariaDB_Generic v1.7.2 +Using mac index = 14 +Connected! IP address: 192.168.2.132 +Connecting to SQL Server @ 192.168.2.112 , Port = 5698 +User = invited-guest , PW = the-invited-guest +DB = test_arduino , Table = hello_sensor +Connecting... +[SQL] Connecting to Server: 192.168.2.112 , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.29-MariaDB-0+deb10u1 +INSERT INTO test_arduino.hello_sensor (message, sensor_num, value) VALUES ('test sensor',24,50.1) +Complex Data Inserted. +[SQL] Disconnected + +Sleeping... +================================================ +``` + +--- + + +#### 19. Complex_Select_WiFi on PORTENTA_H7_M7 + +This is terminal debug output when running [Complex_Insert_WiFi](examples/Portenta_H7/WiFi/Complex_Insert_WiFi) on **TPORTENTA_H7_M7 using Murata WiFi** connecting to MariaDB Server. + +``` +Starting Complex_Select_WiFi on PORTENTA_H7_M7 +MySQL_MariaDB_Generic v1.7.2 +Connecting to HueNet1 +Connected to network. My IP address is: 192.168.2.130 +Connecting to SQL Server @ 192.168.2.112 , Port = 5698 +User = invited-guest , PW = the-invited-guest , DB = world +Connecting... +[SQL] Connecting to Server: 192.168.2.112 , Port = 5698 +[SQL] Connected. Server Version = 5.5.5-10.3.29-MariaDB-0+deb10u1 +==================================================== +> Running SELECT with dynamically supplied parameter +SELECT name, population FROM world.city WHERE population < 928790 ORDER BY population DESC LIMIT 6; +name,population +Patna,917243 +Hohhot,916700 +Rosario,907718 +Voronez,907700 +Soweto,904165 +Torino,903705 +[SQL] Disconnected + +Sleeping... +================================================ +``` + + +--- +--- + +### Debug + +Debug is enabled by default on Serial. Debug Level from 0 to 4. To disable, change the _MYSQL_LOGLEVEL_ to 0 + +```cpp +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 +``` + +--- + +### Troubleshooting + +If you get compilation errors, more often than not, you may need to install a newer version of the core for Arduino boards. + +Sometimes, the library will only work if you update the board core to the latest version because I am using newly added functions. + + +--- +--- + + +### Issues ### + +Submit issues to: [MySQL_MariaDB_Generic issues](https://github.com/khoih-prog/MySQL_MariaDB_Generic/issues) + +--- +--- + +### TO DO + + 1. Support more boards + 2. Support more non-compatible Ethernet Libraries such as Ethernet_Shield_W5200, EtherCard, EtherSia + 3. Bug fixing. + +--- + +### DONE + + 1. Add support to **Arduino SAMD21 (ZERO, MKR, NANO_33_IOT, etc.)** + 2. Add support to **Adafruit SAMD21 (Itsy-Bitsy M0, Metro M0, Feather M0 Express, etc.)**. + 3. Add support to **Adafruit SAMD51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.)**. + 4. Add support to **Seeeduino SAMD21/SAMD51: LoRaWAN, Zero, Femto M0, XIAO M0, Wio GPS Board, Wio Terminal, Grove UI Wireless, etc.** + 5. Add support to **Adafruit nRF52 ( Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.**. + 6. Add support to **STM32F/L/H/G/WB/MP1.** + 7. Add support to SAM DUE and AVR Mega. + 8. Add support to ESP32/ESP8266. + 9. Add support to **WiFiNINA** using [`WiFiNINA_Generic library`](https://github.com/khoih-prog/WiFiNINA_Generic) and WiFiNINA library. +10. Add support to **Ethernet W5x00**, using either [`Ethernet`](https://www.arduino.cc/en/Reference/Ethernet), [`Ethernet2`](https://github.com/khoih-prog/Ethernet2), [`Ethernet3`](https://github.com/khoih-prog/Ethernet3) or [`EthernetLarge`](https://github.com/OPEnSLab-OSU/EthernetLarge) library +11. Add support to **ESP8266/ESP32-AT**, using either [`ESP8266_AT_WebServer library`](https://github.com/khoih-prog/ESP8266_AT_WebServer) or [`WiFiEspAT library`](https://github.com/jandrassy/WiFiEspAT) library +12. Add support to **Ethernet LAN8742A**, using [`STM32Ethernet library`](https://github.com/stm32duino/STM32Ethernet) and [`STM32duino_LwIP library`](https://github.com/stm32duino/LwIP). +13. Split each example into several manageable files. +14. Support ENC28J60 using [`UIPEthernet library`](https://github.com/UIPEthernet/UIPEthernet). +15. Support ENC28J60 using [`EthernetENC library`](https://github.com/jandrassy/EthernetENC). +16. Add Table of Contents and Version String +17. Add support to **ESP32-S2 (ESP32-S2 Saola, AI-Thinker ESP-12K, etc.)** +18. Add support to RP2040-based boards, such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, using [**Earle Philhower's arduino-pico core**](https://github.com/earlephilhower/arduino-pico) to use LittleFS with or without Blynk/WiFiManager features. +19. Add support to RP2040-based boards, such as **Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, using [**Arduino-mbed RP2040** core](https://github.com/arduino/ArduinoCore-mbed) to use LittleFS with or without Blynk/WiFiManager features. +20. Add support to WT32_ETH01 (ESP32 + LAN8720A) +21. Add support to Teensy 4.1 built-in Ethernet using [`NativeEthernet`](https://github.com/vjmuzik/NativeEthernet) library +22. Add support to Teensy 4.1 built-in Ethernet using [`QNEthernet`](https://github.com/ssilverman/QNEthernet) library +23. Add new feature to permit using either server's hostname, such as `your_account.duckdns.org`, or server's IPAddress, such as IPAddress(192,168,2,112) +24. Add support to **Portenta_H7**, using either `Murata WiFi` or `Vision-shield Ethernet` +25. Optimize library code by using `reference-passing` instead of `value-passing` +26. Fix memory leak and memory management bugs. +27. Add support to SAMD21/SAMD51 boards using [Fab_SAM_Arduino core](https://github.com/qbolsee/ArduinoCore-fab-sam) +28. Add support to RP2040 boards using `Seeed RP2040 core` +29 Convert to `h-only` style +30. Add `multiFileProject` examples to demo for multiple-file projects +31. Use new [**Ethernet_Generic** library](https://github.com/khoih-prog/Ethernet_Generic) as default for W5x00. +32. Support **SPI2 for ESP32** +33. Add support to SPI1 for RP2040 using [arduino-pico core](https://github.com/earlephilhower/arduino-pico) +34. Use new function `waitForLink()` for Teensy 4.1 `QNEthernet library v0.14.0+` + +--- +--- + +### Contributions and Thanks + +1. Based on and modified from [Dr. Charles Bell's MySQL_Connector_Arduino Library](https://github.com/ChuckBell/MySQL_Connector_Arduino) +2. Thanks to good work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip) for initiating, inspriring, working with, developing, debugging and testing. +3. Thanks to [graham999au](https://github.com/graham999au) for the enhanement request [**NativeEthernet support for Teensy 4.1** #8](https://github.com/khoih-prog/MySQL_MariaDB_Generic/issues/8), and help testing, leading to new version v1.3.0 +4. Thanks to [Pablo Martikian](https://github.com/pabloandresm) to report issues and create bug-fixing PR: + + - [memory leak on 'server_version' #17](https://github.com/khoih-prog/MySQL_MariaDB_Generic/issues/17) + - [memory leak on MySQL_Connection.MySQL_Packet.buffer #18](https://github.com/khoih-prog/MySQL_MariaDB_Generic/issues/18) + - [corrupt heap at MySQL_Connection destructor #19](https://github.com/khoih-prog/MySQL_MariaDB_Generic/issues/19) + - [malloc server_version result not correctly handled may lead to memory corruption #20](https://github.com/khoih-prog/MySQL_MariaDB_Generic/issues/20) + - [fix server_version memory management #21](https://github.com/khoih-prog/MySQL_MariaDB_Generic/pull/21) + - [suggest replacing all files xxxx_Impl.h by xxxx.cpp #22](https://github.com/khoih-prog/MySQL_MariaDB_Generic/issues/22) + +leading to version v1.6.0, v1.6.1 and v1.7.0 to fix memory leak / management bugs / `Multiple Definitions` Linker Error. + + + + + + + + +
ChuckBell
⭐️ ChuckBell

tcpipchip
Miguel Wisintainer

graham999au
graham999au

pabloandresm
⭐️ Pablo Martikian

+ +--- + +### Contributing + +If you want to contribute to this project: +- Report bugs and errors +- Ask for enhancements +- Create issues and pull requests +- Tell other people about this library + +--- + +### License + +- Most of the credits go to original author [Dr. Charles Bell](https://github.com/ChuckBell) + +- The library is licensed under [MIT](https://github.com/khoih-prog/WebSockets2_Generic/blob/master/LICENSE) + +--- + +## Copyright + +1. Copyright (c) 2012- Oracle +2. Copyright (c) 2012- Dr. Charles Bell +3. Copyright (c) 2020- Khoi Hoang + + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/changelog.md b/libraries/MySQL_MariaDB_Generic-1.7.2/changelog.md new file mode 100644 index 0000000..6003c23 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/changelog.md @@ -0,0 +1,155 @@ +## MySQL_MariaDB_Generic + +[![arduino-library-badge](https://www.ardu-badge.com/badge/MySQL_MariaDB_Generic.svg?)](https://www.ardu-badge.com/MySQL_MariaDB_Generic) +[![GitHub release](https://img.shields.io/github/release/khoih-prog/MySQL_MariaDB_Generic.svg)](https://github.com/khoih-prog/MySQL_MariaDB_Generic/releases) +[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/MySQL_MariaDB_Generic/blob/master/LICENSE) +[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing) +[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/MySQL_MariaDB_Generic.svg)](http://github.com/khoih-prog/MySQL_MariaDB_Generic/issues) + +--- +--- + +## Table of Contents + +* [Changelog](#changelog) + * [Release v1.7.2](#release-v172) + * [Release v1.7.1](#release-v171) + * [Release v1.7.0](#release-v170) + * [Release v1.6.1](#release-v161) + * [Release v1.6.0](#release-v160) + * [Release v1.5.2](#release-v152) + * [Release v1.5.1](#release-v151) + * [Major Release v1.5.0](#major-release-v150) + * [Major Release v1.4.0](#major-release-v140) + * [Release v1.3.1](#release-v131) + * [Release v1.3.0](#release-v130) + * [Release v1.2.0](#release-v120) + * [Major Release v1.1.0](#major-release-v110) + * [Release v1.0.3](#release-v103) + * [Release v1.0.2](#release-v102) + * [Release v1.0.1](#release-v101) + * [Release v1.0.0](#release-v100) + +--- +--- + +## Changelog + +### Release v1.7.2 + +1. Fix missing paragraph in `library.properties` resulting in Arduino IDE's invalid library complaint + +### Release v1.7.1 + +1. Use new [Ethernet_Generic library](https://github.com/khoih-prog/Ethernet_Generic) as default for W5x00. +2. Support SPI2 for ESP32 +3. Add support to SPI1 for RP2040 using [arduino-pico core](https://github.com/earlephilhower/arduino-pico) +4. Use new function `waitForLink()` for Teensy 4.1 QNEthernet library v0.14.0+ +5. Rewrite all the examples to support those new features +6. Update `Packages' Patches` + +### Release v1.7.0 + +1. Convert to `h-only` style +2. Add `multiFileProject` examples to demo for multiple-file projects + +### Release v1.6.1 + +1. Fix memory management bugs. Check [corrupt heap at MySQL_Connection destructor #19](https://github.com/khoih-prog/MySQL_MariaDB_Generic/issues/19) and [malloc server_version result not correctly handled may lead to memory corruption #20](https://github.com/khoih-prog/MySQL_MariaDB_Generic/issues/20) +2. Add support to SAMD21/SAMD51 boards using [Fab_SAM_Arduino core](https://github.com/qbolsee/ArduinoCore-fab-sam) +3. Add support to RP2040 boards using `Seeed RP2040 core` +4. Add `Packages' Patches` for [Fab_SAM_Arduino core](https://github.com/qbolsee/ArduinoCore-fab-sam) + +### Release v1.6.0 + +1. Fix memory leak bugs. Check [memory leak on 'server_version' #17](https://github.com/khoih-prog/MySQL_MariaDB_Generic/issues/17) and [memory leak on MySQL_Connection.MySQL_Packet.buffer #18](https://github.com/khoih-prog/MySQL_MariaDB_Generic/issues/18) +2. Optimize library code by using `reference-passing` instead of `value-passing` +3. Update RP2040 Ethernet-related examples to use the same SS/CS pin GP17 for [ArduinoCore-mbed mbed_rp2040 core](https://github.com/arduino/ArduinoCore-mbed) as [arduino-pico rp2040 core](https://github.com/earlephilhower/arduino-pico) +4. Update `Packages' Patches` + +### Release v1.5.2 + +1. Auto detect ESP32 core version. +2. Fix bug in examples for WT32_ETH01 +3. Update `Packages' Patches` + +### Release v1.5.1 + +1. Update `platform.ini` and `library.json` to use original `khoih-prog` instead of `khoih.prog` after PIO fix +2. Update `Packages' Patches` + +### Major Release v1.5.0 + +1. Add support to **Portenta_H7**, using either WiFi or Vision-shield Ethernet +2. Add examples with new features + +### Major Release v1.4.0 + +1. Add support to [QNEthernet Library](https://github.com/ssilverman/QNEthernet) for Teensy 4.1 built-in Ethernet +2. Fix bug in non-blocking connection +3. Add new feature to permit using either server's hostname, such as `your_account.duckdns.org`, or server's IPAddress, such as IPAddress(192,168,2,112) +4. Update examples with new features, bug-fixes, etc. + +### Release v1.3.1 + +1. Remove unnecessary SPI-bus code in NativeEthernet examples + +### Release v1.3.0 + +1. Add support to **Teensy 4.1 using NativeEthernet** + +### Release v1.2.0 + +1. Add support to WT32_ETH01 (ESP32 + LAN8720A) + +### Major Release v1.1.0 + +1. Add support to RP2040-based boards, such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, using [**Earle Philhower's arduino-pico** v1.8.0+ core](https://github.com/earlephilhower/arduino-pico). +2. Add support to RP2040-based boards, such as **Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, using [**Arduino-mbed RP2040** v2.1.0+ core](https://github.com/arduino/ArduinoCore-mbed). +3. Add support to new **ESP32-S2** boards (**Arduino ESP32C3_DEV**). Check [HOWTO Install esp32 core for ESP32-S2 (Saola, AI-Thinker ESP-12K) and ESP32-C3 boards into Arduino IDE](#howto-install-esp32-core-for-esp32-s2-saola-ai-thinker-esp-12k-and-esp32-c3-boards-into-arduino-ide). +4. Verify working with new ESP8266 core v3.0.0 and new ESP32 core v1.0.6 +5. Suppress all warnings possible. +6. Add Table of Contents and Version String + +### Release v1.0.3 + + 1. Add support to ENC28J60 Ethernet module/shield using new **EthernetENC** library. + 2. Update Platform.ini to support PlatformIO 5.x owner-based dependency declaration. + 3. Enhance examples + +#### Release v1.0.2 + + 1. Fix crashing bug when Client timeout. + 2. Make code more error-proof. + 3. Drop support to ESP8266_AT_Webserver. + 4. Enhance examples + +#### Release v1.0.1 + + 1. Add support to ENC28J60 Ethernet module/shield using **UIPEthernet** library. + 2. Fix bugs + 3. Optimize code + 4. Enhance examples + 5. Add UIPEthernet Library Patches for SAMD21/SAMD51 + +#### Release v1.0.0 + + 1. Add support to **nRF52** boards, such as **AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.** + 2. Add support to **Adafruit SAMD51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.)** + 3. Add support to **Adafruit SAMD21 Itsy-Bitsy M0, Feathr M0, Metro M0, AdaFruit CIRCUITPLAYGROUND_EXPRESS, etc.)** + 4. Add support to **Arduino SAMD21 (ZERO, MKR, NANO_33_IOT, etc.)** + 5. Add support to all **STM32F/L/H/G/WB/MP1 (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.)** + 6. Add support to **Seeeduino SAMD21/SAMD51 boards (SEEED_WIO_TERMINAL, SEEED_FEMTO_M0, SEEED_XIAO_M0, Wio_Lite_MG126, WIO_GPS_BOARD, SEEEDUINO_ZERO, SEEEDUINO_LORAWAN, SEEED_GROVE_UI_WIRELESS, etc.)** + 7. Add support to **SAM DUE and AVR Mega** boards. + 8. Add support to **ESP32/ESP8266** boards. + 9. Add connectNonBlocking() function to use in loop() to avoid being blocked running other tasks. +10. Add support to WiFiNINA using [**WiFiNINA_Generic library**](https://github.com/khoih-prog/WiFiNINA_Generic) or WiFiNINA library. +11. Add support to W5x00 Ethernet module/shield using Ethernet, EthernetLarge, Ethernet2 or Ethernet3 library. +12. Add support to LAN8742A Ethernet module/shield using STM32Ethernet library. +13. Add support to ESP8266/ESP32-AT-command module/shield using [`WiFiEspAT library`](https://github.com/jandrassy/WiFiEspAT) or [`ESP8266_AT_WebServer library`](https://github.com/khoih-prog/ESP8266_AT_WebServer). +14. Add Packages' Patches. +15. Add sample Packages_Patches for **STM32F/L/H/G/WB/MP1** (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8) +16. Add Ethernet Library Patches +17. Add many examples + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Basic_Insert/Basic_Insert.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Basic_Insert/Basic_Insert.ino new file mode 100644 index 0000000..d01b60f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Basic_Insert/Basic_Insert.ino @@ -0,0 +1,292 @@ +/********************************************************************************************************************************* + Basic_Insert.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : basic insert + + This example demonstrates how to issue an INSERT query to store data in a + table. For this, we will create a special database and table for testing. + The following are the SQL commands you will need to run in order to setup + your database for running this sketch. + + CREATE DATABASE test_arduino; + CREATE TABLE test_arduino.hello_arduino ( + num integer primary key auto_increment, + message char(40), + recorded timestamp + ); + + Here we see one database and a table with three fields; a primary key that + is an auto_increment, a string, and a timestamp. This will demonstrate how + to save a date and time of when the row was inserted, which can help you + determine when data was recorded or updated. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Create the database and table as shown above. + 2) Change the address of the server to the IP address of the MySQL server + 3) Change the user and password to a valid MySQL user and password + 4) Connect a USB cable to your Arduino + 5) Select the correct board and port + 6) Compile and upload the sketch to your Arduino + 7) Once uploaded, open Serial Monitor (use 115200 speed) and observe + 8) After the sketch has run for some time, open a mysql client and issue + the command: "SELECT * FROM test_arduino.hello_arduino" to see the data + recorded. Note the field values and how the database handles both the + auto_increment and timestamp fields for us. You can clear the data with + "DELETE FROM test_arduino.hello_arduino". + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "test_arduino"; //"test_arduino"; +char default_table[] = "hello_arduino"; //"test_arduino"; + +String default_value = "Hello, Arduino!"; + +// Sample query +String INSERT_SQL = String("INSERT INTO ") + default_database + "." + default_table + + " (message) VALUES ('" + default_value + "')"; + +MySQL_Connection conn((Client *)&client); + +void initEthernet() +{ +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Default SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#if defined(ESP8266) + // For ESP8266, change for other boards if necessary + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN D2 // For ESP8266 + #endif + + MYSQL_LOGERROR1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // For ESP8266 + // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 + // Ethernet 0 X X X X 0 + // Ethernet2 X X X X X 0 + // Ethernet3 X X X X X 0 + // EthernetLarge X X X X X 0 + // Ethernet_ESP8266 0 0 0 0 0 0 + // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs + // Must use library patch for Ethernet, EthernetLarge libraries + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif defined(ESP32) + + // You can use Ethernet.init(pin) to configure the CS pin + //Ethernet.init(10); // Most Arduino shields + //Ethernet.init(5); // MKR ETH shield + //Ethernet.init(0); // Teensy 2.0 + //Ethernet.init(20); // Teensy++ 2.0 + //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet + //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet + + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 22 // For ESP32 + #endif + + MYSQL_LOGERROR1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge + // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif ETHERNET_USE_RPIPICO + + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 17 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif + + MYSQL_LOGERROR1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_LARGE ) + +#else //defined(ESP8266) + // unknown board, do nothing, use default SS = 10 + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 10 // For other boards + #endif + + MYSQL_LOGERROR3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries + + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#endif //defined(ESP8266) + +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + // Just info to know how to connect correctly + #if defined(CUR_PIN_MISO) + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), CUR_PIN_MOSI); + MYSQL_LOGERROR1(F("MISO:"), CUR_PIN_MISO); + MYSQL_LOGERROR1(F("SCK:"), CUR_PIN_SCK); + MYSQL_LOGERROR1(F("SS:"), CUR_PIN_SS); + #else + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + #endif + + MYSQL_LOGERROR(F("=========================")); +#endif + +#endif // #if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Basic_Insert on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runInsert() +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + MYSQL_DISPLAY(INSERT_SQL); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(INSERT_SQL.c_str()) ) + { + MYSQL_DISPLAY("Insert error"); + } + else + { + MYSQL_DISPLAY("Data Inserted."); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + } +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Basic_Insert/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Basic_Insert/defines.h new file mode 100644 index 0000000..c6efb3d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Basic_Insert/defines.h @@ -0,0 +1,463 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 2 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define ETHERNET_USE_PORTENTA_H7 true + #define USE_ETHERNET_PORTENTA_H7 true + +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(ETHERNET_USE_SAMD) + #undef ETHERNET_USE_SAMD + #endif + #define ETHERNET_USE_SAMD true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(ETHERNET_USE_NRF528XX) + #undef ETHERNET_USE_NRF528XX + #endif + #define ETHERNET_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(ETHERNET_USE_SAM_DUE) + #undef ETHERNET_USE_SAM_DUE + #endif + #define ETHERNET_USE_SAM_DUE true +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(ETHERNET_USE_STM32) + #undef ETHERNET_USE_STM32 + #endif + #define ETHERNET_USE_STM32 true +#endif + +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) + #if defined(ETHERNET_USE_RPIPICO) + #undef ETHERNET_USE_RPIPICO + #endif + #define ETHERNET_USE_RPIPICO true +#endif + +#if defined(ETHERNET_USE_SAMD) + // For SAMD + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #ifdef USE_THIS_SS_PIN + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN A1 + #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif (ETHERNET_USE_SAM_DUE) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "SAM DUE" + +#elif (ETHERNET_USE_NRF528XX) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUITPLAY" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NRF52840_PCA10056" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif ( defined(CORE_TEENSY) ) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #if defined(ARDUINO_TEENSY41) + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET true + #elif defined(ARDUINO_TEENSY40) + #define BOARD_TYPE "TEENSY 4.0" + #else + #define + #endif + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#elif (ETHERNET_USE_STM32) + + #if defined(STM32F0) + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #define BOARD_TYPE "STM32MP1" + #else + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif ( defined(ESP8266) ) + // For ESP8266 + #warning Use ESP8266 architecture + #include + #define ETHERNET_USE_ESP8266 + #define BOARD_TYPE "ESP8266" + +#elif ( defined(ESP32) ) + // For ESP32 + #warning Use ESP32 architecture + #define ETHERNET_USE_ESP32 + #define BOARD_TYPE "ESP32" + + #define W5500_RST_PORT 21 + +#elif ETHERNET_USE_RPIPICO + + // Default pin 5 (in Mbed) or 17 to SS/CS + #if defined(ARDUINO_ARCH_MBED) + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + + #define USE_THIS_SS_PIN 17 + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_TYPE "MBED GENERIC_RP2040" + #else + #define BOARD_TYPE "MBED Unknown RP2040" + #endif + + #else + // For RPI Pico using E. Philhower RP2040 core + #if (USING_SPI2) + // SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1 + #define USE_THIS_SS_PIN 13 + #else + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0 + #define USE_THIS_SS_PIN 17 + #endif + + #endif + + #define SS_PIN_DEFAULT USE_THIS_SS_PIN + + // For RPI Pico + #warning Use RPI-Pico RP2040 architecture + +#else + // For Mega + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "AVR Mega" +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#include + +// Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported + +// To override the default CS/SS pin. Don't use unless you know exactly which pin to use +// You can define here or customize for each board at same place with BOARD_TYPE +// Check @ defined(SEEED_XIAO_M0) +//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false +////// + +#if USE_CUSTOM_ETHERNET + // You have to include an Ethernet library in your program + //#include "Ethernet_XYZ.h" + #include "EthernetLarge.h" + + #define SHIELD_TYPE "Custom Ethernet using EthernetLarge Library" +#endif + +#if (_MYSQL_LOGLEVEL_ > 1) + #if USE_ETHERNET_PORTENTA_H7 + #warning Use Portenta Ethernet lib + #elif USE_QN_ETHERNET + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_NATIVE_ETHERNET + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_ETHERNET_GENERIC + #warning Using Ethernet_Generic lib + #elif USE_ETHERNET_ESP8266 + #warning Using Ethernet_ESP8266 lib + #elif USE_ETHERNET_ENC + #warning Using EthernetENC lib + #elif USE_ETHERNET_LAN8742A + #warning Using LAN8742A Ethernet & STM32Ethernet lib + #elif USE_CUSTOM_ETHERNET + #warning Using Custom Ethernet library + #else + #define USE_ETHERNET_GENERIC true + + #warning Using Ethernet_Generic lib + #endif +#endif + +#if !( USE_ETHERNET_ENC || USE_ETHERNET_ESP8266 || USE_UIP_ETHERNET || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720 || USE_NATIVE_ETHERNET || \ + USE_QN_ETHERNET || USE_CUSTOM_ETHERNET || USE_ETHERNET_PORTENTA_H7 || USE_CUSTOM_ETHERNET ) + #define USE_ETHERNET_GENERIC true +#endif + +#if USE_ETHERNET_GENERIC + #define ETHERNET_LARGE_BUFFERS + + #define _ETG_LOGLEVEL_ 1 +#endif + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Basic_Select/Basic_Select.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Basic_Select/Basic_Select.ino new file mode 100644 index 0000000..3f6583f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Basic_Select/Basic_Select.ino @@ -0,0 +1,326 @@ +/********************************************************************************************************************************* + Basic_Select.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : basic select + + This example demonstrates how to issue a SELECT query with no parameters + and use the data returned. For this, we use the Cursor class to execute + the query and get the results. + + It demonstrates who methods for running queries. The first allows you to + allocate memory for the cursor and later reclaim it, the second shows how + to use a single instance of the cursor use throughout a sketch. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + CAUTION: Don't mix and match the examples. Use one or the other in your + own sketch -- you'll get compilation errors at the least. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "world"; //"test_arduino"; +char default_table[] = "city"; //"test_arduino"; + +String default_column = "population"; +String default_value = "Toronto"; + +String query = String("SELECT ") + default_column + " FROM " + default_database + "." + default_table + + " WHERE name = '" + default_value + "'"; + +MySQL_Connection conn((Client *)&client); +// Create an instance of the cursor passing in the connection +MySQL_Query sql_query = MySQL_Query(&conn); + +void initEthernet() +{ +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Default SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#if defined(ESP8266) + // For ESP8266, change for other boards if necessary + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN D2 // For ESP8266 + #endif + + MYSQL_LOGERROR1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // For ESP8266 + // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 + // Ethernet 0 X X X X 0 + // Ethernet2 X X X X X 0 + // Ethernet3 X X X X X 0 + // EthernetLarge X X X X X 0 + // Ethernet_ESP8266 0 0 0 0 0 0 + // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs + // Must use library patch for Ethernet, EthernetLarge libraries + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif defined(ESP32) + + // You can use Ethernet.init(pin) to configure the CS pin + //Ethernet.init(10); // Most Arduino shields + //Ethernet.init(5); // MKR ETH shield + //Ethernet.init(0); // Teensy 2.0 + //Ethernet.init(20); // Teensy++ 2.0 + //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet + //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet + + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 22 // For ESP32 + #endif + + MYSQL_LOGERROR1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge + // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif ETHERNET_USE_RPIPICO + + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 17 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif + + MYSQL_LOGERROR1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_LARGE ) + +#else //defined(ESP8266) + // unknown board, do nothing, use default SS = 10 + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 10 // For other boards + #endif + + MYSQL_LOGERROR3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries + + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#endif //defined(ESP8266) + +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + // Just info to know how to connect correctly + #if defined(CUR_PIN_MISO) + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), CUR_PIN_MOSI); + MYSQL_LOGERROR1(F("MISO:"), CUR_PIN_MISO); + MYSQL_LOGERROR1(F("SCK:"), CUR_PIN_SCK); + MYSQL_LOGERROR1(F("SS:"), CUR_PIN_SS); + #else + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + #endif + + MYSQL_LOGERROR(F("=========================")); +#endif + +#endif // #if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Basic_Select on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runQuery() +{ + row_values *row = NULL; + long head_count = 0; + + MYSQL_DISPLAY("1) Demonstrating using a dynamically allocated query."); + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + MYSQL_DISPLAY(query); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(query.c_str()) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Fetch the columns (required) but we don't use them. + //column_names *columns = query_mem.get_columns(); + query_mem.get_columns(); + + // Read the row (we are only expecting the one) + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + head_count = atol(row->values[0]); + } + } while (row != NULL); + + // Show the result + MYSQL_DISPLAY1(" Toronto pop =", head_count); + + delay(500); + + MYSQL_DISPLAY("2) Demonstrating using a local, global query."); + + // Execute the query + MYSQL_DISPLAY(query); + sql_query.execute(query.c_str()); + + // Fetch the columns (required) but we don't use them. + sql_query.get_columns(); + + // Read the row (we are only expecting the one) + do + { + row = sql_query.get_next_row(); + if (row != NULL) + { + head_count = atol(row->values[0]); + } + } while (row != NULL); + + // Now we close the cursor to free any memory + sql_query.close(); + + // Show the result but this time do some math on it + MYSQL_DISPLAY1(" Toronto pop =", head_count); + MYSQL_DISPLAY1(" Toronto pop increased by 11725 =", head_count + 11725); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Basic_Select/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Basic_Select/defines.h new file mode 100644 index 0000000..c6efb3d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Basic_Select/defines.h @@ -0,0 +1,463 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 2 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define ETHERNET_USE_PORTENTA_H7 true + #define USE_ETHERNET_PORTENTA_H7 true + +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(ETHERNET_USE_SAMD) + #undef ETHERNET_USE_SAMD + #endif + #define ETHERNET_USE_SAMD true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(ETHERNET_USE_NRF528XX) + #undef ETHERNET_USE_NRF528XX + #endif + #define ETHERNET_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(ETHERNET_USE_SAM_DUE) + #undef ETHERNET_USE_SAM_DUE + #endif + #define ETHERNET_USE_SAM_DUE true +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(ETHERNET_USE_STM32) + #undef ETHERNET_USE_STM32 + #endif + #define ETHERNET_USE_STM32 true +#endif + +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) + #if defined(ETHERNET_USE_RPIPICO) + #undef ETHERNET_USE_RPIPICO + #endif + #define ETHERNET_USE_RPIPICO true +#endif + +#if defined(ETHERNET_USE_SAMD) + // For SAMD + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #ifdef USE_THIS_SS_PIN + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN A1 + #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif (ETHERNET_USE_SAM_DUE) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "SAM DUE" + +#elif (ETHERNET_USE_NRF528XX) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUITPLAY" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NRF52840_PCA10056" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif ( defined(CORE_TEENSY) ) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #if defined(ARDUINO_TEENSY41) + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET true + #elif defined(ARDUINO_TEENSY40) + #define BOARD_TYPE "TEENSY 4.0" + #else + #define + #endif + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#elif (ETHERNET_USE_STM32) + + #if defined(STM32F0) + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #define BOARD_TYPE "STM32MP1" + #else + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif ( defined(ESP8266) ) + // For ESP8266 + #warning Use ESP8266 architecture + #include + #define ETHERNET_USE_ESP8266 + #define BOARD_TYPE "ESP8266" + +#elif ( defined(ESP32) ) + // For ESP32 + #warning Use ESP32 architecture + #define ETHERNET_USE_ESP32 + #define BOARD_TYPE "ESP32" + + #define W5500_RST_PORT 21 + +#elif ETHERNET_USE_RPIPICO + + // Default pin 5 (in Mbed) or 17 to SS/CS + #if defined(ARDUINO_ARCH_MBED) + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + + #define USE_THIS_SS_PIN 17 + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_TYPE "MBED GENERIC_RP2040" + #else + #define BOARD_TYPE "MBED Unknown RP2040" + #endif + + #else + // For RPI Pico using E. Philhower RP2040 core + #if (USING_SPI2) + // SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1 + #define USE_THIS_SS_PIN 13 + #else + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0 + #define USE_THIS_SS_PIN 17 + #endif + + #endif + + #define SS_PIN_DEFAULT USE_THIS_SS_PIN + + // For RPI Pico + #warning Use RPI-Pico RP2040 architecture + +#else + // For Mega + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "AVR Mega" +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#include + +// Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported + +// To override the default CS/SS pin. Don't use unless you know exactly which pin to use +// You can define here or customize for each board at same place with BOARD_TYPE +// Check @ defined(SEEED_XIAO_M0) +//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false +////// + +#if USE_CUSTOM_ETHERNET + // You have to include an Ethernet library in your program + //#include "Ethernet_XYZ.h" + #include "EthernetLarge.h" + + #define SHIELD_TYPE "Custom Ethernet using EthernetLarge Library" +#endif + +#if (_MYSQL_LOGLEVEL_ > 1) + #if USE_ETHERNET_PORTENTA_H7 + #warning Use Portenta Ethernet lib + #elif USE_QN_ETHERNET + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_NATIVE_ETHERNET + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_ETHERNET_GENERIC + #warning Using Ethernet_Generic lib + #elif USE_ETHERNET_ESP8266 + #warning Using Ethernet_ESP8266 lib + #elif USE_ETHERNET_ENC + #warning Using EthernetENC lib + #elif USE_ETHERNET_LAN8742A + #warning Using LAN8742A Ethernet & STM32Ethernet lib + #elif USE_CUSTOM_ETHERNET + #warning Using Custom Ethernet library + #else + #define USE_ETHERNET_GENERIC true + + #warning Using Ethernet_Generic lib + #endif +#endif + +#if !( USE_ETHERNET_ENC || USE_ETHERNET_ESP8266 || USE_UIP_ETHERNET || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720 || USE_NATIVE_ETHERNET || \ + USE_QN_ETHERNET || USE_CUSTOM_ETHERNET || USE_ETHERNET_PORTENTA_H7 || USE_CUSTOM_ETHERNET ) + #define USE_ETHERNET_GENERIC true +#endif + +#if USE_ETHERNET_GENERIC + #define ETHERNET_LARGE_BUFFERS + + #define _ETG_LOGLEVEL_ 1 +#endif + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Complex_Insert/Complex_Insert.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Complex_Insert/Complex_Insert.ino new file mode 100644 index 0000000..49ad166 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Complex_Insert/Complex_Insert.ino @@ -0,0 +1,317 @@ +/********************************************************************************************************************************* + Complex_Insert.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : complex insert + + This example demonstrates how to issue an INSERT query to store data in a + table using data from variables in our sketch. In this case, we supply the + values dynamically. + + This sketch simulates storing data from a sensor in a table. + + For this, we will create a special database and table for testing. + The following are the SQL commands you will need to run in order to setup + your database for running this sketch. + + CREATE DATABASE test_arduino; + CREATE TABLE test_arduino.hello_sensor ( + num integer primary key auto_increment, + message char(40), + sensor_num integer, + value float, + recorded timestamp + ); + + Here we have a table that contains an auto_increment primary key, a text + field, a field to identify the sensor, the value read, and timestamp of + the recorded data. + + Note: Since this sketch uses test data, we place the INSERT in the setup() + method so that it runs only once. Typically, you would have the + INSERT in the loop() method after your code to read from the sensor. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Create the database and table as shown above. + 2) Change the address of the server to the IP address of the MySQL server + 3) Change the user and password to a valid MySQL user and password + 4) Connect a USB cable to your Arduino + 5) Select the correct board and port + 6) Compile and upload the sketch to your Arduino + 7) Once uploaded, open Serial Monitor (use 115200 speed) and observe + 8) After the sketch has run for some time, open a mysql client and issue + the command: "SELECT * FROM test_arduino.hello_sensor" to see the data + recorded. Note the field values and how the database handles both the + auto_increment and timestamp fields for us. You can clear the data with + "DELETE FROM test_arduino.hello_sensor". + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "test_arduino"; //"test_arduino"; +char default_table[] = "hello_sensor"; //"test_arduino"; + +// Sample query +char INSERT_DATA[] = "INSERT INTO %s.%s (message, sensor_num, value) VALUES ('%s',%d,%s)"; + +char query[128]; +char temperature[10]; + +MySQL_Connection conn((Client *)&client); + +#if !( ESP32 || ESP8266 || defined(CORE_TEENSY) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) || defined(STM32F4) || defined(STM32F7) || ( defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED) ) ) + +char *dtostrf(double val, signed char width, unsigned char prec, char *sout) +{ + char fmt[20]; + sprintf(fmt, "%%%d.%df", width, prec); + sprintf(sout, fmt, val); + return sout; +} +#endif + +void initEthernet() +{ +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Default SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#if defined(ESP8266) + // For ESP8266, change for other boards if necessary + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN D2 // For ESP8266 + #endif + + MYSQL_LOGERROR1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // For ESP8266 + // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 + // Ethernet 0 X X X X 0 + // Ethernet2 X X X X X 0 + // Ethernet3 X X X X X 0 + // EthernetLarge X X X X X 0 + // Ethernet_ESP8266 0 0 0 0 0 0 + // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs + // Must use library patch for Ethernet, EthernetLarge libraries + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif defined(ESP32) + + // You can use Ethernet.init(pin) to configure the CS pin + //Ethernet.init(10); // Most Arduino shields + //Ethernet.init(5); // MKR ETH shield + //Ethernet.init(0); // Teensy 2.0 + //Ethernet.init(20); // Teensy++ 2.0 + //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet + //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet + + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 22 // For ESP32 + #endif + + MYSQL_LOGERROR1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge + // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif ETHERNET_USE_RPIPICO + + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 17 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif + + MYSQL_LOGERROR1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_LARGE ) + +#else //defined(ESP8266) + // unknown board, do nothing, use default SS = 10 + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 10 // For other boards + #endif + + MYSQL_LOGERROR3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries + + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#endif //defined(ESP8266) + +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + // Just info to know how to connect correctly + #if defined(CUR_PIN_MISO) + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), CUR_PIN_MOSI); + MYSQL_LOGERROR1(F("MISO:"), CUR_PIN_MISO); + MYSQL_LOGERROR1(F("SCK:"), CUR_PIN_SCK); + MYSQL_LOGERROR1(F("SS:"), CUR_PIN_SS); + #else + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + #endif + + MYSQL_LOGERROR(F("=========================")); +#endif + +#endif // #if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Complex_Insert on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); + MYSQL_DISPLAY3("DB =", default_database, ", Table =", default_table); +} + +void runInsert() +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + // Save + dtostrf(50.125, 1, 1, temperature); + sprintf(query, INSERT_DATA, default_database, default_table, "test sensor", 24, temperature); + + // Execute the query + MYSQL_DISPLAY(query); + + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Complex Insert error"); + } + else + { + MYSQL_DISPLAY("Complex Data Inserted."); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + } +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Complex_Insert/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Complex_Insert/defines.h new file mode 100644 index 0000000..c6efb3d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Complex_Insert/defines.h @@ -0,0 +1,463 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 2 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define ETHERNET_USE_PORTENTA_H7 true + #define USE_ETHERNET_PORTENTA_H7 true + +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(ETHERNET_USE_SAMD) + #undef ETHERNET_USE_SAMD + #endif + #define ETHERNET_USE_SAMD true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(ETHERNET_USE_NRF528XX) + #undef ETHERNET_USE_NRF528XX + #endif + #define ETHERNET_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(ETHERNET_USE_SAM_DUE) + #undef ETHERNET_USE_SAM_DUE + #endif + #define ETHERNET_USE_SAM_DUE true +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(ETHERNET_USE_STM32) + #undef ETHERNET_USE_STM32 + #endif + #define ETHERNET_USE_STM32 true +#endif + +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) + #if defined(ETHERNET_USE_RPIPICO) + #undef ETHERNET_USE_RPIPICO + #endif + #define ETHERNET_USE_RPIPICO true +#endif + +#if defined(ETHERNET_USE_SAMD) + // For SAMD + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #ifdef USE_THIS_SS_PIN + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN A1 + #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif (ETHERNET_USE_SAM_DUE) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "SAM DUE" + +#elif (ETHERNET_USE_NRF528XX) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUITPLAY" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NRF52840_PCA10056" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif ( defined(CORE_TEENSY) ) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #if defined(ARDUINO_TEENSY41) + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET true + #elif defined(ARDUINO_TEENSY40) + #define BOARD_TYPE "TEENSY 4.0" + #else + #define + #endif + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#elif (ETHERNET_USE_STM32) + + #if defined(STM32F0) + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #define BOARD_TYPE "STM32MP1" + #else + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif ( defined(ESP8266) ) + // For ESP8266 + #warning Use ESP8266 architecture + #include + #define ETHERNET_USE_ESP8266 + #define BOARD_TYPE "ESP8266" + +#elif ( defined(ESP32) ) + // For ESP32 + #warning Use ESP32 architecture + #define ETHERNET_USE_ESP32 + #define BOARD_TYPE "ESP32" + + #define W5500_RST_PORT 21 + +#elif ETHERNET_USE_RPIPICO + + // Default pin 5 (in Mbed) or 17 to SS/CS + #if defined(ARDUINO_ARCH_MBED) + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + + #define USE_THIS_SS_PIN 17 + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_TYPE "MBED GENERIC_RP2040" + #else + #define BOARD_TYPE "MBED Unknown RP2040" + #endif + + #else + // For RPI Pico using E. Philhower RP2040 core + #if (USING_SPI2) + // SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1 + #define USE_THIS_SS_PIN 13 + #else + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0 + #define USE_THIS_SS_PIN 17 + #endif + + #endif + + #define SS_PIN_DEFAULT USE_THIS_SS_PIN + + // For RPI Pico + #warning Use RPI-Pico RP2040 architecture + +#else + // For Mega + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "AVR Mega" +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#include + +// Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported + +// To override the default CS/SS pin. Don't use unless you know exactly which pin to use +// You can define here or customize for each board at same place with BOARD_TYPE +// Check @ defined(SEEED_XIAO_M0) +//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false +////// + +#if USE_CUSTOM_ETHERNET + // You have to include an Ethernet library in your program + //#include "Ethernet_XYZ.h" + #include "EthernetLarge.h" + + #define SHIELD_TYPE "Custom Ethernet using EthernetLarge Library" +#endif + +#if (_MYSQL_LOGLEVEL_ > 1) + #if USE_ETHERNET_PORTENTA_H7 + #warning Use Portenta Ethernet lib + #elif USE_QN_ETHERNET + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_NATIVE_ETHERNET + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_ETHERNET_GENERIC + #warning Using Ethernet_Generic lib + #elif USE_ETHERNET_ESP8266 + #warning Using Ethernet_ESP8266 lib + #elif USE_ETHERNET_ENC + #warning Using EthernetENC lib + #elif USE_ETHERNET_LAN8742A + #warning Using LAN8742A Ethernet & STM32Ethernet lib + #elif USE_CUSTOM_ETHERNET + #warning Using Custom Ethernet library + #else + #define USE_ETHERNET_GENERIC true + + #warning Using Ethernet_Generic lib + #endif +#endif + +#if !( USE_ETHERNET_ENC || USE_ETHERNET_ESP8266 || USE_UIP_ETHERNET || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720 || USE_NATIVE_ETHERNET || \ + USE_QN_ETHERNET || USE_CUSTOM_ETHERNET || USE_ETHERNET_PORTENTA_H7 || USE_CUSTOM_ETHERNET ) + #define USE_ETHERNET_GENERIC true +#endif + +#if USE_ETHERNET_GENERIC + #define ETHERNET_LARGE_BUFFERS + + #define _ETG_LOGLEVEL_ 1 +#endif + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Complex_Select/Complex_Select.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Complex_Select/Complex_Select.ino new file mode 100644 index 0000000..9529de8 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Complex_Select/Complex_Select.ino @@ -0,0 +1,323 @@ +/********************************************************************************************************************************* + Complex_Select.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : complex select + + This example demonstrates how to issue a SELECT query with parameters that + we provide from code. Thus, it demonstrates how to build query parameters + dynamically. + + Notice also the sketch demonstrates how to read columns and rows from + the result set. Study this example until you are familiar with how to + do this before writing your own sketch to read and consume query results. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "world"; //"test_arduino"; +char default_table[] = "city"; //"test_arduino"; + +// Sample query +// +// Notice the "%lu" - that's a placeholder for the parameter we will +// supply. See sprintf() documentation for more formatting specifier +// options +unsigned long QUERY_POPULATION = 800000; + +const char QUERY_POP[] = "SELECT name, population FROM world.city WHERE population < %lu ORDER BY population DESC LIMIT 12;"; + +char query[128]; + +MySQL_Connection conn((Client *)&client); + +void initEthernet() +{ +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Default SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#if defined(ESP8266) + // For ESP8266, change for other boards if necessary + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN D2 // For ESP8266 + #endif + + MYSQL_LOGERROR1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // For ESP8266 + // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 + // Ethernet 0 X X X X 0 + // Ethernet2 X X X X X 0 + // Ethernet3 X X X X X 0 + // EthernetLarge X X X X X 0 + // Ethernet_ESP8266 0 0 0 0 0 0 + // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs + // Must use library patch for Ethernet, EthernetLarge libraries + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif defined(ESP32) + + // You can use Ethernet.init(pin) to configure the CS pin + //Ethernet.init(10); // Most Arduino shields + //Ethernet.init(5); // MKR ETH shield + //Ethernet.init(0); // Teensy 2.0 + //Ethernet.init(20); // Teensy++ 2.0 + //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet + //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet + + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 22 // For ESP32 + #endif + + MYSQL_LOGERROR1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge + // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif ETHERNET_USE_RPIPICO + + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 17 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif + + MYSQL_LOGERROR1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_LARGE ) + +#else //defined(ESP8266) + // unknown board, do nothing, use default SS = 10 + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 10 // For other boards + #endif + + MYSQL_LOGERROR3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries + + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#endif //defined(ESP8266) + +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + // Just info to know how to connect correctly + #if defined(CUR_PIN_MISO) + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), CUR_PIN_MOSI); + MYSQL_LOGERROR1(F("MISO:"), CUR_PIN_MISO); + MYSQL_LOGERROR1(F("SCK:"), CUR_PIN_SCK); + MYSQL_LOGERROR1(F("SS:"), CUR_PIN_SS); + #else + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + #endif + + MYSQL_LOGERROR(F("=========================")); +#endif + +#endif // #if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Complex_Select on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runQuery() +{ + MYSQL_DISPLAY("===================================================="); + MYSQL_DISPLAY("> Running SELECT with dynamically supplied parameter"); + + // Supply the parameter for the query + // Here we use the QUERY_POP as the format string and query as the + // destination. This uses twice the memory so another option would be + // to allocate one buffer for all formatted queries or allocate the + // memory as needed (just make sure you allocate enough memory and + // free it when you're done!). + sprintf(query, QUERY_POP, QUERY_POPULATION + (( millis() % 100000 ) * 10) ); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Fetch the columns and print them + column_names *cols = query_mem.get_columns(); + + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(cols->fields[f]->name); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(","); + } + } + + MYSQL_DISPLAY(); + + // Read the rows and print them + row_values *row = NULL; + + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(row->values[f]); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(","); + } + } + + MYSQL_DISPLAY(); + } + } while (row != NULL); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(10000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Complex_Select/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Complex_Select/defines.h new file mode 100644 index 0000000..6129def --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Complex_Select/defines.h @@ -0,0 +1,467 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 2 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define ETHERNET_USE_PORTENTA_H7 true + #define USE_ETHERNET_PORTENTA_H7 true + +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(ETHERNET_USE_SAMD) + #undef ETHERNET_USE_SAMD + #endif + #define ETHERNET_USE_SAMD true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(ETHERNET_USE_NRF528XX) + #undef ETHERNET_USE_NRF528XX + #endif + #define ETHERNET_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(ETHERNET_USE_SAM_DUE) + #undef ETHERNET_USE_SAM_DUE + #endif + #define ETHERNET_USE_SAM_DUE true +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(ETHERNET_USE_STM32) + #undef ETHERNET_USE_STM32 + #endif + #define ETHERNET_USE_STM32 true +#endif + +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) + #if defined(ETHERNET_USE_RPIPICO) + #undef ETHERNET_USE_RPIPICO + #endif + #define ETHERNET_USE_RPIPICO true +#endif + +#if defined(ETHERNET_USE_SAMD) + // For SAMD + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #ifdef USE_THIS_SS_PIN + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN A1 + #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif (ETHERNET_USE_SAM_DUE) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "SAM DUE" + +#elif (ETHERNET_USE_NRF528XX) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUITPLAY" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NRF52840_PCA10056" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif ( defined(CORE_TEENSY) ) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #if defined(ARDUINO_TEENSY41) + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_QN_ETHERNET false + #define USE_NATIVE_ETHERNET false + #elif defined(ARDUINO_TEENSY40) + #define BOARD_TYPE "TEENSY 4.0" + #else + #define + #endif + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#elif (ETHERNET_USE_STM32) + + #if defined(STM32F0) + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #define BOARD_TYPE "STM32MP1" + #else + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif ( defined(ESP8266) ) + // For ESP8266 + #warning Use ESP8266 architecture + #include + #define ETHERNET_USE_ESP8266 + #define BOARD_TYPE "ESP8266" + +#elif ( defined(ESP32) ) + // For ESP32 + #warning Use ESP32 architecture + #define ETHERNET_USE_ESP32 + #define BOARD_TYPE "ESP32" + + #define W5500_RST_PORT 21 + +#elif ETHERNET_USE_RPIPICO + + // Default pin 5 (in Mbed) or 17 to SS/CS + #if defined(ARDUINO_ARCH_MBED) + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + + #define USE_THIS_SS_PIN 17 + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_TYPE "MBED GENERIC_RP2040" + #else + #define BOARD_TYPE "MBED Unknown RP2040" + #endif + + #else + + //#define USING_SPI2 true + + // For RPI Pico using E. Philhower RP2040 core + #if (USING_SPI2) + // SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1 + #define USE_THIS_SS_PIN 13 + #else + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0 + #define USE_THIS_SS_PIN 17 + #endif + + #endif + + #define SS_PIN_DEFAULT USE_THIS_SS_PIN + + // For RPI Pico + #warning Use RPI-Pico RP2040 architecture + +#else + // For Mega + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "AVR Mega" +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#include + +// Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported + +// To override the default CS/SS pin. Don't use unless you know exactly which pin to use +// You can define here or customize for each board at same place with BOARD_TYPE +// Check @ defined(SEEED_XIAO_M0) +//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false +////// + +#if USE_CUSTOM_ETHERNET + // You have to include an Ethernet library in your program + //#include "Ethernet_XYZ.h" + #include "EthernetLarge.h" + + #define SHIELD_TYPE "Custom Ethernet using EthernetLarge Library" +#endif + +#if (_MYSQL_LOGLEVEL_ > 1) + #if USE_ETHERNET_PORTENTA_H7 + #warning Use Portenta Ethernet lib + #elif USE_QN_ETHERNET + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_NATIVE_ETHERNET + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_ETHERNET_GENERIC + #warning Using Ethernet_Generic lib + #elif USE_ETHERNET_ESP8266 + #warning Using Ethernet_ESP8266 lib + #elif USE_ETHERNET_ENC + #warning Using EthernetENC lib + #elif USE_ETHERNET_LAN8742A + #warning Using LAN8742A Ethernet & STM32Ethernet lib + #elif USE_CUSTOM_ETHERNET + #warning Using Custom Ethernet library + #else + #define USE_ETHERNET_GENERIC true + + #warning Using Ethernet_Generic lib + #endif +#endif + +#if !( USE_ETHERNET_ENC || USE_ETHERNET_ESP8266 || USE_UIP_ETHERNET || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720 || USE_NATIVE_ETHERNET || \ + USE_QN_ETHERNET || USE_CUSTOM_ETHERNET || USE_ETHERNET_PORTENTA_H7 || USE_CUSTOM_ETHERNET ) + #define USE_ETHERNET_GENERIC true +#endif + +#if USE_ETHERNET_GENERIC + #define ETHERNET_LARGE_BUFFERS + + #define _ETG_LOGLEVEL_ 1 +#endif + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect/Connect.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect/Connect.ino new file mode 100644 index 0000000..ee5bc08 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect/Connect.ino @@ -0,0 +1,244 @@ +/********************************************************************************************************************************* + Connect.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : connect + + This example demonstrates how to connect to a MySQL server from an + Arduino using an Arduino-compatible Ethernet shield. Note that "compatible" + means it must conform to the Ethernet class library or be a derivative + with the same classes and methods. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "world"; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +MySQL_Connection conn((Client *)&client); + +void initEthernet() +{ +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Default SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#if defined(ESP8266) + // For ESP8266, change for other boards if necessary + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN D2 // For ESP8266 + #endif + + MYSQL_LOGERROR1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // For ESP8266 + // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 + // Ethernet 0 X X X X 0 + // Ethernet2 X X X X X 0 + // Ethernet3 X X X X X 0 + // EthernetLarge X X X X X 0 + // Ethernet_ESP8266 0 0 0 0 0 0 + // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs + // Must use library patch for Ethernet, EthernetLarge libraries + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif defined(ESP32) + + // You can use Ethernet.init(pin) to configure the CS pin + //Ethernet.init(10); // Most Arduino shields + //Ethernet.init(5); // MKR ETH shield + //Ethernet.init(0); // Teensy 2.0 + //Ethernet.init(20); // Teensy++ 2.0 + //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet + //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet + + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 22 // For ESP32 + #endif + + MYSQL_LOGERROR1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge + // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif ETHERNET_USE_RPIPICO + + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 17 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif + + MYSQL_LOGERROR1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_LARGE ) + +#else //defined(ESP8266) + // unknown board, do nothing, use default SS = 10 + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 10 // For other boards + #endif + + MYSQL_LOGERROR3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries + + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#endif //defined(ESP8266) + +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + // Just info to know how to connect correctly + #if defined(CUR_PIN_MISO) + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), CUR_PIN_MOSI); + MYSQL_LOGERROR1(F("MISO:"), CUR_PIN_MISO); + MYSQL_LOGERROR1(F("SCK:"), CUR_PIN_SCK); + MYSQL_LOGERROR1(F("SS:"), CUR_PIN_SS); + #else + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + #endif + + MYSQL_LOGERROR(F("=========================")); +#endif + +#endif // #if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Connect on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password, default_database)) + if (conn.connectNonBlocking(server, server_port, user, password, default_database) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect/defines.h new file mode 100644 index 0000000..c6efb3d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect/defines.h @@ -0,0 +1,463 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 2 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define ETHERNET_USE_PORTENTA_H7 true + #define USE_ETHERNET_PORTENTA_H7 true + +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(ETHERNET_USE_SAMD) + #undef ETHERNET_USE_SAMD + #endif + #define ETHERNET_USE_SAMD true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(ETHERNET_USE_NRF528XX) + #undef ETHERNET_USE_NRF528XX + #endif + #define ETHERNET_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(ETHERNET_USE_SAM_DUE) + #undef ETHERNET_USE_SAM_DUE + #endif + #define ETHERNET_USE_SAM_DUE true +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(ETHERNET_USE_STM32) + #undef ETHERNET_USE_STM32 + #endif + #define ETHERNET_USE_STM32 true +#endif + +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) + #if defined(ETHERNET_USE_RPIPICO) + #undef ETHERNET_USE_RPIPICO + #endif + #define ETHERNET_USE_RPIPICO true +#endif + +#if defined(ETHERNET_USE_SAMD) + // For SAMD + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #ifdef USE_THIS_SS_PIN + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN A1 + #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif (ETHERNET_USE_SAM_DUE) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "SAM DUE" + +#elif (ETHERNET_USE_NRF528XX) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUITPLAY" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NRF52840_PCA10056" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif ( defined(CORE_TEENSY) ) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #if defined(ARDUINO_TEENSY41) + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET true + #elif defined(ARDUINO_TEENSY40) + #define BOARD_TYPE "TEENSY 4.0" + #else + #define + #endif + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#elif (ETHERNET_USE_STM32) + + #if defined(STM32F0) + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #define BOARD_TYPE "STM32MP1" + #else + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif ( defined(ESP8266) ) + // For ESP8266 + #warning Use ESP8266 architecture + #include + #define ETHERNET_USE_ESP8266 + #define BOARD_TYPE "ESP8266" + +#elif ( defined(ESP32) ) + // For ESP32 + #warning Use ESP32 architecture + #define ETHERNET_USE_ESP32 + #define BOARD_TYPE "ESP32" + + #define W5500_RST_PORT 21 + +#elif ETHERNET_USE_RPIPICO + + // Default pin 5 (in Mbed) or 17 to SS/CS + #if defined(ARDUINO_ARCH_MBED) + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + + #define USE_THIS_SS_PIN 17 + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_TYPE "MBED GENERIC_RP2040" + #else + #define BOARD_TYPE "MBED Unknown RP2040" + #endif + + #else + // For RPI Pico using E. Philhower RP2040 core + #if (USING_SPI2) + // SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1 + #define USE_THIS_SS_PIN 13 + #else + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0 + #define USE_THIS_SS_PIN 17 + #endif + + #endif + + #define SS_PIN_DEFAULT USE_THIS_SS_PIN + + // For RPI Pico + #warning Use RPI-Pico RP2040 architecture + +#else + // For Mega + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "AVR Mega" +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#include + +// Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported + +// To override the default CS/SS pin. Don't use unless you know exactly which pin to use +// You can define here or customize for each board at same place with BOARD_TYPE +// Check @ defined(SEEED_XIAO_M0) +//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false +////// + +#if USE_CUSTOM_ETHERNET + // You have to include an Ethernet library in your program + //#include "Ethernet_XYZ.h" + #include "EthernetLarge.h" + + #define SHIELD_TYPE "Custom Ethernet using EthernetLarge Library" +#endif + +#if (_MYSQL_LOGLEVEL_ > 1) + #if USE_ETHERNET_PORTENTA_H7 + #warning Use Portenta Ethernet lib + #elif USE_QN_ETHERNET + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_NATIVE_ETHERNET + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_ETHERNET_GENERIC + #warning Using Ethernet_Generic lib + #elif USE_ETHERNET_ESP8266 + #warning Using Ethernet_ESP8266 lib + #elif USE_ETHERNET_ENC + #warning Using EthernetENC lib + #elif USE_ETHERNET_LAN8742A + #warning Using LAN8742A Ethernet & STM32Ethernet lib + #elif USE_CUSTOM_ETHERNET + #warning Using Custom Ethernet library + #else + #define USE_ETHERNET_GENERIC true + + #warning Using Ethernet_Generic lib + #endif +#endif + +#if !( USE_ETHERNET_ENC || USE_ETHERNET_ESP8266 || USE_UIP_ETHERNET || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720 || USE_NATIVE_ETHERNET || \ + USE_QN_ETHERNET || USE_CUSTOM_ETHERNET || USE_ETHERNET_PORTENTA_H7 || USE_CUSTOM_ETHERNET ) + #define USE_ETHERNET_GENERIC true +#endif + +#if USE_ETHERNET_GENERIC + #define ETHERNET_LARGE_BUFFERS + + #define _ETG_LOGLEVEL_ 1 +#endif + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect_By_Hostname/Connect_By_Hostname.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect_By_Hostname/Connect_By_Hostname.ino new file mode 100644 index 0000000..a25ac19 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect_By_Hostname/Connect_By_Hostname.ino @@ -0,0 +1,243 @@ +/********************************************************************************************************************************* + Connect_By_Hostname.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect by hostname + + This example demonstrates how to connect to a MySQL server resolving the + hostname for cases when you do not know the IP address of the server or + it changes because it is in the cloud. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the hostname variable to the hostname of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ +#include "defines.h" + +#include + +#if !(USE_ETHERNET_PORTENTA_H7) + #include +#endif + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +MySQL_Connection conn((Client *)&client); + +void initEthernet() +{ +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Default SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#if defined(ESP8266) + // For ESP8266, change for other boards if necessary + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN D2 // For ESP8266 + #endif + + MYSQL_LOGERROR1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // For ESP8266 + // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 + // Ethernet 0 X X X X 0 + // Ethernet2 X X X X X 0 + // Ethernet3 X X X X X 0 + // EthernetLarge X X X X X 0 + // Ethernet_ESP8266 0 0 0 0 0 0 + // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs + // Must use library patch for Ethernet, EthernetLarge libraries + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif defined(ESP32) + + // You can use Ethernet.init(pin) to configure the CS pin + //Ethernet.init(10); // Most Arduino shields + //Ethernet.init(5); // MKR ETH shield + //Ethernet.init(0); // Teensy 2.0 + //Ethernet.init(20); // Teensy++ 2.0 + //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet + //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet + + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 22 // For ESP32 + #endif + + MYSQL_LOGERROR1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge + // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif ETHERNET_USE_RPIPICO + + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 17 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif + + MYSQL_LOGERROR1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_LARGE ) + +#else //defined(ESP8266) + // unknown board, do nothing, use default SS = 10 + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 10 // For other boards + #endif + + MYSQL_LOGERROR3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries + + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#endif //defined(ESP8266) + +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + // Just info to know how to connect correctly + #if defined(CUR_PIN_MISO) + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), CUR_PIN_MOSI); + MYSQL_LOGERROR1(F("MISO:"), CUR_PIN_MISO); + MYSQL_LOGERROR1(F("SCK:"), CUR_PIN_SCK); + MYSQL_LOGERROR1(F("SS:"), CUR_PIN_SS); + #else + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + #endif + + MYSQL_LOGERROR(F("=========================")); +#endif + +#endif // #if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Connect_By_Hostname on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect_By_Hostname/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect_By_Hostname/defines.h new file mode 100644 index 0000000..c6efb3d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect_By_Hostname/defines.h @@ -0,0 +1,463 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 2 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define ETHERNET_USE_PORTENTA_H7 true + #define USE_ETHERNET_PORTENTA_H7 true + +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(ETHERNET_USE_SAMD) + #undef ETHERNET_USE_SAMD + #endif + #define ETHERNET_USE_SAMD true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(ETHERNET_USE_NRF528XX) + #undef ETHERNET_USE_NRF528XX + #endif + #define ETHERNET_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(ETHERNET_USE_SAM_DUE) + #undef ETHERNET_USE_SAM_DUE + #endif + #define ETHERNET_USE_SAM_DUE true +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(ETHERNET_USE_STM32) + #undef ETHERNET_USE_STM32 + #endif + #define ETHERNET_USE_STM32 true +#endif + +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) + #if defined(ETHERNET_USE_RPIPICO) + #undef ETHERNET_USE_RPIPICO + #endif + #define ETHERNET_USE_RPIPICO true +#endif + +#if defined(ETHERNET_USE_SAMD) + // For SAMD + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #ifdef USE_THIS_SS_PIN + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN A1 + #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif (ETHERNET_USE_SAM_DUE) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "SAM DUE" + +#elif (ETHERNET_USE_NRF528XX) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUITPLAY" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NRF52840_PCA10056" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif ( defined(CORE_TEENSY) ) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #if defined(ARDUINO_TEENSY41) + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET true + #elif defined(ARDUINO_TEENSY40) + #define BOARD_TYPE "TEENSY 4.0" + #else + #define + #endif + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#elif (ETHERNET_USE_STM32) + + #if defined(STM32F0) + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #define BOARD_TYPE "STM32MP1" + #else + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif ( defined(ESP8266) ) + // For ESP8266 + #warning Use ESP8266 architecture + #include + #define ETHERNET_USE_ESP8266 + #define BOARD_TYPE "ESP8266" + +#elif ( defined(ESP32) ) + // For ESP32 + #warning Use ESP32 architecture + #define ETHERNET_USE_ESP32 + #define BOARD_TYPE "ESP32" + + #define W5500_RST_PORT 21 + +#elif ETHERNET_USE_RPIPICO + + // Default pin 5 (in Mbed) or 17 to SS/CS + #if defined(ARDUINO_ARCH_MBED) + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + + #define USE_THIS_SS_PIN 17 + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_TYPE "MBED GENERIC_RP2040" + #else + #define BOARD_TYPE "MBED Unknown RP2040" + #endif + + #else + // For RPI Pico using E. Philhower RP2040 core + #if (USING_SPI2) + // SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1 + #define USE_THIS_SS_PIN 13 + #else + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0 + #define USE_THIS_SS_PIN 17 + #endif + + #endif + + #define SS_PIN_DEFAULT USE_THIS_SS_PIN + + // For RPI Pico + #warning Use RPI-Pico RP2040 architecture + +#else + // For Mega + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "AVR Mega" +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#include + +// Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported + +// To override the default CS/SS pin. Don't use unless you know exactly which pin to use +// You can define here or customize for each board at same place with BOARD_TYPE +// Check @ defined(SEEED_XIAO_M0) +//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false +////// + +#if USE_CUSTOM_ETHERNET + // You have to include an Ethernet library in your program + //#include "Ethernet_XYZ.h" + #include "EthernetLarge.h" + + #define SHIELD_TYPE "Custom Ethernet using EthernetLarge Library" +#endif + +#if (_MYSQL_LOGLEVEL_ > 1) + #if USE_ETHERNET_PORTENTA_H7 + #warning Use Portenta Ethernet lib + #elif USE_QN_ETHERNET + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_NATIVE_ETHERNET + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_ETHERNET_GENERIC + #warning Using Ethernet_Generic lib + #elif USE_ETHERNET_ESP8266 + #warning Using Ethernet_ESP8266 lib + #elif USE_ETHERNET_ENC + #warning Using EthernetENC lib + #elif USE_ETHERNET_LAN8742A + #warning Using LAN8742A Ethernet & STM32Ethernet lib + #elif USE_CUSTOM_ETHERNET + #warning Using Custom Ethernet library + #else + #define USE_ETHERNET_GENERIC true + + #warning Using Ethernet_Generic lib + #endif +#endif + +#if !( USE_ETHERNET_ENC || USE_ETHERNET_ESP8266 || USE_UIP_ETHERNET || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720 || USE_NATIVE_ETHERNET || \ + USE_QN_ETHERNET || USE_CUSTOM_ETHERNET || USE_ETHERNET_PORTENTA_H7 || USE_CUSTOM_ETHERNET ) + #define USE_ETHERNET_GENERIC true +#endif + +#if USE_ETHERNET_GENERIC + #define ETHERNET_LARGE_BUFFERS + + #define _ETG_LOGLEVEL_ 1 +#endif + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect_Default_Database/Connect_Default_Database.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect_Default_Database/Connect_Default_Database.ino new file mode 100644 index 0000000..7fe490b --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect_Default_Database/Connect_Default_Database.ino @@ -0,0 +1,241 @@ +/********************************************************************************************************************************* + Connect_Default_Database.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect with default database + + This example demonstrates how to connect to a MySQL server and specifying + the default database when connecting. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "world"; + +MySQL_Connection conn((Client *)&client); + +void initEthernet() +{ +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Default SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#if defined(ESP8266) + // For ESP8266, change for other boards if necessary + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN D2 // For ESP8266 + #endif + + MYSQL_LOGERROR1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // For ESP8266 + // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 + // Ethernet 0 X X X X 0 + // Ethernet2 X X X X X 0 + // Ethernet3 X X X X X 0 + // EthernetLarge X X X X X 0 + // Ethernet_ESP8266 0 0 0 0 0 0 + // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs + // Must use library patch for Ethernet, EthernetLarge libraries + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif defined(ESP32) + + // You can use Ethernet.init(pin) to configure the CS pin + //Ethernet.init(10); // Most Arduino shields + //Ethernet.init(5); // MKR ETH shield + //Ethernet.init(0); // Teensy 2.0 + //Ethernet.init(20); // Teensy++ 2.0 + //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet + //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet + + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 22 // For ESP32 + #endif + + MYSQL_LOGERROR1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge + // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif ETHERNET_USE_RPIPICO + + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 17 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif + + MYSQL_LOGERROR1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_LARGE ) + +#else //defined(ESP8266) + // unknown board, do nothing, use default SS = 10 + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 10 // For other boards + #endif + + MYSQL_LOGERROR3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries + + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#endif //defined(ESP8266) + +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + // Just info to know how to connect correctly + #if defined(CUR_PIN_MISO) + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), CUR_PIN_MOSI); + MYSQL_LOGERROR1(F("MISO:"), CUR_PIN_MISO); + MYSQL_LOGERROR1(F("SCK:"), CUR_PIN_SCK); + MYSQL_LOGERROR1(F("SS:"), CUR_PIN_SS); + #else + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + #endif + + MYSQL_LOGERROR(F("=========================")); +#endif + +#endif // #if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Connect_Default_Database on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect_Default_Database/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect_Default_Database/defines.h new file mode 100644 index 0000000..c6efb3d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect_Default_Database/defines.h @@ -0,0 +1,463 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 2 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define ETHERNET_USE_PORTENTA_H7 true + #define USE_ETHERNET_PORTENTA_H7 true + +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(ETHERNET_USE_SAMD) + #undef ETHERNET_USE_SAMD + #endif + #define ETHERNET_USE_SAMD true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(ETHERNET_USE_NRF528XX) + #undef ETHERNET_USE_NRF528XX + #endif + #define ETHERNET_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(ETHERNET_USE_SAM_DUE) + #undef ETHERNET_USE_SAM_DUE + #endif + #define ETHERNET_USE_SAM_DUE true +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(ETHERNET_USE_STM32) + #undef ETHERNET_USE_STM32 + #endif + #define ETHERNET_USE_STM32 true +#endif + +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) + #if defined(ETHERNET_USE_RPIPICO) + #undef ETHERNET_USE_RPIPICO + #endif + #define ETHERNET_USE_RPIPICO true +#endif + +#if defined(ETHERNET_USE_SAMD) + // For SAMD + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #ifdef USE_THIS_SS_PIN + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN A1 + #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif (ETHERNET_USE_SAM_DUE) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "SAM DUE" + +#elif (ETHERNET_USE_NRF528XX) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUITPLAY" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NRF52840_PCA10056" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif ( defined(CORE_TEENSY) ) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #if defined(ARDUINO_TEENSY41) + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET true + #elif defined(ARDUINO_TEENSY40) + #define BOARD_TYPE "TEENSY 4.0" + #else + #define + #endif + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#elif (ETHERNET_USE_STM32) + + #if defined(STM32F0) + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #define BOARD_TYPE "STM32MP1" + #else + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif ( defined(ESP8266) ) + // For ESP8266 + #warning Use ESP8266 architecture + #include + #define ETHERNET_USE_ESP8266 + #define BOARD_TYPE "ESP8266" + +#elif ( defined(ESP32) ) + // For ESP32 + #warning Use ESP32 architecture + #define ETHERNET_USE_ESP32 + #define BOARD_TYPE "ESP32" + + #define W5500_RST_PORT 21 + +#elif ETHERNET_USE_RPIPICO + + // Default pin 5 (in Mbed) or 17 to SS/CS + #if defined(ARDUINO_ARCH_MBED) + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + + #define USE_THIS_SS_PIN 17 + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_TYPE "MBED GENERIC_RP2040" + #else + #define BOARD_TYPE "MBED Unknown RP2040" + #endif + + #else + // For RPI Pico using E. Philhower RP2040 core + #if (USING_SPI2) + // SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1 + #define USE_THIS_SS_PIN 13 + #else + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0 + #define USE_THIS_SS_PIN 17 + #endif + + #endif + + #define SS_PIN_DEFAULT USE_THIS_SS_PIN + + // For RPI Pico + #warning Use RPI-Pico RP2040 architecture + +#else + // For Mega + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "AVR Mega" +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#include + +// Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported + +// To override the default CS/SS pin. Don't use unless you know exactly which pin to use +// You can define here or customize for each board at same place with BOARD_TYPE +// Check @ defined(SEEED_XIAO_M0) +//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false +////// + +#if USE_CUSTOM_ETHERNET + // You have to include an Ethernet library in your program + //#include "Ethernet_XYZ.h" + #include "EthernetLarge.h" + + #define SHIELD_TYPE "Custom Ethernet using EthernetLarge Library" +#endif + +#if (_MYSQL_LOGLEVEL_ > 1) + #if USE_ETHERNET_PORTENTA_H7 + #warning Use Portenta Ethernet lib + #elif USE_QN_ETHERNET + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_NATIVE_ETHERNET + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_ETHERNET_GENERIC + #warning Using Ethernet_Generic lib + #elif USE_ETHERNET_ESP8266 + #warning Using Ethernet_ESP8266 lib + #elif USE_ETHERNET_ENC + #warning Using EthernetENC lib + #elif USE_ETHERNET_LAN8742A + #warning Using LAN8742A Ethernet & STM32Ethernet lib + #elif USE_CUSTOM_ETHERNET + #warning Using Custom Ethernet library + #else + #define USE_ETHERNET_GENERIC true + + #warning Using Ethernet_Generic lib + #endif +#endif + +#if !( USE_ETHERNET_ENC || USE_ETHERNET_ESP8266 || USE_UIP_ETHERNET || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720 || USE_NATIVE_ETHERNET || \ + USE_QN_ETHERNET || USE_CUSTOM_ETHERNET || USE_ETHERNET_PORTENTA_H7 || USE_CUSTOM_ETHERNET ) + #define USE_ETHERNET_GENERIC true +#endif + +#if USE_ETHERNET_GENERIC + #define ETHERNET_LARGE_BUFFERS + + #define _ETG_LOGLEVEL_ 1 +#endif + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect_Disconnect/Connect_Disconnect.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect_Disconnect/Connect_Disconnect.ino new file mode 100644 index 0000000..a992b06 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect_Disconnect/Connect_Disconnect.ino @@ -0,0 +1,256 @@ +/********************************************************************************************************************************* + Connect_Disconnect.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : connect and disconnect (close) + + This example demonstrates how to use the connection to open at the start + of a loop, perform some query, then close the connection. Use this technique + for solutions that must sleep for a long period or otherwise require + additional processing or delays. The connect/close pair allow you to + control how long the connection is open and thus reduce the amount of + time a connection is held open. It also helps for lossy connections. + + This example demonstrates how to connect to a MySQL server and specifying + the default database when connecting. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +MySQL_Connection conn((Client *)&client); +MySQL_Query query = MySQL_Query(&conn); + +void initEthernet() +{ +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Default SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#if defined(ESP8266) + // For ESP8266, change for other boards if necessary + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN D2 // For ESP8266 + #endif + + MYSQL_LOGERROR1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // For ESP8266 + // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 + // Ethernet 0 X X X X 0 + // Ethernet2 X X X X X 0 + // Ethernet3 X X X X X 0 + // EthernetLarge X X X X X 0 + // Ethernet_ESP8266 0 0 0 0 0 0 + // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs + // Must use library patch for Ethernet, EthernetLarge libraries + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif defined(ESP32) + + // You can use Ethernet.init(pin) to configure the CS pin + //Ethernet.init(10); // Most Arduino shields + //Ethernet.init(5); // MKR ETH shield + //Ethernet.init(0); // Teensy 2.0 + //Ethernet.init(20); // Teensy++ 2.0 + //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet + //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet + + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 22 // For ESP32 + #endif + + MYSQL_LOGERROR1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge + // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif ETHERNET_USE_RPIPICO + + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 17 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif + + MYSQL_LOGERROR1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_LARGE ) + +#else //defined(ESP8266) + // unknown board, do nothing, use default SS = 10 + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 10 // For other boards + #endif + + MYSQL_LOGERROR3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries + + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#endif //defined(ESP8266) + +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + // Just info to know how to connect correctly + #if defined(CUR_PIN_MISO) + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), CUR_PIN_MOSI); + MYSQL_LOGERROR1(F("MISO:"), CUR_PIN_MISO); + MYSQL_LOGERROR1(F("SCK:"), CUR_PIN_SCK); + MYSQL_LOGERROR1(F("SS:"), CUR_PIN_SS); + #else + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + #endif + + MYSQL_LOGERROR(F("=========================")); +#endif + +#endif // #if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Connect_Disconnect on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); +} + +void runQuery() +{ + MYSQL_DISPLAY("Running a query: SELECT * FROM test_arduino.hello_arduino LIMIT 6;"); + + // Execute the query + // KH, check if valid before fetching + if ( !query.execute("SELECT * FROM test_arduino.hello_arduino LIMIT 6;") ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + query.show_results(); // show the results + query.close(); // close the query +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect_Disconnect/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect_Disconnect/defines.h new file mode 100644 index 0000000..c6efb3d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Connect_Disconnect/defines.h @@ -0,0 +1,463 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 2 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define ETHERNET_USE_PORTENTA_H7 true + #define USE_ETHERNET_PORTENTA_H7 true + +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(ETHERNET_USE_SAMD) + #undef ETHERNET_USE_SAMD + #endif + #define ETHERNET_USE_SAMD true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(ETHERNET_USE_NRF528XX) + #undef ETHERNET_USE_NRF528XX + #endif + #define ETHERNET_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(ETHERNET_USE_SAM_DUE) + #undef ETHERNET_USE_SAM_DUE + #endif + #define ETHERNET_USE_SAM_DUE true +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(ETHERNET_USE_STM32) + #undef ETHERNET_USE_STM32 + #endif + #define ETHERNET_USE_STM32 true +#endif + +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) + #if defined(ETHERNET_USE_RPIPICO) + #undef ETHERNET_USE_RPIPICO + #endif + #define ETHERNET_USE_RPIPICO true +#endif + +#if defined(ETHERNET_USE_SAMD) + // For SAMD + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #ifdef USE_THIS_SS_PIN + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN A1 + #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif (ETHERNET_USE_SAM_DUE) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "SAM DUE" + +#elif (ETHERNET_USE_NRF528XX) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUITPLAY" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NRF52840_PCA10056" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif ( defined(CORE_TEENSY) ) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #if defined(ARDUINO_TEENSY41) + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET true + #elif defined(ARDUINO_TEENSY40) + #define BOARD_TYPE "TEENSY 4.0" + #else + #define + #endif + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#elif (ETHERNET_USE_STM32) + + #if defined(STM32F0) + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #define BOARD_TYPE "STM32MP1" + #else + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif ( defined(ESP8266) ) + // For ESP8266 + #warning Use ESP8266 architecture + #include + #define ETHERNET_USE_ESP8266 + #define BOARD_TYPE "ESP8266" + +#elif ( defined(ESP32) ) + // For ESP32 + #warning Use ESP32 architecture + #define ETHERNET_USE_ESP32 + #define BOARD_TYPE "ESP32" + + #define W5500_RST_PORT 21 + +#elif ETHERNET_USE_RPIPICO + + // Default pin 5 (in Mbed) or 17 to SS/CS + #if defined(ARDUINO_ARCH_MBED) + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + + #define USE_THIS_SS_PIN 17 + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_TYPE "MBED GENERIC_RP2040" + #else + #define BOARD_TYPE "MBED Unknown RP2040" + #endif + + #else + // For RPI Pico using E. Philhower RP2040 core + #if (USING_SPI2) + // SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1 + #define USE_THIS_SS_PIN 13 + #else + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0 + #define USE_THIS_SS_PIN 17 + #endif + + #endif + + #define SS_PIN_DEFAULT USE_THIS_SS_PIN + + // For RPI Pico + #warning Use RPI-Pico RP2040 architecture + +#else + // For Mega + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "AVR Mega" +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#include + +// Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported + +// To override the default CS/SS pin. Don't use unless you know exactly which pin to use +// You can define here or customize for each board at same place with BOARD_TYPE +// Check @ defined(SEEED_XIAO_M0) +//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false +////// + +#if USE_CUSTOM_ETHERNET + // You have to include an Ethernet library in your program + //#include "Ethernet_XYZ.h" + #include "EthernetLarge.h" + + #define SHIELD_TYPE "Custom Ethernet using EthernetLarge Library" +#endif + +#if (_MYSQL_LOGLEVEL_ > 1) + #if USE_ETHERNET_PORTENTA_H7 + #warning Use Portenta Ethernet lib + #elif USE_QN_ETHERNET + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_NATIVE_ETHERNET + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_ETHERNET_GENERIC + #warning Using Ethernet_Generic lib + #elif USE_ETHERNET_ESP8266 + #warning Using Ethernet_ESP8266 lib + #elif USE_ETHERNET_ENC + #warning Using EthernetENC lib + #elif USE_ETHERNET_LAN8742A + #warning Using LAN8742A Ethernet & STM32Ethernet lib + #elif USE_CUSTOM_ETHERNET + #warning Using Custom Ethernet library + #else + #define USE_ETHERNET_GENERIC true + + #warning Using Ethernet_Generic lib + #endif +#endif + +#if !( USE_ETHERNET_ENC || USE_ETHERNET_ESP8266 || USE_UIP_ETHERNET || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720 || USE_NATIVE_ETHERNET || \ + USE_QN_ETHERNET || USE_CUSTOM_ETHERNET || USE_ETHERNET_PORTENTA_H7 || USE_CUSTOM_ETHERNET ) + #define USE_ETHERNET_GENERIC true +#endif + +#if USE_ETHERNET_GENERIC + #define ETHERNET_LARGE_BUFFERS + + #define _ETG_LOGLEVEL_ 1 +#endif + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Query_Progmem/Query_Progmem.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Query_Progmem/Query_Progmem.ino new file mode 100644 index 0000000..0916deb --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Query_Progmem/Query_Progmem.ino @@ -0,0 +1,270 @@ +/********************************************************************************************************************************* + Query_Progmem.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : query with PROGMEM strings + + This example demonstrates how to issue queries using strings stored in + PROGMEM. As you will see, you need only add a parameter to the execute() + method in the cursor class, const and PROGMEM to the string declaration + and add the #include directive. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +#if !(ESP32 || ESP8266) + #include +#endif + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +// Sample query +const char PROGMEM query[] = "SELECT * FROM test_arduino.hello_arduino LIMIT 6"; + +MySQL_Connection conn((Client *)&client); + +void initEthernet() +{ +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Default SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#if defined(ESP8266) + // For ESP8266, change for other boards if necessary + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN D2 // For ESP8266 + #endif + + MYSQL_LOGERROR1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // For ESP8266 + // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 + // Ethernet 0 X X X X 0 + // Ethernet2 X X X X X 0 + // Ethernet3 X X X X X 0 + // EthernetLarge X X X X X 0 + // Ethernet_ESP8266 0 0 0 0 0 0 + // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs + // Must use library patch for Ethernet, EthernetLarge libraries + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif defined(ESP32) + + // You can use Ethernet.init(pin) to configure the CS pin + //Ethernet.init(10); // Most Arduino shields + //Ethernet.init(5); // MKR ETH shield + //Ethernet.init(0); // Teensy 2.0 + //Ethernet.init(20); // Teensy++ 2.0 + //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet + //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet + + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 22 // For ESP32 + #endif + + MYSQL_LOGERROR1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge + // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif ETHERNET_USE_RPIPICO + + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 17 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif + + MYSQL_LOGERROR1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_LARGE ) + +#else //defined(ESP8266) + // unknown board, do nothing, use default SS = 10 + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 10 // For other boards + #endif + + MYSQL_LOGERROR3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries + + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#endif //defined(ESP8266) + +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + // Just info to know how to connect correctly + #if defined(CUR_PIN_MISO) + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), CUR_PIN_MOSI); + MYSQL_LOGERROR1(F("MISO:"), CUR_PIN_MISO); + MYSQL_LOGERROR1(F("SCK:"), CUR_PIN_SCK); + MYSQL_LOGERROR1(F("SS:"), CUR_PIN_SS); + #else + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + #endif + + MYSQL_LOGERROR(F("=========================")); +#endif + +#endif // #if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Query_Progmem on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void runQuery() +{ + MYSQL_DISPLAY("\nRunning SELECT from PROGMEM and printing results\n"); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query with the PROGMEM option + // KH, check if valid before fetching + if ( !query_mem.execute(query, true) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Show the results + query_mem.show_results(); + // close the query + query_mem.close(); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(10000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Query_Progmem/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Query_Progmem/defines.h new file mode 100644 index 0000000..c6efb3d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Query_Progmem/defines.h @@ -0,0 +1,463 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 2 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define ETHERNET_USE_PORTENTA_H7 true + #define USE_ETHERNET_PORTENTA_H7 true + +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(ETHERNET_USE_SAMD) + #undef ETHERNET_USE_SAMD + #endif + #define ETHERNET_USE_SAMD true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(ETHERNET_USE_NRF528XX) + #undef ETHERNET_USE_NRF528XX + #endif + #define ETHERNET_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(ETHERNET_USE_SAM_DUE) + #undef ETHERNET_USE_SAM_DUE + #endif + #define ETHERNET_USE_SAM_DUE true +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(ETHERNET_USE_STM32) + #undef ETHERNET_USE_STM32 + #endif + #define ETHERNET_USE_STM32 true +#endif + +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) + #if defined(ETHERNET_USE_RPIPICO) + #undef ETHERNET_USE_RPIPICO + #endif + #define ETHERNET_USE_RPIPICO true +#endif + +#if defined(ETHERNET_USE_SAMD) + // For SAMD + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #ifdef USE_THIS_SS_PIN + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN A1 + #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif (ETHERNET_USE_SAM_DUE) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "SAM DUE" + +#elif (ETHERNET_USE_NRF528XX) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUITPLAY" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NRF52840_PCA10056" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif ( defined(CORE_TEENSY) ) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #if defined(ARDUINO_TEENSY41) + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET true + #elif defined(ARDUINO_TEENSY40) + #define BOARD_TYPE "TEENSY 4.0" + #else + #define + #endif + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#elif (ETHERNET_USE_STM32) + + #if defined(STM32F0) + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #define BOARD_TYPE "STM32MP1" + #else + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif ( defined(ESP8266) ) + // For ESP8266 + #warning Use ESP8266 architecture + #include + #define ETHERNET_USE_ESP8266 + #define BOARD_TYPE "ESP8266" + +#elif ( defined(ESP32) ) + // For ESP32 + #warning Use ESP32 architecture + #define ETHERNET_USE_ESP32 + #define BOARD_TYPE "ESP32" + + #define W5500_RST_PORT 21 + +#elif ETHERNET_USE_RPIPICO + + // Default pin 5 (in Mbed) or 17 to SS/CS + #if defined(ARDUINO_ARCH_MBED) + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + + #define USE_THIS_SS_PIN 17 + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_TYPE "MBED GENERIC_RP2040" + #else + #define BOARD_TYPE "MBED Unknown RP2040" + #endif + + #else + // For RPI Pico using E. Philhower RP2040 core + #if (USING_SPI2) + // SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1 + #define USE_THIS_SS_PIN 13 + #else + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0 + #define USE_THIS_SS_PIN 17 + #endif + + #endif + + #define SS_PIN_DEFAULT USE_THIS_SS_PIN + + // For RPI Pico + #warning Use RPI-Pico RP2040 architecture + +#else + // For Mega + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "AVR Mega" +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#include + +// Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported + +// To override the default CS/SS pin. Don't use unless you know exactly which pin to use +// You can define here or customize for each board at same place with BOARD_TYPE +// Check @ defined(SEEED_XIAO_M0) +//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false +////// + +#if USE_CUSTOM_ETHERNET + // You have to include an Ethernet library in your program + //#include "Ethernet_XYZ.h" + #include "EthernetLarge.h" + + #define SHIELD_TYPE "Custom Ethernet using EthernetLarge Library" +#endif + +#if (_MYSQL_LOGLEVEL_ > 1) + #if USE_ETHERNET_PORTENTA_H7 + #warning Use Portenta Ethernet lib + #elif USE_QN_ETHERNET + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_NATIVE_ETHERNET + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_ETHERNET_GENERIC + #warning Using Ethernet_Generic lib + #elif USE_ETHERNET_ESP8266 + #warning Using Ethernet_ESP8266 lib + #elif USE_ETHERNET_ENC + #warning Using EthernetENC lib + #elif USE_ETHERNET_LAN8742A + #warning Using LAN8742A Ethernet & STM32Ethernet lib + #elif USE_CUSTOM_ETHERNET + #warning Using Custom Ethernet library + #else + #define USE_ETHERNET_GENERIC true + + #warning Using Ethernet_Generic lib + #endif +#endif + +#if !( USE_ETHERNET_ENC || USE_ETHERNET_ESP8266 || USE_UIP_ETHERNET || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720 || USE_NATIVE_ETHERNET || \ + USE_QN_ETHERNET || USE_CUSTOM_ETHERNET || USE_ETHERNET_PORTENTA_H7 || USE_CUSTOM_ETHERNET ) + #define USE_ETHERNET_GENERIC true +#endif + +#if USE_ETHERNET_GENERIC + #define ETHERNET_LARGE_BUFFERS + + #define _ETG_LOGLEVEL_ 1 +#endif + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Query_Results/Query_Results.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Query_Results/Query_Results.ino new file mode 100644 index 0000000..dd6c8f4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Query_Results/Query_Results.ino @@ -0,0 +1,300 @@ +/********************************************************************************************************************************* + Query_Results.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : query results + + This example demonstrates how to issue a SELECT query and how to read columns + and rows from the result set. Study this example until you are familiar with how to + do this before writing your own sketch to read and consume query results. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +// Sample query +char query[] = "SELECT * FROM test_arduino.hello_arduino LIMIT 6"; + +MySQL_Connection conn((Client *)&client); + +void initEthernet() +{ +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Default SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#if defined(ESP8266) + // For ESP8266, change for other boards if necessary + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN D2 // For ESP8266 + #endif + + MYSQL_LOGERROR1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // For ESP8266 + // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 + // Ethernet 0 X X X X 0 + // Ethernet2 X X X X X 0 + // Ethernet3 X X X X X 0 + // EthernetLarge X X X X X 0 + // Ethernet_ESP8266 0 0 0 0 0 0 + // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs + // Must use library patch for Ethernet, EthernetLarge libraries + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif defined(ESP32) + + // You can use Ethernet.init(pin) to configure the CS pin + //Ethernet.init(10); // Most Arduino shields + //Ethernet.init(5); // MKR ETH shield + //Ethernet.init(0); // Teensy 2.0 + //Ethernet.init(20); // Teensy++ 2.0 + //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet + //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet + + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 22 // For ESP32 + #endif + + MYSQL_LOGERROR1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge + // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif ETHERNET_USE_RPIPICO + + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 17 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif + + MYSQL_LOGERROR1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_LARGE ) + +#else //defined(ESP8266) + // unknown board, do nothing, use default SS = 10 + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 10 // For other boards + #endif + + MYSQL_LOGERROR3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries + + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#endif //defined(ESP8266) + +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + // Just info to know how to connect correctly + #if defined(CUR_PIN_MISO) + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), CUR_PIN_MOSI); + MYSQL_LOGERROR1(F("MISO:"), CUR_PIN_MISO); + MYSQL_LOGERROR1(F("SCK:"), CUR_PIN_SCK); + MYSQL_LOGERROR1(F("SS:"), CUR_PIN_SS); + #else + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + #endif + + MYSQL_LOGERROR(F("=========================")); +#endif + +#endif // #if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Query_Results on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void runQuery() +{ + MYSQL_DISPLAY("\nRunning SELECT and printing results"); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + ////// + + // Fetch the columns and print them + column_names *cols = query_mem.get_columns(); + + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(cols->fields[f]->name); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(", "); + } + } + + MYSQL_DISPLAY(); + + // Read the rows and print them + row_values *row = NULL; + + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(row->values[f]); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(", "); + } + } + + MYSQL_DISPLAY(); + } + } while (row != NULL); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(10000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Query_Results/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Query_Results/defines.h new file mode 100644 index 0000000..c6efb3d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/Query_Results/defines.h @@ -0,0 +1,463 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 2 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define ETHERNET_USE_PORTENTA_H7 true + #define USE_ETHERNET_PORTENTA_H7 true + +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(ETHERNET_USE_SAMD) + #undef ETHERNET_USE_SAMD + #endif + #define ETHERNET_USE_SAMD true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(ETHERNET_USE_NRF528XX) + #undef ETHERNET_USE_NRF528XX + #endif + #define ETHERNET_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(ETHERNET_USE_SAM_DUE) + #undef ETHERNET_USE_SAM_DUE + #endif + #define ETHERNET_USE_SAM_DUE true +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(ETHERNET_USE_STM32) + #undef ETHERNET_USE_STM32 + #endif + #define ETHERNET_USE_STM32 true +#endif + +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) + #if defined(ETHERNET_USE_RPIPICO) + #undef ETHERNET_USE_RPIPICO + #endif + #define ETHERNET_USE_RPIPICO true +#endif + +#if defined(ETHERNET_USE_SAMD) + // For SAMD + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #ifdef USE_THIS_SS_PIN + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN A1 + #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif (ETHERNET_USE_SAM_DUE) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "SAM DUE" + +#elif (ETHERNET_USE_NRF528XX) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUITPLAY" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NRF52840_PCA10056" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif ( defined(CORE_TEENSY) ) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #if defined(ARDUINO_TEENSY41) + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET true + #elif defined(ARDUINO_TEENSY40) + #define BOARD_TYPE "TEENSY 4.0" + #else + #define + #endif + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#elif (ETHERNET_USE_STM32) + + #if defined(STM32F0) + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #define BOARD_TYPE "STM32MP1" + #else + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif ( defined(ESP8266) ) + // For ESP8266 + #warning Use ESP8266 architecture + #include + #define ETHERNET_USE_ESP8266 + #define BOARD_TYPE "ESP8266" + +#elif ( defined(ESP32) ) + // For ESP32 + #warning Use ESP32 architecture + #define ETHERNET_USE_ESP32 + #define BOARD_TYPE "ESP32" + + #define W5500_RST_PORT 21 + +#elif ETHERNET_USE_RPIPICO + + // Default pin 5 (in Mbed) or 17 to SS/CS + #if defined(ARDUINO_ARCH_MBED) + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + + #define USE_THIS_SS_PIN 17 + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_TYPE "MBED GENERIC_RP2040" + #else + #define BOARD_TYPE "MBED Unknown RP2040" + #endif + + #else + // For RPI Pico using E. Philhower RP2040 core + #if (USING_SPI2) + // SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1 + #define USE_THIS_SS_PIN 13 + #else + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0 + #define USE_THIS_SS_PIN 17 + #endif + + #endif + + #define SS_PIN_DEFAULT USE_THIS_SS_PIN + + // For RPI Pico + #warning Use RPI-Pico RP2040 architecture + +#else + // For Mega + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "AVR Mega" +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#include + +// Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported + +// To override the default CS/SS pin. Don't use unless you know exactly which pin to use +// You can define here or customize for each board at same place with BOARD_TYPE +// Check @ defined(SEEED_XIAO_M0) +//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false +////// + +#if USE_CUSTOM_ETHERNET + // You have to include an Ethernet library in your program + //#include "Ethernet_XYZ.h" + #include "EthernetLarge.h" + + #define SHIELD_TYPE "Custom Ethernet using EthernetLarge Library" +#endif + +#if (_MYSQL_LOGLEVEL_ > 1) + #if USE_ETHERNET_PORTENTA_H7 + #warning Use Portenta Ethernet lib + #elif USE_QN_ETHERNET + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_NATIVE_ETHERNET + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_ETHERNET_GENERIC + #warning Using Ethernet_Generic lib + #elif USE_ETHERNET_ESP8266 + #warning Using Ethernet_ESP8266 lib + #elif USE_ETHERNET_ENC + #warning Using EthernetENC lib + #elif USE_ETHERNET_LAN8742A + #warning Using LAN8742A Ethernet & STM32Ethernet lib + #elif USE_CUSTOM_ETHERNET + #warning Using Custom Ethernet library + #else + #define USE_ETHERNET_GENERIC true + + #warning Using Ethernet_Generic lib + #endif +#endif + +#if !( USE_ETHERNET_ENC || USE_ETHERNET_ESP8266 || USE_UIP_ETHERNET || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720 || USE_NATIVE_ETHERNET || \ + USE_QN_ETHERNET || USE_CUSTOM_ETHERNET || USE_ETHERNET_PORTENTA_H7 || USE_CUSTOM_ETHERNET ) + #define USE_ETHERNET_GENERIC true +#endif + +#if USE_ETHERNET_GENERIC + #define ETHERNET_LARGE_BUFFERS + + #define _ETG_LOGLEVEL_ 1 +#endif + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/multiFileProject_Ethernet/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/multiFileProject_Ethernet/defines.h new file mode 100644 index 0000000..c6efb3d --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/multiFileProject_Ethernet/defines.h @@ -0,0 +1,463 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 2 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define ETHERNET_USE_PORTENTA_H7 true + #define USE_ETHERNET_PORTENTA_H7 true + +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(ETHERNET_USE_SAMD) + #undef ETHERNET_USE_SAMD + #endif + #define ETHERNET_USE_SAMD true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(ETHERNET_USE_NRF528XX) + #undef ETHERNET_USE_NRF528XX + #endif + #define ETHERNET_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(ETHERNET_USE_SAM_DUE) + #undef ETHERNET_USE_SAM_DUE + #endif + #define ETHERNET_USE_SAM_DUE true +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(ETHERNET_USE_STM32) + #undef ETHERNET_USE_STM32 + #endif + #define ETHERNET_USE_STM32 true +#endif + +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) + #if defined(ETHERNET_USE_RPIPICO) + #undef ETHERNET_USE_RPIPICO + #endif + #define ETHERNET_USE_RPIPICO true +#endif + +#if defined(ETHERNET_USE_SAMD) + // For SAMD + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #ifdef USE_THIS_SS_PIN + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN A1 + #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif (ETHERNET_USE_SAM_DUE) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "SAM DUE" + +#elif (ETHERNET_USE_NRF528XX) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUITPLAY" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NRF52840_PCA10056" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif ( defined(CORE_TEENSY) ) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #if defined(ARDUINO_TEENSY41) + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET true + #elif defined(ARDUINO_TEENSY40) + #define BOARD_TYPE "TEENSY 4.0" + #else + #define + #endif + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#elif (ETHERNET_USE_STM32) + + #if defined(STM32F0) + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #define BOARD_TYPE "STM32MP1" + #else + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif ( defined(ESP8266) ) + // For ESP8266 + #warning Use ESP8266 architecture + #include + #define ETHERNET_USE_ESP8266 + #define BOARD_TYPE "ESP8266" + +#elif ( defined(ESP32) ) + // For ESP32 + #warning Use ESP32 architecture + #define ETHERNET_USE_ESP32 + #define BOARD_TYPE "ESP32" + + #define W5500_RST_PORT 21 + +#elif ETHERNET_USE_RPIPICO + + // Default pin 5 (in Mbed) or 17 to SS/CS + #if defined(ARDUINO_ARCH_MBED) + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + + #define USE_THIS_SS_PIN 17 + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_TYPE "MBED GENERIC_RP2040" + #else + #define BOARD_TYPE "MBED Unknown RP2040" + #endif + + #else + // For RPI Pico using E. Philhower RP2040 core + #if (USING_SPI2) + // SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1 + #define USE_THIS_SS_PIN 13 + #else + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0 + #define USE_THIS_SS_PIN 17 + #endif + + #endif + + #define SS_PIN_DEFAULT USE_THIS_SS_PIN + + // For RPI Pico + #warning Use RPI-Pico RP2040 architecture + +#else + // For Mega + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "AVR Mega" +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#include + +// Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported + +// To override the default CS/SS pin. Don't use unless you know exactly which pin to use +// You can define here or customize for each board at same place with BOARD_TYPE +// Check @ defined(SEEED_XIAO_M0) +//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false +////// + +#if USE_CUSTOM_ETHERNET + // You have to include an Ethernet library in your program + //#include "Ethernet_XYZ.h" + #include "EthernetLarge.h" + + #define SHIELD_TYPE "Custom Ethernet using EthernetLarge Library" +#endif + +#if (_MYSQL_LOGLEVEL_ > 1) + #if USE_ETHERNET_PORTENTA_H7 + #warning Use Portenta Ethernet lib + #elif USE_QN_ETHERNET + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_NATIVE_ETHERNET + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #elif USE_ETHERNET_GENERIC + #warning Using Ethernet_Generic lib + #elif USE_ETHERNET_ESP8266 + #warning Using Ethernet_ESP8266 lib + #elif USE_ETHERNET_ENC + #warning Using EthernetENC lib + #elif USE_ETHERNET_LAN8742A + #warning Using LAN8742A Ethernet & STM32Ethernet lib + #elif USE_CUSTOM_ETHERNET + #warning Using Custom Ethernet library + #else + #define USE_ETHERNET_GENERIC true + + #warning Using Ethernet_Generic lib + #endif +#endif + +#if !( USE_ETHERNET_ENC || USE_ETHERNET_ESP8266 || USE_UIP_ETHERNET || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720 || USE_NATIVE_ETHERNET || \ + USE_QN_ETHERNET || USE_CUSTOM_ETHERNET || USE_ETHERNET_PORTENTA_H7 || USE_CUSTOM_ETHERNET ) + #define USE_ETHERNET_GENERIC true +#endif + +#if USE_ETHERNET_GENERIC + #define ETHERNET_LARGE_BUFFERS + + #define _ETG_LOGLEVEL_ 1 +#endif + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/multiFileProject_Ethernet/multiFileProject.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/multiFileProject_Ethernet/multiFileProject.cpp new file mode 100644 index 0000000..e1f0fe7 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/multiFileProject_Ethernet/multiFileProject.cpp @@ -0,0 +1,17 @@ +/**************************************************************************************************************************** + multiFileProject.cpp + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#include "multiFileProject.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/multiFileProject_Ethernet/multiFileProject.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/multiFileProject_Ethernet/multiFileProject.h new file mode 100644 index 0000000..5811a68 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/multiFileProject_Ethernet/multiFileProject.h @@ -0,0 +1,20 @@ +/**************************************************************************************************************************** + multiFileProject.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#pragma once + +// Can be included as many times as necessary, without `Multiple Definitions` Linker Error +#include "MySQL_Generic.hpp" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/multiFileProject_Ethernet/multiFileProject_Ethernet.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/multiFileProject_Ethernet/multiFileProject_Ethernet.ino new file mode 100644 index 0000000..7282564 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Ethernet/multiFileProject_Ethernet/multiFileProject_Ethernet.ino @@ -0,0 +1,188 @@ +/**************************************************************************************************************************** + multiFileProject.ino + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#include "defines.h" + +#define MYSQL_MARIADB_GENERIC_VERSION_MIN_TARGET "MySQL_MariaDB_Generic v1.7.0" +#define MYSQL_MARIADB_GENERIC_VERSION_MIN 1007000 + +#include "multiFileProject.h" + +// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error +#include "MySQL_Generic.h" + +void initEthernet() +{ +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Default SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#if defined(ESP8266) + // For ESP8266, change for other boards if necessary + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN D2 // For ESP8266 + #endif + + MYSQL_LOGERROR1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // For ESP8266 + // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 + // Ethernet 0 X X X X 0 + // Ethernet2 X X X X X 0 + // Ethernet3 X X X X X 0 + // EthernetLarge X X X X X 0 + // Ethernet_ESP8266 0 0 0 0 0 0 + // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs + // Must use library patch for Ethernet, EthernetLarge libraries + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif defined(ESP32) + + // You can use Ethernet.init(pin) to configure the CS pin + //Ethernet.init(10); // Most Arduino shields + //Ethernet.init(5); // MKR ETH shield + //Ethernet.init(0); // Teensy 2.0 + //Ethernet.init(20); // Teensy++ 2.0 + //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet + //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet + + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 22 // For ESP32 + #endif + + MYSQL_LOGERROR1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge + // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#elif ETHERNET_USE_RPIPICO + + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 17 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif + + MYSQL_LOGERROR1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_LARGE ) + +#else //defined(ESP8266) + // unknown board, do nothing, use default SS = 10 + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 10 // For other boards + #endif + + MYSQL_LOGERROR3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries + + Ethernet.init (USE_THIS_SS_PIN); + + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + +#endif //defined(ESP8266) + +#if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + // Just info to know how to connect correctly + #if defined(CUR_PIN_MISO) + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), CUR_PIN_MOSI); + MYSQL_LOGERROR1(F("MISO:"), CUR_PIN_MISO); + MYSQL_LOGERROR1(F("SCK:"), CUR_PIN_SCK); + MYSQL_LOGERROR1(F("SS:"), CUR_PIN_SS); + #else + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + #endif + + MYSQL_LOGERROR(F("=========================")); +#endif + +#endif // #if !(USE_ETHERNET_PORTENTA_H7 || USE_ETHERNET_LAN8742A || USE_ETHERNET_LAN8720) + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + Serial.println("\nStart multiFileProject"); + Serial.println(MYSQL_MARIADB_GENERIC_VERSION); + +#if defined(MYSQL_MARIADB_GENERIC_VERSION_MIN) + if (MYSQL_MARIADB_GENERIC_VERSION_INT < MYSQL_MARIADB_GENERIC_VERSION_MIN) + { + Serial.print("Warning. Must use this example on Version equal or later than : "); + Serial.println(MYSQL_MARIADB_GENERIC_VERSION_MIN_TARGET); + } +#endif +} + +void loop() +{ + // put your main code here, to run repeatedly: +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Basic_Insert/Basic_Insert.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Basic_Insert/Basic_Insert.ino new file mode 100644 index 0000000..f775320 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Basic_Insert/Basic_Insert.ino @@ -0,0 +1,159 @@ +/********************************************************************************************************************************* + Basic_Insert.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : basic insert + + This example demonstrates how to issue an INSERT query to store data in a + table. For this, we will create a special database and table for testing. + The following are the SQL commands you will need to run in order to setup + your database for running this sketch. + + CREATE DATABASE test_arduino; + CREATE TABLE test_arduino.hello_arduino ( + num integer primary key auto_increment, + message char(40), + recorded timestamp + ); + + Here we see one database and a table with three fields; a primary key that + is an auto_increment, a string, and a timestamp. This will demonstrate how + to save a date and time of when the row was inserted, which can help you + determine when data was recorded or updated. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Create the database and table as shown above. + 2) Change the address of the server to the IP address of the MySQL server + 3) Change the user and password to a valid MySQL user and password + 4) Connect a USB cable to your Arduino + 5) Select the correct board and port + 6) Compile and upload the sketch to your Arduino + 7) Once uploaded, open Serial Monitor (use 115200 speed) and observe + 8) After the sketch has run for some time, open a mysql client and issue + the command: "SELECT * FROM test_arduino.hello_arduino" to see the data + recorded. Note the field values and how the database handles both the + auto_increment and timestamp fields for us. You can clear the data with + "DELETE FROM test_arduino.hello_arduino". + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "test_arduino"; //"test_arduino"; +char default_table[] = "hello_arduino"; //"test_arduino"; + +String default_value = "Hello, Arduino!"; + +// Sample query +String INSERT_SQL = String("INSERT INTO ") + default_database + "." + default_table + + " (message) VALUES ('" + default_value + "')"; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Basic_Insert on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runInsert() +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + MYSQL_DISPLAY(INSERT_SQL); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(INSERT_SQL.c_str()) ) + { + MYSQL_DISPLAY("Insert error"); + } + else + { + MYSQL_DISPLAY("Data Inserted."); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + } +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Basic_Insert/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Basic_Insert/defines.h new file mode 100644 index 0000000..2640e25 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Basic_Insert/defines.h @@ -0,0 +1,84 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) || defined(ARDUINO_TEENSY41) ) + #if defined(USE_NATIVE_ETHERNET) + #undef USE_NATIVE_ETHERNET + #endif + #define USE_NATIVE_ETHERNET true + #define USE_QN_ETHERNET false + + #define BOARD_TYPE "Teensy 4.1" + #warning Use Teensy 4,1 with NativeEthernet library +#else + #error For Teensy 4.1 using NativeEthernet only. +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Basic_Select/Basic_Select.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Basic_Select/Basic_Select.ino new file mode 100644 index 0000000..c75680c --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Basic_Select/Basic_Select.ino @@ -0,0 +1,193 @@ +/********************************************************************************************************************************* + Basic_Select.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : basic select + + This example demonstrates how to issue a SELECT query with no parameters + and use the data returned. For this, we use the Cursor class to execute + the query and get the results. + + It demonstrates who methods for running queries. The first allows you to + allocate memory for the cursor and later reclaim it, the second shows how + to use a single instance of the cursor use throughout a sketch. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + CAUTION: Don't mix and match the examples. Use one or the other in your + own sketch -- you'll get compilation errors at the least. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "world"; //"test_arduino"; +char default_table[] = "city"; //"test_arduino"; + +String default_column = "population"; +String default_value = "Toronto"; + +String query = String("SELECT ") + default_column + " FROM " + default_database + "." + default_table + + " WHERE name = '" + default_value + "'"; + +MySQL_Connection conn((Client *)&client); +// Create an instance of the cursor passing in the connection +MySQL_Query sql_query = MySQL_Query(&conn); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Basic_Select on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runQuery() +{ + row_values *row = NULL; + long head_count = 0; + + MYSQL_DISPLAY("1) Demonstrating using a dynamically allocated query."); + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + MYSQL_DISPLAY(query); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(query.c_str()) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Fetch the columns (required) but we don't use them. + //column_names *columns = query_mem.get_columns(); + query_mem.get_columns(); + + // Read the row (we are only expecting the one) + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + head_count = atol(row->values[0]); + } + } while (row != NULL); + + // Show the result + MYSQL_DISPLAY1(" Toronto pop =", head_count); + + delay(500); + + MYSQL_DISPLAY("2) Demonstrating using a local, global query."); + + // Execute the query + MYSQL_DISPLAY(query); + sql_query.execute(query.c_str()); + + // Fetch the columns (required) but we don't use them. + sql_query.get_columns(); + + // Read the row (we are only expecting the one) + do + { + row = sql_query.get_next_row(); + if (row != NULL) + { + head_count = atol(row->values[0]); + } + } while (row != NULL); + + // Now we close the cursor to free any memory + sql_query.close(); + + // Show the result but this time do some math on it + MYSQL_DISPLAY1(" Toronto pop =", head_count); + MYSQL_DISPLAY1(" Toronto pop increased by 11725 =", head_count + 11725); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Basic_Select/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Basic_Select/defines.h new file mode 100644 index 0000000..2640e25 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Basic_Select/defines.h @@ -0,0 +1,84 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) || defined(ARDUINO_TEENSY41) ) + #if defined(USE_NATIVE_ETHERNET) + #undef USE_NATIVE_ETHERNET + #endif + #define USE_NATIVE_ETHERNET true + #define USE_QN_ETHERNET false + + #define BOARD_TYPE "Teensy 4.1" + #warning Use Teensy 4,1 with NativeEthernet library +#else + #error For Teensy 4.1 using NativeEthernet only. +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Complex_Insert/Complex_Insert.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Complex_Insert/Complex_Insert.ino new file mode 100644 index 0000000..5ddc718 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Complex_Insert/Complex_Insert.ino @@ -0,0 +1,184 @@ +/********************************************************************************************************************************* + Complex_Insert.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : complex insert + + This example demonstrates how to issue an INSERT query to store data in a + table using data from variables in our sketch. In this case, we supply the + values dynamically. + + This sketch simulates storing data from a sensor in a table. + + For this, we will create a special database and table for testing. + The following are the SQL commands you will need to run in order to setup + your database for running this sketch. + + CREATE DATABASE test_arduino; + CREATE TABLE test_arduino.hello_sensor ( + num integer primary key auto_increment, + message char(40), + sensor_num integer, + value float, + recorded timestamp + ); + + Here we have a table that contains an auto_increment primary key, a text + field, a field to identify the sensor, the value read, and timestamp of + the recorded data. + + Note: Since this sketch uses test data, we place the INSERT in the setup() + method so that it runs only once. Typically, you would have the + INSERT in the loop() method after your code to read from the sensor. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Create the database and table as shown above. + 2) Change the address of the server to the IP address of the MySQL server + 3) Change the user and password to a valid MySQL user and password + 4) Connect a USB cable to your Arduino + 5) Select the correct board and port + 6) Compile and upload the sketch to your Arduino + 7) Once uploaded, open Serial Monitor (use 115200 speed) and observe + 8) After the sketch has run for some time, open a mysql client and issue + the command: "SELECT * FROM test_arduino.hello_sensor" to see the data + recorded. Note the field values and how the database handles both the + auto_increment and timestamp fields for us. You can clear the data with + "DELETE FROM test_arduino.hello_sensor". + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "test_arduino"; //"test_arduino"; +char default_table[] = "hello_sensor"; //"test_arduino"; + +// Sample query +char INSERT_DATA[] = "INSERT INTO %s.%s (message, sensor_num, value) VALUES ('%s',%d,%s)"; + +char query[128]; +char temperature[10]; + +MySQL_Connection conn((Client *)&client); + +#if !( ESP32 || ESP8266 || defined(CORE_TEENSY) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) || defined(STM32F4) || defined(STM32F7) || ( defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED) ) ) + +char *dtostrf(double val, signed char width, unsigned char prec, char *sout) +{ + char fmt[20]; + sprintf(fmt, "%%%d.%df", width, prec); + sprintf(sout, fmt, val); + return sout; +} +#endif + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Complex_Insert on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); + MYSQL_DISPLAY3("DB =", default_database, ", Table =", default_table); +} + +void runInsert() +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + // Save + dtostrf(50.125, 1, 1, temperature); + sprintf(query, INSERT_DATA, default_database, default_table, "test sensor", 24, temperature); + + // Execute the query + MYSQL_DISPLAY(query); + + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Complex Insert error"); + } + else + { + MYSQL_DISPLAY("Complex Data Inserted."); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + } +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Complex_Insert/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Complex_Insert/defines.h new file mode 100644 index 0000000..2640e25 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Complex_Insert/defines.h @@ -0,0 +1,84 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) || defined(ARDUINO_TEENSY41) ) + #if defined(USE_NATIVE_ETHERNET) + #undef USE_NATIVE_ETHERNET + #endif + #define USE_NATIVE_ETHERNET true + #define USE_QN_ETHERNET false + + #define BOARD_TYPE "Teensy 4.1" + #warning Use Teensy 4,1 with NativeEthernet library +#else + #error For Teensy 4.1 using NativeEthernet only. +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Complex_Select/Complex_Select.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Complex_Select/Complex_Select.ino new file mode 100644 index 0000000..d46f0e1 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Complex_Select/Complex_Select.ino @@ -0,0 +1,190 @@ +/********************************************************************************************************************************* + Complex_Select.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : complex select + + This example demonstrates how to issue a SELECT query with parameters that + we provide from code. Thus, it demonstrates how to build query parameters + dynamically. + + Notice also the sketch demonstrates how to read columns and rows from + the result set. Study this example until you are familiar with how to + do this before writing your own sketch to read and consume query results. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "world"; //"test_arduino"; +char default_table[] = "city"; //"test_arduino"; + +// Sample query +// +// Notice the "%lu" - that's a placeholder for the parameter we will +// supply. See sprintf() documentation for more formatting specifier +// options +unsigned long QUERY_POPULATION = 800000; + +const char QUERY_POP[] = "SELECT name, population FROM world.city WHERE population < %lu ORDER BY population DESC LIMIT 12;"; + +char query[128]; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Complex_Select on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runQuery() +{ + MYSQL_DISPLAY("===================================================="); + MYSQL_DISPLAY("> Running SELECT with dynamically supplied parameter"); + + // Supply the parameter for the query + // Here we use the QUERY_POP as the format string and query as the + // destination. This uses twice the memory so another option would be + // to allocate one buffer for all formatted queries or allocate the + // memory as needed (just make sure you allocate enough memory and + // free it when you're done!). + sprintf(query, QUERY_POP, QUERY_POPULATION + (( millis() % 100000 ) * 10) ); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Fetch the columns and print them + column_names *cols = query_mem.get_columns(); + + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(cols->fields[f]->name); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(","); + } + } + + MYSQL_DISPLAY(); + + // Read the rows and print them + row_values *row = NULL; + + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(row->values[f]); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(","); + } + } + + MYSQL_DISPLAY(); + } + } while (row != NULL); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(10000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Complex_Select/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Complex_Select/defines.h new file mode 100644 index 0000000..2640e25 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Complex_Select/defines.h @@ -0,0 +1,84 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) || defined(ARDUINO_TEENSY41) ) + #if defined(USE_NATIVE_ETHERNET) + #undef USE_NATIVE_ETHERNET + #endif + #define USE_NATIVE_ETHERNET true + #define USE_QN_ETHERNET false + + #define BOARD_TYPE "Teensy 4.1" + #warning Use Teensy 4,1 with NativeEthernet library +#else + #error For Teensy 4.1 using NativeEthernet only. +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect/Connect.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect/Connect.ino new file mode 100644 index 0000000..f68e67b --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect/Connect.ino @@ -0,0 +1,111 @@ +/********************************************************************************************************************************* + Connect.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : connect + + This example demonstrates how to connect to a MySQL server from an + Arduino using an Arduino-compatible Ethernet shield. Note that "compatible" + means it must conform to the Ethernet class library or be a derivative + with the same classes and methods. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "world"; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Connect on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password, default_database)) + if (conn.connectNonBlocking(server, server_port, user, password, default_database) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect/defines.h new file mode 100644 index 0000000..2640e25 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect/defines.h @@ -0,0 +1,84 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) || defined(ARDUINO_TEENSY41) ) + #if defined(USE_NATIVE_ETHERNET) + #undef USE_NATIVE_ETHERNET + #endif + #define USE_NATIVE_ETHERNET true + #define USE_QN_ETHERNET false + + #define BOARD_TYPE "Teensy 4.1" + #warning Use Teensy 4,1 with NativeEthernet library +#else + #error For Teensy 4.1 using NativeEthernet only. +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect_By_Hostname/Connect_By_Hostname.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect_By_Hostname/Connect_By_Hostname.ino new file mode 100644 index 0000000..6ffb14c --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect_By_Hostname/Connect_By_Hostname.ino @@ -0,0 +1,109 @@ +/********************************************************************************************************************************* + Connect_By_Hostname.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect by hostname + + This example demonstrates how to connect to a MySQL server resolving the + hostname for cases when you do not know the IP address of the server or + it changes because it is in the cloud. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the hostname variable to the hostname of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ +#include "defines.h" + +#include +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +MySQL_Connection conn((Client *)&client); +DNSClient dns_client; // DNS instance + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Connect_By_Hostname on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect_By_Hostname/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect_By_Hostname/defines.h new file mode 100644 index 0000000..2640e25 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect_By_Hostname/defines.h @@ -0,0 +1,84 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) || defined(ARDUINO_TEENSY41) ) + #if defined(USE_NATIVE_ETHERNET) + #undef USE_NATIVE_ETHERNET + #endif + #define USE_NATIVE_ETHERNET true + #define USE_QN_ETHERNET false + + #define BOARD_TYPE "Teensy 4.1" + #warning Use Teensy 4,1 with NativeEthernet library +#else + #error For Teensy 4.1 using NativeEthernet only. +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect_Default_Database/Connect_Default_Database.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect_Default_Database/Connect_Default_Database.ino new file mode 100644 index 0000000..18c986a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect_Default_Database/Connect_Default_Database.ino @@ -0,0 +1,107 @@ +/********************************************************************************************************************************* + Connect_Default_Database.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect with default database + + This example demonstrates how to connect to a MySQL server and specifying + the default database when connecting. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "world"; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Connect_Default_Database on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect_Default_Database/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect_Default_Database/defines.h new file mode 100644 index 0000000..2640e25 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect_Default_Database/defines.h @@ -0,0 +1,84 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) || defined(ARDUINO_TEENSY41) ) + #if defined(USE_NATIVE_ETHERNET) + #undef USE_NATIVE_ETHERNET + #endif + #define USE_NATIVE_ETHERNET true + #define USE_QN_ETHERNET false + + #define BOARD_TYPE "Teensy 4.1" + #warning Use Teensy 4,1 with NativeEthernet library +#else + #error For Teensy 4.1 using NativeEthernet only. +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect_Disconnect/Connect_Disconnect.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect_Disconnect/Connect_Disconnect.ino new file mode 100644 index 0000000..024460e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect_Disconnect/Connect_Disconnect.ino @@ -0,0 +1,123 @@ +/********************************************************************************************************************************* + Connect_Disconnect.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : connect and disconnect (close) + + This example demonstrates how to use the connection to open at the start + of a loop, perform some query, then close the connection. Use this technique + for solutions that must sleep for a long period or otherwise require + additional processing or delays. The connect/close pair allow you to + control how long the connection is open and thus reduce the amount of + time a connection is held open. It also helps for lossy connections. + + This example demonstrates how to connect to a MySQL server and specifying + the default database when connecting. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +MySQL_Connection conn((Client *)&client); +MySQL_Query query = MySQL_Query(&conn); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Connect_Disconnect on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); +} + +void runQuery() +{ + MYSQL_DISPLAY("Running a query: SELECT * FROM test_arduino.hello_arduino LIMIT 6;"); + + // Execute the query + // KH, check if valid before fetching + if ( !query.execute("SELECT * FROM test_arduino.hello_arduino LIMIT 6;") ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + query.show_results(); // show the results + query.close(); // close the query +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect_Disconnect/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect_Disconnect/defines.h new file mode 100644 index 0000000..2640e25 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Connect_Disconnect/defines.h @@ -0,0 +1,84 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) || defined(ARDUINO_TEENSY41) ) + #if defined(USE_NATIVE_ETHERNET) + #undef USE_NATIVE_ETHERNET + #endif + #define USE_NATIVE_ETHERNET true + #define USE_QN_ETHERNET false + + #define BOARD_TYPE "Teensy 4.1" + #warning Use Teensy 4,1 with NativeEthernet library +#else + #error For Teensy 4.1 using NativeEthernet only. +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Query_Progmem/Query_Progmem.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Query_Progmem/Query_Progmem.ino new file mode 100644 index 0000000..de85d1a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Query_Progmem/Query_Progmem.ino @@ -0,0 +1,134 @@ +/********************************************************************************************************************************* + Query_Progmem.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : query with PROGMEM strings + + This example demonstrates how to issue queries using strings stored in + PROGMEM. As you will see, you need only add a parameter to the execute() + method in the cursor class, const and PROGMEM to the string declaration + and add the #include directive. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +// Sample query +const char PROGMEM query[] = "SELECT * FROM test_arduino.hello_arduino LIMIT 6"; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Query_Progmem on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void runQuery() +{ + MYSQL_DISPLAY("\nRunning SELECT from PROGMEM and printing results\n"); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query with the PROGMEM option + // KH, check if valid before fetching + if ( !query_mem.execute(query, true) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Show the results + query_mem.show_results(); + // close the query + query_mem.close(); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(10000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Query_Progmem/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Query_Progmem/defines.h new file mode 100644 index 0000000..2640e25 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Query_Progmem/defines.h @@ -0,0 +1,84 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) || defined(ARDUINO_TEENSY41) ) + #if defined(USE_NATIVE_ETHERNET) + #undef USE_NATIVE_ETHERNET + #endif + #define USE_NATIVE_ETHERNET true + #define USE_QN_ETHERNET false + + #define BOARD_TYPE "Teensy 4.1" + #warning Use Teensy 4,1 with NativeEthernet library +#else + #error For Teensy 4.1 using NativeEthernet only. +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Query_Results/Query_Results.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Query_Results/Query_Results.ino new file mode 100644 index 0000000..adc2f74 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Query_Results/Query_Results.ino @@ -0,0 +1,167 @@ +/********************************************************************************************************************************* + Query_Results.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : query results + + This example demonstrates how to issue a SELECT query and how to read columns + and rows from the result set. Study this example until you are familiar with how to + do this before writing your own sketch to read and consume query results. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +// Sample query +char query[] = "SELECT * FROM test_arduino.hello_arduino LIMIT 6"; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Query_Results on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void runQuery() +{ + MYSQL_DISPLAY("\nRunning SELECT and printing results"); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + ////// + + // Fetch the columns and print them + column_names *cols = query_mem.get_columns(); + + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(cols->fields[f]->name); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(", "); + } + } + + MYSQL_DISPLAY(); + + // Read the rows and print them + row_values *row = NULL; + + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(row->values[f]); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(", "); + } + } + + MYSQL_DISPLAY(); + } + } while (row != NULL); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(10000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Query_Results/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Query_Results/defines.h new file mode 100644 index 0000000..2640e25 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/Query_Results/defines.h @@ -0,0 +1,84 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) || defined(ARDUINO_TEENSY41) ) + #if defined(USE_NATIVE_ETHERNET) + #undef USE_NATIVE_ETHERNET + #endif + #define USE_NATIVE_ETHERNET true + #define USE_QN_ETHERNET false + + #define BOARD_TYPE "Teensy 4.1" + #warning Use Teensy 4,1 with NativeEthernet library +#else + #error For Teensy 4.1 using NativeEthernet only. +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/multiFileProject_NativeEthernet/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/multiFileProject_NativeEthernet/defines.h new file mode 100644 index 0000000..2640e25 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/multiFileProject_NativeEthernet/defines.h @@ -0,0 +1,84 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) || defined(ARDUINO_TEENSY41) ) + #if defined(USE_NATIVE_ETHERNET) + #undef USE_NATIVE_ETHERNET + #endif + #define USE_NATIVE_ETHERNET true + #define USE_QN_ETHERNET false + + #define BOARD_TYPE "Teensy 4.1" + #warning Use Teensy 4,1 with NativeEthernet library +#else + #error For Teensy 4.1 using NativeEthernet only. +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/multiFileProject_NativeEthernet/multiFileProject.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/multiFileProject_NativeEthernet/multiFileProject.cpp new file mode 100644 index 0000000..e1f0fe7 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/multiFileProject_NativeEthernet/multiFileProject.cpp @@ -0,0 +1,17 @@ +/**************************************************************************************************************************** + multiFileProject.cpp + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#include "multiFileProject.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/multiFileProject_NativeEthernet/multiFileProject.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/multiFileProject_NativeEthernet/multiFileProject.h new file mode 100644 index 0000000..5811a68 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/multiFileProject_NativeEthernet/multiFileProject.h @@ -0,0 +1,20 @@ +/**************************************************************************************************************************** + multiFileProject.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#pragma once + +// Can be included as many times as necessary, without `Multiple Definitions` Linker Error +#include "MySQL_Generic.hpp" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/multiFileProject_NativeEthernet/multiFileProject_NativeEthernet.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/multiFileProject_NativeEthernet/multiFileProject_NativeEthernet.ino new file mode 100644 index 0000000..ebb9431 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/NativeEthernet/multiFileProject_NativeEthernet/multiFileProject_NativeEthernet.ino @@ -0,0 +1,47 @@ +/**************************************************************************************************************************** + multiFileProject_NativeEthernet.ino + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#include "defines.h" + +#define MYSQL_MARIADB_GENERIC_VERSION_MIN_TARGET "MySQL_MariaDB_Generic v1.7.0" +#define MYSQL_MARIADB_GENERIC_VERSION_MIN 1007000 + +#include "multiFileProject.h" + +// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error +#include "MySQL_Generic.h" + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + Serial.println("\nStart multiFileProject_NativeEthernet"); + Serial.println(MYSQL_MARIADB_GENERIC_VERSION); + +#if defined(MYSQL_MARIADB_GENERIC_VERSION_MIN) + if (MYSQL_MARIADB_GENERIC_VERSION_INT < MYSQL_MARIADB_GENERIC_VERSION_MIN) + { + Serial.print("Warning. Must use this example on Version equal or later than : "); + Serial.println(MYSQL_MARIADB_GENERIC_VERSION_MIN_TARGET); + } +#endif +} + +void loop() +{ + // put your main code here, to run repeatedly: +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Basic_Insert/Basic_Insert.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Basic_Insert/Basic_Insert.ino new file mode 100644 index 0000000..4548c3a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Basic_Insert/Basic_Insert.ino @@ -0,0 +1,313 @@ +/********************************************************************************************************************************* + Basic_Insert.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : basic insert + + This example demonstrates how to issue an INSERT query to store data in a + table. For this, we will create a special database and table for testing. + The following are the SQL commands you will need to run in order to setup + your database for running this sketch. + + CREATE DATABASE test_arduino; + CREATE TABLE test_arduino.hello_arduino ( + num integer primary key auto_increment, + message char(40), + recorded timestamp + ); + + Here we see one database and a table with three fields; a primary key that + is an auto_increment, a string, and a timestamp. This will demonstrate how + to save a date and time of when the row was inserted, which can help you + determine when data was recorded or updated. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Create the database and table as shown above. + 2) Change the address of the server to the IP address of the MySQL server + 3) Change the user and password to a valid MySQL user and password + 4) Connect a USB cable to your Arduino + 5) Select the correct board and port + 6) Compile and upload the sketch to your Arduino + 7) Once uploaded, open Serial Monitor (use 115200 speed) and observe + 8) After the sketch has run for some time, open a mysql client and issue + the command: "SELECT * FROM test_arduino.hello_arduino" to see the data + recorded. Note the field values and how the database handles both the + auto_increment and timestamp fields for us. You can clear the data with + "DELETE FROM test_arduino.hello_arduino". + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "test_arduino"; //"test_arduino"; +char default_table[] = "hello_arduino"; //"test_arduino"; + +String default_value = "Hello, Arduino!"; + +// Sample query +String INSERT_SQL = String("INSERT INTO ") + default_database + "." + default_table + + " (message) VALUES ('" + default_value + "')"; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Basic_Insert on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + +#if !(USE_ETHERNET_PORTENTA_H7) + + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Default SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#if defined(ESP8266) + // For ESP8266, change for other boards if necessary + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN D2 // For ESP8266 + #endif + + MYSQL_LOGERROR1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // For ESP8266 + // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 + // Ethernet 0 X X X X 0 + // Ethernet2 X X X X X 0 + // Ethernet3 X X X X X 0 + // EthernetLarge X X X X X 0 + // Ethernet_ESP8266 0 0 0 0 0 0 + // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs + // Must use library patch for Ethernet, EthernetLarge libraries + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET_LARGE || USE_ETHERNET_ENC ) + +#elif defined(ESP32) + + // You can use Ethernet.init(pin) to configure the CS pin + //Ethernet.init(10); // Most Arduino shields + //Ethernet.init(5); // MKR ETH shield + //Ethernet.init(0); // Teensy 2.0 + //Ethernet.init(20); // Teensy++ 2.0 + //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet + //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet + + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 22 // For ESP32 + #endif + + MYSQL_LOGERROR1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge + // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET_LARGE || USE_ETHERNET_ENC ) + +#elif ETHERNET_USE_RPIPICO + + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 5 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif + + MYSQL_LOGERROR1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE ) + +#else //defined(ESP8266) + // unknown board, do nothing, use default SS = 10 + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 10 // For other boards + #endif + + MYSQL_LOGERROR3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries + + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET_LARGE || USE_ETHERNET_ENC ) + +#endif //defined(ESP8266) + + // Just info to know how to connect correctly + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#endif // #if !(USE_ETHERNET_PORTENTA_H7) + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runInsert() +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + MYSQL_DISPLAY(INSERT_SQL); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(INSERT_SQL.c_str()) ) + { + MYSQL_DISPLAY("Insert error"); + } + else + { + MYSQL_DISPLAY("Data Inserted."); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + } +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Basic_Insert/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Basic_Insert/defines.h new file mode 100644 index 0000000..1d00cfa --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Basic_Insert/defines.h @@ -0,0 +1,443 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define ETHERNET_USE_PORTENTA_H7 true + #define USE_ETHERNET_PORTENTA_H7 true + + #define USE_ETHERNET_WRAPPER false + +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(ETHERNET_USE_SAMD) + #undef ETHERNET_USE_SAMD + #endif + #define ETHERNET_USE_SAMD true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(ETHERNET_USE_NRF528XX) + #undef ETHERNET_USE_NRF528XX + #endif + #define ETHERNET_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(ETHERNET_USE_SAM_DUE) + #undef ETHERNET_USE_SAM_DUE + #endif + #define ETHERNET_USE_SAM_DUE true +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(ETHERNET_USE_STM32) + #undef ETHERNET_USE_STM32 + #endif + #define ETHERNET_USE_STM32 true +#endif + +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) + #if defined(ETHERNET_USE_RPIPICO) + #undef ETHERNET_USE_RPIPICO + #endif + #define ETHERNET_USE_RPIPICO true +#endif + +#if defined(ETHERNET_USE_SAMD) + // For SAMD + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #ifdef USE_THIS_SS_PIN + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN A1 + #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif (ETHERNET_USE_SAM_DUE) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "SAM DUE" + +#elif (ETHERNET_USE_NRF528XX) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUITPLAY" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NRF52840_PCA10056" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif ( defined(CORE_TEENSY) ) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#elif (ETHERNET_USE_STM32) + + #if defined(STM32F0) + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #define BOARD_TYPE "STM32MP1" + #else + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif ( defined(ESP8266) ) + // For ESP8266 + #warning Use ESP8266 architecture + #include + #define ETHERNET_USE_ESP8266 + #define BOARD_TYPE "ESP8266" + +#elif ( defined(ESP32) ) + // For ESP32 + #warning Use ESP32 architecture + #define ETHERNET_USE_ESP32 + #define BOARD_TYPE "ESP32" + + #define W5500_RST_PORT 21 + +#elif ETHERNET_USE_RPIPICO + + // Default pin 5 (in Mbed) or 17 to SS/CS + #if defined(ARDUINO_ARCH_MBED) + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + + #define USE_THIS_SS_PIN 5 + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_TYPE "MBED GENERIC_RP2040" + #else + #define BOARD_TYPE "MBED Unknown RP2040" + #endif + + #else + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + #define USE_THIS_SS_PIN 17 + + #endif + + #define SS_PIN_DEFAULT USE_THIS_SS_PIN + + // For RPI Pico + #warning Use RPI-Pico RP2040 architecture + +#else + // For Mega + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "AVR Mega" +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#include + +// Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported + +// To override the default CS/SS pin. Don't use unless you know exactly which pin to use +// You can define here or customize for each board at same place with BOARD_TYPE +// Check @ defined(SEEED_XIAO_M0) +//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 + +// Only one of the following to be true. +#define USE_ETHERNET false +#define USE_ETHERNET_LARGE false +#define USE_ETHERNET2 false +#define USE_ETHERNET3 false +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false + +// KH, from v1.0.1 +#define USE_UIP_ETHERNET false +////// + +#if USE_ETHERNET_PORTENTA_H7 + #warning Use Portenta Ethernet lib + #define SHIELD_TYPE "Ethernet using Portenta_Ethernet Library" +#elif USE_ETHERNET + #warning Use Ethernet lib + #define SHIELD_TYPE "W5x00 using Ethernet Library" +#elif USE_ETHERNET_LARGE + #warning Use EthernetLarge lib + #define SHIELD_TYPE "W5x00 using EthernetLarge Library" +#elif USE_ETHERNET2 + #warning Use Ethernet2 lib + #define SHIELD_TYPE "W5x00 using Ethernet2 Library" +#elif USE_ETHERNET3 + #warning Use Ethernet3 lib + #define SHIELD_TYPE "W5x00 using Ethernet3 Library" +#elif USE_ETHERNET_ESP8266 + #warning Using Ethernet_ESP8266 lib + #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" +#elif USE_ETHERNET_ENC + #warning Using EthernetENC lib + #define SHIELD_TYPE "ENC28J60 using EthernetENC Library" +#elif USE_ETHERNET_LAN8742A + #warning Using LAN8742A Ethernet & STM32Ethernet lib + #define SHIELD_TYPE "LAN8742A Ethernet & STM32Ethernet Library" +#else + #define USE_ETHERNET true + #include "Ethernet.h" + #warning Use Ethernet lib + #define SHIELD_TYPE "W5x00 using Ethernet Library" +#endif + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Basic_Select/Basic_Select.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Basic_Select/Basic_Select.ino new file mode 100644 index 0000000..b2a4da3 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Basic_Select/Basic_Select.ino @@ -0,0 +1,347 @@ +/********************************************************************************************************************************* + Basic_Select.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : basic select + + This example demonstrates how to issue a SELECT query with no parameters + and use the data returned. For this, we use the Cursor class to execute + the query and get the results. + + It demonstrates who methods for running queries. The first allows you to + allocate memory for the cursor and later reclaim it, the second shows how + to use a single instance of the cursor use throughout a sketch. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + CAUTION: Don't mix and match the examples. Use one or the other in your + own sketch -- you'll get compilation errors at the least. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "world"; //"test_arduino"; +char default_table[] = "city"; //"test_arduino"; + +String default_column = "population"; +String default_value = "Toronto"; + +String query = String("SELECT ") + default_column + " FROM " + default_database + "." + default_table + + " WHERE name = '" + default_value + "'"; + +MySQL_Connection conn((Client *)&client); +// Create an instance of the cursor passing in the connection +MySQL_Query sql_query = MySQL_Query(&conn); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Basic_Select on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + +#if !(USE_ETHERNET_PORTENTA_H7) + + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Default SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#if defined(ESP8266) + // For ESP8266, change for other boards if necessary + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN D2 // For ESP8266 + #endif + + MYSQL_LOGERROR1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // For ESP8266 + // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 + // Ethernet 0 X X X X 0 + // Ethernet2 X X X X X 0 + // Ethernet3 X X X X X 0 + // EthernetLarge X X X X X 0 + // Ethernet_ESP8266 0 0 0 0 0 0 + // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs + // Must use library patch for Ethernet, EthernetLarge libraries + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET_LARGE || USE_ETHERNET_ENC ) + +#elif defined(ESP32) + + // You can use Ethernet.init(pin) to configure the CS pin + //Ethernet.init(10); // Most Arduino shields + //Ethernet.init(5); // MKR ETH shield + //Ethernet.init(0); // Teensy 2.0 + //Ethernet.init(20); // Teensy++ 2.0 + //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet + //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet + + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 22 // For ESP32 + #endif + + MYSQL_LOGERROR1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge + // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET_LARGE || USE_ETHERNET_ENC ) + +#elif ETHERNET_USE_RPIPICO + + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 5 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif + + MYSQL_LOGERROR1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE ) + +#else //defined(ESP8266) + // unknown board, do nothing, use default SS = 10 + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 10 // For other boards + #endif + + MYSQL_LOGERROR3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries + + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET_LARGE || USE_ETHERNET_ENC ) + +#endif //defined(ESP8266) + + // Just info to know how to connect correctly + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#endif // #if !(USE_ETHERNET_PORTENTA_H7) + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runQuery() +{ + row_values *row = NULL; + long head_count = 0; + + MYSQL_DISPLAY("1) Demonstrating using a dynamically allocated query."); + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + MYSQL_DISPLAY(query); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(query.c_str()) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Fetch the columns (required) but we don't use them. + //column_names *columns = query_mem.get_columns(); + query_mem.get_columns(); + + // Read the row (we are only expecting the one) + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + head_count = atol(row->values[0]); + } + } while (row != NULL); + + // Show the result + MYSQL_DISPLAY1(" Toronto pop =", head_count); + + delay(500); + + MYSQL_DISPLAY("2) Demonstrating using a local, global query."); + + // Execute the query + MYSQL_DISPLAY(query); + sql_query.execute(query.c_str()); + + // Fetch the columns (required) but we don't use them. + sql_query.get_columns(); + + // Read the row (we are only expecting the one) + do + { + row = sql_query.get_next_row(); + if (row != NULL) + { + head_count = atol(row->values[0]); + } + } while (row != NULL); + + // Now we close the cursor to free any memory + sql_query.close(); + + // Show the result but this time do some math on it + MYSQL_DISPLAY1(" Toronto pop =", head_count); + MYSQL_DISPLAY1(" Toronto pop increased by 11725 =", head_count + 11725); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Basic_Select/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Basic_Select/defines.h new file mode 100644 index 0000000..1d00cfa --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Basic_Select/defines.h @@ -0,0 +1,443 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define ETHERNET_USE_PORTENTA_H7 true + #define USE_ETHERNET_PORTENTA_H7 true + + #define USE_ETHERNET_WRAPPER false + +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(ETHERNET_USE_SAMD) + #undef ETHERNET_USE_SAMD + #endif + #define ETHERNET_USE_SAMD true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(ETHERNET_USE_NRF528XX) + #undef ETHERNET_USE_NRF528XX + #endif + #define ETHERNET_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(ETHERNET_USE_SAM_DUE) + #undef ETHERNET_USE_SAM_DUE + #endif + #define ETHERNET_USE_SAM_DUE true +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(ETHERNET_USE_STM32) + #undef ETHERNET_USE_STM32 + #endif + #define ETHERNET_USE_STM32 true +#endif + +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) + #if defined(ETHERNET_USE_RPIPICO) + #undef ETHERNET_USE_RPIPICO + #endif + #define ETHERNET_USE_RPIPICO true +#endif + +#if defined(ETHERNET_USE_SAMD) + // For SAMD + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #ifdef USE_THIS_SS_PIN + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN A1 + #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif (ETHERNET_USE_SAM_DUE) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "SAM DUE" + +#elif (ETHERNET_USE_NRF528XX) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUITPLAY" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NRF52840_PCA10056" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif ( defined(CORE_TEENSY) ) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#elif (ETHERNET_USE_STM32) + + #if defined(STM32F0) + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #define BOARD_TYPE "STM32MP1" + #else + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif ( defined(ESP8266) ) + // For ESP8266 + #warning Use ESP8266 architecture + #include + #define ETHERNET_USE_ESP8266 + #define BOARD_TYPE "ESP8266" + +#elif ( defined(ESP32) ) + // For ESP32 + #warning Use ESP32 architecture + #define ETHERNET_USE_ESP32 + #define BOARD_TYPE "ESP32" + + #define W5500_RST_PORT 21 + +#elif ETHERNET_USE_RPIPICO + + // Default pin 5 (in Mbed) or 17 to SS/CS + #if defined(ARDUINO_ARCH_MBED) + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + + #define USE_THIS_SS_PIN 5 + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_TYPE "MBED GENERIC_RP2040" + #else + #define BOARD_TYPE "MBED Unknown RP2040" + #endif + + #else + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + #define USE_THIS_SS_PIN 17 + + #endif + + #define SS_PIN_DEFAULT USE_THIS_SS_PIN + + // For RPI Pico + #warning Use RPI-Pico RP2040 architecture + +#else + // For Mega + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "AVR Mega" +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#include + +// Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported + +// To override the default CS/SS pin. Don't use unless you know exactly which pin to use +// You can define here or customize for each board at same place with BOARD_TYPE +// Check @ defined(SEEED_XIAO_M0) +//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 + +// Only one of the following to be true. +#define USE_ETHERNET false +#define USE_ETHERNET_LARGE false +#define USE_ETHERNET2 false +#define USE_ETHERNET3 false +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false + +// KH, from v1.0.1 +#define USE_UIP_ETHERNET false +////// + +#if USE_ETHERNET_PORTENTA_H7 + #warning Use Portenta Ethernet lib + #define SHIELD_TYPE "Ethernet using Portenta_Ethernet Library" +#elif USE_ETHERNET + #warning Use Ethernet lib + #define SHIELD_TYPE "W5x00 using Ethernet Library" +#elif USE_ETHERNET_LARGE + #warning Use EthernetLarge lib + #define SHIELD_TYPE "W5x00 using EthernetLarge Library" +#elif USE_ETHERNET2 + #warning Use Ethernet2 lib + #define SHIELD_TYPE "W5x00 using Ethernet2 Library" +#elif USE_ETHERNET3 + #warning Use Ethernet3 lib + #define SHIELD_TYPE "W5x00 using Ethernet3 Library" +#elif USE_ETHERNET_ESP8266 + #warning Using Ethernet_ESP8266 lib + #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" +#elif USE_ETHERNET_ENC + #warning Using EthernetENC lib + #define SHIELD_TYPE "ENC28J60 using EthernetENC Library" +#elif USE_ETHERNET_LAN8742A + #warning Using LAN8742A Ethernet & STM32Ethernet lib + #define SHIELD_TYPE "LAN8742A Ethernet & STM32Ethernet Library" +#else + #define USE_ETHERNET true + #include "Ethernet.h" + #warning Use Ethernet lib + #define SHIELD_TYPE "W5x00 using Ethernet Library" +#endif + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Complex_Insert/Complex_Insert.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Complex_Insert/Complex_Insert.ino new file mode 100644 index 0000000..c857877 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Complex_Insert/Complex_Insert.ino @@ -0,0 +1,338 @@ +/********************************************************************************************************************************* + Complex_Insert.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : complex insert + + This example demonstrates how to issue an INSERT query to store data in a + table using data from variables in our sketch. In this case, we supply the + values dynamically. + + This sketch simulates storing data from a sensor in a table. + + For this, we will create a special database and table for testing. + The following are the SQL commands you will need to run in order to setup + your database for running this sketch. + + CREATE DATABASE test_arduino; + CREATE TABLE test_arduino.hello_sensor ( + num integer primary key auto_increment, + message char(40), + sensor_num integer, + value float, + recorded timestamp + ); + + Here we have a table that contains an auto_increment primary key, a text + field, a field to identify the sensor, the value read, and timestamp of + the recorded data. + + Note: Since this sketch uses test data, we place the INSERT in the setup() + method so that it runs only once. Typically, you would have the + INSERT in the loop() method after your code to read from the sensor. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Create the database and table as shown above. + 2) Change the address of the server to the IP address of the MySQL server + 3) Change the user and password to a valid MySQL user and password + 4) Connect a USB cable to your Arduino + 5) Select the correct board and port + 6) Compile and upload the sketch to your Arduino + 7) Once uploaded, open Serial Monitor (use 115200 speed) and observe + 8) After the sketch has run for some time, open a mysql client and issue + the command: "SELECT * FROM test_arduino.hello_sensor" to see the data + recorded. Note the field values and how the database handles both the + auto_increment and timestamp fields for us. You can clear the data with + "DELETE FROM test_arduino.hello_sensor". + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "test_arduino"; //"test_arduino"; +char default_table[] = "hello_sensor"; //"test_arduino"; + +// Sample query +char INSERT_DATA[] = "INSERT INTO %s.%s (message, sensor_num, value) VALUES ('%s',%d,%s)"; + +char query[128]; +char temperature[10]; + +MySQL_Connection conn((Client *)&client); + +#if !( ESP32 || ESP8266 || defined(CORE_TEENSY) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) || defined(STM32F4) || defined(STM32F7) || ( defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED) ) ) + +char *dtostrf(double val, signed char width, unsigned char prec, char *sout) +{ + char fmt[20]; + sprintf(fmt, "%%%d.%df", width, prec); + sprintf(sout, fmt, val); + return sout; +} +#endif + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Complex_Insert on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + +#if !(USE_ETHERNET_PORTENTA_H7) + + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Default SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#if defined(ESP8266) + // For ESP8266, change for other boards if necessary + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN D2 // For ESP8266 + #endif + + MYSQL_LOGERROR1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // For ESP8266 + // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 + // Ethernet 0 X X X X 0 + // Ethernet2 X X X X X 0 + // Ethernet3 X X X X X 0 + // EthernetLarge X X X X X 0 + // Ethernet_ESP8266 0 0 0 0 0 0 + // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs + // Must use library patch for Ethernet, EthernetLarge libraries + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET_LARGE || USE_ETHERNET_ENC ) + +#elif defined(ESP32) + + // You can use Ethernet.init(pin) to configure the CS pin + //Ethernet.init(10); // Most Arduino shields + //Ethernet.init(5); // MKR ETH shield + //Ethernet.init(0); // Teensy 2.0 + //Ethernet.init(20); // Teensy++ 2.0 + //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet + //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet + + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 22 // For ESP32 + #endif + + MYSQL_LOGERROR1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge + // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET_LARGE || USE_ETHERNET_ENC ) + +#elif ETHERNET_USE_RPIPICO + + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 5 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif + + MYSQL_LOGERROR1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE ) + +#else //defined(ESP8266) + // unknown board, do nothing, use default SS = 10 + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 10 // For other boards + #endif + + MYSQL_LOGERROR3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries + + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET_LARGE || USE_ETHERNET_ENC ) + +#endif //defined(ESP8266) + + // Just info to know how to connect correctly + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#endif // #if !(USE_ETHERNET_PORTENTA_H7) + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); + MYSQL_DISPLAY3("DB =", default_database, ", Table =", default_table); +} + +void runInsert() +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + // Save + dtostrf(50.125, 1, 1, temperature); + sprintf(query, INSERT_DATA, default_database, default_table, "test sensor", 24, temperature); + + // Execute the query + MYSQL_DISPLAY(query); + + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Complex Insert error"); + } + else + { + MYSQL_DISPLAY("Complex Data Inserted."); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + } +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Complex_Insert/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Complex_Insert/defines.h new file mode 100644 index 0000000..1d00cfa --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Complex_Insert/defines.h @@ -0,0 +1,443 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define ETHERNET_USE_PORTENTA_H7 true + #define USE_ETHERNET_PORTENTA_H7 true + + #define USE_ETHERNET_WRAPPER false + +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(ETHERNET_USE_SAMD) + #undef ETHERNET_USE_SAMD + #endif + #define ETHERNET_USE_SAMD true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(ETHERNET_USE_NRF528XX) + #undef ETHERNET_USE_NRF528XX + #endif + #define ETHERNET_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(ETHERNET_USE_SAM_DUE) + #undef ETHERNET_USE_SAM_DUE + #endif + #define ETHERNET_USE_SAM_DUE true +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(ETHERNET_USE_STM32) + #undef ETHERNET_USE_STM32 + #endif + #define ETHERNET_USE_STM32 true +#endif + +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) + #if defined(ETHERNET_USE_RPIPICO) + #undef ETHERNET_USE_RPIPICO + #endif + #define ETHERNET_USE_RPIPICO true +#endif + +#if defined(ETHERNET_USE_SAMD) + // For SAMD + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #ifdef USE_THIS_SS_PIN + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN A1 + #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif (ETHERNET_USE_SAM_DUE) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "SAM DUE" + +#elif (ETHERNET_USE_NRF528XX) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUITPLAY" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NRF52840_PCA10056" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif ( defined(CORE_TEENSY) ) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#elif (ETHERNET_USE_STM32) + + #if defined(STM32F0) + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #define BOARD_TYPE "STM32MP1" + #else + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif ( defined(ESP8266) ) + // For ESP8266 + #warning Use ESP8266 architecture + #include + #define ETHERNET_USE_ESP8266 + #define BOARD_TYPE "ESP8266" + +#elif ( defined(ESP32) ) + // For ESP32 + #warning Use ESP32 architecture + #define ETHERNET_USE_ESP32 + #define BOARD_TYPE "ESP32" + + #define W5500_RST_PORT 21 + +#elif ETHERNET_USE_RPIPICO + + // Default pin 5 (in Mbed) or 17 to SS/CS + #if defined(ARDUINO_ARCH_MBED) + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + + #define USE_THIS_SS_PIN 5 + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_TYPE "MBED GENERIC_RP2040" + #else + #define BOARD_TYPE "MBED Unknown RP2040" + #endif + + #else + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + #define USE_THIS_SS_PIN 17 + + #endif + + #define SS_PIN_DEFAULT USE_THIS_SS_PIN + + // For RPI Pico + #warning Use RPI-Pico RP2040 architecture + +#else + // For Mega + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "AVR Mega" +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#include + +// Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported + +// To override the default CS/SS pin. Don't use unless you know exactly which pin to use +// You can define here or customize for each board at same place with BOARD_TYPE +// Check @ defined(SEEED_XIAO_M0) +//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 + +// Only one of the following to be true. +#define USE_ETHERNET false +#define USE_ETHERNET_LARGE false +#define USE_ETHERNET2 false +#define USE_ETHERNET3 false +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false + +// KH, from v1.0.1 +#define USE_UIP_ETHERNET false +////// + +#if USE_ETHERNET_PORTENTA_H7 + #warning Use Portenta Ethernet lib + #define SHIELD_TYPE "Ethernet using Portenta_Ethernet Library" +#elif USE_ETHERNET + #warning Use Ethernet lib + #define SHIELD_TYPE "W5x00 using Ethernet Library" +#elif USE_ETHERNET_LARGE + #warning Use EthernetLarge lib + #define SHIELD_TYPE "W5x00 using EthernetLarge Library" +#elif USE_ETHERNET2 + #warning Use Ethernet2 lib + #define SHIELD_TYPE "W5x00 using Ethernet2 Library" +#elif USE_ETHERNET3 + #warning Use Ethernet3 lib + #define SHIELD_TYPE "W5x00 using Ethernet3 Library" +#elif USE_ETHERNET_ESP8266 + #warning Using Ethernet_ESP8266 lib + #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" +#elif USE_ETHERNET_ENC + #warning Using EthernetENC lib + #define SHIELD_TYPE "ENC28J60 using EthernetENC Library" +#elif USE_ETHERNET_LAN8742A + #warning Using LAN8742A Ethernet & STM32Ethernet lib + #define SHIELD_TYPE "LAN8742A Ethernet & STM32Ethernet Library" +#else + #define USE_ETHERNET true + #include "Ethernet.h" + #warning Use Ethernet lib + #define SHIELD_TYPE "W5x00 using Ethernet Library" +#endif + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Connect/Connect.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Connect/Connect.ino new file mode 100644 index 0000000..18fa11f --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Connect/Connect.ino @@ -0,0 +1,265 @@ +/********************************************************************************************************************************* + Connect.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : connect + + This example demonstrates how to connect to a MySQL server from an + Arduino using an Arduino-compatible Ethernet shield. Note that "compatible" + means it must conform to the Ethernet class library or be a derivative + with the same classes and methods. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "world"; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Connect on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + +#if !(USE_ETHERNET_PORTENTA_H7) + + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Default SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#if defined(ESP8266) + // For ESP8266, change for other boards if necessary + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN D2 // For ESP8266 + #endif + + MYSQL_LOGERROR1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // For ESP8266 + // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 + // Ethernet 0 X X X X 0 + // Ethernet2 X X X X X 0 + // Ethernet3 X X X X X 0 + // EthernetLarge X X X X X 0 + // Ethernet_ESP8266 0 0 0 0 0 0 + // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs + // Must use library patch for Ethernet, EthernetLarge libraries + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET_LARGE || USE_ETHERNET_ENC ) + +#elif defined(ESP32) + + // You can use Ethernet.init(pin) to configure the CS pin + //Ethernet.init(10); // Most Arduino shields + //Ethernet.init(5); // MKR ETH shield + //Ethernet.init(0); // Teensy 2.0 + //Ethernet.init(20); // Teensy++ 2.0 + //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet + //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet + + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 22 // For ESP32 + #endif + + MYSQL_LOGERROR1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge + // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET_LARGE || USE_ETHERNET_ENC ) + +#elif ETHERNET_USE_RPIPICO + + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 5 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif + + MYSQL_LOGERROR1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE ) + +#else //defined(ESP8266) + // unknown board, do nothing, use default SS = 10 + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 10 // For other boards + #endif + + MYSQL_LOGERROR3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries + + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET_LARGE || USE_ETHERNET_ENC ) + +#endif //defined(ESP8266) + + // Just info to know how to connect correctly + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#endif // #if !(USE_ETHERNET_PORTENTA_H7) + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password, default_database)) + if (conn.connectNonBlocking(server, server_port, user, password, default_database) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Connect/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Connect/defines.h new file mode 100644 index 0000000..1d00cfa --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Connect/defines.h @@ -0,0 +1,443 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define ETHERNET_USE_PORTENTA_H7 true + #define USE_ETHERNET_PORTENTA_H7 true + + #define USE_ETHERNET_WRAPPER false + +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(ETHERNET_USE_SAMD) + #undef ETHERNET_USE_SAMD + #endif + #define ETHERNET_USE_SAMD true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(ETHERNET_USE_NRF528XX) + #undef ETHERNET_USE_NRF528XX + #endif + #define ETHERNET_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(ETHERNET_USE_SAM_DUE) + #undef ETHERNET_USE_SAM_DUE + #endif + #define ETHERNET_USE_SAM_DUE true +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(ETHERNET_USE_STM32) + #undef ETHERNET_USE_STM32 + #endif + #define ETHERNET_USE_STM32 true +#endif + +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) + #if defined(ETHERNET_USE_RPIPICO) + #undef ETHERNET_USE_RPIPICO + #endif + #define ETHERNET_USE_RPIPICO true +#endif + +#if defined(ETHERNET_USE_SAMD) + // For SAMD + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #ifdef USE_THIS_SS_PIN + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN A1 + #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif (ETHERNET_USE_SAM_DUE) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "SAM DUE" + +#elif (ETHERNET_USE_NRF528XX) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUITPLAY" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NRF52840_PCA10056" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif ( defined(CORE_TEENSY) ) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#elif (ETHERNET_USE_STM32) + + #if defined(STM32F0) + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #define BOARD_TYPE "STM32MP1" + #else + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif ( defined(ESP8266) ) + // For ESP8266 + #warning Use ESP8266 architecture + #include + #define ETHERNET_USE_ESP8266 + #define BOARD_TYPE "ESP8266" + +#elif ( defined(ESP32) ) + // For ESP32 + #warning Use ESP32 architecture + #define ETHERNET_USE_ESP32 + #define BOARD_TYPE "ESP32" + + #define W5500_RST_PORT 21 + +#elif ETHERNET_USE_RPIPICO + + // Default pin 5 (in Mbed) or 17 to SS/CS + #if defined(ARDUINO_ARCH_MBED) + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + + #define USE_THIS_SS_PIN 5 + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_TYPE "MBED GENERIC_RP2040" + #else + #define BOARD_TYPE "MBED Unknown RP2040" + #endif + + #else + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + #define USE_THIS_SS_PIN 17 + + #endif + + #define SS_PIN_DEFAULT USE_THIS_SS_PIN + + // For RPI Pico + #warning Use RPI-Pico RP2040 architecture + +#else + // For Mega + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "AVR Mega" +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#include + +// Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported + +// To override the default CS/SS pin. Don't use unless you know exactly which pin to use +// You can define here or customize for each board at same place with BOARD_TYPE +// Check @ defined(SEEED_XIAO_M0) +//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 + +// Only one of the following to be true. +#define USE_ETHERNET false +#define USE_ETHERNET_LARGE false +#define USE_ETHERNET2 false +#define USE_ETHERNET3 false +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false + +// KH, from v1.0.1 +#define USE_UIP_ETHERNET false +////// + +#if USE_ETHERNET_PORTENTA_H7 + #warning Use Portenta Ethernet lib + #define SHIELD_TYPE "Ethernet using Portenta_Ethernet Library" +#elif USE_ETHERNET + #warning Use Ethernet lib + #define SHIELD_TYPE "W5x00 using Ethernet Library" +#elif USE_ETHERNET_LARGE + #warning Use EthernetLarge lib + #define SHIELD_TYPE "W5x00 using EthernetLarge Library" +#elif USE_ETHERNET2 + #warning Use Ethernet2 lib + #define SHIELD_TYPE "W5x00 using Ethernet2 Library" +#elif USE_ETHERNET3 + #warning Use Ethernet3 lib + #define SHIELD_TYPE "W5x00 using Ethernet3 Library" +#elif USE_ETHERNET_ESP8266 + #warning Using Ethernet_ESP8266 lib + #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" +#elif USE_ETHERNET_ENC + #warning Using EthernetENC lib + #define SHIELD_TYPE "ENC28J60 using EthernetENC Library" +#elif USE_ETHERNET_LAN8742A + #warning Using LAN8742A Ethernet & STM32Ethernet lib + #define SHIELD_TYPE "LAN8742A Ethernet & STM32Ethernet Library" +#else + #define USE_ETHERNET true + #include "Ethernet.h" + #warning Use Ethernet lib + #define SHIELD_TYPE "W5x00 using Ethernet Library" +#endif + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Connect_By_Hostname/Connect_By_Hostname.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Connect_By_Hostname/Connect_By_Hostname.ino new file mode 100644 index 0000000..9aa5101 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Connect_By_Hostname/Connect_By_Hostname.ino @@ -0,0 +1,264 @@ +/********************************************************************************************************************************* + Connect_By_Hostname.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect by hostname + + This example demonstrates how to connect to a MySQL server resolving the + hostname for cases when you do not know the IP address of the server or + it changes because it is in the cloud. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the hostname variable to the hostname of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ +#include "defines.h" + +#include + +#if !(USE_ETHERNET_PORTENTA_H7) + #include +#endif + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Connect_By_Hostname on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + +#if !(USE_ETHERNET_PORTENTA_H7) + + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Default SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#if defined(ESP8266) + // For ESP8266, change for other boards if necessary + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN D2 // For ESP8266 + #endif + + MYSQL_LOGERROR1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // For ESP8266 + // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 + // Ethernet 0 X X X X 0 + // Ethernet2 X X X X X 0 + // Ethernet3 X X X X X 0 + // EthernetLarge X X X X X 0 + // Ethernet_ESP8266 0 0 0 0 0 0 + // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs + // Must use library patch for Ethernet, EthernetLarge libraries + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET_LARGE || USE_ETHERNET_ENC ) + +#elif defined(ESP32) + + // You can use Ethernet.init(pin) to configure the CS pin + //Ethernet.init(10); // Most Arduino shields + //Ethernet.init(5); // MKR ETH shield + //Ethernet.init(0); // Teensy 2.0 + //Ethernet.init(20); // Teensy++ 2.0 + //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet + //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet + + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 22 // For ESP32 + #endif + + MYSQL_LOGERROR1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge + // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET_LARGE || USE_ETHERNET_ENC ) + +#elif ETHERNET_USE_RPIPICO + + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 5 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif + + MYSQL_LOGERROR1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE ) + +#else //defined(ESP8266) + // unknown board, do nothing, use default SS = 10 + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 10 // For other boards + #endif + + MYSQL_LOGERROR3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries + + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET_LARGE || USE_ETHERNET_ENC ) + +#endif //defined(ESP8266) + + // Just info to know how to connect correctly + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#endif // #if !(USE_ETHERNET_PORTENTA_H7) + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Connect_By_Hostname/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Connect_By_Hostname/defines.h new file mode 100644 index 0000000..1d00cfa --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Connect_By_Hostname/defines.h @@ -0,0 +1,443 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define ETHERNET_USE_PORTENTA_H7 true + #define USE_ETHERNET_PORTENTA_H7 true + + #define USE_ETHERNET_WRAPPER false + +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(ETHERNET_USE_SAMD) + #undef ETHERNET_USE_SAMD + #endif + #define ETHERNET_USE_SAMD true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(ETHERNET_USE_NRF528XX) + #undef ETHERNET_USE_NRF528XX + #endif + #define ETHERNET_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(ETHERNET_USE_SAM_DUE) + #undef ETHERNET_USE_SAM_DUE + #endif + #define ETHERNET_USE_SAM_DUE true +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(ETHERNET_USE_STM32) + #undef ETHERNET_USE_STM32 + #endif + #define ETHERNET_USE_STM32 true +#endif + +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) + #if defined(ETHERNET_USE_RPIPICO) + #undef ETHERNET_USE_RPIPICO + #endif + #define ETHERNET_USE_RPIPICO true +#endif + +#if defined(ETHERNET_USE_SAMD) + // For SAMD + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #ifdef USE_THIS_SS_PIN + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN A1 + #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif (ETHERNET_USE_SAM_DUE) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "SAM DUE" + +#elif (ETHERNET_USE_NRF528XX) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUITPLAY" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NRF52840_PCA10056" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif ( defined(CORE_TEENSY) ) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#elif (ETHERNET_USE_STM32) + + #if defined(STM32F0) + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #define BOARD_TYPE "STM32MP1" + #else + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif ( defined(ESP8266) ) + // For ESP8266 + #warning Use ESP8266 architecture + #include + #define ETHERNET_USE_ESP8266 + #define BOARD_TYPE "ESP8266" + +#elif ( defined(ESP32) ) + // For ESP32 + #warning Use ESP32 architecture + #define ETHERNET_USE_ESP32 + #define BOARD_TYPE "ESP32" + + #define W5500_RST_PORT 21 + +#elif ETHERNET_USE_RPIPICO + + // Default pin 5 (in Mbed) or 17 to SS/CS + #if defined(ARDUINO_ARCH_MBED) + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + + #define USE_THIS_SS_PIN 5 + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_TYPE "MBED GENERIC_RP2040" + #else + #define BOARD_TYPE "MBED Unknown RP2040" + #endif + + #else + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + #define USE_THIS_SS_PIN 17 + + #endif + + #define SS_PIN_DEFAULT USE_THIS_SS_PIN + + // For RPI Pico + #warning Use RPI-Pico RP2040 architecture + +#else + // For Mega + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "AVR Mega" +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#include + +// Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported + +// To override the default CS/SS pin. Don't use unless you know exactly which pin to use +// You can define here or customize for each board at same place with BOARD_TYPE +// Check @ defined(SEEED_XIAO_M0) +//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 + +// Only one of the following to be true. +#define USE_ETHERNET false +#define USE_ETHERNET_LARGE false +#define USE_ETHERNET2 false +#define USE_ETHERNET3 false +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false + +// KH, from v1.0.1 +#define USE_UIP_ETHERNET false +////// + +#if USE_ETHERNET_PORTENTA_H7 + #warning Use Portenta Ethernet lib + #define SHIELD_TYPE "Ethernet using Portenta_Ethernet Library" +#elif USE_ETHERNET + #warning Use Ethernet lib + #define SHIELD_TYPE "W5x00 using Ethernet Library" +#elif USE_ETHERNET_LARGE + #warning Use EthernetLarge lib + #define SHIELD_TYPE "W5x00 using EthernetLarge Library" +#elif USE_ETHERNET2 + #warning Use Ethernet2 lib + #define SHIELD_TYPE "W5x00 using Ethernet2 Library" +#elif USE_ETHERNET3 + #warning Use Ethernet3 lib + #define SHIELD_TYPE "W5x00 using Ethernet3 Library" +#elif USE_ETHERNET_ESP8266 + #warning Using Ethernet_ESP8266 lib + #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" +#elif USE_ETHERNET_ENC + #warning Using EthernetENC lib + #define SHIELD_TYPE "ENC28J60 using EthernetENC Library" +#elif USE_ETHERNET_LAN8742A + #warning Using LAN8742A Ethernet & STM32Ethernet lib + #define SHIELD_TYPE "LAN8742A Ethernet & STM32Ethernet Library" +#else + #define USE_ETHERNET true + #include "Ethernet.h" + #warning Use Ethernet lib + #define SHIELD_TYPE "W5x00 using Ethernet Library" +#endif + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Connect_Default_Database/Connect_Default_Database.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Connect_Default_Database/Connect_Default_Database.ino new file mode 100644 index 0000000..fddd1e0 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Connect_Default_Database/Connect_Default_Database.ino @@ -0,0 +1,262 @@ +/********************************************************************************************************************************* + Connect_Default_Database.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect with default database + + This example demonstrates how to connect to a MySQL server and specifying + the default database when connecting. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +// Select the static Local IP address according to your local network +IPAddress ip(192, 168, 2, 222); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "world"; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY3("\nStarting Connect_Default_Database on", BOARD_NAME, ", with", SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + +#if !(USE_ETHERNET_PORTENTA_H7) + + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Default SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#if defined(ESP8266) + // For ESP8266, change for other boards if necessary + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN D2 // For ESP8266 + #endif + + MYSQL_LOGERROR1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // For ESP8266 + // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 + // Ethernet 0 X X X X 0 + // Ethernet2 X X X X X 0 + // Ethernet3 X X X X X 0 + // EthernetLarge X X X X X 0 + // Ethernet_ESP8266 0 0 0 0 0 0 + // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs + // Must use library patch for Ethernet, EthernetLarge libraries + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET_LARGE || USE_ETHERNET_ENC ) + +#elif defined(ESP32) + + // You can use Ethernet.init(pin) to configure the CS pin + //Ethernet.init(10); // Most Arduino shields + //Ethernet.init(5); // MKR ETH shield + //Ethernet.init(0); // Teensy 2.0 + //Ethernet.init(20); // Teensy++ 2.0 + //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet + //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet + + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 22 // For ESP32 + #endif + + MYSQL_LOGERROR1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge + // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET_LARGE || USE_ETHERNET_ENC ) + +#elif ETHERNET_USE_RPIPICO + + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 5 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif + + MYSQL_LOGERROR1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE ) + +#else //defined(ESP8266) + // unknown board, do nothing, use default SS = 10 + #ifndef USE_THIS_SS_PIN + #define USE_THIS_SS_PIN 10 // For other boards + #endif + + MYSQL_LOGERROR3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + + // For other boards, to change if necessary + #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries + + Ethernet.init (USE_THIS_SS_PIN); + + #elif USE_ETHERNET3 + // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer + #ifndef ETHERNET3_MAX_SOCK_NUM + #define ETHERNET3_MAX_SOCK_NUM 4 + #endif + + Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (ETHERNET3_MAX_SOCK_NUM); + + #endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET_LARGE || USE_ETHERNET_ENC ) + +#endif //defined(ESP8266) + + // Just info to know how to connect correctly + MYSQL_LOGERROR(F("=========================================")); + MYSQL_LOGERROR(F("Currently Used SPI pinout:")); + MYSQL_LOGERROR1(F("MOSI:"), MOSI); + MYSQL_LOGERROR1(F("MISO:"), MISO); + MYSQL_LOGERROR1(F("SCK:"), SCK); + MYSQL_LOGERROR1(F("SS:"), SS); + MYSQL_LOGERROR(F("=========================================")); + +#endif // #if !(USE_ETHERNET_PORTENTA_H7) + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Connect_Default_Database/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Connect_Default_Database/defines.h new file mode 100644 index 0000000..1d00cfa --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/Connect_Default_Database/defines.h @@ -0,0 +1,443 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define ETHERNET_USE_PORTENTA_H7 true + #define USE_ETHERNET_PORTENTA_H7 true + + #define USE_ETHERNET_WRAPPER false + +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(ETHERNET_USE_SAMD) + #undef ETHERNET_USE_SAMD + #endif + #define ETHERNET_USE_SAMD true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(ETHERNET_USE_NRF528XX) + #undef ETHERNET_USE_NRF528XX + #endif + #define ETHERNET_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(ETHERNET_USE_SAM_DUE) + #undef ETHERNET_USE_SAM_DUE + #endif + #define ETHERNET_USE_SAM_DUE true +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(ETHERNET_USE_STM32) + #undef ETHERNET_USE_STM32 + #endif + #define ETHERNET_USE_STM32 true +#endif + +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) + #if defined(ETHERNET_USE_RPIPICO) + #undef ETHERNET_USE_RPIPICO + #endif + #define ETHERNET_USE_RPIPICO true +#endif + +#if defined(ETHERNET_USE_SAMD) + // For SAMD + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #ifdef USE_THIS_SS_PIN + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN A1 + #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif (ETHERNET_USE_SAM_DUE) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "SAM DUE" + +#elif (ETHERNET_USE_NRF528XX) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUITPLAY" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NRF52840_PCA10056" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif ( defined(CORE_TEENSY) ) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#elif (ETHERNET_USE_STM32) + + #if defined(STM32F0) + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #define BOARD_TYPE "STM32MP1" + #else + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif ( defined(ESP8266) ) + // For ESP8266 + #warning Use ESP8266 architecture + #include + #define ETHERNET_USE_ESP8266 + #define BOARD_TYPE "ESP8266" + +#elif ( defined(ESP32) ) + // For ESP32 + #warning Use ESP32 architecture + #define ETHERNET_USE_ESP32 + #define BOARD_TYPE "ESP32" + + #define W5500_RST_PORT 21 + +#elif ETHERNET_USE_RPIPICO + + // Default pin 5 (in Mbed) or 17 to SS/CS + #if defined(ARDUINO_ARCH_MBED) + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + + #define USE_THIS_SS_PIN 5 + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_TYPE "MBED GENERIC_RP2040" + #else + #define BOARD_TYPE "MBED Unknown RP2040" + #endif + + #else + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + #define USE_THIS_SS_PIN 17 + + #endif + + #define SS_PIN_DEFAULT USE_THIS_SS_PIN + + // For RPI Pico + #warning Use RPI-Pico RP2040 architecture + +#else + // For Mega + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "AVR Mega" +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#include + +// Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported + +// To override the default CS/SS pin. Don't use unless you know exactly which pin to use +// You can define here or customize for each board at same place with BOARD_TYPE +// Check @ defined(SEEED_XIAO_M0) +//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 + +// Only one of the following to be true. +#define USE_ETHERNET false +#define USE_ETHERNET_LARGE false +#define USE_ETHERNET2 false +#define USE_ETHERNET3 false +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false + +// KH, from v1.0.1 +#define USE_UIP_ETHERNET false +////// + +#if USE_ETHERNET_PORTENTA_H7 + #warning Use Portenta Ethernet lib + #define SHIELD_TYPE "Ethernet using Portenta_Ethernet Library" +#elif USE_ETHERNET + #warning Use Ethernet lib + #define SHIELD_TYPE "W5x00 using Ethernet Library" +#elif USE_ETHERNET_LARGE + #warning Use EthernetLarge lib + #define SHIELD_TYPE "W5x00 using EthernetLarge Library" +#elif USE_ETHERNET2 + #warning Use Ethernet2 lib + #define SHIELD_TYPE "W5x00 using Ethernet2 Library" +#elif USE_ETHERNET3 + #warning Use Ethernet3 lib + #define SHIELD_TYPE "W5x00 using Ethernet3 Library" +#elif USE_ETHERNET_ESP8266 + #warning Using Ethernet_ESP8266 lib + #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" +#elif USE_ETHERNET_ENC + #warning Using EthernetENC lib + #define SHIELD_TYPE "ENC28J60 using EthernetENC Library" +#elif USE_ETHERNET_LAN8742A + #warning Using LAN8742A Ethernet & STM32Ethernet lib + #define SHIELD_TYPE "LAN8742A Ethernet & STM32Ethernet Library" +#else + #define USE_ETHERNET true + #include "Ethernet.h" + #warning Use Ethernet lib + #define SHIELD_TYPE "W5x00 using Ethernet Library" +#endif + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/multiFileProject_Portenta_H7_Ethernet/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/multiFileProject_Portenta_H7_Ethernet/defines.h new file mode 100644 index 0000000..1d00cfa --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/multiFileProject_Portenta_H7_Ethernet/defines.h @@ -0,0 +1,443 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define ETHERNET_USE_PORTENTA_H7 true + #define USE_ETHERNET_PORTENTA_H7 true + + #define USE_ETHERNET_WRAPPER false + +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(ETHERNET_USE_SAMD) + #undef ETHERNET_USE_SAMD + #endif + #define ETHERNET_USE_SAMD true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(ETHERNET_USE_NRF528XX) + #undef ETHERNET_USE_NRF528XX + #endif + #define ETHERNET_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(ETHERNET_USE_SAM_DUE) + #undef ETHERNET_USE_SAM_DUE + #endif + #define ETHERNET_USE_SAM_DUE true +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(ETHERNET_USE_STM32) + #undef ETHERNET_USE_STM32 + #endif + #define ETHERNET_USE_STM32 true +#endif + +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) + #if defined(ETHERNET_USE_RPIPICO) + #undef ETHERNET_USE_RPIPICO + #endif + #define ETHERNET_USE_RPIPICO true +#endif + +#if defined(ETHERNET_USE_SAMD) + // For SAMD + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #ifdef USE_THIS_SS_PIN + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN A1 + #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif (ETHERNET_USE_SAM_DUE) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "SAM DUE" + +#elif (ETHERNET_USE_NRF528XX) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUITPLAY" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NRF52840_PCA10056" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif ( defined(CORE_TEENSY) ) + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#elif (ETHERNET_USE_STM32) + + #if defined(STM32F0) + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #define BOARD_TYPE "STM32MP1" + #else + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif ( defined(ESP8266) ) + // For ESP8266 + #warning Use ESP8266 architecture + #include + #define ETHERNET_USE_ESP8266 + #define BOARD_TYPE "ESP8266" + +#elif ( defined(ESP32) ) + // For ESP32 + #warning Use ESP32 architecture + #define ETHERNET_USE_ESP32 + #define BOARD_TYPE "ESP32" + + #define W5500_RST_PORT 21 + +#elif ETHERNET_USE_RPIPICO + + // Default pin 5 (in Mbed) or 17 to SS/CS + #if defined(ARDUINO_ARCH_MBED) + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + + #define USE_THIS_SS_PIN 5 + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_TYPE "MBED GENERIC_RP2040" + #else + #define BOARD_TYPE "MBED Unknown RP2040" + #endif + + #else + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + #define USE_THIS_SS_PIN 17 + + #endif + + #define SS_PIN_DEFAULT USE_THIS_SS_PIN + + // For RPI Pico + #warning Use RPI-Pico RP2040 architecture + +#else + // For Mega + // Default pin 10 to SS/CS + #define USE_THIS_SS_PIN 10 + + #define BOARD_TYPE "AVR Mega" +#endif + + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#include + +// Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported + +// To override the default CS/SS pin. Don't use unless you know exactly which pin to use +// You can define here or customize for each board at same place with BOARD_TYPE +// Check @ defined(SEEED_XIAO_M0) +//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 + +// Only one of the following to be true. +#define USE_ETHERNET false +#define USE_ETHERNET_LARGE false +#define USE_ETHERNET2 false +#define USE_ETHERNET3 false +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false + +// KH, from v1.0.1 +#define USE_UIP_ETHERNET false +////// + +#if USE_ETHERNET_PORTENTA_H7 + #warning Use Portenta Ethernet lib + #define SHIELD_TYPE "Ethernet using Portenta_Ethernet Library" +#elif USE_ETHERNET + #warning Use Ethernet lib + #define SHIELD_TYPE "W5x00 using Ethernet Library" +#elif USE_ETHERNET_LARGE + #warning Use EthernetLarge lib + #define SHIELD_TYPE "W5x00 using EthernetLarge Library" +#elif USE_ETHERNET2 + #warning Use Ethernet2 lib + #define SHIELD_TYPE "W5x00 using Ethernet2 Library" +#elif USE_ETHERNET3 + #warning Use Ethernet3 lib + #define SHIELD_TYPE "W5x00 using Ethernet3 Library" +#elif USE_ETHERNET_ESP8266 + #warning Using Ethernet_ESP8266 lib + #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" +#elif USE_ETHERNET_ENC + #warning Using EthernetENC lib + #define SHIELD_TYPE "ENC28J60 using EthernetENC Library" +#elif USE_ETHERNET_LAN8742A + #warning Using LAN8742A Ethernet & STM32Ethernet lib + #define SHIELD_TYPE "LAN8742A Ethernet & STM32Ethernet Library" +#else + #define USE_ETHERNET true + #include "Ethernet.h" + #warning Use Ethernet lib + #define SHIELD_TYPE "W5x00 using Ethernet Library" +#endif + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/multiFileProject_Portenta_H7_Ethernet/multiFileProject.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/multiFileProject_Portenta_H7_Ethernet/multiFileProject.cpp new file mode 100644 index 0000000..e1f0fe7 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/multiFileProject_Portenta_H7_Ethernet/multiFileProject.cpp @@ -0,0 +1,17 @@ +/**************************************************************************************************************************** + multiFileProject.cpp + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#include "multiFileProject.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/multiFileProject_Portenta_H7_Ethernet/multiFileProject.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/multiFileProject_Portenta_H7_Ethernet/multiFileProject.h new file mode 100644 index 0000000..5811a68 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/multiFileProject_Portenta_H7_Ethernet/multiFileProject.h @@ -0,0 +1,20 @@ +/**************************************************************************************************************************** + multiFileProject.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#pragma once + +// Can be included as many times as necessary, without `Multiple Definitions` Linker Error +#include "MySQL_Generic.hpp" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/multiFileProject_Portenta_H7_Ethernet/multiFileProject_Portenta_H7_Ethernet.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/multiFileProject_Portenta_H7_Ethernet/multiFileProject_Portenta_H7_Ethernet.ino new file mode 100644 index 0000000..88f0871 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/Ethernet/multiFileProject_Portenta_H7_Ethernet/multiFileProject_Portenta_H7_Ethernet.ino @@ -0,0 +1,47 @@ +/**************************************************************************************************************************** + multiFileProject_Portenta_H7_Ethernet.ino + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#include "defines.h" + +#define MYSQL_MARIADB_GENERIC_VERSION_MIN_TARGET "MySQL_MariaDB_Generic v1.7.0" +#define MYSQL_MARIADB_GENERIC_VERSION_MIN 1007000 + +#include "multiFileProject.h" + +// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error +#include "MySQL_Generic.h" + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + Serial.println("\nStart multiFileProject_Portenta_H7_Ethernet"); + Serial.println(MYSQL_MARIADB_GENERIC_VERSION); + +#if defined(MYSQL_MARIADB_GENERIC_VERSION_MIN) + if (MYSQL_MARIADB_GENERIC_VERSION_INT < MYSQL_MARIADB_GENERIC_VERSION_MIN) + { + Serial.print("Warning. Must use this example on Version equal or later than : "); + Serial.println(MYSQL_MARIADB_GENERIC_VERSION_MIN_TARGET); + } +#endif +} + +void loop() +{ + // put your main code here, to run repeatedly: +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Basic_Insert_WiFi/Basic_Insert_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Basic_Insert_WiFi/Basic_Insert_WiFi.ino new file mode 100644 index 0000000..a3c5bd8 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Basic_Insert_WiFi/Basic_Insert_WiFi.ino @@ -0,0 +1,159 @@ +/********************************************************************************************************************************* + Basic_Insert_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : basic insert + + This example demonstrates how to issue an INSERT query to store data in a + table. For this, we will create a special database and table for testing. + The following are the SQL commands you will need to run in order to setup + your database for running this sketch. + + CREATE DATABASE test_arduino; + CREATE TABLE test_arduino.hello_arduino ( + num integer primary key auto_increment, + message char(40), + recorded timestamp + ); + + Here we see one database and a table with three fields; a primary key that + is an auto_increment, a string, and a timestamp. This will demonstrate how + to save a date and time of when the row was inserted, which can help you + determine when data was recorded or updated. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Create the database and table as shown above. + 2) Change the address of the server to the IP address of the MySQL server + 3) Change the user and password to a valid MySQL user and password + 4) Connect a USB cable to your Arduino + 5) Select the correct board and port + 6) Compile and upload the sketch to your Arduino + 7) Once uploaded, open Serial Monitor (use 115200 speed) and observe + 8) After the sketch has run for some time, open a mysql client and issue + the command: "SELECT * FROM test_arduino.hello_arduino" to see the data + recorded. Note the field values and how the database handles both the + auto_increment and timestamp fields for us. You can clear the data with + "DELETE FROM test_arduino.hello_arduino". + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "test_arduino"; //"test_arduino"; +char default_table[] = "hello_arduino"; //"test_arduino"; + +String default_value = "Hello, Arduino!"; + +// Sample query +String INSERT_SQL = String("INSERT INTO ") + default_database + "." + default_table + + " (message) VALUES ('" + default_value + "')"; + +MySQL_Connection conn((Client *)&client); + +MySQL_Query *query_mem; + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Basic_Insert_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runInsert() +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + MYSQL_DISPLAY(INSERT_SQL); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(INSERT_SQL.c_str()) ) + { + MYSQL_DISPLAY("Insert error"); + } + else + { + MYSQL_DISPLAY("Data Inserted."); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + } +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Basic_Insert_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Basic_Insert_WiFi/Credentials.h new file mode 100644 index 0000000..96e7c00 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Basic_Insert_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "your_ssid"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Basic_Insert_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Basic_Insert_WiFi/defines.h new file mode 100644 index 0000000..962d826 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Basic_Insert_WiFi/defines.h @@ -0,0 +1,52 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define USE_WIFI_PORTENTA_H7 true + + #define USE_WIFI_NINA false + + // To use the default WiFi library here + #define USE_WIFI_CUSTOM false + +#else + #error This code is intended to run on the Portenta_H7 platform! Please check your Tools->Board setting. +#endif + +#define SHIELD_TYPE "Portenta_H7 WiFi" + +#warning Using Portenta H7 WiFi + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Basic_Select_WiFi/Basic_Select_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Basic_Select_WiFi/Basic_Select_WiFi.ino new file mode 100644 index 0000000..a500007 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Basic_Select_WiFi/Basic_Select_WiFi.ino @@ -0,0 +1,192 @@ +/********************************************************************************************************************************* + Basic_Select_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : basic select + + This example demonstrates how to issue a SELECT query with no parameters + and use the data returned. For this, we use the Cursor class to execute + the query and get the results. + + It demonstrates who methods for running queries. The first allows you to + allocate memory for the cursor and later reclaim it, the second shows how + to use a single instance of the cursor use throughout a sketch. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + CAUTION: Don't mix and match the examples. Use one or the other in your + own sketch -- you'll get compilation errors at the least. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "world"; //"test_arduino"; +char default_table[] = "city"; //"test_arduino"; + +String default_column = "population"; +String default_value = "Toronto"; + +String query = String("SELECT ") + default_column + " FROM " + default_database + "." + default_table + + " WHERE name = '" + default_value + "'"; + +MySQL_Connection conn((Client *)&client); + +// Create an instance of the cursor passing in the connection +MySQL_Query sql_query = MySQL_Query(&conn); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Basic_Select_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runQuery() +{ + row_values *row = NULL; + long head_count = 0; + + MYSQL_DISPLAY("1) Demonstrating using a dynamically allocated query."); + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + MYSQL_DISPLAY(query); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(query.c_str()) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Fetch the columns (required) but we don't use them. + //column_names *columns = query_mem.get_columns(); + query_mem.get_columns(); + + // Read the row (we are only expecting the one) + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + head_count = atol(row->values[0]); + } + } while (row != NULL); + + // Show the result + MYSQL_DISPLAY1(" Toronto pop =", head_count); + + delay(500); + + MYSQL_DISPLAY("2) Demonstrating using a local, global query."); + + // Execute the query + MYSQL_DISPLAY(query); + sql_query.execute(query.c_str()); + + // Fetch the columns (required) but we don't use them. + sql_query.get_columns(); + + // Read the row (we are only expecting the one) + do + { + row = sql_query.get_next_row(); + if (row != NULL) + { + head_count = atol(row->values[0]); + } + } while (row != NULL); + + // Now we close the cursor to free any memory + sql_query.close(); + + // Show the result but this time do some math on it + MYSQL_DISPLAY1(" Toronto pop =", head_count); + MYSQL_DISPLAY1(" Toronto pop increased by 11725 =", head_count + 11725); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Basic_Select_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Basic_Select_WiFi/Credentials.h new file mode 100644 index 0000000..96e7c00 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Basic_Select_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "your_ssid"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Basic_Select_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Basic_Select_WiFi/defines.h new file mode 100644 index 0000000..962d826 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Basic_Select_WiFi/defines.h @@ -0,0 +1,52 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define USE_WIFI_PORTENTA_H7 true + + #define USE_WIFI_NINA false + + // To use the default WiFi library here + #define USE_WIFI_CUSTOM false + +#else + #error This code is intended to run on the Portenta_H7 platform! Please check your Tools->Board setting. +#endif + +#define SHIELD_TYPE "Portenta_H7 WiFi" + +#warning Using Portenta H7 WiFi + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Complex_Insert_WiFi/Complex_Insert_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Complex_Insert_WiFi/Complex_Insert_WiFi.ino new file mode 100644 index 0000000..c5c51a4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Complex_Insert_WiFi/Complex_Insert_WiFi.ino @@ -0,0 +1,182 @@ +/********************************************************************************************************************************* + Complex_Insert_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : complex insert + + This example demonstrates how to issue an INSERT query to store data in a + table using data from variables in our sketch. In this case, we supply the + values dynamically. + + This sketch simulates storing data from a sensor in a table. + + For this, we will create a special database and table for testing. + The following are the SQL commands you will need to run in order to setup + your database for running this sketch. + + CREATE DATABASE test_arduino; + CREATE TABLE test_arduino.hello_sensor ( + num integer primary key auto_increment, + message char(40), + sensor_num integer, + value float, + recorded timestamp + ); + + Here we have a table that contains an auto_increment primary key, a text + field, a field to identify the sensor, the value read, and timestamp of + the recorded data. + + Note: Since this sketch uses test data, we place the INSERT in the setup() + method so that it runs only once. Typically, you would have the + INSERT in the loop() method after your code to read from the sensor. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Create the database and table as shown above. + 2) Change the address of the server to the IP address of the MySQL server + 3) Change the user and password to a valid MySQL user and password + 4) Connect a USB cable to your Arduino + 5) Select the correct board and port + 6) Compile and upload the sketch to your Arduino + 7) Once uploaded, open Serial Monitor (use 115200 speed) and observe + 8) After the sketch has run for some time, open a mysql client and issue + the command: "SELECT * FROM test_arduino.hello_sensor" to see the data + recorded. Note the field values and how the database handles both the + auto_increment and timestamp fields for us. You can clear the data with + "DELETE FROM test_arduino.hello_sensor". + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "test_arduino"; //"test_arduino"; +char default_table[] = "hello_sensor"; //"test_arduino"; + +// Sample query +char INSERT_DATA[] = "INSERT INTO %s.%s (message, sensor_num, value) VALUES ('%s',%d,%s)"; + +char query[128]; +char temperature[10]; + +MySQL_Connection conn((Client *)&client); + +#if !( ESP32 || ESP8266 || defined(CORE_TEENSY) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) || defined(STM32F4) || defined(STM32F7) || ( defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED) ) ) + +char *dtostrf(double val, signed char width, unsigned char prec, char *sout) +{ + char fmt[20]; + sprintf(fmt, "%%%d.%df", width, prec); + sprintf(sout, fmt, val); + return sout; +} +#endif + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Complex_Insert_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runInsert() +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + // Save + dtostrf(50.125, 1, 1, temperature); + sprintf(query, INSERT_DATA, default_database, default_table, "test sensor", 24, temperature); + + // Execute the query + MYSQL_DISPLAY(query); + + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Complex Insert error"); + } + else + { + MYSQL_DISPLAY("Complex Data Inserted."); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + } +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Complex_Insert_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Complex_Insert_WiFi/Credentials.h new file mode 100644 index 0000000..96e7c00 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Complex_Insert_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "your_ssid"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Complex_Insert_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Complex_Insert_WiFi/defines.h new file mode 100644 index 0000000..962d826 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Complex_Insert_WiFi/defines.h @@ -0,0 +1,52 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define USE_WIFI_PORTENTA_H7 true + + #define USE_WIFI_NINA false + + // To use the default WiFi library here + #define USE_WIFI_CUSTOM false + +#else + #error This code is intended to run on the Portenta_H7 platform! Please check your Tools->Board setting. +#endif + +#define SHIELD_TYPE "Portenta_H7 WiFi" + +#warning Using Portenta H7 WiFi + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Complex_Select_WiFi/Complex_Select_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Complex_Select_WiFi/Complex_Select_WiFi.ino new file mode 100644 index 0000000..08050c5 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Complex_Select_WiFi/Complex_Select_WiFi.ino @@ -0,0 +1,190 @@ +/********************************************************************************************************************************* + Complex_Select_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : complex select + + This example demonstrates how to issue a SELECT query with parameters that + we provide from code. Thus, it demonstrates how to build query parameters + dynamically. + + Notice also the sketch demonstrates how to read columns and rows from + the result set. Study this example until you are familiar with how to + do this before writing your own sketch to read and consume query results. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "world"; //"test_arduino"; +char default_table[] = "city"; //"test_arduino"; + +// Sample query +// +// Notice the "%lu" - that's a placeholder for the parameter we will +// supply. See sprintf() documentation for more formatting specifier +// options + +unsigned long QUERY_POPULATION = 800000; + +const char QUERY_POP[] = "SELECT name, population FROM world.city WHERE population < %lu ORDER BY population DESC LIMIT 6;"; + +char query[128]; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Complex_Select_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runQuery() +{ + MYSQL_DISPLAY("===================================================="); + MYSQL_DISPLAY("> Running SELECT with dynamically supplied parameter"); + + // Supply the parameter for the query + // Here we use the QUERY_POP as the format string and query as the + // destination. This uses twice the memory so another option would be + // to allocate one buffer for all formatted queries or allocate the + // memory as needed (just make sure you allocate enough memory and + // free it when you're done!). + sprintf(query, QUERY_POP, QUERY_POPULATION + (( millis() % 100000 ) * 10) ); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Fetch the columns and print them + column_names *cols = query_mem.get_columns(); + + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(cols->fields[f]->name); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(","); + } + } + + MYSQL_DISPLAY(); + + // Read the rows and print them + row_values *row = NULL; + + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(row->values[f]); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(","); + } + } + + MYSQL_DISPLAY(); + } + } while (row != NULL); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(10000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Complex_Select_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Complex_Select_WiFi/Credentials.h new file mode 100644 index 0000000..96e7c00 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Complex_Select_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "your_ssid"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Complex_Select_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Complex_Select_WiFi/defines.h new file mode 100644 index 0000000..962d826 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Complex_Select_WiFi/defines.h @@ -0,0 +1,52 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define USE_WIFI_PORTENTA_H7 true + + #define USE_WIFI_NINA false + + // To use the default WiFi library here + #define USE_WIFI_CUSTOM false + +#else + #error This code is intended to run on the Portenta_H7 platform! Please check your Tools->Board setting. +#endif + +#define SHIELD_TYPE "Portenta_H7 WiFi" + +#warning Using Portenta H7 WiFi + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_Default_Database_WiFi/Connect_Default_Database_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_Default_Database_WiFi/Connect_Default_Database_WiFi.ino new file mode 100644 index 0000000..59a631e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_Default_Database_WiFi/Connect_Default_Database_WiFi.ino @@ -0,0 +1,108 @@ +/********************************************************************************************************************************* + Connect_Default_Database_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* +/* + MySQL Connector/Arduino Example : connect with default database + + This example demonstrates how to connect to a MySQL server and specifying + the default database when connecting. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "world"; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Connect_Default_Database_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password, default_database)) + if (conn.connectNonBlocking(server, server_port, user, password, default_database) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_Default_Database_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_Default_Database_WiFi/Credentials.h new file mode 100644 index 0000000..96e7c00 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_Default_Database_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "your_ssid"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_Default_Database_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_Default_Database_WiFi/defines.h new file mode 100644 index 0000000..962d826 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_Default_Database_WiFi/defines.h @@ -0,0 +1,52 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define USE_WIFI_PORTENTA_H7 true + + #define USE_WIFI_NINA false + + // To use the default WiFi library here + #define USE_WIFI_CUSTOM false + +#else + #error This code is intended to run on the Portenta_H7 platform! Please check your Tools->Board setting. +#endif + +#define SHIELD_TYPE "Portenta_H7 WiFi" + +#warning Using Portenta H7 WiFi + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_Disconnect_WiFi/Connect_Disconnect_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_Disconnect_WiFi/Connect_Disconnect_WiFi.ino new file mode 100644 index 0000000..2c819c2 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_Disconnect_WiFi/Connect_Disconnect_WiFi.ino @@ -0,0 +1,122 @@ +/********************************************************************************************************************************* + Connect_Disconnect_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect and disconnect (close) + + This example demonstrates how to use the connection to open at the start + of a loop, perform some query, then close the connection. Use this technique + for solutions that must sleep for a long period or otherwise require + additional processing or delays. The connect/close pair allow you to + control how long the connection is open and thus reduce the amount of + time a connection is held open. It also helps for lossy connections. + + This example demonstrates how to connect to a MySQL server and specifying + the default database when connecting. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +MySQL_Connection conn((Client *)&client); +MySQL_Query query = MySQL_Query(&conn); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Connect_Disconnect_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); +} + +void runQuery() +{ + MYSQL_DISPLAY("Running a query: SELECT * FROM test_arduino.hello_arduino LIMIT 6;"); + + // Execute the query + // KH, check if valid before fetching + if ( !query.execute("SELECT * FROM test_arduino.hello_arduino LIMIT 6;") ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + query.show_results(); // show the results + query.close(); // close the query +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_Disconnect_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_Disconnect_WiFi/Credentials.h new file mode 100644 index 0000000..96e7c00 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_Disconnect_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "your_ssid"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_Disconnect_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_Disconnect_WiFi/defines.h new file mode 100644 index 0000000..962d826 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_Disconnect_WiFi/defines.h @@ -0,0 +1,52 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define USE_WIFI_PORTENTA_H7 true + + #define USE_WIFI_NINA false + + // To use the default WiFi library here + #define USE_WIFI_CUSTOM false + +#else + #error This code is intended to run on the Portenta_H7 platform! Please check your Tools->Board setting. +#endif + +#define SHIELD_TYPE "Portenta_H7 WiFi" + +#warning Using Portenta H7 WiFi + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_WiFi/Connect_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_WiFi/Connect_WiFi.ino new file mode 100644 index 0000000..ab27884 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_WiFi/Connect_WiFi.ino @@ -0,0 +1,108 @@ +/********************************************************************************************************************************* + Connect_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect + + This example demonstrates how to connect to a MySQL server from an + Arduino using an Arduino-compatible Ethernet shield. Note that "compatible" + means it must conform to the Ethernet class library or be a derivative + with the same classes and methods. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Connect_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_WiFi/Credentials.h new file mode 100644 index 0000000..96e7c00 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "your_ssid"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_WiFi/defines.h new file mode 100644 index 0000000..962d826 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Connect_WiFi/defines.h @@ -0,0 +1,52 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define USE_WIFI_PORTENTA_H7 true + + #define USE_WIFI_NINA false + + // To use the default WiFi library here + #define USE_WIFI_CUSTOM false + +#else + #error This code is intended to run on the Portenta_H7 platform! Please check your Tools->Board setting. +#endif + +#define SHIELD_TYPE "Portenta_H7 WiFi" + +#warning Using Portenta H7 WiFi + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Reboot_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Reboot_WiFi/Credentials.h new file mode 100644 index 0000000..96e7c00 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Reboot_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "your_ssid"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Reboot_WiFi/Reboot_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Reboot_WiFi/Reboot_WiFi.ino new file mode 100644 index 0000000..1e6ecc9 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Reboot_WiFi/Reboot_WiFi.ino @@ -0,0 +1,193 @@ +/********************************************************************************************************************************* + Reboot_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : reboot if connection lost + + This example demonstrates how to reboot an Arduino if connection to the + server is lost for a period of time. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + To test the reboot, unplug your Ethernet cable once you see "disconnected" + then wait for the timeout. Once the Arduino reboots, plug the cable in again + and you should see the query processing resume. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +MySQL_Connection conn((Client *)&client); +MySQL_Query query = MySQL_Query(&conn); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Reboot_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); +} + +// Begin reboot code +int num_fails; // variable for number of failure attempts +#define MAX_FAILED_CONNECTS 5 // maximum number of failed connects to MySQL + +void soft_reset() +{ +#if WIFI_USE_SAMD + #if ( defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) || defined(__SAMD51G19A__) ) + // For SAMD51 + // see Table 17-5 Timeout Period (valid values 0-11) + WDT->CONFIG.reg = 5; + WDT->CTRLA.reg = WDT_CTRLA_ENABLE; + // To check if OK or bit.ENABLE/CLEAR + while (WDT->SYNCBUSY.bit.WEN == 1); + + // use the WDT watchdog timer to force a system reset. + WDT->CLEAR.reg = 0x00; + // To check if OK or bit.ENABLE/CLEAR + while (WDT->SYNCBUSY.bit.WEN == 1); + #else + // For SAMD21, etc + // see Table 17-5 Timeout Period (valid values 0-11) + WDT->CONFIG.reg = 5; + WDT->CTRL.reg = WDT_CTRL_ENABLE; + while (WDT->STATUS.bit.SYNCBUSY == 1); + + // use the WDT watchdog timer to force a system reset. + WDT->CLEAR.reg = 0x00; + while (WDT->STATUS.bit.SYNCBUSY == 1); + #endif +#elif ( WIFI_USE_NRF528XX || USE_WIFI_PORTENTA_H7 ) + //delay(1000); + // Restart for nRF52 + NVIC_SystemReset(); +#elif WIFI_USE_SAMDUE + void(*resetFunc)() = 0; + resetFunc(); +#elif WIFI_USE_STM32 + void(*resetFunc)() = 0; + resetFunc(); + +#elif WIFI_USE_TEENSY + #if defined(__IMXRT1062__) + // Teensy 4.1/4.0 + SCB_AIRCR = 0x05FA0004; //write value for restart for Teensy + #else + void(*resetFunc)() = 0; + resetFunc(); + #endif + +#elif ( defined(WIFI_USE_RP2040) && defined(ARDUINO_ARCH_MBED) ) + + NVIC_SystemReset(); + +#endif +} + +// End reboot code + +void loop() +{ + if (conn.connected()) + { + MYSQL_DISPLAY("Running a query: SHOW DATABASES"); + + // Execute the query + + // KH, check if valid before fetching + if ( !query.execute("SHOW DATABASES") ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + ////// + + query.show_results(); // show the results + query.close(); // close the cursor + conn.close(); // close the connection + num_fails = 0; // reset failures + + delay(10000); + } + else + { + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + } + else + { + num_fails++; + MYSQL_DISPLAY("Connect failed!"); + + if (num_fails == MAX_FAILED_CONNECTS) + { + MYSQL_DISPLAY("Ok, that's it. I'm outta here. Rebooting..."); + delay(2000); + // Here we tell the Arduino to reboot by redirecting the instruction + // pointer to the "top" or position 0. This is a soft reset and may + // not solve all hardware-related lockups. + soft_reset(); + } + } + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("=========================================="); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Reboot_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Reboot_WiFi/defines.h new file mode 100644 index 0000000..962d826 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/Reboot_WiFi/defines.h @@ -0,0 +1,52 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define USE_WIFI_PORTENTA_H7 true + + #define USE_WIFI_NINA false + + // To use the default WiFi library here + #define USE_WIFI_CUSTOM false + +#else + #error This code is intended to run on the Portenta_H7 platform! Please check your Tools->Board setting. +#endif + +#define SHIELD_TYPE "Portenta_H7 WiFi" + +#warning Using Portenta H7 WiFi + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/multiFileProject_Portenta_H7_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/multiFileProject_Portenta_H7_WiFi/Credentials.h new file mode 100644 index 0000000..96e7c00 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/multiFileProject_Portenta_H7_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "your_ssid"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/multiFileProject_Portenta_H7_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/multiFileProject_Portenta_H7_WiFi/defines.h new file mode 100644 index 0000000..962d826 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/multiFileProject_Portenta_H7_WiFi/defines.h @@ -0,0 +1,52 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(CORE_CM7) + #warning Using Portenta H7 M7 core + #define BOARD_NAME "PORTENTA_H7_M7" + #else + #warning Using Portenta H7 M4 core + #define BOARD_NAME "PORTENTA_H7_M4" + #endif + + #define USE_WIFI_PORTENTA_H7 true + + #define USE_WIFI_NINA false + + // To use the default WiFi library here + #define USE_WIFI_CUSTOM false + +#else + #error This code is intended to run on the Portenta_H7 platform! Please check your Tools->Board setting. +#endif + +#define SHIELD_TYPE "Portenta_H7 WiFi" + +#warning Using Portenta H7 WiFi + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/multiFileProject_Portenta_H7_WiFi/multiFileProject.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/multiFileProject_Portenta_H7_WiFi/multiFileProject.cpp new file mode 100644 index 0000000..e1f0fe7 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/multiFileProject_Portenta_H7_WiFi/multiFileProject.cpp @@ -0,0 +1,17 @@ +/**************************************************************************************************************************** + multiFileProject.cpp + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#include "multiFileProject.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/multiFileProject_Portenta_H7_WiFi/multiFileProject.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/multiFileProject_Portenta_H7_WiFi/multiFileProject.h new file mode 100644 index 0000000..5811a68 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/multiFileProject_Portenta_H7_WiFi/multiFileProject.h @@ -0,0 +1,20 @@ +/**************************************************************************************************************************** + multiFileProject.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#pragma once + +// Can be included as many times as necessary, without `Multiple Definitions` Linker Error +#include "MySQL_Generic.hpp" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/multiFileProject_Portenta_H7_WiFi/multiFileProject_Portenta_H7_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/multiFileProject_Portenta_H7_WiFi/multiFileProject_Portenta_H7_WiFi.ino new file mode 100644 index 0000000..8c8e966 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/Portenta_H7/WiFi/multiFileProject_Portenta_H7_WiFi/multiFileProject_Portenta_H7_WiFi.ino @@ -0,0 +1,48 @@ +/**************************************************************************************************************************** + multiFileProject_Portenta_H7_WiFi.ino + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#include "defines.h" +#include "Credentials.h" + +#define MYSQL_MARIADB_GENERIC_VERSION_MIN_TARGET "MySQL_MariaDB_Generic v1.7.0" +#define MYSQL_MARIADB_GENERIC_VERSION_MIN 1007000 + +#include "multiFileProject.h" + +// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error +#include "MySQL_Generic.h" + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + Serial.println("\nStart multiFileProject_Portenta_H7_WiFi"); + Serial.println(MYSQL_MARIADB_GENERIC_VERSION); + +#if defined(MYSQL_MARIADB_GENERIC_VERSION_MIN) + if (MYSQL_MARIADB_GENERIC_VERSION_INT < MYSQL_MARIADB_GENERIC_VERSION_MIN) + { + Serial.print("Warning. Must use this example on Version equal or later than : "); + Serial.println(MYSQL_MARIADB_GENERIC_VERSION_MIN_TARGET); + } +#endif +} + +void loop() +{ + // put your main code here, to run repeatedly: +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Basic_Insert/Basic_Insert.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Basic_Insert/Basic_Insert.ino new file mode 100644 index 0000000..2178931 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Basic_Insert/Basic_Insert.ino @@ -0,0 +1,215 @@ +/********************************************************************************************************************************* + Basic_Insert.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : basic insert + + This example demonstrates how to issue an INSERT query to store data in a + table. For this, we will create a special database and table for testing. + The following are the SQL commands you will need to run in order to setup + your database for running this sketch. + + CREATE DATABASE test_arduino; + CREATE TABLE test_arduino.hello_arduino ( + num integer primary key auto_increment, + message char(40), + recorded timestamp + ); + + Here we see one database and a table with three fields; a primary key that + is an auto_increment, a string, and a timestamp. This will demonstrate how + to save a date and time of when the row was inserted, which can help you + determine when data was recorded or updated. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Create the database and table as shown above. + 2) Change the address of the server to the IP address of the MySQL server + 3) Change the user and password to a valid MySQL user and password + 4) Connect a USB cable to your Arduino + 5) Select the correct board and port + 6) Compile and upload the sketch to your Arduino + 7) Once uploaded, open Serial Monitor (use 115200 speed) and observe + 8) After the sketch has run for some time, open a mysql client and issue + the command: "SELECT * FROM test_arduino.hello_arduino" to see the data + recorded. Note the field values and how the database handles both the + auto_increment and timestamp fields for us. You can clear the data with + "DELETE FROM test_arduino.hello_arduino". + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "test_arduino"; //"test_arduino"; +char default_table[] = "hello_arduino"; //"test_arduino"; + +String default_value = "Hello, Arduino!"; + +// Sample query +String INSERT_SQL = String("INSERT INTO ") + default_database + "." + default_table + + " (message) VALUES ('" + default_value + "')"; + +MySQL_Connection conn((Client *)&client); + +void initEthernet() +{ +#if USE_NATIVE_ETHERNET + MYSQL_DISPLAY(F("======== USE_NATIVE_ETHERNET ========")); +#elif USE_QN_ETHERNET + MYSQL_DISPLAY(F("=========== USE_QN_ETHERNET ===========")); +#endif + +#if USE_NATIVE_ETHERNET + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY(F("=========================")); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + // give the Ethernet shield 2 seconds to initialize: + delay(2000); + +#else + + #if USING_DHCP + // Start the Ethernet connection, using DHCP + Serial.print("Initialize Ethernet using DHCP => "); + Ethernet.begin(); + #else + // Start the Ethernet connection, using static IP + Serial.print("Initialize Ethernet using static IP => "); + Ethernet.begin(myIP, myNetmask, myGW); + Ethernet.setDNSServerIP(mydnsServer); + #endif + + if (!Ethernet.waitForLocalIP(5000)) + { + Serial.println("Failed to configure Ethernet"); + + if (!Ethernet.linkStatus()) + { + Serial.println("Ethernet cable is not connected."); + } + + // Stay here forever + while (true) + { + delay(1); + } + } + + if (!Ethernet.waitForLink(5000)) + { + Serial.println(F("Failed to wait for Link")); + } + else + { + Serial.print("IP Address = "); + Serial.println(Ethernet.localIP()); + } + +#endif +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY2("\nStarting Basic_Insert on", BOARD_NAME, SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runInsert() +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + MYSQL_DISPLAY(INSERT_SQL); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(INSERT_SQL.c_str()) ) + { + MYSQL_DISPLAY("Insert error"); + } + else + { + MYSQL_DISPLAY("Data Inserted."); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + } +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Basic_Insert/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Basic_Insert/defines.h new file mode 100644 index 0000000..d422085 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Basic_Insert/defines.h @@ -0,0 +1,103 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) && defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) ) + // For Teensy 4.1 + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET false + #define USE_QN_ETHERNET true +#else + #error Only Teensy 4.1 supported +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +#if USE_NATIVE_ETHERNET + #include "NativeEthernet.h" + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using NativeEthernet" +#elif USE_QN_ETHERNET + #include "QNEthernet.h" // https://github.com/ssilverman/QNEthernet + using namespace qindesign::network; + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using QNEthernet" +#endif + +#if USE_NATIVE_ETHERNET + // Enter a MAC address and IP address for your controller below. + #define NUMBER_OF_MAC 20 + + byte mac[][NUMBER_OF_MAC] = + { + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, + }; + +#else + + #define USING_DHCP false //true + + #if !USING_DHCP + // Set the static IP address to use if the DHCP fails to assign + IPAddress myIP(192, 168, 2, 222); + IPAddress myNetmask(255, 255, 255, 0); + IPAddress myGW(192, 168, 2, 1); + //IPAddress mydnsServer(192, 168, 2, 1); + IPAddress mydnsServer(8, 8, 8, 8); + #endif + +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Basic_Select/Basic_Select.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Basic_Select/Basic_Select.ino new file mode 100644 index 0000000..3091c68 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Basic_Select/Basic_Select.ino @@ -0,0 +1,249 @@ +/********************************************************************************************************************************* + Basic_Select.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : basic select + + This example demonstrates how to issue a SELECT query with no parameters + and use the data returned. For this, we use the Cursor class to execute + the query and get the results. + + It demonstrates who methods for running queries. The first allows you to + allocate memory for the cursor and later reclaim it, the second shows how + to use a single instance of the cursor use throughout a sketch. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + CAUTION: Don't mix and match the examples. Use one or the other in your + own sketch -- you'll get compilation errors at the least. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "world"; //"test_arduino"; +char default_table[] = "city"; //"test_arduino"; + +String default_column = "population"; +String default_value = "Toronto"; + +String query = String("SELECT ") + default_column + " FROM " + default_database + "." + default_table + + " WHERE name = '" + default_value + "'"; + +MySQL_Connection conn((Client *)&client); +// Create an instance of the cursor passing in the connection +MySQL_Query sql_query = MySQL_Query(&conn); + +void initEthernet() +{ +#if USE_NATIVE_ETHERNET + MYSQL_DISPLAY(F("======== USE_NATIVE_ETHERNET ========")); +#elif USE_QN_ETHERNET + MYSQL_DISPLAY(F("=========== USE_QN_ETHERNET ===========")); +#endif + +#if USE_NATIVE_ETHERNET + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY(F("=========================")); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + // give the Ethernet shield 2 seconds to initialize: + delay(2000); + +#else + + #if USING_DHCP + // Start the Ethernet connection, using DHCP + Serial.print("Initialize Ethernet using DHCP => "); + Ethernet.begin(); + #else + // Start the Ethernet connection, using static IP + Serial.print("Initialize Ethernet using static IP => "); + Ethernet.begin(myIP, myNetmask, myGW); + Ethernet.setDNSServerIP(mydnsServer); + #endif + + if (!Ethernet.waitForLocalIP(5000)) + { + Serial.println("Failed to configure Ethernet"); + + if (!Ethernet.linkStatus()) + { + Serial.println("Ethernet cable is not connected."); + } + + // Stay here forever + while (true) + { + delay(1); + } + } + + if (!Ethernet.waitForLink(5000)) + { + Serial.println(F("Failed to wait for Link")); + } + else + { + Serial.print("IP Address = "); + Serial.println(Ethernet.localIP()); + } + +#endif +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY2("\nStarting Basic_Select on", BOARD_NAME, SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runQuery() +{ + row_values *row = NULL; + long head_count = 0; + + MYSQL_DISPLAY("1) Demonstrating using a dynamically allocated query."); + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + MYSQL_DISPLAY(query); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(query.c_str()) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Fetch the columns (required) but we don't use them. + //column_names *columns = query_mem.get_columns(); + query_mem.get_columns(); + + // Read the row (we are only expecting the one) + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + head_count = atol(row->values[0]); + } + } while (row != NULL); + + // Show the result + MYSQL_DISPLAY1(" Toronto pop =", head_count); + + delay(500); + + MYSQL_DISPLAY("2) Demonstrating using a local, global query."); + + // Execute the query + MYSQL_DISPLAY(query); + sql_query.execute(query.c_str()); + + // Fetch the columns (required) but we don't use them. + sql_query.get_columns(); + + // Read the row (we are only expecting the one) + do + { + row = sql_query.get_next_row(); + if (row != NULL) + { + head_count = atol(row->values[0]); + } + } while (row != NULL); + + // Now we close the cursor to free any memory + sql_query.close(); + + // Show the result but this time do some math on it + MYSQL_DISPLAY1(" Toronto pop =", head_count); + MYSQL_DISPLAY1(" Toronto pop increased by 11725 =", head_count + 11725); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Basic_Select/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Basic_Select/defines.h new file mode 100644 index 0000000..d422085 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Basic_Select/defines.h @@ -0,0 +1,103 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) && defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) ) + // For Teensy 4.1 + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET false + #define USE_QN_ETHERNET true +#else + #error Only Teensy 4.1 supported +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +#if USE_NATIVE_ETHERNET + #include "NativeEthernet.h" + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using NativeEthernet" +#elif USE_QN_ETHERNET + #include "QNEthernet.h" // https://github.com/ssilverman/QNEthernet + using namespace qindesign::network; + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using QNEthernet" +#endif + +#if USE_NATIVE_ETHERNET + // Enter a MAC address and IP address for your controller below. + #define NUMBER_OF_MAC 20 + + byte mac[][NUMBER_OF_MAC] = + { + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, + }; + +#else + + #define USING_DHCP false //true + + #if !USING_DHCP + // Set the static IP address to use if the DHCP fails to assign + IPAddress myIP(192, 168, 2, 222); + IPAddress myNetmask(255, 255, 255, 0); + IPAddress myGW(192, 168, 2, 1); + //IPAddress mydnsServer(192, 168, 2, 1); + IPAddress mydnsServer(8, 8, 8, 8); + #endif + +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Complex_Insert/Complex_Insert.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Complex_Insert/Complex_Insert.ino new file mode 100644 index 0000000..7282f5a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Complex_Insert/Complex_Insert.ino @@ -0,0 +1,240 @@ +/********************************************************************************************************************************* + Complex_Insert.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : complex insert + + This example demonstrates how to issue an INSERT query to store data in a + table using data from variables in our sketch. In this case, we supply the + values dynamically. + + This sketch simulates storing data from a sensor in a table. + + For this, we will create a special database and table for testing. + The following are the SQL commands you will need to run in order to setup + your database for running this sketch. + + CREATE DATABASE test_arduino; + CREATE TABLE test_arduino.hello_sensor ( + num integer primary key auto_increment, + message char(40), + sensor_num integer, + value float, + recorded timestamp + ); + + Here we have a table that contains an auto_increment primary key, a text + field, a field to identify the sensor, the value read, and timestamp of + the recorded data. + + Note: Since this sketch uses test data, we place the INSERT in the setup() + method so that it runs only once. Typically, you would have the + INSERT in the loop() method after your code to read from the sensor. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Create the database and table as shown above. + 2) Change the address of the server to the IP address of the MySQL server + 3) Change the user and password to a valid MySQL user and password + 4) Connect a USB cable to your Arduino + 5) Select the correct board and port + 6) Compile and upload the sketch to your Arduino + 7) Once uploaded, open Serial Monitor (use 115200 speed) and observe + 8) After the sketch has run for some time, open a mysql client and issue + the command: "SELECT * FROM test_arduino.hello_sensor" to see the data + recorded. Note the field values and how the database handles both the + auto_increment and timestamp fields for us. You can clear the data with + "DELETE FROM test_arduino.hello_sensor". + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "test_arduino"; //"test_arduino"; +char default_table[] = "hello_sensor"; //"test_arduino"; + +// Sample query +char INSERT_DATA[] = "INSERT INTO %s.%s (message, sensor_num, value) VALUES ('%s',%d,%s)"; + +char query[128]; +char temperature[10]; + +MySQL_Connection conn((Client *)&client); + +#if !( ESP32 || ESP8266 || defined(CORE_TEENSY) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) || defined(STM32F4) || defined(STM32F7) || ( defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED) ) ) + +char *dtostrf(double val, signed char width, unsigned char prec, char *sout) +{ + char fmt[20]; + sprintf(fmt, "%%%d.%df", width, prec); + sprintf(sout, fmt, val); + return sout; +} +#endif + +void initEthernet() +{ +#if USE_NATIVE_ETHERNET + MYSQL_DISPLAY(F("======== USE_NATIVE_ETHERNET ========")); +#elif USE_QN_ETHERNET + MYSQL_DISPLAY(F("=========== USE_QN_ETHERNET ===========")); +#endif + +#if USE_NATIVE_ETHERNET + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY(F("=========================")); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + // give the Ethernet shield 2 seconds to initialize: + delay(2000); + +#else + + #if USING_DHCP + // Start the Ethernet connection, using DHCP + Serial.print("Initialize Ethernet using DHCP => "); + Ethernet.begin(); + #else + // Start the Ethernet connection, using static IP + Serial.print("Initialize Ethernet using static IP => "); + Ethernet.begin(myIP, myNetmask, myGW); + Ethernet.setDNSServerIP(mydnsServer); + #endif + + if (!Ethernet.waitForLocalIP(5000)) + { + Serial.println("Failed to configure Ethernet"); + + if (!Ethernet.linkStatus()) + { + Serial.println("Ethernet cable is not connected."); + } + + // Stay here forever + while (true) + { + delay(1); + } + } + + if (!Ethernet.waitForLink(5000)) + { + Serial.println(F("Failed to wait for Link")); + } + else + { + Serial.print("IP Address = "); + Serial.println(Ethernet.localIP()); + } + +#endif +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY2("\nStarting Complex_Insert on", BOARD_NAME, SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); + MYSQL_DISPLAY3("DB =", default_database, ", Table =", default_table); +} + +void runInsert() +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + // Save + dtostrf(50.125, 1, 1, temperature); + sprintf(query, INSERT_DATA, default_database, default_table, "test sensor", 24, temperature); + + // Execute the query + MYSQL_DISPLAY(query); + + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Complex Insert error"); + } + else + { + MYSQL_DISPLAY("Complex Data Inserted."); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + } +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Complex_Insert/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Complex_Insert/defines.h new file mode 100644 index 0000000..d422085 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Complex_Insert/defines.h @@ -0,0 +1,103 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) && defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) ) + // For Teensy 4.1 + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET false + #define USE_QN_ETHERNET true +#else + #error Only Teensy 4.1 supported +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +#if USE_NATIVE_ETHERNET + #include "NativeEthernet.h" + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using NativeEthernet" +#elif USE_QN_ETHERNET + #include "QNEthernet.h" // https://github.com/ssilverman/QNEthernet + using namespace qindesign::network; + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using QNEthernet" +#endif + +#if USE_NATIVE_ETHERNET + // Enter a MAC address and IP address for your controller below. + #define NUMBER_OF_MAC 20 + + byte mac[][NUMBER_OF_MAC] = + { + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, + }; + +#else + + #define USING_DHCP false //true + + #if !USING_DHCP + // Set the static IP address to use if the DHCP fails to assign + IPAddress myIP(192, 168, 2, 222); + IPAddress myNetmask(255, 255, 255, 0); + IPAddress myGW(192, 168, 2, 1); + //IPAddress mydnsServer(192, 168, 2, 1); + IPAddress mydnsServer(8, 8, 8, 8); + #endif + +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Complex_Select/Complex_Select.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Complex_Select/Complex_Select.ino new file mode 100644 index 0000000..7b6c516 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Complex_Select/Complex_Select.ino @@ -0,0 +1,246 @@ +/********************************************************************************************************************************* + Complex_Select.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : complex select + + This example demonstrates how to issue a SELECT query with parameters that + we provide from code. Thus, it demonstrates how to build query parameters + dynamically. + + Notice also the sketch demonstrates how to read columns and rows from + the result set. Study this example until you are familiar with how to + do this before writing your own sketch to read and consume query results. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "world"; //"test_arduino"; +char default_table[] = "city"; //"test_arduino"; + +// Sample query +// +// Notice the "%lu" - that's a placeholder for the parameter we will +// supply. See sprintf() documentation for more formatting specifier +// options +unsigned long QUERY_POPULATION = 800000; + +const char QUERY_POP[] = "SELECT name, population FROM world.city WHERE population < %lu ORDER BY population DESC LIMIT 12;"; + +char query[128]; + +MySQL_Connection conn((Client *)&client); + +void initEthernet() +{ +#if USE_NATIVE_ETHERNET + MYSQL_DISPLAY(F("======== USE_NATIVE_ETHERNET ========")); +#elif USE_QN_ETHERNET + MYSQL_DISPLAY(F("=========== USE_QN_ETHERNET ===========")); +#endif + +#if USE_NATIVE_ETHERNET + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY(F("=========================")); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + // give the Ethernet shield 2 seconds to initialize: + delay(2000); + +#else + + #if USING_DHCP + // Start the Ethernet connection, using DHCP + Serial.print("Initialize Ethernet using DHCP => "); + Ethernet.begin(); + #else + // Start the Ethernet connection, using static IP + Serial.print("Initialize Ethernet using static IP => "); + Ethernet.begin(myIP, myNetmask, myGW); + Ethernet.setDNSServerIP(mydnsServer); + #endif + + if (!Ethernet.waitForLocalIP(5000)) + { + Serial.println("Failed to configure Ethernet"); + + if (!Ethernet.linkStatus()) + { + Serial.println("Ethernet cable is not connected."); + } + + // Stay here forever + while (true) + { + delay(1); + } + } + + if (!Ethernet.waitForLink(5000)) + { + Serial.println(F("Failed to wait for Link")); + } + else + { + Serial.print("IP Address = "); + Serial.println(Ethernet.localIP()); + } + +#endif +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY2("\nStarting Complex_Select on", BOARD_NAME, SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runQuery() +{ + MYSQL_DISPLAY("===================================================="); + MYSQL_DISPLAY("> Running SELECT with dynamically supplied parameter"); + + // Supply the parameter for the query + // Here we use the QUERY_POP as the format string and query as the + // destination. This uses twice the memory so another option would be + // to allocate one buffer for all formatted queries or allocate the + // memory as needed (just make sure you allocate enough memory and + // free it when you're done!). + sprintf(query, QUERY_POP, QUERY_POPULATION + (( millis() % 100000 ) * 10) ); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Fetch the columns and print them + column_names *cols = query_mem.get_columns(); + + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(cols->fields[f]->name); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(","); + } + } + + MYSQL_DISPLAY(); + + // Read the rows and print them + row_values *row = NULL; + + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(row->values[f]); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(","); + } + } + + MYSQL_DISPLAY(); + } + } while (row != NULL); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(10000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Complex_Select/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Complex_Select/defines.h new file mode 100644 index 0000000..d422085 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Complex_Select/defines.h @@ -0,0 +1,103 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) && defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) ) + // For Teensy 4.1 + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET false + #define USE_QN_ETHERNET true +#else + #error Only Teensy 4.1 supported +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +#if USE_NATIVE_ETHERNET + #include "NativeEthernet.h" + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using NativeEthernet" +#elif USE_QN_ETHERNET + #include "QNEthernet.h" // https://github.com/ssilverman/QNEthernet + using namespace qindesign::network; + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using QNEthernet" +#endif + +#if USE_NATIVE_ETHERNET + // Enter a MAC address and IP address for your controller below. + #define NUMBER_OF_MAC 20 + + byte mac[][NUMBER_OF_MAC] = + { + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, + }; + +#else + + #define USING_DHCP false //true + + #if !USING_DHCP + // Set the static IP address to use if the DHCP fails to assign + IPAddress myIP(192, 168, 2, 222); + IPAddress myNetmask(255, 255, 255, 0); + IPAddress myGW(192, 168, 2, 1); + //IPAddress mydnsServer(192, 168, 2, 1); + IPAddress mydnsServer(8, 8, 8, 8); + #endif + +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect/Connect.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect/Connect.ino new file mode 100644 index 0000000..6b4bee0 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect/Connect.ino @@ -0,0 +1,167 @@ +/********************************************************************************************************************************* + Connect.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : connect + + This example demonstrates how to connect to a MySQL server from an + Arduino using an Arduino-compatible Ethernet shield. Note that "compatible" + means it must conform to the Ethernet class library or be a derivative + with the same classes and methods. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "world"; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +MySQL_Connection conn((Client *)&client); + +void initEthernet() +{ +#if USE_NATIVE_ETHERNET + MYSQL_DISPLAY(F("======== USE_NATIVE_ETHERNET ========")); +#elif USE_QN_ETHERNET + MYSQL_DISPLAY(F("=========== USE_QN_ETHERNET ===========")); +#endif + +#if USE_NATIVE_ETHERNET + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY(F("=========================")); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + // give the Ethernet shield 2 seconds to initialize: + delay(2000); + +#else + + #if USING_DHCP + // Start the Ethernet connection, using DHCP + Serial.print("Initialize Ethernet using DHCP => "); + Ethernet.begin(); + #else + // Start the Ethernet connection, using static IP + Serial.print("Initialize Ethernet using static IP => "); + Ethernet.begin(myIP, myNetmask, myGW); + Ethernet.setDNSServerIP(mydnsServer); + #endif + + if (!Ethernet.waitForLocalIP(5000)) + { + Serial.println("Failed to configure Ethernet"); + + if (!Ethernet.linkStatus()) + { + Serial.println("Ethernet cable is not connected."); + } + + // Stay here forever + while (true) + { + delay(1); + } + } + + if (!Ethernet.waitForLink(5000)) + { + Serial.println(F("Failed to wait for Link")); + } + else + { + Serial.print("IP Address = "); + Serial.println(Ethernet.localIP()); + } + +#endif +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY2("\nStarting Connect on", BOARD_NAME, SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password, default_database)) + if (conn.connectNonBlocking(server, server_port, user, password, default_database) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect/defines.h new file mode 100644 index 0000000..d422085 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect/defines.h @@ -0,0 +1,103 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) && defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) ) + // For Teensy 4.1 + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET false + #define USE_QN_ETHERNET true +#else + #error Only Teensy 4.1 supported +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +#if USE_NATIVE_ETHERNET + #include "NativeEthernet.h" + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using NativeEthernet" +#elif USE_QN_ETHERNET + #include "QNEthernet.h" // https://github.com/ssilverman/QNEthernet + using namespace qindesign::network; + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using QNEthernet" +#endif + +#if USE_NATIVE_ETHERNET + // Enter a MAC address and IP address for your controller below. + #define NUMBER_OF_MAC 20 + + byte mac[][NUMBER_OF_MAC] = + { + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, + }; + +#else + + #define USING_DHCP false //true + + #if !USING_DHCP + // Set the static IP address to use if the DHCP fails to assign + IPAddress myIP(192, 168, 2, 222); + IPAddress myNetmask(255, 255, 255, 0); + IPAddress myGW(192, 168, 2, 1); + //IPAddress mydnsServer(192, 168, 2, 1); + IPAddress mydnsServer(8, 8, 8, 8); + #endif + +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect_By_Hostname/Connect_By_Hostname.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect_By_Hostname/Connect_By_Hostname.ino new file mode 100644 index 0000000..6e59bf3 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect_By_Hostname/Connect_By_Hostname.ino @@ -0,0 +1,172 @@ +/********************************************************************************************************************************* + Connect_By_Hostname.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect by hostname + + This example demonstrates how to connect to a MySQL server resolving the + hostname for cases when you do not know the IP address of the server or + it changes because it is in the cloud. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the hostname variable to the hostname of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ +#include "defines.h" + +#include + +#if USE_NATIVE_ETHERNET + #include + DNSClient dns_client; // DNS instance +#elif USE_QN_ETHERNET + +#endif + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +IPAddress server_addr; + +MySQL_Connection conn((Client *)&client); + + +void initEthernet() +{ +#if USE_NATIVE_ETHERNET + MYSQL_DISPLAY(F("======== USE_NATIVE_ETHERNET ========")); +#elif USE_QN_ETHERNET + MYSQL_DISPLAY(F("=========== USE_QN_ETHERNET ===========")); +#endif + +#if USE_NATIVE_ETHERNET + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY(F("=========================")); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + // give the Ethernet shield 2 seconds to initialize: + delay(2000); + +#else + + #if USING_DHCP + // Start the Ethernet connection, using DHCP + Serial.print("Initialize Ethernet using DHCP => "); + Ethernet.begin(); + #else + // Start the Ethernet connection, using static IP + Serial.print("Initialize Ethernet using static IP => "); + Ethernet.begin(myIP, myNetmask, myGW); + Ethernet.setDNSServerIP(mydnsServer); + #endif + + if (!Ethernet.waitForLocalIP(5000)) + { + Serial.println("Failed to configure Ethernet"); + + if (!Ethernet.linkStatus()) + { + Serial.println("Ethernet cable is not connected."); + } + + // Stay here forever + while (true) + { + delay(1); + } + } + + if (!Ethernet.waitForLink(5000)) + { + Serial.println(F("Failed to wait for Link")); + } + else + { + Serial.print("IP Address = "); + Serial.println(Ethernet.localIP()); + } + +#endif +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY2("\nStarting Connect_By_Hostname on", BOARD_NAME, SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port) + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect_By_Hostname/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect_By_Hostname/defines.h new file mode 100644 index 0000000..d422085 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect_By_Hostname/defines.h @@ -0,0 +1,103 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) && defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) ) + // For Teensy 4.1 + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET false + #define USE_QN_ETHERNET true +#else + #error Only Teensy 4.1 supported +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +#if USE_NATIVE_ETHERNET + #include "NativeEthernet.h" + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using NativeEthernet" +#elif USE_QN_ETHERNET + #include "QNEthernet.h" // https://github.com/ssilverman/QNEthernet + using namespace qindesign::network; + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using QNEthernet" +#endif + +#if USE_NATIVE_ETHERNET + // Enter a MAC address and IP address for your controller below. + #define NUMBER_OF_MAC 20 + + byte mac[][NUMBER_OF_MAC] = + { + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, + }; + +#else + + #define USING_DHCP false //true + + #if !USING_DHCP + // Set the static IP address to use if the DHCP fails to assign + IPAddress myIP(192, 168, 2, 222); + IPAddress myNetmask(255, 255, 255, 0); + IPAddress myGW(192, 168, 2, 1); + //IPAddress mydnsServer(192, 168, 2, 1); + IPAddress mydnsServer(8, 8, 8, 8); + #endif + +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect_Default_Database/Connect_Default_Database.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect_Default_Database/Connect_Default_Database.ino new file mode 100644 index 0000000..4cc0c89 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect_Default_Database/Connect_Default_Database.ino @@ -0,0 +1,164 @@ +/********************************************************************************************************************************* + Connect_Default_Database.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect with default database + + This example demonstrates how to connect to a MySQL server and specifying + the default database when connecting. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "world"; + +MySQL_Connection conn((Client *)&client); + +void initEthernet() +{ +#if USE_NATIVE_ETHERNET + MYSQL_DISPLAY(F("======== USE_NATIVE_ETHERNET ========")); +#elif USE_QN_ETHERNET + MYSQL_DISPLAY(F("=========== USE_QN_ETHERNET ===========")); +#endif + +#if USE_NATIVE_ETHERNET + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY(F("=========================")); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + // give the Ethernet shield 2 seconds to initialize: + delay(2000); + +#else + + #if USING_DHCP + // Start the Ethernet connection, using DHCP + Serial.print("Initialize Ethernet using DHCP => "); + Ethernet.begin(); + #else + // Start the Ethernet connection, using static IP + Serial.print("Initialize Ethernet using static IP => "); + Ethernet.begin(myIP, myNetmask, myGW); + Ethernet.setDNSServerIP(mydnsServer); + #endif + + if (!Ethernet.waitForLocalIP(5000)) + { + Serial.println("Failed to configure Ethernet"); + + if (!Ethernet.linkStatus()) + { + Serial.println("Ethernet cable is not connected."); + } + + // Stay here forever + while (true) + { + delay(1); + } + } + + if (!Ethernet.waitForLink(5000)) + { + Serial.println(F("Failed to wait for Link")); + } + else + { + Serial.print("IP Address = "); + Serial.println(Ethernet.localIP()); + } + +#endif +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY2("\nStarting Connect_Default_Database on", BOARD_NAME, SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect_Default_Database/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect_Default_Database/defines.h new file mode 100644 index 0000000..d422085 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect_Default_Database/defines.h @@ -0,0 +1,103 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) && defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) ) + // For Teensy 4.1 + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET false + #define USE_QN_ETHERNET true +#else + #error Only Teensy 4.1 supported +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +#if USE_NATIVE_ETHERNET + #include "NativeEthernet.h" + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using NativeEthernet" +#elif USE_QN_ETHERNET + #include "QNEthernet.h" // https://github.com/ssilverman/QNEthernet + using namespace qindesign::network; + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using QNEthernet" +#endif + +#if USE_NATIVE_ETHERNET + // Enter a MAC address and IP address for your controller below. + #define NUMBER_OF_MAC 20 + + byte mac[][NUMBER_OF_MAC] = + { + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, + }; + +#else + + #define USING_DHCP false //true + + #if !USING_DHCP + // Set the static IP address to use if the DHCP fails to assign + IPAddress myIP(192, 168, 2, 222); + IPAddress myNetmask(255, 255, 255, 0); + IPAddress myGW(192, 168, 2, 1); + //IPAddress mydnsServer(192, 168, 2, 1); + IPAddress mydnsServer(8, 8, 8, 8); + #endif + +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect_Disconnect/Connect_Disconnect.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect_Disconnect/Connect_Disconnect.ino new file mode 100644 index 0000000..212c703 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect_Disconnect/Connect_Disconnect.ino @@ -0,0 +1,179 @@ +/********************************************************************************************************************************* + Connect_Disconnect.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : connect and disconnect (close) + + This example demonstrates how to use the connection to open at the start + of a loop, perform some query, then close the connection. Use this technique + for solutions that must sleep for a long period or otherwise require + additional processing or delays. The connect/close pair allow you to + control how long the connection is open and thus reduce the amount of + time a connection is held open. It also helps for lossy connections. + + This example demonstrates how to connect to a MySQL server and specifying + the default database when connecting. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +MySQL_Connection conn((Client *)&client); +MySQL_Query query = MySQL_Query(&conn); + +void initEthernet() +{ +#if USE_NATIVE_ETHERNET + MYSQL_DISPLAY(F("======== USE_NATIVE_ETHERNET ========")); +#elif USE_QN_ETHERNET + MYSQL_DISPLAY(F("=========== USE_QN_ETHERNET ===========")); +#endif + +#if USE_NATIVE_ETHERNET + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY(F("=========================")); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + // give the Ethernet shield 2 seconds to initialize: + delay(2000); + +#else + + #if USING_DHCP + // Start the Ethernet connection, using DHCP + Serial.print("Initialize Ethernet using DHCP => "); + Ethernet.begin(); + #else + // Start the Ethernet connection, using static IP + Serial.print("Initialize Ethernet using static IP => "); + Ethernet.begin(myIP, myNetmask, myGW); + Ethernet.setDNSServerIP(mydnsServer); + #endif + + if (!Ethernet.waitForLocalIP(5000)) + { + Serial.println("Failed to configure Ethernet"); + + if (!Ethernet.linkStatus()) + { + Serial.println("Ethernet cable is not connected."); + } + + // Stay here forever + while (true) + { + delay(1); + } + } + + if (!Ethernet.waitForLink(5000)) + { + Serial.println(F("Failed to wait for Link")); + } + else + { + Serial.print("IP Address = "); + Serial.println(Ethernet.localIP()); + } + +#endif +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY2("\nStarting Connect_Disconnect on", BOARD_NAME, SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); +} + +void runQuery() +{ + MYSQL_DISPLAY("Running a query: SELECT * FROM test_arduino.hello_arduino LIMIT 6;"); + + // Execute the query + // KH, check if valid before fetching + if ( !query.execute("SELECT * FROM test_arduino.hello_arduino LIMIT 6;") ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + query.show_results(); // show the results + query.close(); // close the query +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect_Disconnect/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect_Disconnect/defines.h new file mode 100644 index 0000000..d422085 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Connect_Disconnect/defines.h @@ -0,0 +1,103 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) && defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) ) + // For Teensy 4.1 + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET false + #define USE_QN_ETHERNET true +#else + #error Only Teensy 4.1 supported +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +#if USE_NATIVE_ETHERNET + #include "NativeEthernet.h" + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using NativeEthernet" +#elif USE_QN_ETHERNET + #include "QNEthernet.h" // https://github.com/ssilverman/QNEthernet + using namespace qindesign::network; + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using QNEthernet" +#endif + +#if USE_NATIVE_ETHERNET + // Enter a MAC address and IP address for your controller below. + #define NUMBER_OF_MAC 20 + + byte mac[][NUMBER_OF_MAC] = + { + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, + }; + +#else + + #define USING_DHCP false //true + + #if !USING_DHCP + // Set the static IP address to use if the DHCP fails to assign + IPAddress myIP(192, 168, 2, 222); + IPAddress myNetmask(255, 255, 255, 0); + IPAddress myGW(192, 168, 2, 1); + //IPAddress mydnsServer(192, 168, 2, 1); + IPAddress mydnsServer(8, 8, 8, 8); + #endif + +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Query_Progmem/Query_Progmem.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Query_Progmem/Query_Progmem.ino new file mode 100644 index 0000000..bb5d1b7 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Query_Progmem/Query_Progmem.ino @@ -0,0 +1,190 @@ +/********************************************************************************************************************************* + Query_Progmem.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : query with PROGMEM strings + + This example demonstrates how to issue queries using strings stored in + PROGMEM. As you will see, you need only add a parameter to the execute() + method in the cursor class, const and PROGMEM to the string declaration + and add the #include directive. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +// Sample query +const char PROGMEM query[] = "SELECT * FROM test_arduino.hello_arduino LIMIT 6"; + +MySQL_Connection conn((Client *)&client); + +void initEthernet() +{ +#if USE_NATIVE_ETHERNET + MYSQL_DISPLAY(F("======== USE_NATIVE_ETHERNET ========")); +#elif USE_QN_ETHERNET + MYSQL_DISPLAY(F("=========== USE_QN_ETHERNET ===========")); +#endif + +#if USE_NATIVE_ETHERNET + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY(F("=========================")); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + // give the Ethernet shield 2 seconds to initialize: + delay(2000); + +#else + + #if USING_DHCP + // Start the Ethernet connection, using DHCP + Serial.print("Initialize Ethernet using DHCP => "); + Ethernet.begin(); + #else + // Start the Ethernet connection, using static IP + Serial.print("Initialize Ethernet using static IP => "); + Ethernet.begin(myIP, myNetmask, myGW); + Ethernet.setDNSServerIP(mydnsServer); + #endif + + if (!Ethernet.waitForLocalIP(5000)) + { + Serial.println("Failed to configure Ethernet"); + + if (!Ethernet.linkStatus()) + { + Serial.println("Ethernet cable is not connected."); + } + + // Stay here forever + while (true) + { + delay(1); + } + } + + if (!Ethernet.waitForLink(5000)) + { + Serial.println(F("Failed to wait for Link")); + } + else + { + Serial.print("IP Address = "); + Serial.println(Ethernet.localIP()); + } + +#endif +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY2("\nStarting Query_Progmem on", BOARD_NAME, SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void runQuery() +{ + MYSQL_DISPLAY("\nRunning SELECT from PROGMEM and printing results\n"); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query with the PROGMEM option + // KH, check if valid before fetching + if ( !query_mem.execute(query, true) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Show the results + query_mem.show_results(); + // close the query + query_mem.close(); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(10000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Query_Progmem/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Query_Progmem/defines.h new file mode 100644 index 0000000..d422085 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Query_Progmem/defines.h @@ -0,0 +1,103 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) && defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) ) + // For Teensy 4.1 + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET false + #define USE_QN_ETHERNET true +#else + #error Only Teensy 4.1 supported +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +#if USE_NATIVE_ETHERNET + #include "NativeEthernet.h" + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using NativeEthernet" +#elif USE_QN_ETHERNET + #include "QNEthernet.h" // https://github.com/ssilverman/QNEthernet + using namespace qindesign::network; + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using QNEthernet" +#endif + +#if USE_NATIVE_ETHERNET + // Enter a MAC address and IP address for your controller below. + #define NUMBER_OF_MAC 20 + + byte mac[][NUMBER_OF_MAC] = + { + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, + }; + +#else + + #define USING_DHCP false //true + + #if !USING_DHCP + // Set the static IP address to use if the DHCP fails to assign + IPAddress myIP(192, 168, 2, 222); + IPAddress myNetmask(255, 255, 255, 0); + IPAddress myGW(192, 168, 2, 1); + //IPAddress mydnsServer(192, 168, 2, 1); + IPAddress mydnsServer(8, 8, 8, 8); + #endif + +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Query_Results/Query_Results.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Query_Results/Query_Results.ino new file mode 100644 index 0000000..39d037b --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Query_Results/Query_Results.ino @@ -0,0 +1,224 @@ +/********************************************************************************************************************************* + Query_Results.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : query results + + This example demonstrates how to issue a SELECT query and how to read columns + and rows from the result set. Study this example until you are familiar with how to + do this before writing your own sketch to read and consume query results. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + //char server[] = "your_account.ddns.net"; // change to your server's hostname/URL + char server[] = "khoih.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +// Sample query +char query[] = "SELECT * FROM test_arduino.hello_arduino LIMIT 6"; + +MySQL_Connection conn((Client *)&client); + +void initEthernet() +{ +#if USE_NATIVE_ETHERNET + MYSQL_DISPLAY(F("======== USE_NATIVE_ETHERNET ========")); +#elif USE_QN_ETHERNET + MYSQL_DISPLAY(F("=========== USE_QN_ETHERNET ===========")); +#endif + +#if USE_NATIVE_ETHERNET + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + MYSQL_DISPLAY(F("=========================")); + + MYSQL_DISPLAY1("Using mac index =", index); + MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP()); + + // give the Ethernet shield 2 seconds to initialize: + delay(2000); + +#else + + #if USING_DHCP + // Start the Ethernet connection, using DHCP + Serial.print("Initialize Ethernet using DHCP => "); + Ethernet.begin(); + #else + // Start the Ethernet connection, using static IP + Serial.print("Initialize Ethernet using static IP => "); + Ethernet.begin(myIP, myNetmask, myGW); + Ethernet.setDNSServerIP(mydnsServer); + #endif + + if (!Ethernet.waitForLocalIP(5000)) + { + Serial.println("Failed to configure Ethernet"); + + if (!Ethernet.linkStatus()) + { + Serial.println("Ethernet cable is not connected."); + } + + // Stay here forever + while (true) + { + delay(1); + } + } + + if (!Ethernet.waitForLink(5000)) + { + Serial.println(F("Failed to wait for Link")); + } + else + { + Serial.print("IP Address = "); + Serial.println(Ethernet.localIP()); + } + +#endif +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY2("\nStarting Query_Results on", BOARD_NAME, SHIELD_TYPE); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + initEthernet(); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void runQuery() +{ + MYSQL_DISPLAY("\nRunning SELECT and printing results"); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + ////// + + // Fetch the columns and print them + column_names *cols = query_mem.get_columns(); + + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(cols->fields[f]->name); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(", "); + } + } + + MYSQL_DISPLAY(); + + // Read the rows and print them + row_values *row = NULL; + + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(row->values[f]); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(", "); + } + } + + MYSQL_DISPLAY(); + } + } while (row != NULL); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(10000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Query_Results/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Query_Results/defines.h new file mode 100644 index 0000000..d422085 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/Query_Results/defines.h @@ -0,0 +1,103 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) && defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) ) + // For Teensy 4.1 + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET false + #define USE_QN_ETHERNET true +#else + #error Only Teensy 4.1 supported +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +#if USE_NATIVE_ETHERNET + #include "NativeEthernet.h" + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using NativeEthernet" +#elif USE_QN_ETHERNET + #include "QNEthernet.h" // https://github.com/ssilverman/QNEthernet + using namespace qindesign::network; + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using QNEthernet" +#endif + +#if USE_NATIVE_ETHERNET + // Enter a MAC address and IP address for your controller below. + #define NUMBER_OF_MAC 20 + + byte mac[][NUMBER_OF_MAC] = + { + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, + }; + +#else + + #define USING_DHCP false //true + + #if !USING_DHCP + // Set the static IP address to use if the DHCP fails to assign + IPAddress myIP(192, 168, 2, 222); + IPAddress myNetmask(255, 255, 255, 0); + IPAddress myGW(192, 168, 2, 1); + //IPAddress mydnsServer(192, 168, 2, 1); + IPAddress mydnsServer(8, 8, 8, 8); + #endif + +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/multiFileProject_QNEthernet/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/multiFileProject_QNEthernet/defines.h new file mode 100644 index 0000000..d422085 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/multiFileProject_QNEthernet/defines.h @@ -0,0 +1,103 @@ +/********************************************************************************************************************************* + defines.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define ETHERNET_DEBUG 4 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(CORE_TEENSY) && defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) ) + // For Teensy 4.1 + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET false + #define USE_QN_ETHERNET true +#else + #error Only Teensy 4.1 supported +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +// Only one of the following to be true. +#define USE_ETHERNET_GENERIC true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_ETHERNET_LAN8742A false +#define USE_ETHERNET_LAN8720 false +#define USE_CUSTOM_ETHERNET false +#define USE_UIP_ETHERNET false + +#if USE_NATIVE_ETHERNET + #include "NativeEthernet.h" + #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using NativeEthernet" +#elif USE_QN_ETHERNET + #include "QNEthernet.h" // https://github.com/ssilverman/QNEthernet + using namespace qindesign::network; + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using QNEthernet" +#endif + +#if USE_NATIVE_ETHERNET + // Enter a MAC address and IP address for your controller below. + #define NUMBER_OF_MAC 20 + + byte mac[][NUMBER_OF_MAC] = + { + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, + }; + +#else + + #define USING_DHCP false //true + + #if !USING_DHCP + // Set the static IP address to use if the DHCP fails to assign + IPAddress myIP(192, 168, 2, 222); + IPAddress myNetmask(255, 255, 255, 0); + IPAddress myGW(192, 168, 2, 1); + //IPAddress mydnsServer(192, 168, 2, 1); + IPAddress mydnsServer(8, 8, 8, 8); + #endif + +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/multiFileProject_QNEthernet/multiFileProject.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/multiFileProject_QNEthernet/multiFileProject.cpp new file mode 100644 index 0000000..e1f0fe7 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/multiFileProject_QNEthernet/multiFileProject.cpp @@ -0,0 +1,17 @@ +/**************************************************************************************************************************** + multiFileProject.cpp + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#include "multiFileProject.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/multiFileProject_QNEthernet/multiFileProject.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/multiFileProject_QNEthernet/multiFileProject.h new file mode 100644 index 0000000..5811a68 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/multiFileProject_QNEthernet/multiFileProject.h @@ -0,0 +1,20 @@ +/**************************************************************************************************************************** + multiFileProject.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#pragma once + +// Can be included as many times as necessary, without `Multiple Definitions` Linker Error +#include "MySQL_Generic.hpp" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/multiFileProject_QNEthernet/multiFileProject_QNEthernet.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/multiFileProject_QNEthernet/multiFileProject_QNEthernet.ino new file mode 100644 index 0000000..e549038 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/QNEthernet/multiFileProject_QNEthernet/multiFileProject_QNEthernet.ino @@ -0,0 +1,47 @@ +/**************************************************************************************************************************** + multiFileProject_QNEthernet.ino + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#include "defines.h" + +#define MYSQL_MARIADB_GENERIC_VERSION_MIN_TARGET "MySQL_MariaDB_Generic v1.7.0" +#define MYSQL_MARIADB_GENERIC_VERSION_MIN 1007000 + +#include "multiFileProject.h" + +// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error +#include "MySQL_Generic.h" + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + Serial.println("\nStart multiFileProject_QNEthernet"); + Serial.println(MYSQL_MARIADB_GENERIC_VERSION); + +#if defined(MYSQL_MARIADB_GENERIC_VERSION_MIN) + if (MYSQL_MARIADB_GENERIC_VERSION_INT < MYSQL_MARIADB_GENERIC_VERSION_MIN) + { + Serial.print("Warning. Must use this example on Version equal or later than : "); + Serial.println(MYSQL_MARIADB_GENERIC_VERSION_MIN_TARGET); + } +#endif +} + +void loop() +{ + // put your main code here, to run repeatedly: +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Basic_Insert_WT32_ETH01/Basic_Insert_WT32_ETH01.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Basic_Insert_WT32_ETH01/Basic_Insert_WT32_ETH01.ino new file mode 100644 index 0000000..d78f5b2 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Basic_Insert_WT32_ETH01/Basic_Insert_WT32_ETH01.ino @@ -0,0 +1,168 @@ +/********************************************************************************************************************************* + Basic_Insert_ESP.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect by wifi + + This example demonstrates how to connect to a MySQL server from an + Arduino using an Arduino-compatible Wifi shield. Note that "compatible" + means it must conform to the Ethernet class library or be a derivative + with the same classes and methods. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Change the SSID and pass to match your WiFi network + 4) Connect a USB cable to your Arduino + 5) Select the correct board and port + 6) Compile and upload the sketch to your Arduino + 7) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Created by: Dr. Charles A. Bell +*/ + +#if !(defined(ESP32)) + #error This code is intended to run on the WT32 boards and ESP32 platform ! Please check your Tools->Board setting. +#endif + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _ETHERNET_WEBSERVER_LOGLEVEL_ 3 +#define _MYSQL_LOGLEVEL_ 1 + +#include + +#include + +// Select the IP address according to your local network +IPAddress myIP(192, 168, 2, 232); +IPAddress myGW(192, 168, 2, 1); +IPAddress mySN(255, 255, 255, 0); + +// Google DNS Server IP +IPAddress myDNS(8, 8, 8, 8); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "test_arduino"; //"test_arduino"; +char default_table[] = "hello_arduino"; //"test_arduino"; + +String default_value = "Hello, Arduino!"; + +// Sample query +String INSERT_SQL = String("INSERT INTO ") + default_database + "." + default_table + + " (message) VALUES ('" + default_value + "')"; + +MySQL_Connection conn((Client *)&client); + +MySQL_Query *query_mem; + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Basic_Insert_WT32_ETH01 on", BOARD_NAME); + MYSQL_DISPLAY(WEBSERVER_WT32_ETH01_VERSION); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // To be called before ETH.begin() + WT32_ETH01_onEvent(); + + //bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO, + // eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE); + //ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLK_MODE); + ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER); + + // Static IP, leave without this line to get IP via DHCP + //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); + ETH.config(myIP, myGW, mySN, myDNS); + + WT32_ETH01_waitForConnect(); + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", ETH.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runInsert() +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + MYSQL_DISPLAY(INSERT_SQL); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(INSERT_SQL.c_str()) ) + { + MYSQL_DISPLAY("Insert error"); + } + else + { + MYSQL_DISPLAY("Data Inserted."); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + } +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Basic_Select_WT32_ETH01/Basic_Select_WT32_ETH01.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Basic_Select_WT32_ETH01/Basic_Select_WT32_ETH01.ino new file mode 100644 index 0000000..3ee3efb --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Basic_Select_WT32_ETH01/Basic_Select_WT32_ETH01.ino @@ -0,0 +1,215 @@ +/********************************************************************************************************************************* + Basic_Select_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : basic select + + This example demonstrates how to issue a SELECT query with no parameters + and use the data returned. For this, we use the Cursor class to execute + the query and get the results. + + It demonstrates who methods for running queries. The first allows you to + allocate memory for the cursor and later reclaim it, the second shows how + to use a single instance of the cursor use throughout a sketch. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + CAUTION: Don't mix and match the examples. Use one or the other in your + own sketch -- you'll get compilation errors at the least. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#if !(defined(ESP32)) + #error This code is intended to run on the WT32 boards and ESP32 platform ! Please check your Tools->Board setting. +#endif + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#include + +#include + +// Select the IP address according to your local network +IPAddress myIP(192, 168, 2, 232); +IPAddress myGW(192, 168, 2, 1); +IPAddress mySN(255, 255, 255, 0); + +// Google DNS Server IP +IPAddress myDNS(8, 8, 8, 8); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "world"; //"test_arduino"; +char default_table[] = "city"; //"test_arduino"; + +String default_column = "population"; +String default_value = "Toronto"; + +String query = String("SELECT ") + default_column + " FROM " + default_database + "." + default_table + + " WHERE name = '" + default_value + "'"; + +MySQL_Connection conn((Client *)&client); + +// Create an instance of the cursor passing in the connection +MySQL_Query sql_query = MySQL_Query(&conn); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Basic_Select_WT32_ETH01 on", BOARD_NAME); + MYSQL_DISPLAY(WEBSERVER_WT32_ETH01_VERSION); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // To be called before ETH.begin() + WT32_ETH01_onEvent(); + + //bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO, + // eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE); + //ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLK_MODE); + ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER); + + // Static IP, leave without this line to get IP via DHCP + //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); + ETH.config(myIP, myGW, mySN, myDNS); + + WT32_ETH01_waitForConnect(); + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", ETH.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runQuery() +{ + row_values *row = NULL; + long head_count = 0; + + MYSQL_DISPLAY("1) Demonstrating using a dynamically allocated query."); + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + MYSQL_DISPLAY(query); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(query.c_str()) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Fetch the columns (required) but we don't use them. + //column_names *columns = query_mem.get_columns(); + query_mem.get_columns(); + + // Read the row (we are only expecting the one) + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + head_count = atol(row->values[0]); + } + } while (row != NULL); + + // Show the result + MYSQL_DISPLAY1(" Toronto pop =", head_count); + + delay(500); + + MYSQL_DISPLAY("2) Demonstrating using a local, global query."); + + // Execute the query + MYSQL_DISPLAY(query); + sql_query.execute(query.c_str()); + + // Fetch the columns (required) but we don't use them. + sql_query.get_columns(); + + // Read the row (we are only expecting the one) + do + { + row = sql_query.get_next_row(); + if (row != NULL) + { + head_count = atol(row->values[0]); + } + } while (row != NULL); + + // Now we close the cursor to free any memory + sql_query.close(); + + // Show the result but this time do some math on it + MYSQL_DISPLAY1(" Toronto pop =", head_count); + MYSQL_DISPLAY1(" Toronto pop increased by 11725 =", head_count + 11725); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Complex_Insert_WT32_ETH01/Complex_Insert_WT32_ETH01.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Complex_Insert_WT32_ETH01/Complex_Insert_WT32_ETH01.ino new file mode 100644 index 0000000..622b605 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Complex_Insert_WT32_ETH01/Complex_Insert_WT32_ETH01.ino @@ -0,0 +1,205 @@ +/********************************************************************************************************************************* + Complex_Insert_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : complex insert + + This example demonstrates how to issue an INSERT query to store data in a + table using data from variables in our sketch. In this case, we supply the + values dynamically. + + This sketch simulates storing data from a sensor in a table. + + For this, we will create a special database and table for testing. + The following are the SQL commands you will need to run in order to setup + your database for running this sketch. + + CREATE DATABASE test_arduino; + CREATE TABLE test_arduino.hello_sensor ( + num integer primary key auto_increment, + message char(40), + sensor_num integer, + value float, + recorded timestamp + ); + + Here we have a table that contains an auto_increment primary key, a text + field, a field to identify the sensor, the value read, and timestamp of + the recorded data. + + Note: Since this sketch uses test data, we place the INSERT in the setup() + method so that it runs only once. Typically, you would have the + INSERT in the loop() method after your code to read from the sensor. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Create the database and table as shown above. + 2) Change the address of the server to the IP address of the MySQL server + 3) Change the user and password to a valid MySQL user and password + 4) Connect a USB cable to your Arduino + 5) Select the correct board and port + 6) Compile and upload the sketch to your Arduino + 7) Once uploaded, open Serial Monitor (use 115200 speed) and observe + 8) After the sketch has run for some time, open a mysql client and issue + the command: "SELECT * FROM test_arduino.hello_sensor" to see the data + recorded. Note the field values and how the database handles both the + auto_increment and timestamp fields for us. You can clear the data with + "DELETE FROM test_arduino.hello_sensor". + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#if !(defined(ESP32)) + #error This code is intended to run on the WT32 boards and ESP32 platform ! Please check your Tools->Board setting. +#endif + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#include + +#include + +// Select the IP address according to your local network +IPAddress myIP(192, 168, 2, 232); +IPAddress myGW(192, 168, 2, 1); +IPAddress mySN(255, 255, 255, 0); + +// Google DNS Server IP +IPAddress myDNS(8, 8, 8, 8); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "test_arduino"; //"test_arduino"; +char default_table[] = "hello_sensor"; //"test_arduino"; + +// Sample query +char INSERT_DATA[] = "INSERT INTO %s.%s (message, sensor_num, value) VALUES ('%s',%d,%s)"; + +char query[128]; +char temperature[10]; + +MySQL_Connection conn((Client *)&client); + +#if !( ESP32 || ESP8266 || defined(CORE_TEENSY) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) || defined(STM32F4) || defined(STM32F7) || ( defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED) ) ) + +char *dtostrf(double val, signed char width, unsigned char prec, char *sout) +{ + char fmt[20]; + sprintf(fmt, "%%%d.%df", width, prec); + sprintf(sout, fmt, val); + return sout; +} +#endif + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Complex_Insert_WT32_ETH01 on", BOARD_NAME); + MYSQL_DISPLAY(WEBSERVER_WT32_ETH01_VERSION); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // To be called before ETH.begin() + WT32_ETH01_onEvent(); + + //bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO, + // eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE); + //ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLK_MODE); + ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER); + + // Static IP, leave without this line to get IP via DHCP + //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); + ETH.config(myIP, myGW, mySN, myDNS); + + WT32_ETH01_waitForConnect(); + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", ETH.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runInsert() +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + // Save + dtostrf(50.125, 1, 1, temperature); + sprintf(query, INSERT_DATA, default_database, default_table, "test sensor", 24, temperature); + + // Execute the query + MYSQL_DISPLAY(query); + + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Complex Insert error"); + } + else + { + MYSQL_DISPLAY("Complex Data Inserted."); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + } +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Complex_Select_WT32_ETH01/Complex_Select_WT32_ETH01.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Complex_Select_WT32_ETH01/Complex_Select_WT32_ETH01.ino new file mode 100644 index 0000000..6ec1852 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Complex_Select_WT32_ETH01/Complex_Select_WT32_ETH01.ino @@ -0,0 +1,212 @@ +/********************************************************************************************************************************* + Complex_Select_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : complex select + + This example demonstrates how to issue a SELECT query with parameters that + we provide from code. Thus, it demonstrates how to build query parameters + dynamically. + + Notice also the sketch demonstrates how to read columns and rows from + the result set. Study this example until you are familiar with how to + do this before writing your own sketch to read and consume query results. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#if !(defined(ESP32)) + #error This code is intended to run on the WT32 boards and ESP32 platform ! Please check your Tools->Board setting. +#endif + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#include + +#include + +// Select the IP address according to your local network +IPAddress myIP(192, 168, 2, 232); +IPAddress myGW(192, 168, 2, 1); +IPAddress mySN(255, 255, 255, 0); + +// Google DNS Server IP +IPAddress myDNS(8, 8, 8, 8); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "world"; //"test_arduino"; +char default_table[] = "city"; //"test_arduino"; + +// Sample query +// +// Notice the "%lu" - that's a placeholder for the parameter we will +// supply. See sprintf() documentation for more formatting specifier +// options + +unsigned long QUERY_POPULATION = 800000; + +const char QUERY_POP[] = "SELECT name, population FROM world.city WHERE population < %lu ORDER BY population DESC LIMIT 6;"; + +char query[128]; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Complex_Select_WT32_ETH01 on", BOARD_NAME); + MYSQL_DISPLAY(WEBSERVER_WT32_ETH01_VERSION); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // To be called before ETH.begin() + WT32_ETH01_onEvent(); + + //bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO, + // eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE); + //ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLK_MODE); + ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER); + + // Static IP, leave without this line to get IP via DHCP + //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); + ETH.config(myIP, myGW, mySN, myDNS); + + WT32_ETH01_waitForConnect(); + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", ETH.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runQuery() +{ + MYSQL_DISPLAY("===================================================="); + MYSQL_DISPLAY("> Running SELECT with dynamically supplied parameter"); + + // Supply the parameter for the query + // Here we use the QUERY_POP as the format string and query as the + // destination. This uses twice the memory so another option would be + // to allocate one buffer for all formatted queries or allocate the + // memory as needed (just make sure you allocate enough memory and + // free it when you're done!). + sprintf(query, QUERY_POP, QUERY_POPULATION + (( millis() % 100000 ) * 10) ); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Fetch the columns and print them + column_names *cols = query_mem.get_columns(); + + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(cols->fields[f]->name); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(","); + } + } + + MYSQL_DISPLAY(); + + // Read the rows and print them + row_values *row = NULL; + + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(row->values[f]); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(","); + } + } + + MYSQL_DISPLAY(); + } + } while (row != NULL); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(10000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Connect_Default_Database_WT32_ETH01/Connect_Default_Database_WT32_ETH01.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Connect_Default_Database_WT32_ETH01/Connect_Default_Database_WT32_ETH01.ino new file mode 100644 index 0000000..70259a3 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Connect_Default_Database_WT32_ETH01/Connect_Default_Database_WT32_ETH01.ino @@ -0,0 +1,130 @@ +/********************************************************************************************************************************* + Connect_Default_Database_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect with default database + + This example demonstrates how to connect to a MySQL server and specifying + the default database when connecting. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#if !(defined(ESP32)) + #error This code is intended to run on the WT32 boards and ESP32 platform ! Please check your Tools->Board setting. +#endif + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#include + +#include + +// Select the IP address according to your local network +IPAddress myIP(192, 168, 2, 232); +IPAddress myGW(192, 168, 2, 1); +IPAddress mySN(255, 255, 255, 0); + +// Google DNS Server IP +IPAddress myDNS(8, 8, 8, 8); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +char default_database[] = "world"; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Connect_Default_Database_WT32_ETH01 on", BOARD_NAME); + MYSQL_DISPLAY(WEBSERVER_WT32_ETH01_VERSION); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // To be called before ETH.begin() + WT32_ETH01_onEvent(); + + //bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO, + // eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE); + //ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLK_MODE); + ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER); + + // Static IP, leave without this line to get IP via DHCP + //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); + ETH.config(myIP, myGW, mySN, myDNS); + + WT32_ETH01_waitForConnect(); + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", ETH.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password, default_database)) + if (conn.connectNonBlocking(server, server_port, user, password, default_database) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Connect_Disconnect_WT32_ETH01/Connect_Disconnect_WT32_ETH01.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Connect_Disconnect_WT32_ETH01/Connect_Disconnect_WT32_ETH01.ino new file mode 100644 index 0000000..12523f7 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Connect_Disconnect_WT32_ETH01/Connect_Disconnect_WT32_ETH01.ino @@ -0,0 +1,144 @@ +/********************************************************************************************************************************* + Connect_Disconnect_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect and disconnect (close) + + This example demonstrates how to use the connection to open at the start + of a loop, perform some query, then close the connection. Use this technique + for solutions that must sleep for a long period or otherwise require + additional processing or delays. The connect/close pair allow you to + control how long the connection is open and thus reduce the amount of + time a connection is held open. It also helps for lossy connections. + + This example demonstrates how to connect to a MySQL server and specifying + the default database when connecting. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Created by: Dr. Charles A. Bell +*/ + +#if !(defined(ESP32)) + #error This code is intended to run on the WT32 boards and ESP32 platform ! Please check your Tools->Board setting. +#endif + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#include + +#include + +// Select the IP address according to your local network +IPAddress myIP(192, 168, 2, 232); +IPAddress myGW(192, 168, 2, 1); +IPAddress mySN(255, 255, 255, 0); + +// Google DNS Server IP +IPAddress myDNS(8, 8, 8, 8); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +MySQL_Connection conn((Client *)&client); +MySQL_Query query = MySQL_Query(&conn); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Connect_Disconnect_WT32_ETH01 on", BOARD_NAME); + MYSQL_DISPLAY(WEBSERVER_WT32_ETH01_VERSION); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // To be called before ETH.begin() + WT32_ETH01_onEvent(); + + //bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO, + // eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE); + //ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLK_MODE); + ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER); + + // Static IP, leave without this line to get IP via DHCP + //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); + ETH.config(myIP, myGW, mySN, myDNS); + + WT32_ETH01_waitForConnect(); + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", ETH.localIP()); +} + +void runQuery() +{ + MYSQL_DISPLAY("Running a query: SELECT * FROM test_arduino.hello_arduino LIMIT 6;"); + + // Execute the query + // KH, check if valid before fetching + if ( !query.execute("SELECT * FROM test_arduino.hello_arduino LIMIT 6;") ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + query.show_results(); // show the results + query.close(); // close the query +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Connect_WT32_ETH01/Connect_WT32_ETH01.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Connect_WT32_ETH01/Connect_WT32_ETH01.ino new file mode 100644 index 0000000..c8447b1 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Connect_WT32_ETH01/Connect_WT32_ETH01.ino @@ -0,0 +1,130 @@ +/********************************************************************************************************************************* + Connect_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect + + This example demonstrates how to connect to a MySQL server from an + Arduino using an Arduino-compatible Ethernet shield. Note that "compatible" + means it must conform to the Ethernet class library or be a derivative + with the same classes and methods. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#if !(defined(ESP32)) + #error This code is intended to run on the WT32 boards and ESP32 platform ! Please check your Tools->Board setting. +#endif + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#include + +#include + +// Select the IP address according to your local network +IPAddress myIP(192, 168, 2, 232); +IPAddress myGW(192, 168, 2, 1); +IPAddress mySN(255, 255, 255, 0); + +// Google DNS Server IP +IPAddress myDNS(8, 8, 8, 8); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Connect_WT32_ETH01 on", BOARD_NAME); + MYSQL_DISPLAY(WEBSERVER_WT32_ETH01_VERSION); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // To be called before ETH.begin() + WT32_ETH01_onEvent(); + + //bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO, + // eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE); + //ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLK_MODE); + ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER); + + // Static IP, leave without this line to get IP via DHCP + //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); + ETH.config(myIP, myGW, mySN, myDNS); + + WT32_ETH01_waitForConnect(); + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", ETH.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Query_Progmem_WT32_ETH01/Query_Progmem_WT32_ETH01.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Query_Progmem_WT32_ETH01/Query_Progmem_WT32_ETH01.ino new file mode 100644 index 0000000..1df8037 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Query_Progmem_WT32_ETH01/Query_Progmem_WT32_ETH01.ino @@ -0,0 +1,155 @@ +/********************************************************************************************************************************* + Query_Progmem_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : query with PROGMEM strings + + This example demonstrates how to issue queries using strings stored in + PROGMEM. As you will see, you need only add a parameter to the execute() + method in the cursor class, const and PROGMEM to the string declaration + and add the #include directive. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#if !(defined(ESP32)) + #error This code is intended to run on the WT32 boards and ESP32 platform ! Please check your Tools->Board setting. +#endif + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#include + +#include + +// Select the IP address according to your local network +IPAddress myIP(192, 168, 2, 232); +IPAddress myGW(192, 168, 2, 1); +IPAddress mySN(255, 255, 255, 0); + +// Google DNS Server IP +IPAddress myDNS(8, 8, 8, 8); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +// Sample query +const char PROGMEM query[] = "SELECT * FROM test_arduino.hello_arduino LIMIT 6;"; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Query_Progmem_WT32_ETH01 on", BOARD_NAME); + MYSQL_DISPLAY(WEBSERVER_WT32_ETH01_VERSION); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // To be called before ETH.begin() + WT32_ETH01_onEvent(); + + //bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO, + // eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE); + //ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLK_MODE); + ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER); + + // Static IP, leave without this line to get IP via DHCP + //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); + ETH.config(myIP, myGW, mySN, myDNS); + + WT32_ETH01_waitForConnect(); + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", ETH.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void runQuery() +{ + MYSQL_DISPLAY("\nRunning SELECT from PROGMEM and printing results\n"); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query with the PROGMEM option + // KH, check if valid before fetching + if ( !query_mem.execute(query, true) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Show the results + query_mem.show_results(); + // close the query + query_mem.close(); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Query_Results_WT32_ETH01/Query_Results_WT32_ETH01.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Query_Results_WT32_ETH01/Query_Results_WT32_ETH01.ino new file mode 100644 index 0000000..d5824e8 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Query_Results_WT32_ETH01/Query_Results_WT32_ETH01.ino @@ -0,0 +1,190 @@ +/********************************************************************************************************************************* + Query_Results_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : query results + + This example demonstrates how to issue a SELECT query and how to read columns + and rows from the result set. Study this example until you are familiar with how to + do this before writing your own sketch to read and consume query results. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#if !(defined(ESP32)) + #error This code is intended to run on the WT32 boards and ESP32 platform ! Please check your Tools->Board setting. +#endif + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#include + +#include + +// Select the IP address according to your local network +IPAddress myIP(192, 168, 2, 232); +IPAddress myGW(192, 168, 2, 1); +IPAddress mySN(255, 255, 255, 0); + +// Google DNS Server IP +IPAddress myDNS(8, 8, 8, 8); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +// Sample query +const char query[] = "SELECT * FROM world.city LIMIT 6"; +//const char query[] = "SELECT * FROM test_arduino.hello_arduino LIMIT 6;"; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Query_Results_WT32_ETH01 on", BOARD_NAME); + MYSQL_DISPLAY(WEBSERVER_WT32_ETH01_VERSION); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // To be called before ETH.begin() + WT32_ETH01_onEvent(); + + //bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO, + // eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE); + //ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLK_MODE); + ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER); + + // Static IP, leave without this line to get IP via DHCP + //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); + ETH.config(myIP, myGW, mySN, myDNS); + + WT32_ETH01_waitForConnect(); + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", ETH.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void runQuery() +{ + MYSQL_DISPLAY("\nRunning SELECT and printing results"); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + ////// + + // Fetch the columns and print them + column_names *cols = query_mem.get_columns(); + + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(cols->fields[f]->name); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(", "); + } + } + + MYSQL_DISPLAY(); + + // Read the rows and print them + row_values *row = NULL; + + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(row->values[f]); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(", "); + } + } + + MYSQL_DISPLAY(); + } + } while (row != NULL); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Reboot_WT32_ETH01/Reboot_WT32_ETH01.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Reboot_WT32_ETH01/Reboot_WT32_ETH01.ino new file mode 100644 index 0000000..503030e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/Reboot_WT32_ETH01/Reboot_WT32_ETH01.ino @@ -0,0 +1,216 @@ +/********************************************************************************************************************************* + Reboot_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : reboot if connection lost + + This example demonstrates how to reboot an Arduino if connection to the + server is lost for a period of time. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + To test the reboot, unplug your Ethernet cable once you see "disconnected" + then wait for the timeout. Once the Arduino reboots, plug the cable in again + and you should see the query processing resume. + + Created by: Dr. Charles A. Bell +*/ + +#if !(defined(ESP32)) + #error This code is intended to run on the WT32 boards and ESP32 platform ! Please check your Tools->Board setting. +#endif + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#include + +#include + +// Select the IP address according to your local network +IPAddress myIP(192, 168, 2, 232); +IPAddress myGW(192, 168, 2, 1); +IPAddress mySN(255, 255, 255, 0); + +// Google DNS Server IP +IPAddress myDNS(8, 8, 8, 8); + +#define USING_HOST_NAME false //true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +MySQL_Connection conn((Client *)&client); +MySQL_Query query = MySQL_Query(&conn); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Reboot_WT32_ETH01 on", BOARD_NAME); + MYSQL_DISPLAY(WEBSERVER_WT32_ETH01_VERSION); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // To be called before ETH.begin() + WT32_ETH01_onEvent(); + + //bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO, + // eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE); + //ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLK_MODE); + ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER); + + // Static IP, leave without this line to get IP via DHCP + //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); + ETH.config(myIP, myGW, mySN, myDNS); + + WT32_ETH01_waitForConnect(); + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", ETH.localIP()); +} + +// Begin reboot code +int num_fails; // variable for number of failure attempts +#define MAX_FAILED_CONNECTS 5 // maximum number of failed connects to MySQL + +void soft_reset() +{ +#if WIFI_USE_SAMD + #if ( defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) || defined(__SAMD51G19A__) ) + // For SAMD51 + // see Table 17-5 Timeout Period (valid values 0-11) + WDT->CONFIG.reg = 5; + WDT->CTRLA.reg = WDT_CTRLA_ENABLE; + // To check if OK or bit.ENABLE/CLEAR + while (WDT->SYNCBUSY.bit.WEN == 1); + + // use the WDT watchdog timer to force a system reset. + WDT->CLEAR.reg = 0x00; + // To check if OK or bit.ENABLE/CLEAR + while (WDT->SYNCBUSY.bit.WEN == 1); + #else + // For SAMD21, etc + // see Table 17-5 Timeout Period (valid values 0-11) + WDT->CONFIG.reg = 5; + WDT->CTRL.reg = WDT_CTRL_ENABLE; + while (WDT->STATUS.bit.SYNCBUSY == 1); + + // use the WDT watchdog timer to force a system reset. + WDT->CLEAR.reg = 0x00; + while (WDT->STATUS.bit.SYNCBUSY == 1); + #endif +#elif WIFI_USE_NRF528XX + //delay(1000); + // Restart for nRF52 + NVIC_SystemReset(); +#elif WIFI_USE_SAMDUE + void(*resetFunc)() = 0; + resetFunc(); +#elif WIFI_USE_STM32 + void(*resetFunc)() = 0; + resetFunc(); + +#elif WIFI_USE_TEENSY + #if defined(__IMXRT1062__) + // Teensy 4.1/4.0 + SCB_AIRCR = 0x05FA0004; //write value for restart for Teensy + #else + void(*resetFunc)() = 0; + resetFunc(); + #endif + +#elif ( defined(WIFI_USE_RP2040) && defined(ARDUINO_ARCH_MBED) ) + + NVIC_SystemReset(); + +#endif +} + +// End reboot code + +void loop() +{ + if (conn.connected()) + { + MYSQL_DISPLAY("Running a query: SHOW DATABASES"); + + // Execute the query + + // KH, check if valid before fetching + if ( !query.execute("SHOW DATABASES") ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + ////// + + query.show_results(); // show the results + query.close(); // close the cursor + conn.close(); // close the connection + num_fails = 0; // reset failures + + delay(10000); + } + else + { + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + } + else + { + num_fails++; + MYSQL_DISPLAY("Connect failed!"); + + if (num_fails == MAX_FAILED_CONNECTS) + { + MYSQL_DISPLAY("Ok, that's it. I'm outta here. Rebooting..."); + delay(2000); + // Here we tell the Arduino to reboot by redirecting the instruction + // pointer to the "top" or position 0. This is a soft reset and may + // not solve all hardware-related lockups. + soft_reset(); + } + } + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("=========================================="); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/multiFileProject_WT32_ETH01/multiFileProject.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/multiFileProject_WT32_ETH01/multiFileProject.cpp new file mode 100644 index 0000000..e1f0fe7 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/multiFileProject_WT32_ETH01/multiFileProject.cpp @@ -0,0 +1,17 @@ +/**************************************************************************************************************************** + multiFileProject.cpp + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#include "multiFileProject.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/multiFileProject_WT32_ETH01/multiFileProject.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/multiFileProject_WT32_ETH01/multiFileProject.h new file mode 100644 index 0000000..5811a68 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/multiFileProject_WT32_ETH01/multiFileProject.h @@ -0,0 +1,20 @@ +/**************************************************************************************************************************** + multiFileProject.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#pragma once + +// Can be included as many times as necessary, without `Multiple Definitions` Linker Error +#include "MySQL_Generic.hpp" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/multiFileProject_WT32_ETH01/multiFileProject_WT32_ETH01.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/multiFileProject_WT32_ETH01/multiFileProject_WT32_ETH01.ino new file mode 100644 index 0000000..c6859a6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WT32_ETH01/multiFileProject_WT32_ETH01/multiFileProject_WT32_ETH01.ino @@ -0,0 +1,56 @@ +/**************************************************************************************************************************** + multiFileProject_WT32_ETH01.ino + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#if !(defined(ESP32)) + #error This code is intended to run on the WT32 boards and ESP32 platform ! Please check your Tools->Board setting. +#endif + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#include + +#define MYSQL_MARIADB_GENERIC_VERSION_MIN_TARGET "MySQL_MariaDB_Generic v1.7.0" +#define MYSQL_MARIADB_GENERIC_VERSION_MIN 1007000 + +#include "multiFileProject.h" + +// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error +#include "MySQL_Generic.h" + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + Serial.println("\nStart multiFileProject_WT32_ETH01"); + Serial.println(MYSQL_MARIADB_GENERIC_VERSION); + +#if defined(MYSQL_MARIADB_GENERIC_VERSION_MIN) + if (MYSQL_MARIADB_GENERIC_VERSION_INT < MYSQL_MARIADB_GENERIC_VERSION_MIN) + { + Serial.print("Warning. Must use this example on Version equal or later than : "); + Serial.println(MYSQL_MARIADB_GENERIC_VERSION_MIN_TARGET); + } +#endif +} + +void loop() +{ + // put your main code here, to run repeatedly: +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Insert_ESP/Basic_Insert_ESP.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Insert_ESP/Basic_Insert_ESP.ino new file mode 100644 index 0000000..a1e2eac --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Insert_ESP/Basic_Insert_ESP.ino @@ -0,0 +1,152 @@ +/********************************************************************************************************************************* + Basic_Insert_ESP.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect by wifi + + This example demonstrates how to connect to a MySQL server from an + Arduino using an Arduino-compatible Wifi shield. Note that "compatible" + means it must conform to the Ethernet class library or be a derivative + with the same classes and methods. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Change the SSID and pass to match your WiFi network + 4) Connect a USB cable to your Arduino + 5) Select the correct board and port + 6) Compile and upload the sketch to your Arduino + 7) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Created by: Dr. Charles A. Bell +*/ + +#if ! (ESP8266 || ESP32 ) + #error This code is intended to run on the ESP8266/ESP32 platform! Please check your Tools->Board setting +#endif + +#include "Credentials.h" + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "test_arduino"; //"test_arduino"; +char default_table[] = "hello_arduino"; //"test_arduino"; + +String default_value = "Hello, Arduino!"; + +// Sample query +String INSERT_SQL = String("INSERT INTO ") + default_database + "." + default_table + + " (message) VALUES ('" + default_value + "')"; + +MySQL_Connection conn((Client *)&client); + +MySQL_Query *query_mem; + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Basic_Insert_ESP on", ARDUINO_BOARD); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runInsert() +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + MYSQL_DISPLAY(INSERT_SQL); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(INSERT_SQL.c_str()) ) + { + MYSQL_DISPLAY("Insert error"); + } + else + { + MYSQL_DISPLAY("Data Inserted."); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + } +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Insert_ESP/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Insert_ESP/Credentials.h new file mode 100644 index 0000000..9e3d7e7 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Insert_ESP/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Insert_WiFi/Basic_Insert_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Insert_WiFi/Basic_Insert_WiFi.ino new file mode 100644 index 0000000..de135e6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Insert_WiFi/Basic_Insert_WiFi.ino @@ -0,0 +1,183 @@ +/********************************************************************************************************************************* + Basic_Insert_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : basic insert + + This example demonstrates how to issue an INSERT query to store data in a + table. For this, we will create a special database and table for testing. + The following are the SQL commands you will need to run in order to setup + your database for running this sketch. + + CREATE DATABASE test_arduino; + CREATE TABLE test_arduino.hello_arduino ( + num integer primary key auto_increment, + message char(40), + recorded timestamp + ); + + Here we see one database and a table with three fields; a primary key that + is an auto_increment, a string, and a timestamp. This will demonstrate how + to save a date and time of when the row was inserted, which can help you + determine when data was recorded or updated. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Create the database and table as shown above. + 2) Change the address of the server to the IP address of the MySQL server + 3) Change the user and password to a valid MySQL user and password + 4) Connect a USB cable to your Arduino + 5) Select the correct board and port + 6) Compile and upload the sketch to your Arduino + 7) Once uploaded, open Serial Monitor (use 115200 speed) and observe + 8) After the sketch has run for some time, open a mysql client and issue + the command: "SELECT * FROM test_arduino.hello_arduino" to see the data + recorded. Note the field values and how the database handles both the + auto_increment and timestamp fields for us. You can clear the data with + "DELETE FROM test_arduino.hello_arduino". + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "test_arduino"; //"test_arduino"; +char default_table[] = "hello_arduino"; //"test_arduino"; + +String default_value = "Hello, Arduino!"; + +// Sample query +String INSERT_SQL = String("INSERT INTO ") + default_database + "." + default_table + + " (message) VALUES ('" + default_value + "')"; + +MySQL_Connection conn((Client *)&client); + +MySQL_Query *query_mem; + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Basic_Insert_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // Remember to initialize your WiFi module +#if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #if ( USING_WIFI_ESP8266_AT ) + MYSQL_DISPLAY("Using ESP8266_AT/ESP8266_AT_WebServer Library"); + #elif ( USING_WIFIESPAT_LIB ) + MYSQL_DISPLAY("Using WiFiEspAT Library"); + #endif + + // initialize serial for ESP module + EspSerial.begin(115200); + // initialize ESP module + WiFi.init(&EspSerial); + + MYSQL_DISPLAY(F("WiFi shield init done")); + + // check for the presence of the shield + if (WiFi.status() == WL_NO_SHIELD) + { + MYSQL_DISPLAY(F("WiFi shield not present")); + // don't continue + while (true); + } +#endif + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runInsert() +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + MYSQL_DISPLAY(INSERT_SQL); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(INSERT_SQL.c_str()) ) + { + MYSQL_DISPLAY("Insert error"); + } + else + { + MYSQL_DISPLAY("Data Inserted."); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + } +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Insert_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Insert_WiFi/Credentials.h new file mode 100644 index 0000000..a311e60 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Insert_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Insert_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Insert_WiFi/defines.h new file mode 100644 index 0000000..ed63a72 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Insert_WiFi/defines.h @@ -0,0 +1,381 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define DEBUG_ESP8266_AT_WEBSERVER_PORT Serial + +// Debug Level from 0 to 4 +#define _ESP_AT_LOGLEVEL_ 1 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ! (ESP8266 || ESP32 ) + // Select only one of these libraries, only for boards other than ESP8266/ESP32 + #define USING_WIFI_ESP8266_AT false + #define USING_WIFININA_GENERIC false + #define USING_WIFININA false + #define USING_WIFIESPAT_LIB true + #define USING_WIFI_CUSTOM false +#endif + +#if defined(ARDUINO_SAMD_MKR1000) + #if defined(USE_WIFI_NINA) + #undef USE_WIFI_NINA + #endif + #define USE_WIFI_NINA false + #define USE_WIFI101 true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX + #endif + #define WIFI_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD + #endif + #define WIFI_USE_SAMD true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFI_USE_SAM_DUE) + #undef WIFI_USE_SAM_DUE + #endif + #define WIFI_USE_SAM_DUE true + #warning Use SAM_DUE architecture +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 + #endif + #define WIFI_USE_STM32 true +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFI_USE_RP2040) + #undef WIFI_USE_RP2040 + #endif + #define WIFI_USE_RP2040 true +#endif + +#ifdef CORE_TEENSY + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For Teensy 4.1/4.0 + #define EspSerial Serial2 //Serial2, Pin RX2 : 7, TX2 : 8 + #endif + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" +#endif + +#elif defined(WIFI_USE_NRF528XX) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif defined(WIFI_USE_SAMD) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For SAMD + #define EspSerial Serial1 + #endif + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif defined(WIFI_USE_STM32) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For STM32 + #if defined(ARDUINO_NUCLEO_F767ZI) + #warning Nucleo-144 NUCLEO_F767ZI board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); + #elif defined(ARDUINO_NUCLEO_L053R8) + #warning Nucleo-64 NUCLEO_L053R8 board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); // (PA3, PA2); + #endif + + #warning EspSerial using SERIAL_PORT_HARDWARE, can be Serial or Serial1. See your board variant.h + #define EspSerial SERIAL_PORT_HARDWARE //Serial1 + #endif + + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif (ESP8266) + #warning ESP8266 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif (ESP32) + #warning ESP32 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif defined(WIFI_USE_RP2040) && !defined(ARDUINO_ARCH_MBED) + + // For RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + +#elif defined(WIFI_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + // For MBED RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#else + // For Mega + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #define BOARD_TYPE "AVR Mega" +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Select_WiFi/Basic_Select_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Select_WiFi/Basic_Select_WiFi.ino new file mode 100644 index 0000000..b732d66 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Select_WiFi/Basic_Select_WiFi.ino @@ -0,0 +1,216 @@ +/********************************************************************************************************************************* + Basic_Select_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : basic select + + This example demonstrates how to issue a SELECT query with no parameters + and use the data returned. For this, we use the Cursor class to execute + the query and get the results. + + It demonstrates who methods for running queries. The first allows you to + allocate memory for the cursor and later reclaim it, the second shows how + to use a single instance of the cursor use throughout a sketch. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + CAUTION: Don't mix and match the examples. Use one or the other in your + own sketch -- you'll get compilation errors at the least. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "world"; //"test_arduino"; +char default_table[] = "city"; //"test_arduino"; + +String default_column = "population"; +String default_value = "Toronto"; + +String query = String("SELECT ") + default_column + " FROM " + default_database + "." + default_table + + " WHERE name = '" + default_value + "'"; + +MySQL_Connection conn((Client *)&client); + +// Create an instance of the cursor passing in the connection +MySQL_Query sql_query = MySQL_Query(&conn); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Basic_Select_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // Remember to initialize your WiFi module +#if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #if ( USING_WIFI_ESP8266_AT ) + MYSQL_DISPLAY("Using ESP8266_AT/ESP8266_AT_WebServer Library"); + #elif ( USING_WIFIESPAT_LIB ) + MYSQL_DISPLAY("Using WiFiEspAT Library"); + #endif + + // initialize serial for ESP module + EspSerial.begin(115200); + // initialize ESP module + WiFi.init(&EspSerial); + + MYSQL_DISPLAY(F("WiFi shield init done")); + + // check for the presence of the shield + if (WiFi.status() == WL_NO_SHIELD) + { + MYSQL_DISPLAY(F("WiFi shield not present")); + // don't continue + while (true); + } +#endif + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runQuery() +{ + row_values *row = NULL; + long head_count = 0; + + MYSQL_DISPLAY("1) Demonstrating using a dynamically allocated query."); + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + MYSQL_DISPLAY(query); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(query.c_str()) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Fetch the columns (required) but we don't use them. + //column_names *columns = query_mem.get_columns(); + query_mem.get_columns(); + + // Read the row (we are only expecting the one) + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + head_count = atol(row->values[0]); + } + } while (row != NULL); + + // Show the result + MYSQL_DISPLAY1(" Toronto pop =", head_count); + + delay(500); + + MYSQL_DISPLAY("2) Demonstrating using a local, global query."); + + // Execute the query + MYSQL_DISPLAY(query); + sql_query.execute(query.c_str()); + + // Fetch the columns (required) but we don't use them. + sql_query.get_columns(); + + // Read the row (we are only expecting the one) + do + { + row = sql_query.get_next_row(); + if (row != NULL) + { + head_count = atol(row->values[0]); + } + } while (row != NULL); + + // Now we close the cursor to free any memory + sql_query.close(); + + // Show the result but this time do some math on it + MYSQL_DISPLAY1(" Toronto pop =", head_count); + MYSQL_DISPLAY1(" Toronto pop increased by 11725 =", head_count + 11725); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Select_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Select_WiFi/Credentials.h new file mode 100644 index 0000000..a311e60 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Select_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Select_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Select_WiFi/defines.h new file mode 100644 index 0000000..ed63a72 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Basic_Select_WiFi/defines.h @@ -0,0 +1,381 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define DEBUG_ESP8266_AT_WEBSERVER_PORT Serial + +// Debug Level from 0 to 4 +#define _ESP_AT_LOGLEVEL_ 1 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ! (ESP8266 || ESP32 ) + // Select only one of these libraries, only for boards other than ESP8266/ESP32 + #define USING_WIFI_ESP8266_AT false + #define USING_WIFININA_GENERIC false + #define USING_WIFININA false + #define USING_WIFIESPAT_LIB true + #define USING_WIFI_CUSTOM false +#endif + +#if defined(ARDUINO_SAMD_MKR1000) + #if defined(USE_WIFI_NINA) + #undef USE_WIFI_NINA + #endif + #define USE_WIFI_NINA false + #define USE_WIFI101 true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX + #endif + #define WIFI_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD + #endif + #define WIFI_USE_SAMD true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFI_USE_SAM_DUE) + #undef WIFI_USE_SAM_DUE + #endif + #define WIFI_USE_SAM_DUE true + #warning Use SAM_DUE architecture +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 + #endif + #define WIFI_USE_STM32 true +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFI_USE_RP2040) + #undef WIFI_USE_RP2040 + #endif + #define WIFI_USE_RP2040 true +#endif + +#ifdef CORE_TEENSY + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For Teensy 4.1/4.0 + #define EspSerial Serial2 //Serial2, Pin RX2 : 7, TX2 : 8 + #endif + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" +#endif + +#elif defined(WIFI_USE_NRF528XX) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif defined(WIFI_USE_SAMD) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For SAMD + #define EspSerial Serial1 + #endif + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif defined(WIFI_USE_STM32) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For STM32 + #if defined(ARDUINO_NUCLEO_F767ZI) + #warning Nucleo-144 NUCLEO_F767ZI board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); + #elif defined(ARDUINO_NUCLEO_L053R8) + #warning Nucleo-64 NUCLEO_L053R8 board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); // (PA3, PA2); + #endif + + #warning EspSerial using SERIAL_PORT_HARDWARE, can be Serial or Serial1. See your board variant.h + #define EspSerial SERIAL_PORT_HARDWARE //Serial1 + #endif + + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif (ESP8266) + #warning ESP8266 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif (ESP32) + #warning ESP32 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif defined(WIFI_USE_RP2040) && !defined(ARDUINO_ARCH_MBED) + + // For RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + +#elif defined(WIFI_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + // For MBED RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#else + // For Mega + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #define BOARD_TYPE "AVR Mega" +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Complex_Insert_WiFi/Complex_Insert_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Complex_Insert_WiFi/Complex_Insert_WiFi.ino new file mode 100644 index 0000000..044aeff --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Complex_Insert_WiFi/Complex_Insert_WiFi.ino @@ -0,0 +1,206 @@ +/********************************************************************************************************************************* + Complex_Insert_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : complex insert + + This example demonstrates how to issue an INSERT query to store data in a + table using data from variables in our sketch. In this case, we supply the + values dynamically. + + This sketch simulates storing data from a sensor in a table. + + For this, we will create a special database and table for testing. + The following are the SQL commands you will need to run in order to setup + your database for running this sketch. + + CREATE DATABASE test_arduino; + CREATE TABLE test_arduino.hello_sensor ( + num integer primary key auto_increment, + message char(40), + sensor_num integer, + value float, + recorded timestamp + ); + + Here we have a table that contains an auto_increment primary key, a text + field, a field to identify the sensor, the value read, and timestamp of + the recorded data. + + Note: Since this sketch uses test data, we place the INSERT in the setup() + method so that it runs only once. Typically, you would have the + INSERT in the loop() method after your code to read from the sensor. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Create the database and table as shown above. + 2) Change the address of the server to the IP address of the MySQL server + 3) Change the user and password to a valid MySQL user and password + 4) Connect a USB cable to your Arduino + 5) Select the correct board and port + 6) Compile and upload the sketch to your Arduino + 7) Once uploaded, open Serial Monitor (use 115200 speed) and observe + 8) After the sketch has run for some time, open a mysql client and issue + the command: "SELECT * FROM test_arduino.hello_sensor" to see the data + recorded. Note the field values and how the database handles both the + auto_increment and timestamp fields for us. You can clear the data with + "DELETE FROM test_arduino.hello_sensor". + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "test_arduino"; //"test_arduino"; +char default_table[] = "hello_sensor"; //"test_arduino"; + +// Sample query +char INSERT_DATA[] = "INSERT INTO %s.%s (message, sensor_num, value) VALUES ('%s',%d,%s)"; + +char query[128]; +char temperature[10]; + +MySQL_Connection conn((Client *)&client); + +#if !( ESP32 || ESP8266 || defined(CORE_TEENSY) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) || defined(STM32F4) || defined(STM32F7) || ( defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED) ) ) + +char *dtostrf(double val, signed char width, unsigned char prec, char *sout) +{ + char fmt[20]; + sprintf(fmt, "%%%d.%df", width, prec); + sprintf(sout, fmt, val); + return sout; +} +#endif + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Complex_Insert_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // Remember to initialize your WiFi module +#if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #if ( USING_WIFI_ESP8266_AT ) + MYSQL_DISPLAY("Using ESP8266_AT/ESP8266_AT_WebServer Library"); + #elif ( USING_WIFIESPAT_LIB ) + MYSQL_DISPLAY("Using WiFiEspAT Library"); + #endif + + // initialize serial for ESP module + EspSerial.begin(115200); + // initialize ESP module + WiFi.init(&EspSerial); + + MYSQL_DISPLAY(F("WiFi shield init done")); + + // check for the presence of the shield + if (WiFi.status() == WL_NO_SHIELD) + { + MYSQL_DISPLAY(F("WiFi shield not present")); + // don't continue + while (true); + } +#endif + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runInsert() +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + // Save + dtostrf(50.125, 1, 1, temperature); + sprintf(query, INSERT_DATA, default_database, default_table, "test sensor", 24, temperature); + + // Execute the query + MYSQL_DISPLAY(query); + + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Complex Insert error"); + } + else + { + MYSQL_DISPLAY("Complex Data Inserted."); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + } +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Complex_Insert_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Complex_Insert_WiFi/Credentials.h new file mode 100644 index 0000000..a311e60 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Complex_Insert_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Complex_Insert_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Complex_Insert_WiFi/defines.h new file mode 100644 index 0000000..ed63a72 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Complex_Insert_WiFi/defines.h @@ -0,0 +1,381 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define DEBUG_ESP8266_AT_WEBSERVER_PORT Serial + +// Debug Level from 0 to 4 +#define _ESP_AT_LOGLEVEL_ 1 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ! (ESP8266 || ESP32 ) + // Select only one of these libraries, only for boards other than ESP8266/ESP32 + #define USING_WIFI_ESP8266_AT false + #define USING_WIFININA_GENERIC false + #define USING_WIFININA false + #define USING_WIFIESPAT_LIB true + #define USING_WIFI_CUSTOM false +#endif + +#if defined(ARDUINO_SAMD_MKR1000) + #if defined(USE_WIFI_NINA) + #undef USE_WIFI_NINA + #endif + #define USE_WIFI_NINA false + #define USE_WIFI101 true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX + #endif + #define WIFI_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD + #endif + #define WIFI_USE_SAMD true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFI_USE_SAM_DUE) + #undef WIFI_USE_SAM_DUE + #endif + #define WIFI_USE_SAM_DUE true + #warning Use SAM_DUE architecture +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 + #endif + #define WIFI_USE_STM32 true +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFI_USE_RP2040) + #undef WIFI_USE_RP2040 + #endif + #define WIFI_USE_RP2040 true +#endif + +#ifdef CORE_TEENSY + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For Teensy 4.1/4.0 + #define EspSerial Serial2 //Serial2, Pin RX2 : 7, TX2 : 8 + #endif + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" +#endif + +#elif defined(WIFI_USE_NRF528XX) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif defined(WIFI_USE_SAMD) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For SAMD + #define EspSerial Serial1 + #endif + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif defined(WIFI_USE_STM32) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For STM32 + #if defined(ARDUINO_NUCLEO_F767ZI) + #warning Nucleo-144 NUCLEO_F767ZI board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); + #elif defined(ARDUINO_NUCLEO_L053R8) + #warning Nucleo-64 NUCLEO_L053R8 board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); // (PA3, PA2); + #endif + + #warning EspSerial using SERIAL_PORT_HARDWARE, can be Serial or Serial1. See your board variant.h + #define EspSerial SERIAL_PORT_HARDWARE //Serial1 + #endif + + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif (ESP8266) + #warning ESP8266 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif (ESP32) + #warning ESP32 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif defined(WIFI_USE_RP2040) && !defined(ARDUINO_ARCH_MBED) + + // For RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + +#elif defined(WIFI_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + // For MBED RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#else + // For Mega + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #define BOARD_TYPE "AVR Mega" +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Complex_Select_WiFi/Complex_Select_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Complex_Select_WiFi/Complex_Select_WiFi.ino new file mode 100644 index 0000000..6f49ea7 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Complex_Select_WiFi/Complex_Select_WiFi.ino @@ -0,0 +1,213 @@ +/********************************************************************************************************************************* + Complex_Select_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : complex select + + This example demonstrates how to issue a SELECT query with parameters that + we provide from code. Thus, it demonstrates how to build query parameters + dynamically. + + Notice also the sketch demonstrates how to read columns and rows from + the result set. Study this example until you are familiar with how to + do this before writing your own sketch to read and consume query results. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "world"; //"test_arduino"; +char default_table[] = "city"; //"test_arduino"; + +// Sample query +// +// Notice the "%lu" - that's a placeholder for the parameter we will +// supply. See sprintf() documentation for more formatting specifier +// options + +unsigned long QUERY_POPULATION = 800000; + +const char QUERY_POP[] = "SELECT name, population FROM world.city WHERE population < %lu ORDER BY population DESC LIMIT 6;"; + +char query[128]; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Complex_Select_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // Remember to initialize your WiFi module +#if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #if ( USING_WIFI_ESP8266_AT ) + MYSQL_DISPLAY("Using ESP8266_AT/ESP8266_AT_WebServer Library"); + #elif ( USING_WIFIESPAT_LIB ) + MYSQL_DISPLAY("Using WiFiEspAT Library"); + #endif + + // initialize serial for ESP module + EspSerial.begin(115200); + // initialize ESP module + WiFi.init(&EspSerial); + + MYSQL_DISPLAY(F("WiFi shield init done")); + + // check for the presence of the shield + if (WiFi.status() == WL_NO_SHIELD) + { + MYSQL_DISPLAY(F("WiFi shield not present")); + // don't continue + while (true); + } +#endif + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runQuery() +{ + MYSQL_DISPLAY("===================================================="); + MYSQL_DISPLAY("> Running SELECT with dynamically supplied parameter"); + + // Supply the parameter for the query + // Here we use the QUERY_POP as the format string and query as the + // destination. This uses twice the memory so another option would be + // to allocate one buffer for all formatted queries or allocate the + // memory as needed (just make sure you allocate enough memory and + // free it when you're done!). + sprintf(query, QUERY_POP, QUERY_POPULATION + (( millis() % 100000 ) * 10) ); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Fetch the columns and print them + column_names *cols = query_mem.get_columns(); + + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(cols->fields[f]->name); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(","); + } + } + + MYSQL_DISPLAY(); + + // Read the rows and print them + row_values *row = NULL; + + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(row->values[f]); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(","); + } + } + + MYSQL_DISPLAY(); + } + } while (row != NULL); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(10000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Complex_Select_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Complex_Select_WiFi/Credentials.h new file mode 100644 index 0000000..a311e60 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Complex_Select_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Complex_Select_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Complex_Select_WiFi/defines.h new file mode 100644 index 0000000..ed63a72 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Complex_Select_WiFi/defines.h @@ -0,0 +1,381 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define DEBUG_ESP8266_AT_WEBSERVER_PORT Serial + +// Debug Level from 0 to 4 +#define _ESP_AT_LOGLEVEL_ 1 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ! (ESP8266 || ESP32 ) + // Select only one of these libraries, only for boards other than ESP8266/ESP32 + #define USING_WIFI_ESP8266_AT false + #define USING_WIFININA_GENERIC false + #define USING_WIFININA false + #define USING_WIFIESPAT_LIB true + #define USING_WIFI_CUSTOM false +#endif + +#if defined(ARDUINO_SAMD_MKR1000) + #if defined(USE_WIFI_NINA) + #undef USE_WIFI_NINA + #endif + #define USE_WIFI_NINA false + #define USE_WIFI101 true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX + #endif + #define WIFI_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD + #endif + #define WIFI_USE_SAMD true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFI_USE_SAM_DUE) + #undef WIFI_USE_SAM_DUE + #endif + #define WIFI_USE_SAM_DUE true + #warning Use SAM_DUE architecture +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 + #endif + #define WIFI_USE_STM32 true +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFI_USE_RP2040) + #undef WIFI_USE_RP2040 + #endif + #define WIFI_USE_RP2040 true +#endif + +#ifdef CORE_TEENSY + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For Teensy 4.1/4.0 + #define EspSerial Serial2 //Serial2, Pin RX2 : 7, TX2 : 8 + #endif + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" +#endif + +#elif defined(WIFI_USE_NRF528XX) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif defined(WIFI_USE_SAMD) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For SAMD + #define EspSerial Serial1 + #endif + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif defined(WIFI_USE_STM32) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For STM32 + #if defined(ARDUINO_NUCLEO_F767ZI) + #warning Nucleo-144 NUCLEO_F767ZI board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); + #elif defined(ARDUINO_NUCLEO_L053R8) + #warning Nucleo-64 NUCLEO_L053R8 board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); // (PA3, PA2); + #endif + + #warning EspSerial using SERIAL_PORT_HARDWARE, can be Serial or Serial1. See your board variant.h + #define EspSerial SERIAL_PORT_HARDWARE //Serial1 + #endif + + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif (ESP8266) + #warning ESP8266 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif (ESP32) + #warning ESP32 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif defined(WIFI_USE_RP2040) && !defined(ARDUINO_ARCH_MBED) + + // For RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + +#elif defined(WIFI_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + // For MBED RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#else + // For Mega + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #define BOARD_TYPE "AVR Mega" +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_Default_Database_WiFi/Connect_Default_Database_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_Default_Database_WiFi/Connect_Default_Database_WiFi.ino new file mode 100644 index 0000000..0375809 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_Default_Database_WiFi/Connect_Default_Database_WiFi.ino @@ -0,0 +1,132 @@ +/********************************************************************************************************************************* + Connect_Default_Database_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* +/* + MySQL Connector/Arduino Example : connect with default database + + This example demonstrates how to connect to a MySQL server and specifying + the default database when connecting. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "world"; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Connect_Default_Database_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // Remember to initialize your WiFi module +#if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #if ( USING_WIFI_ESP8266_AT ) + MYSQL_DISPLAY("Using ESP8266_AT/ESP8266_AT_WebServer Library"); + #elif ( USING_WIFIESPAT_LIB ) + MYSQL_DISPLAY("Using WiFiEspAT Library"); + #endif + + // initialize serial for ESP module + EspSerial.begin(115200); + // initialize ESP module + WiFi.init(&EspSerial); + + MYSQL_DISPLAY(F("WiFi shield init done")); + + // check for the presence of the shield + if (WiFi.status() == WL_NO_SHIELD) + { + MYSQL_DISPLAY(F("WiFi shield not present")); + // don't continue + while (true); + } +#endif + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password, default_database)) + if (conn.connectNonBlocking(server, server_port, user, password, default_database) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_Default_Database_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_Default_Database_WiFi/Credentials.h new file mode 100644 index 0000000..a311e60 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_Default_Database_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_Default_Database_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_Default_Database_WiFi/defines.h new file mode 100644 index 0000000..ed63a72 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_Default_Database_WiFi/defines.h @@ -0,0 +1,381 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define DEBUG_ESP8266_AT_WEBSERVER_PORT Serial + +// Debug Level from 0 to 4 +#define _ESP_AT_LOGLEVEL_ 1 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ! (ESP8266 || ESP32 ) + // Select only one of these libraries, only for boards other than ESP8266/ESP32 + #define USING_WIFI_ESP8266_AT false + #define USING_WIFININA_GENERIC false + #define USING_WIFININA false + #define USING_WIFIESPAT_LIB true + #define USING_WIFI_CUSTOM false +#endif + +#if defined(ARDUINO_SAMD_MKR1000) + #if defined(USE_WIFI_NINA) + #undef USE_WIFI_NINA + #endif + #define USE_WIFI_NINA false + #define USE_WIFI101 true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX + #endif + #define WIFI_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD + #endif + #define WIFI_USE_SAMD true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFI_USE_SAM_DUE) + #undef WIFI_USE_SAM_DUE + #endif + #define WIFI_USE_SAM_DUE true + #warning Use SAM_DUE architecture +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 + #endif + #define WIFI_USE_STM32 true +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFI_USE_RP2040) + #undef WIFI_USE_RP2040 + #endif + #define WIFI_USE_RP2040 true +#endif + +#ifdef CORE_TEENSY + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For Teensy 4.1/4.0 + #define EspSerial Serial2 //Serial2, Pin RX2 : 7, TX2 : 8 + #endif + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" +#endif + +#elif defined(WIFI_USE_NRF528XX) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif defined(WIFI_USE_SAMD) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For SAMD + #define EspSerial Serial1 + #endif + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif defined(WIFI_USE_STM32) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For STM32 + #if defined(ARDUINO_NUCLEO_F767ZI) + #warning Nucleo-144 NUCLEO_F767ZI board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); + #elif defined(ARDUINO_NUCLEO_L053R8) + #warning Nucleo-64 NUCLEO_L053R8 board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); // (PA3, PA2); + #endif + + #warning EspSerial using SERIAL_PORT_HARDWARE, can be Serial or Serial1. See your board variant.h + #define EspSerial SERIAL_PORT_HARDWARE //Serial1 + #endif + + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif (ESP8266) + #warning ESP8266 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif (ESP32) + #warning ESP32 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif defined(WIFI_USE_RP2040) && !defined(ARDUINO_ARCH_MBED) + + // For RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + +#elif defined(WIFI_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + // For MBED RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#else + // For Mega + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #define BOARD_TYPE "AVR Mega" +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_Disconnect_WiFi/Connect_Disconnect_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_Disconnect_WiFi/Connect_Disconnect_WiFi.ino new file mode 100644 index 0000000..637c21c --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_Disconnect_WiFi/Connect_Disconnect_WiFi.ino @@ -0,0 +1,145 @@ +/********************************************************************************************************************************* + Connect_Disconnect_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect and disconnect (close) + + This example demonstrates how to use the connection to open at the start + of a loop, perform some query, then close the connection. Use this technique + for solutions that must sleep for a long period or otherwise require + additional processing or delays. The connect/close pair allow you to + control how long the connection is open and thus reduce the amount of + time a connection is held open. It also helps for lossy connections. + + This example demonstrates how to connect to a MySQL server and specifying + the default database when connecting. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +MySQL_Connection conn((Client *)&client); +MySQL_Query query = MySQL_Query(&conn); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Connect_Disconnect_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // Remember to initialize your WiFi module +#if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #if ( USING_WIFI_ESP8266_AT ) + MYSQL_DISPLAY("Using ESP8266_AT/ESP8266_AT_WebServer Library"); + #elif ( USING_WIFIESPAT_LIB ) + MYSQL_DISPLAY("Using WiFiEspAT Library"); + #endif + + // initialize serial for ESP module + EspSerial.begin(115200); + // initialize ESP module + WiFi.init(&EspSerial); + + MYSQL_DISPLAY(F("WiFi shield init done")); + + // check for the presence of the shield + if (WiFi.status() == WL_NO_SHIELD) + { + MYSQL_DISPLAY(F("WiFi shield not present")); + // don't continue + while (true); + } +#endif + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); +} + +void runQuery() +{ + MYSQL_DISPLAY("Running a query: SELECT * FROM test_arduino.hello_arduino LIMIT 6;"); + + // Execute the query + // KH, check if valid before fetching + if ( !query.execute("SELECT * FROM test_arduino.hello_arduino LIMIT 6;") ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + query.show_results(); // show the results + query.close(); // close the query +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_Disconnect_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_Disconnect_WiFi/Credentials.h new file mode 100644 index 0000000..a311e60 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_Disconnect_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_Disconnect_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_Disconnect_WiFi/defines.h new file mode 100644 index 0000000..ed63a72 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_Disconnect_WiFi/defines.h @@ -0,0 +1,381 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define DEBUG_ESP8266_AT_WEBSERVER_PORT Serial + +// Debug Level from 0 to 4 +#define _ESP_AT_LOGLEVEL_ 1 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ! (ESP8266 || ESP32 ) + // Select only one of these libraries, only for boards other than ESP8266/ESP32 + #define USING_WIFI_ESP8266_AT false + #define USING_WIFININA_GENERIC false + #define USING_WIFININA false + #define USING_WIFIESPAT_LIB true + #define USING_WIFI_CUSTOM false +#endif + +#if defined(ARDUINO_SAMD_MKR1000) + #if defined(USE_WIFI_NINA) + #undef USE_WIFI_NINA + #endif + #define USE_WIFI_NINA false + #define USE_WIFI101 true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX + #endif + #define WIFI_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD + #endif + #define WIFI_USE_SAMD true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFI_USE_SAM_DUE) + #undef WIFI_USE_SAM_DUE + #endif + #define WIFI_USE_SAM_DUE true + #warning Use SAM_DUE architecture +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 + #endif + #define WIFI_USE_STM32 true +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFI_USE_RP2040) + #undef WIFI_USE_RP2040 + #endif + #define WIFI_USE_RP2040 true +#endif + +#ifdef CORE_TEENSY + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For Teensy 4.1/4.0 + #define EspSerial Serial2 //Serial2, Pin RX2 : 7, TX2 : 8 + #endif + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" +#endif + +#elif defined(WIFI_USE_NRF528XX) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif defined(WIFI_USE_SAMD) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For SAMD + #define EspSerial Serial1 + #endif + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif defined(WIFI_USE_STM32) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For STM32 + #if defined(ARDUINO_NUCLEO_F767ZI) + #warning Nucleo-144 NUCLEO_F767ZI board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); + #elif defined(ARDUINO_NUCLEO_L053R8) + #warning Nucleo-64 NUCLEO_L053R8 board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); // (PA3, PA2); + #endif + + #warning EspSerial using SERIAL_PORT_HARDWARE, can be Serial or Serial1. See your board variant.h + #define EspSerial SERIAL_PORT_HARDWARE //Serial1 + #endif + + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif (ESP8266) + #warning ESP8266 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif (ESP32) + #warning ESP32 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif defined(WIFI_USE_RP2040) && !defined(ARDUINO_ARCH_MBED) + + // For RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + +#elif defined(WIFI_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + // For MBED RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#else + // For Mega + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #define BOARD_TYPE "AVR Mega" +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_WiFi/Connect_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_WiFi/Connect_WiFi.ino new file mode 100644 index 0000000..1dc0972 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_WiFi/Connect_WiFi.ino @@ -0,0 +1,131 @@ +/********************************************************************************************************************************* + Connect_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect + + This example demonstrates how to connect to a MySQL server from an + Arduino using an Arduino-compatible Ethernet shield. Note that "compatible" + means it must conform to the Ethernet class library or be a derivative + with the same classes and methods. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Connect_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // Remember to initialize your WiFi module +#if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #if ( USING_WIFI_ESP8266_AT ) + MYSQL_DISPLAY("Using ESP8266_AT/ESP8266_AT_WebServer Library"); + #elif ( USING_WIFIESPAT_LIB ) + MYSQL_DISPLAY("Using WiFiEspAT Library"); + #endif + + // initialize serial for ESP module + EspSerial.begin(115200); + // initialize ESP module + WiFi.init(&EspSerial); + + MYSQL_DISPLAY(F("WiFi shield init done")); + + // check for the presence of the shield + if (WiFi.status() == WL_NO_SHIELD) + { + MYSQL_DISPLAY(F("WiFi shield not present")); + // don't continue + while (true); + } +#endif + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_WiFi/Credentials.h new file mode 100644 index 0000000..a311e60 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_WiFi/defines.h new file mode 100644 index 0000000..ed63a72 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Connect_WiFi/defines.h @@ -0,0 +1,381 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define DEBUG_ESP8266_AT_WEBSERVER_PORT Serial + +// Debug Level from 0 to 4 +#define _ESP_AT_LOGLEVEL_ 1 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ! (ESP8266 || ESP32 ) + // Select only one of these libraries, only for boards other than ESP8266/ESP32 + #define USING_WIFI_ESP8266_AT false + #define USING_WIFININA_GENERIC false + #define USING_WIFININA false + #define USING_WIFIESPAT_LIB true + #define USING_WIFI_CUSTOM false +#endif + +#if defined(ARDUINO_SAMD_MKR1000) + #if defined(USE_WIFI_NINA) + #undef USE_WIFI_NINA + #endif + #define USE_WIFI_NINA false + #define USE_WIFI101 true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX + #endif + #define WIFI_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD + #endif + #define WIFI_USE_SAMD true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFI_USE_SAM_DUE) + #undef WIFI_USE_SAM_DUE + #endif + #define WIFI_USE_SAM_DUE true + #warning Use SAM_DUE architecture +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 + #endif + #define WIFI_USE_STM32 true +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFI_USE_RP2040) + #undef WIFI_USE_RP2040 + #endif + #define WIFI_USE_RP2040 true +#endif + +#ifdef CORE_TEENSY + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For Teensy 4.1/4.0 + #define EspSerial Serial2 //Serial2, Pin RX2 : 7, TX2 : 8 + #endif + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" +#endif + +#elif defined(WIFI_USE_NRF528XX) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif defined(WIFI_USE_SAMD) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For SAMD + #define EspSerial Serial1 + #endif + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif defined(WIFI_USE_STM32) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For STM32 + #if defined(ARDUINO_NUCLEO_F767ZI) + #warning Nucleo-144 NUCLEO_F767ZI board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); + #elif defined(ARDUINO_NUCLEO_L053R8) + #warning Nucleo-64 NUCLEO_L053R8 board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); // (PA3, PA2); + #endif + + #warning EspSerial using SERIAL_PORT_HARDWARE, can be Serial or Serial1. See your board variant.h + #define EspSerial SERIAL_PORT_HARDWARE //Serial1 + #endif + + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif (ESP8266) + #warning ESP8266 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif (ESP32) + #warning ESP32 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif defined(WIFI_USE_RP2040) && !defined(ARDUINO_ARCH_MBED) + + // For RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + +#elif defined(WIFI_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + // For MBED RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#else + // For Mega + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #define BOARD_TYPE "AVR Mega" +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Query_Progmem_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Query_Progmem_WiFi/Credentials.h new file mode 100644 index 0000000..a311e60 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Query_Progmem_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Query_Progmem_WiFi/Query_Progmem_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Query_Progmem_WiFi/Query_Progmem_WiFi.ino new file mode 100644 index 0000000..da01363 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Query_Progmem_WiFi/Query_Progmem_WiFi.ino @@ -0,0 +1,160 @@ +/********************************************************************************************************************************* + Query_Progmem_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : query with PROGMEM strings + + This example demonstrates how to issue queries using strings stored in + PROGMEM. As you will see, you need only add a parameter to the execute() + method in the cursor class, const and PROGMEM to the string declaration + and add the #include directive. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#if ! (ESP32 || ESP8266) + #include +#endif + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +// Sample query +const char PROGMEM query[] = "SELECT * FROM test_arduino.hello_arduino LIMIT 6;"; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Query_Progmem_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // Remember to initialize your WiFi module +#if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #if ( USING_WIFI_ESP8266_AT ) + MYSQL_DISPLAY("Using ESP8266_AT/ESP8266_AT_WebServer Library"); + #elif ( USING_WIFIESPAT_LIB ) + MYSQL_DISPLAY("Using WiFiEspAT Library"); + #endif + + // initialize serial for ESP module + EspSerial.begin(115200); + // initialize ESP module + WiFi.init(&EspSerial); + + MYSQL_DISPLAY(F("WiFi shield init done")); + + // check for the presence of the shield + if (WiFi.status() == WL_NO_SHIELD) + { + MYSQL_DISPLAY(F("WiFi shield not present")); + // don't continue + while (true); + } +#endif + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void runQuery() +{ + MYSQL_DISPLAY("\nRunning SELECT from PROGMEM and printing results\n"); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query with the PROGMEM option + // KH, check if valid before fetching + if ( !query_mem.execute(query, true) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Show the results + query_mem.show_results(); + // close the query + query_mem.close(); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Query_Progmem_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Query_Progmem_WiFi/defines.h new file mode 100644 index 0000000..ed63a72 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Query_Progmem_WiFi/defines.h @@ -0,0 +1,381 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define DEBUG_ESP8266_AT_WEBSERVER_PORT Serial + +// Debug Level from 0 to 4 +#define _ESP_AT_LOGLEVEL_ 1 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ! (ESP8266 || ESP32 ) + // Select only one of these libraries, only for boards other than ESP8266/ESP32 + #define USING_WIFI_ESP8266_AT false + #define USING_WIFININA_GENERIC false + #define USING_WIFININA false + #define USING_WIFIESPAT_LIB true + #define USING_WIFI_CUSTOM false +#endif + +#if defined(ARDUINO_SAMD_MKR1000) + #if defined(USE_WIFI_NINA) + #undef USE_WIFI_NINA + #endif + #define USE_WIFI_NINA false + #define USE_WIFI101 true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX + #endif + #define WIFI_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD + #endif + #define WIFI_USE_SAMD true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFI_USE_SAM_DUE) + #undef WIFI_USE_SAM_DUE + #endif + #define WIFI_USE_SAM_DUE true + #warning Use SAM_DUE architecture +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 + #endif + #define WIFI_USE_STM32 true +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFI_USE_RP2040) + #undef WIFI_USE_RP2040 + #endif + #define WIFI_USE_RP2040 true +#endif + +#ifdef CORE_TEENSY + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For Teensy 4.1/4.0 + #define EspSerial Serial2 //Serial2, Pin RX2 : 7, TX2 : 8 + #endif + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" +#endif + +#elif defined(WIFI_USE_NRF528XX) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif defined(WIFI_USE_SAMD) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For SAMD + #define EspSerial Serial1 + #endif + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif defined(WIFI_USE_STM32) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For STM32 + #if defined(ARDUINO_NUCLEO_F767ZI) + #warning Nucleo-144 NUCLEO_F767ZI board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); + #elif defined(ARDUINO_NUCLEO_L053R8) + #warning Nucleo-64 NUCLEO_L053R8 board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); // (PA3, PA2); + #endif + + #warning EspSerial using SERIAL_PORT_HARDWARE, can be Serial or Serial1. See your board variant.h + #define EspSerial SERIAL_PORT_HARDWARE //Serial1 + #endif + + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif (ESP8266) + #warning ESP8266 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif (ESP32) + #warning ESP32 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif defined(WIFI_USE_RP2040) && !defined(ARDUINO_ARCH_MBED) + + // For RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + +#elif defined(WIFI_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + // For MBED RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#else + // For Mega + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #define BOARD_TYPE "AVR Mega" +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Query_Results_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Query_Results_WiFi/Credentials.h new file mode 100644 index 0000000..a311e60 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Query_Results_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Query_Results_WiFi/Query_Results_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Query_Results_WiFi/Query_Results_WiFi.ino new file mode 100644 index 0000000..4add7a5 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Query_Results_WiFi/Query_Results_WiFi.ino @@ -0,0 +1,191 @@ +/********************************************************************************************************************************* + Query_Results_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : query results + + This example demonstrates how to issue a SELECT query and how to read columns + and rows from the result set. Study this example until you are familiar with how to + do this before writing your own sketch to read and consume query results. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +// Sample query +const char query[] = "SELECT * FROM world.city LIMIT 6"; +//const char query[] = "SELECT * FROM test_arduino.hello_arduino LIMIT 6;"; + +MySQL_Connection conn((Client *)&client); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Query_Results_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // Remember to initialize your WiFi module +#if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #if ( USING_WIFI_ESP8266_AT ) + MYSQL_DISPLAY("Using ESP8266_AT/ESP8266_AT_WebServer Library"); + #elif ( USING_WIFIESPAT_LIB ) + MYSQL_DISPLAY("Using WiFiEspAT Library"); + #endif + + // initialize serial for ESP module + EspSerial.begin(115200); + // initialize ESP module + WiFi.init(&EspSerial); + + MYSQL_DISPLAY(F("WiFi shield init done")); + + // check for the presence of the shield + if (WiFi.status() == WL_NO_SHIELD) + { + MYSQL_DISPLAY(F("WiFi shield not present")); + // don't continue + while (true); + } +#endif + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void runQuery() +{ + MYSQL_DISPLAY("\nRunning SELECT and printing results"); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + ////// + + // Fetch the columns and print them + column_names *cols = query_mem.get_columns(); + + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(cols->fields[f]->name); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(", "); + } + } + + MYSQL_DISPLAY(); + + // Read the rows and print them + row_values *row = NULL; + + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(row->values[f]); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(", "); + } + } + + MYSQL_DISPLAY(); + } + } while (row != NULL); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Query_Results_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Query_Results_WiFi/defines.h new file mode 100644 index 0000000..ed63a72 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Query_Results_WiFi/defines.h @@ -0,0 +1,381 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define DEBUG_ESP8266_AT_WEBSERVER_PORT Serial + +// Debug Level from 0 to 4 +#define _ESP_AT_LOGLEVEL_ 1 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ! (ESP8266 || ESP32 ) + // Select only one of these libraries, only for boards other than ESP8266/ESP32 + #define USING_WIFI_ESP8266_AT false + #define USING_WIFININA_GENERIC false + #define USING_WIFININA false + #define USING_WIFIESPAT_LIB true + #define USING_WIFI_CUSTOM false +#endif + +#if defined(ARDUINO_SAMD_MKR1000) + #if defined(USE_WIFI_NINA) + #undef USE_WIFI_NINA + #endif + #define USE_WIFI_NINA false + #define USE_WIFI101 true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX + #endif + #define WIFI_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD + #endif + #define WIFI_USE_SAMD true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFI_USE_SAM_DUE) + #undef WIFI_USE_SAM_DUE + #endif + #define WIFI_USE_SAM_DUE true + #warning Use SAM_DUE architecture +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 + #endif + #define WIFI_USE_STM32 true +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFI_USE_RP2040) + #undef WIFI_USE_RP2040 + #endif + #define WIFI_USE_RP2040 true +#endif + +#ifdef CORE_TEENSY + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For Teensy 4.1/4.0 + #define EspSerial Serial2 //Serial2, Pin RX2 : 7, TX2 : 8 + #endif + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" +#endif + +#elif defined(WIFI_USE_NRF528XX) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif defined(WIFI_USE_SAMD) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For SAMD + #define EspSerial Serial1 + #endif + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif defined(WIFI_USE_STM32) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For STM32 + #if defined(ARDUINO_NUCLEO_F767ZI) + #warning Nucleo-144 NUCLEO_F767ZI board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); + #elif defined(ARDUINO_NUCLEO_L053R8) + #warning Nucleo-64 NUCLEO_L053R8 board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); // (PA3, PA2); + #endif + + #warning EspSerial using SERIAL_PORT_HARDWARE, can be Serial or Serial1. See your board variant.h + #define EspSerial SERIAL_PORT_HARDWARE //Serial1 + #endif + + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif (ESP8266) + #warning ESP8266 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif (ESP32) + #warning ESP32 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif defined(WIFI_USE_RP2040) && !defined(ARDUINO_ARCH_MBED) + + // For RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + +#elif defined(WIFI_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + // For MBED RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#else + // For Mega + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #define BOARD_TYPE "AVR Mega" +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Reboot_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Reboot_WiFi/Credentials.h new file mode 100644 index 0000000..a311e60 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Reboot_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Reboot_WiFi/Reboot_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Reboot_WiFi/Reboot_WiFi.ino new file mode 100644 index 0000000..cf8cae7 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Reboot_WiFi/Reboot_WiFi.ino @@ -0,0 +1,217 @@ +/********************************************************************************************************************************* + Reboot_WiFi.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : reboot if connection lost + + This example demonstrates how to reboot an Arduino if connection to the + server is lost for a period of time. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + To test the reboot, unplug your Ethernet cable once you see "disconnected" + then wait for the timeout. Once the Arduino reboots, plug the cable in again + and you should see the query processing resume. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +MySQL_Connection conn((Client *)&client); +MySQL_Query query = MySQL_Query(&conn); + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Reboot_WiFi on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // Remember to initialize your WiFi module +#if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #if ( USING_WIFI_ESP8266_AT ) + MYSQL_DISPLAY("Using ESP8266_AT/ESP8266_AT_WebServer Library"); + #elif ( USING_WIFIESPAT_LIB ) + MYSQL_DISPLAY("Using WiFiEspAT Library"); + #endif + + // initialize serial for ESP module + EspSerial.begin(115200); + // initialize ESP module + WiFi.init(&EspSerial); + + MYSQL_DISPLAY(F("WiFi shield init done")); + + // check for the presence of the shield + if (WiFi.status() == WL_NO_SHIELD) + { + MYSQL_DISPLAY(F("WiFi shield not present")); + // don't continue + while (true); + } +#endif + + // Begin WiFi section + MYSQL_DISPLAY1("Connecting to", ssid); + + WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + MYSQL_DISPLAY0("."); + } + + // print out info about the connection: + MYSQL_DISPLAY1("Connected to network. My IP address is:", WiFi.localIP()); +} + +// Begin reboot code +int num_fails; // variable for number of failure attempts +#define MAX_FAILED_CONNECTS 5 // maximum number of failed connects to MySQL + +void soft_reset() +{ +#if WIFI_USE_SAMD + #if ( defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) || defined(__SAMD51G19A__) ) + // For SAMD51 + // see Table 17-5 Timeout Period (valid values 0-11) + WDT->CONFIG.reg = 5; + WDT->CTRLA.reg = WDT_CTRLA_ENABLE; + // To check if OK or bit.ENABLE/CLEAR + while (WDT->SYNCBUSY.bit.WEN == 1); + + // use the WDT watchdog timer to force a system reset. + WDT->CLEAR.reg = 0x00; + // To check if OK or bit.ENABLE/CLEAR + while (WDT->SYNCBUSY.bit.WEN == 1); + #else + // For SAMD21, etc + // see Table 17-5 Timeout Period (valid values 0-11) + WDT->CONFIG.reg = 5; + WDT->CTRL.reg = WDT_CTRL_ENABLE; + while (WDT->STATUS.bit.SYNCBUSY == 1); + + // use the WDT watchdog timer to force a system reset. + WDT->CLEAR.reg = 0x00; + while (WDT->STATUS.bit.SYNCBUSY == 1); + #endif +#elif WIFI_USE_NRF528XX + //delay(1000); + // Restart for nRF52 + NVIC_SystemReset(); +#elif WIFI_USE_SAMDUE + void(*resetFunc)() = 0; + resetFunc(); +#elif WIFI_USE_STM32 + void(*resetFunc)() = 0; + resetFunc(); + +#elif WIFI_USE_TEENSY + #if defined(__IMXRT1062__) + // Teensy 4.1/4.0 + SCB_AIRCR = 0x05FA0004; //write value for restart for Teensy + #else + void(*resetFunc)() = 0; + resetFunc(); + #endif + +#elif ( defined(WIFI_USE_RP2040) && defined(ARDUINO_ARCH_MBED) ) + + NVIC_SystemReset(); + +#endif +} + +// End reboot code + +void loop() +{ + if (conn.connected()) + { + MYSQL_DISPLAY("Running a query: SHOW DATABASES"); + + // Execute the query + + // KH, check if valid before fetching + if ( !query.execute("SHOW DATABASES") ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + ////// + + query.show_results(); // show the results + query.close(); // close the cursor + conn.close(); // close the connection + num_fails = 0; // reset failures + + delay(10000); + } + else + { + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + } + else + { + num_fails++; + MYSQL_DISPLAY("Connect failed!"); + + if (num_fails == MAX_FAILED_CONNECTS) + { + MYSQL_DISPLAY("Ok, that's it. I'm outta here. Rebooting..."); + delay(2000); + // Here we tell the Arduino to reboot by redirecting the instruction + // pointer to the "top" or position 0. This is a soft reset and may + // not solve all hardware-related lockups. + soft_reset(); + } + } + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("=========================================="); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Reboot_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Reboot_WiFi/defines.h new file mode 100644 index 0000000..ed63a72 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/Reboot_WiFi/defines.h @@ -0,0 +1,381 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define DEBUG_ESP8266_AT_WEBSERVER_PORT Serial + +// Debug Level from 0 to 4 +#define _ESP_AT_LOGLEVEL_ 1 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ! (ESP8266 || ESP32 ) + // Select only one of these libraries, only for boards other than ESP8266/ESP32 + #define USING_WIFI_ESP8266_AT false + #define USING_WIFININA_GENERIC false + #define USING_WIFININA false + #define USING_WIFIESPAT_LIB true + #define USING_WIFI_CUSTOM false +#endif + +#if defined(ARDUINO_SAMD_MKR1000) + #if defined(USE_WIFI_NINA) + #undef USE_WIFI_NINA + #endif + #define USE_WIFI_NINA false + #define USE_WIFI101 true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX + #endif + #define WIFI_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD + #endif + #define WIFI_USE_SAMD true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFI_USE_SAM_DUE) + #undef WIFI_USE_SAM_DUE + #endif + #define WIFI_USE_SAM_DUE true + #warning Use SAM_DUE architecture +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 + #endif + #define WIFI_USE_STM32 true +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFI_USE_RP2040) + #undef WIFI_USE_RP2040 + #endif + #define WIFI_USE_RP2040 true +#endif + +#ifdef CORE_TEENSY + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For Teensy 4.1/4.0 + #define EspSerial Serial2 //Serial2, Pin RX2 : 7, TX2 : 8 + #endif + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" +#endif + +#elif defined(WIFI_USE_NRF528XX) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif defined(WIFI_USE_SAMD) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For SAMD + #define EspSerial Serial1 + #endif + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif defined(WIFI_USE_STM32) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For STM32 + #if defined(ARDUINO_NUCLEO_F767ZI) + #warning Nucleo-144 NUCLEO_F767ZI board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); + #elif defined(ARDUINO_NUCLEO_L053R8) + #warning Nucleo-64 NUCLEO_L053R8 board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); // (PA3, PA2); + #endif + + #warning EspSerial using SERIAL_PORT_HARDWARE, can be Serial or Serial1. See your board variant.h + #define EspSerial SERIAL_PORT_HARDWARE //Serial1 + #endif + + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif (ESP8266) + #warning ESP8266 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif (ESP32) + #warning ESP32 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif defined(WIFI_USE_RP2040) && !defined(ARDUINO_ARCH_MBED) + + // For RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + +#elif defined(WIFI_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + // For MBED RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#else + // For Mega + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #define BOARD_TYPE "AVR Mega" +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/multiFileProject_WiFi/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/multiFileProject_WiFi/Credentials.h new file mode 100644 index 0000000..a311e60 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/multiFileProject_WiFi/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/multiFileProject_WiFi/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/multiFileProject_WiFi/defines.h new file mode 100644 index 0000000..ed63a72 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/multiFileProject_WiFi/defines.h @@ -0,0 +1,381 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define DEBUG_ESP8266_AT_WEBSERVER_PORT Serial + +// Debug Level from 0 to 4 +#define _ESP_AT_LOGLEVEL_ 1 + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ! (ESP8266 || ESP32 ) + // Select only one of these libraries, only for boards other than ESP8266/ESP32 + #define USING_WIFI_ESP8266_AT false + #define USING_WIFININA_GENERIC false + #define USING_WIFININA false + #define USING_WIFIESPAT_LIB true + #define USING_WIFI_CUSTOM false +#endif + +#if defined(ARDUINO_SAMD_MKR1000) + #if defined(USE_WIFI_NINA) + #undef USE_WIFI_NINA + #endif + #define USE_WIFI_NINA false + #define USE_WIFI101 true +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX + #endif + #define WIFI_USE_NRF528XX true +#endif + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD + #endif + #define WIFI_USE_SAMD true +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFI_USE_SAM_DUE) + #undef WIFI_USE_SAM_DUE + #endif + #define WIFI_USE_SAM_DUE true + #warning Use SAM_DUE architecture +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 + #endif + #define WIFI_USE_STM32 true +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFI_USE_RP2040) + #undef WIFI_USE_RP2040 + #endif + #define WIFI_USE_RP2040 true +#endif + +#ifdef CORE_TEENSY + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For Teensy 4.1/4.0 + #define EspSerial Serial2 //Serial2, Pin RX2 : 7, TX2 : 8 + #endif + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" +#endif + +#elif defined(WIFI_USE_NRF528XX) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#elif defined(WIFI_USE_SAMD) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For SAMD + #define EspSerial Serial1 + #endif + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#elif defined(WIFI_USE_STM32) + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + // For STM32 + #if defined(ARDUINO_NUCLEO_F767ZI) + #warning Nucleo-144 NUCLEO_F767ZI board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); + #elif defined(ARDUINO_NUCLEO_L053R8) + #warning Nucleo-64 NUCLEO_L053R8 board selected, using HardwareSerial Serial1 @ pin D0/RX and D1/TX + // RX TX + HardwareSerial Serial1(D0, D1); // (PA3, PA2); + #endif + + #warning EspSerial using SERIAL_PORT_HARDWARE, can be Serial or Serial1. See your board variant.h + #define EspSerial SERIAL_PORT_HARDWARE //Serial1 + #endif + + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#elif (ESP8266) + #warning ESP8266 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif (ESP32) + #warning ESP32 board selected + #define BOARD_TYPE ARDUINO_BOARD + +#elif defined(WIFI_USE_RP2040) && !defined(ARDUINO_ARCH_MBED) + + // For RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + +#elif defined(WIFI_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + // For MBED RP2040 + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#else + // For Mega + #if ( USING_WIFI_ESP8266_AT || USING_WIFIESPAT_LIB ) + #define EspSerial Serial1 + #endif + + #define BOARD_TYPE "AVR Mega" +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/multiFileProject_WiFi/multiFileProject.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/multiFileProject_WiFi/multiFileProject.cpp new file mode 100644 index 0000000..e1f0fe7 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/multiFileProject_WiFi/multiFileProject.cpp @@ -0,0 +1,17 @@ +/**************************************************************************************************************************** + multiFileProject.cpp + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#include "multiFileProject.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/multiFileProject_WiFi/multiFileProject.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/multiFileProject_WiFi/multiFileProject.h new file mode 100644 index 0000000..5811a68 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/multiFileProject_WiFi/multiFileProject.h @@ -0,0 +1,20 @@ +/**************************************************************************************************************************** + multiFileProject.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#pragma once + +// Can be included as many times as necessary, without `Multiple Definitions` Linker Error +#include "MySQL_Generic.hpp" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/multiFileProject_WiFi/multiFileProject_WiFi.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/multiFileProject_WiFi/multiFileProject_WiFi.ino new file mode 100644 index 0000000..31c1064 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFi/multiFileProject_WiFi/multiFileProject_WiFi.ino @@ -0,0 +1,48 @@ +/**************************************************************************************************************************** + multiFileProject_WiFi.ino + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#include "defines.h" +#include "Credentials.h" + +#define MYSQL_MARIADB_GENERIC_VERSION_MIN_TARGET "MySQL_MariaDB_Generic v1.7.0" +#define MYSQL_MARIADB_GENERIC_VERSION_MIN 1007000 + +#include "multiFileProject.h" + +// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error +#include "MySQL_Generic.h" + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + Serial.println("\nStart multiFileProject_WiFi"); + Serial.println(MYSQL_MARIADB_GENERIC_VERSION); + +#if defined(MYSQL_MARIADB_GENERIC_VERSION_MIN) + if (MYSQL_MARIADB_GENERIC_VERSION_INT < MYSQL_MARIADB_GENERIC_VERSION_MIN) + { + Serial.print("Warning. Must use this example on Version equal or later than : "); + Serial.println(MYSQL_MARIADB_GENERIC_VERSION_MIN_TARGET); + } +#endif +} + +void loop() +{ + // put your main code here, to run repeatedly: +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Basic_Insert_WiFiNINA/Basic_Insert_WiFiNINA.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Basic_Insert_WiFiNINA/Basic_Insert_WiFiNINA.ino new file mode 100644 index 0000000..e387865 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Basic_Insert_WiFiNINA/Basic_Insert_WiFiNINA.ino @@ -0,0 +1,184 @@ +/********************************************************************************************************************************* + Basic_Insert_WiFiNINA.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : basic insert + + This example demonstrates how to issue an INSERT query to store data in a + table. For this, we will create a special database and table for testing. + The following are the SQL commands you will need to run in order to setup + your database for running this sketch. + + CREATE DATABASE test_arduino; + CREATE TABLE test_arduino.hello_arduino ( + num integer primary key auto_increment, + message char(40), + recorded timestamp + ); + + Here we see one database and a table with three fields; a primary key that + is an auto_increment, a string, and a timestamp. This will demonstrate how + to save a date and time of when the row was inserted, which can help you + determine when data was recorded or updated. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Create the database and table as shown above. + 2) Change the address of the server to the IP address of the MySQL server + 3) Change the user and password to a valid MySQL user and password + 4) Connect a USB cable to your Arduino + 5) Select the correct board and port + 6) Compile and upload the sketch to your Arduino + 7) Once uploaded, open Serial Monitor (use 115200 speed) and observe + 8) After the sketch has run for some time, open a mysql client and issue + the command: "SELECT * FROM test_arduino.hello_arduino" to see the data + recorded. Note the field values and how the database handles both the + auto_increment and timestamp fields for us. You can clear the data with + "DELETE FROM test_arduino.hello_arduino". + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "test_arduino"; //"test_arduino"; +char default_table[] = "hello_arduino"; //"test_arduino"; + +String default_value = "Hello, Arduino!"; + +// Sample query +String INSERT_SQL = String("INSERT INTO ") + default_database + "." + default_table + + " (message) VALUES ('" + default_value + "')"; + +MySQL_Connection conn((Client *)&client); + +int status = WL_IDLE_STATUS; + +void printWifiStatus() +{ + // print the SSID and IP address of the network you're attached to: + MYSQL_DISPLAY3("SSID:", WiFi.SSID(), "IP Address:", WiFi.localIP()); + + // print the received signal strength: + MYSQL_DISPLAY2("Signal strength (RSSI):", WiFi.RSSI(), "dBm"); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Basic_Insert_WiFiNINA on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) + { + MYSQL_DISPLAY("Communication with WiFi module failed!"); + // don't continue + while (true); + } + + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + MYSQL_DISPLAY("Please upgrade the firmware"); + } + + // attempt to connect to Wifi network: + while (status != WL_CONNECTED) + { + MYSQL_DISPLAY1("Attempting to connect to SSID:", ssid); + // Connect to WPA/WPA2 network. Change this line if using open or WEP network: + status = WiFi.begin(ssid, pass); + + // wait 10 seconds for connection: + //delay(10000); + } + + printWifiStatus(); + + // End WiFi section + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runInsert() +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + MYSQL_DISPLAY(INSERT_SQL); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(INSERT_SQL.c_str()) ) + { + MYSQL_DISPLAY("Insert error"); + } + else + { + MYSQL_DISPLAY("Data Inserted."); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + } +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Basic_Insert_WiFiNINA/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Basic_Insert_WiFiNINA/Credentials.h new file mode 100644 index 0000000..c8f6b7a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Basic_Insert_WiFiNINA/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Basic_Insert_WiFiNINA/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Basic_Insert_WiFiNINA/defines.h new file mode 100644 index 0000000..2f6ab02 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Basic_Insert_WiFiNINA/defines.h @@ -0,0 +1,356 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD + #endif + #define WIFININA_USE_SAMD true +#endif + +#if defined(WIFININA_USE_SAMD) + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 + #endif + #define WIFININA_USE_NRF52 true +#endif + +#if defined(WIFININA_USE_NRF52) + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFININA_USE_SAMDUE) + #undef WIFININA_USE_SAMDUE + #endif + #define WIFININA_USE_SAMDUE true +#endif + +#if defined(WIFININA_USE_SAMDUE) + + // For SAM DUE + #if defined(ARDUINO_SAM_DUE) + #define BOARD_TYPE "SAM DUE" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM SAM3X8E" + #else + #define BOARD_TYPE "SAM Unknown" + #endif + +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 + #endif + #define WIFININA_USE_STM32 true +#endif + +#if defined(WIFININA_USE_STM32) + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#endif + +#ifdef CORE_TEENSY + + #if defined(WIFININA_USE_TEENSY) + #undef WIFININA_USE_TEENSY + #endif + #define WIFININA_USE_TEENSY true + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#endif + +#if ( defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_MEGA) ) + #if defined(ARDUINO_AVR_MEGA2560) + #define BOARD_TYPE "AVR Mega 2560" + #elif defined(ARDUINO_AVR_MEGA) + #define BOARD_TYPE "AVR Mega" + #endif +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFININA_USE_RP2040) + #undef WIFININA_USE_RP2040 + #undef WIFI_USE_RP2040 + #endif + #define WIFININA_USE_RP2040 true + #define WIFI_USE_RP2040 true +#endif + + +#if defined(WIFININA_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#endif + +#ifndef BOARD_TYPE + #define BOARD_TYPE "Unknown Board" +#endif + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#define DEBUG_WIFININA_PORT Serial +// Debug Level from 0 to 4 +#define _WIFININA_LOGLEVEL_ 1 + +#define USING_WIFININA_GENERIC true +#define USING_WIFININA false + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Basic_Select_WiFiNINA/Basic_Select_WiFiNINA.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Basic_Select_WiFiNINA/Basic_Select_WiFiNINA.ino new file mode 100644 index 0000000..9f05113 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Basic_Select_WiFiNINA/Basic_Select_WiFiNINA.ino @@ -0,0 +1,219 @@ +/********************************************************************************************************************************* + Basic_Select_WiFiNINA.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : basic select + + This example demonstrates how to issue a SELECT query with no parameters + and use the data returned. For this, we use the Cursor class to execute + the query and get the results. + + It demonstrates who methods for running queries. The first allows you to + allocate memory for the cursor and later reclaim it, the second shows how + to use a single instance of the cursor use throughout a sketch. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + CAUTION: Don't mix and match the examples. Use one or the other in your + own sketch -- you'll get compilation errors at the least. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "world"; //"test_arduino"; +char default_table[] = "city"; //"test_arduino"; + +String default_column = "population"; +String default_value = "Toronto"; + +// Sample query +String query = String("SELECT ") + default_column + " FROM " + default_database + "." + default_table + + " WHERE name = '" + default_value + "'"; + +MySQL_Connection conn((Client *)&client); +// Create an instance of the cursor passing in the connection +MySQL_Query sql_query = MySQL_Query(&conn); + +int status = WL_IDLE_STATUS; + +void printWifiStatus() +{ + // print the SSID and IP address of the network you're attached to: + MYSQL_DISPLAY3("SSID:", WiFi.SSID(), "IP Address:", WiFi.localIP()); + + // print the received signal strength: + MYSQL_DISPLAY2("Signal strength (RSSI):", WiFi.RSSI(), "dBm"); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Basic_Select_WiFiNINA on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) + { + MYSQL_DISPLAY("Communication with WiFi module failed!"); + // don't continue + while (true); + } + + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + MYSQL_DISPLAY("Please upgrade the firmware"); + } + + // attempt to connect to Wifi network: + while (status != WL_CONNECTED) + { + MYSQL_DISPLAY1("Attempting to connect to SSID:", ssid); + // Connect to WPA/WPA2 network. Change this line if using open or WEP network: + status = WiFi.begin(ssid, pass); + + // wait 10 seconds for connection: + //delay(10000); + } + + printWifiStatus(); + + // End WiFi section + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runQuery() +{ + row_values *row = NULL; + long head_count = 0; + + MYSQL_DISPLAY("1) Demonstrating using a dynamically allocated query."); + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + MYSQL_DISPLAY(query); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(query.c_str()) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Fetch the columns (required) but we don't use them. + //column_names *columns = query_mem.get_columns(); + query_mem.get_columns(); + + // Read the row (we are only expecting the one) + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + head_count = atol(row->values[0]); + } + } while (row != NULL); + + // Show the result + MYSQL_DISPLAY1(" Toronto pop =", head_count); + + delay(500); + + MYSQL_DISPLAY("2) Demonstrating using a local, global query."); + + // Execute the query + MYSQL_DISPLAY(query); + sql_query.execute(query.c_str()); + + // Fetch the columns (required) but we don't use them. + sql_query.get_columns(); + + // Read the row (we are only expecting the one) + do + { + row = sql_query.get_next_row(); + if (row != NULL) + { + head_count = atol(row->values[0]); + } + } while (row != NULL); + + // Now we close the cursor to free any memory + sql_query.close(); + + // Show the result but this time do some math on it + MYSQL_DISPLAY1(" Toronto pop =", head_count); + MYSQL_DISPLAY1(" Toronto pop increased by 11725 =", head_count + 11725); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Basic_Select_WiFiNINA/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Basic_Select_WiFiNINA/Credentials.h new file mode 100644 index 0000000..c8f6b7a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Basic_Select_WiFiNINA/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Basic_Select_WiFiNINA/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Basic_Select_WiFiNINA/defines.h new file mode 100644 index 0000000..2f6ab02 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Basic_Select_WiFiNINA/defines.h @@ -0,0 +1,356 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD + #endif + #define WIFININA_USE_SAMD true +#endif + +#if defined(WIFININA_USE_SAMD) + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 + #endif + #define WIFININA_USE_NRF52 true +#endif + +#if defined(WIFININA_USE_NRF52) + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFININA_USE_SAMDUE) + #undef WIFININA_USE_SAMDUE + #endif + #define WIFININA_USE_SAMDUE true +#endif + +#if defined(WIFININA_USE_SAMDUE) + + // For SAM DUE + #if defined(ARDUINO_SAM_DUE) + #define BOARD_TYPE "SAM DUE" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM SAM3X8E" + #else + #define BOARD_TYPE "SAM Unknown" + #endif + +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 + #endif + #define WIFININA_USE_STM32 true +#endif + +#if defined(WIFININA_USE_STM32) + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#endif + +#ifdef CORE_TEENSY + + #if defined(WIFININA_USE_TEENSY) + #undef WIFININA_USE_TEENSY + #endif + #define WIFININA_USE_TEENSY true + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#endif + +#if ( defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_MEGA) ) + #if defined(ARDUINO_AVR_MEGA2560) + #define BOARD_TYPE "AVR Mega 2560" + #elif defined(ARDUINO_AVR_MEGA) + #define BOARD_TYPE "AVR Mega" + #endif +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFININA_USE_RP2040) + #undef WIFININA_USE_RP2040 + #undef WIFI_USE_RP2040 + #endif + #define WIFININA_USE_RP2040 true + #define WIFI_USE_RP2040 true +#endif + + +#if defined(WIFININA_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#endif + +#ifndef BOARD_TYPE + #define BOARD_TYPE "Unknown Board" +#endif + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#define DEBUG_WIFININA_PORT Serial +// Debug Level from 0 to 4 +#define _WIFININA_LOGLEVEL_ 1 + +#define USING_WIFININA_GENERIC true +#define USING_WIFININA false + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Complex_Insert_WiFiNINA/Complex_Insert_WiFiNINA.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Complex_Insert_WiFiNINA/Complex_Insert_WiFiNINA.ino new file mode 100644 index 0000000..06c26d1 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Complex_Insert_WiFiNINA/Complex_Insert_WiFiNINA.ino @@ -0,0 +1,209 @@ +/********************************************************************************************************************************* + Complex_Insert_WiFiNINA.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : complex insert + + This example demonstrates how to issue an INSERT query to store data in a + table using data from variables in our sketch. In this case, we supply the + values dynamically. + + This sketch simulates storing data from a sensor in a table. + + For this, we will create a special database and table for testing. + The following are the SQL commands you will need to run in order to setup + your database for running this sketch. + + CREATE DATABASE test_arduino; + CREATE TABLE test_arduino.hello_sensor ( + num integer primary key auto_increment, + message char(40), + sensor_num integer, + value float, + recorded timestamp + ); + + Here we have a table that contains an auto_increment primary key, a text + field, a field to identify the sensor, the value read, and timestamp of + the recorded data. + + Note: Since this sketch uses test data, we place the INSERT in the setup() + method so that it runs only once. Typically, you would have the + INSERT in the loop() method after your code to read from the sensor. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Create the database and table as shown above. + 2) Change the address of the server to the IP address of the MySQL server + 3) Change the user and password to a valid MySQL user and password + 4) Connect a USB cable to your Arduino + 5) Select the correct board and port + 6) Compile and upload the sketch to your Arduino + 7) Once uploaded, open Serial Monitor (use 115200 speed) and observe + 8) After the sketch has run for some time, open a mysql client and issue + the command: "SELECT * FROM test_arduino.hello_sensor" to see the data + recorded. Note the field values and how the database handles both the + auto_increment and timestamp fields for us. You can clear the data with + "DELETE FROM test_arduino.hello_sensor". + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "test_arduino"; //"test_arduino"; +char default_table[] = "hello_sensor"; //"test_arduino"; + +// Sample query +char INSERT_DATA[] = "INSERT INTO %s.%s (message, sensor_num, value) VALUES ('%s',%d,%s)"; + +char query[128]; +char temperature[10]; + +MySQL_Connection conn((Client *)&client); + +int status = WL_IDLE_STATUS; + +#if !( ESP32 || ESP8266 || defined(CORE_TEENSY) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) || defined(STM32F4) || defined(STM32F7) || ( defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED) ) ) + +char *dtostrf(double val, signed char width, unsigned char prec, char *sout) +{ + char fmt[20]; + sprintf(fmt, "%%%d.%df", width, prec); + sprintf(sout, fmt, val); + return sout; +} +#endif + +void printWifiStatus() +{ + // print the SSID and IP address of the network you're attached to: + MYSQL_DISPLAY3("SSID:", WiFi.SSID(), "IP Address:", WiFi.localIP()); + + // print the received signal strength: + MYSQL_DISPLAY2("Signal strength (RSSI):", WiFi.RSSI(), "dBm"); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Complex_Insert_WiFiNINA on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) + { + MYSQL_DISPLAY("Communication with WiFi module failed!"); + // don't continue + while (true); + } + + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + MYSQL_DISPLAY("Please upgrade the firmware"); + } + + // attempt to connect to Wifi network: + while (status != WL_CONNECTED) + { + MYSQL_DISPLAY1("Attempting to connect to SSID:", ssid); + // Connect to WPA/WPA2 network. Change this line if using open or WEP network: + status = WiFi.begin(ssid, pass); + + // wait 10 seconds for connection: + //delay(10000); + } + + printWifiStatus(); + + // End WiFi section + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runInsert() +{ + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + if (conn.connected()) + { + // Save + dtostrf(50.125, 1, 1, temperature); + sprintf(query, INSERT_DATA, default_database, default_table, "test sensor", 24, temperature); + + // Execute the query + MYSQL_DISPLAY(query); + + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Complex Insert error"); + } + else + { + MYSQL_DISPLAY("Complex Data Inserted."); + } + } + else + { + MYSQL_DISPLAY("Disconnected from Server. Can't insert."); + } +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runInsert(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Complex_Insert_WiFiNINA/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Complex_Insert_WiFiNINA/Credentials.h new file mode 100644 index 0000000..c8f6b7a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Complex_Insert_WiFiNINA/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Complex_Insert_WiFiNINA/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Complex_Insert_WiFiNINA/defines.h new file mode 100644 index 0000000..2f6ab02 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Complex_Insert_WiFiNINA/defines.h @@ -0,0 +1,356 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD + #endif + #define WIFININA_USE_SAMD true +#endif + +#if defined(WIFININA_USE_SAMD) + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 + #endif + #define WIFININA_USE_NRF52 true +#endif + +#if defined(WIFININA_USE_NRF52) + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFININA_USE_SAMDUE) + #undef WIFININA_USE_SAMDUE + #endif + #define WIFININA_USE_SAMDUE true +#endif + +#if defined(WIFININA_USE_SAMDUE) + + // For SAM DUE + #if defined(ARDUINO_SAM_DUE) + #define BOARD_TYPE "SAM DUE" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM SAM3X8E" + #else + #define BOARD_TYPE "SAM Unknown" + #endif + +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 + #endif + #define WIFININA_USE_STM32 true +#endif + +#if defined(WIFININA_USE_STM32) + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#endif + +#ifdef CORE_TEENSY + + #if defined(WIFININA_USE_TEENSY) + #undef WIFININA_USE_TEENSY + #endif + #define WIFININA_USE_TEENSY true + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#endif + +#if ( defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_MEGA) ) + #if defined(ARDUINO_AVR_MEGA2560) + #define BOARD_TYPE "AVR Mega 2560" + #elif defined(ARDUINO_AVR_MEGA) + #define BOARD_TYPE "AVR Mega" + #endif +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFININA_USE_RP2040) + #undef WIFININA_USE_RP2040 + #undef WIFI_USE_RP2040 + #endif + #define WIFININA_USE_RP2040 true + #define WIFI_USE_RP2040 true +#endif + + +#if defined(WIFININA_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#endif + +#ifndef BOARD_TYPE + #define BOARD_TYPE "Unknown Board" +#endif + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#define DEBUG_WIFININA_PORT Serial +// Debug Level from 0 to 4 +#define _WIFININA_LOGLEVEL_ 1 + +#define USING_WIFININA_GENERIC true +#define USING_WIFININA false + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Complex_Select_WiFiNINA/Complex_Select_WiFiNINA.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Complex_Select_WiFiNINA/Complex_Select_WiFiNINA.ino new file mode 100644 index 0000000..73b881a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Complex_Select_WiFiNINA/Complex_Select_WiFiNINA.ino @@ -0,0 +1,215 @@ +/********************************************************************************************************************************* + Complex_Select_WiFiNINA.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : complex select + + This example demonstrates how to issue a SELECT query with parameters that + we provide from code. Thus, it demonstrates how to build query parameters + dynamically. + + Notice also the sketch demonstrates how to read columns and rows from + the result set. Study this example until you are familiar with how to + do this before writing your own sketch to read and consume query results. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "world"; //"test_arduino"; +char default_table[] = "city"; //"test_arduino"; + +// Sample query +// +// Notice the "%lu" - that's a placeholder for the parameter we will +// supply. See sprintf() documentation for more formatting specifier +// options +unsigned long QUERY_POPULATION = 800000; + +const char QUERY_POP[] = "SELECT name, population FROM world.city WHERE population < %lu ORDER BY population DESC LIMIT 12;"; + +char query[128]; + +MySQL_Connection conn((Client *)&client); + +int status = WL_IDLE_STATUS; + +void printWifiStatus() +{ + // print the SSID and IP address of the network you're attached to: + MYSQL_DISPLAY3("SSID:", WiFi.SSID(), "IP Address:", WiFi.localIP()); + + // print the received signal strength: + MYSQL_DISPLAY2("Signal strength (RSSI):", WiFi.RSSI(), "dBm"); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Complex_Select_WiFiNINA on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) + { + MYSQL_DISPLAY("Communication with WiFi module failed!"); + // don't continue + while (true); + } + + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + MYSQL_DISPLAY("Please upgrade the firmware"); + } + + // attempt to connect to Wifi network: + while (status != WL_CONNECTED) + { + MYSQL_DISPLAY1("Attempting to connect to SSID:", ssid); + // Connect to WPA/WPA2 network. Change this line if using open or WEP network: + status = WiFi.begin(ssid, pass); + + // wait 10 seconds for connection: + //delay(10000); + } + + printWifiStatus(); + + // End WiFi section + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void runQuery() +{ + MYSQL_DISPLAY("===================================================="); + MYSQL_DISPLAY("> Running SELECT with dynamically supplied parameter"); + + // Supply the parameter for the query + // Here we use the QUERY_POP as the format string and query as the + // destination. This uses twice the memory so another option would be + // to allocate one buffer for all formatted queries or allocate the + // memory as needed (just make sure you allocate enough memory and + // free it when you're done!). + sprintf(query, QUERY_POP, QUERY_POPULATION + (( millis() % 100000 ) * 10) ); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Fetch the columns and print them + column_names *cols = query_mem.get_columns(); + + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(cols->fields[f]->name); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(","); + } + } + + MYSQL_DISPLAY(); + + // Read the rows and print them + row_values *row = NULL; + + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(row->values[f]); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(","); + } + } + + MYSQL_DISPLAY(); + } + } while (row != NULL); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(10000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Complex_Select_WiFiNINA/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Complex_Select_WiFiNINA/Credentials.h new file mode 100644 index 0000000..c8f6b7a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Complex_Select_WiFiNINA/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Complex_Select_WiFiNINA/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Complex_Select_WiFiNINA/defines.h new file mode 100644 index 0000000..2f6ab02 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Complex_Select_WiFiNINA/defines.h @@ -0,0 +1,356 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD + #endif + #define WIFININA_USE_SAMD true +#endif + +#if defined(WIFININA_USE_SAMD) + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 + #endif + #define WIFININA_USE_NRF52 true +#endif + +#if defined(WIFININA_USE_NRF52) + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFININA_USE_SAMDUE) + #undef WIFININA_USE_SAMDUE + #endif + #define WIFININA_USE_SAMDUE true +#endif + +#if defined(WIFININA_USE_SAMDUE) + + // For SAM DUE + #if defined(ARDUINO_SAM_DUE) + #define BOARD_TYPE "SAM DUE" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM SAM3X8E" + #else + #define BOARD_TYPE "SAM Unknown" + #endif + +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 + #endif + #define WIFININA_USE_STM32 true +#endif + +#if defined(WIFININA_USE_STM32) + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#endif + +#ifdef CORE_TEENSY + + #if defined(WIFININA_USE_TEENSY) + #undef WIFININA_USE_TEENSY + #endif + #define WIFININA_USE_TEENSY true + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#endif + +#if ( defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_MEGA) ) + #if defined(ARDUINO_AVR_MEGA2560) + #define BOARD_TYPE "AVR Mega 2560" + #elif defined(ARDUINO_AVR_MEGA) + #define BOARD_TYPE "AVR Mega" + #endif +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFININA_USE_RP2040) + #undef WIFININA_USE_RP2040 + #undef WIFI_USE_RP2040 + #endif + #define WIFININA_USE_RP2040 true + #define WIFI_USE_RP2040 true +#endif + + +#if defined(WIFININA_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#endif + +#ifndef BOARD_TYPE + #define BOARD_TYPE "Unknown Board" +#endif + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#define DEBUG_WIFININA_PORT Serial +// Debug Level from 0 to 4 +#define _WIFININA_LOGLEVEL_ 1 + +#define USING_WIFININA_GENERIC true +#define USING_WIFININA false + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_Default_Database_WiFiNINA/Connect_Default_Database_WiFiNINA.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_Default_Database_WiFiNINA/Connect_Default_Database_WiFiNINA.ino new file mode 100644 index 0000000..6bae4cc --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_Default_Database_WiFiNINA/Connect_Default_Database_WiFiNINA.ino @@ -0,0 +1,134 @@ +/********************************************************************************************************************************* + Connect_Default_Database_WiFiNINA.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect with default database + + This example demonstrates how to connect to a MySQL server and specifying + the default database when connecting. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +char default_database[] = "world"; + +MySQL_Connection conn((Client *)&client); + +int status = WL_IDLE_STATUS; + +void printWifiStatus() +{ + // print the SSID and IP address of the network you're attached to: + MYSQL_DISPLAY3("SSID:", WiFi.SSID(), "IP Address:", WiFi.localIP()); + + // print the received signal strength: + MYSQL_DISPLAY2("Signal strength (RSSI):", WiFi.RSSI(), "dBm"); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Connect_Default_Database_WiFiNINA on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) + { + MYSQL_DISPLAY("Communication with WiFi module failed!"); + // don't continue + while (true); + } + + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + MYSQL_DISPLAY("Please upgrade the firmware"); + } + + // attempt to connect to Wifi network: + while (status != WL_CONNECTED) + { + MYSQL_DISPLAY1("Attempting to connect to SSID:", ssid); + // Connect to WPA/WPA2 network. Change this line if using open or WEP network: + status = WiFi.begin(ssid, pass); + + // wait 10 seconds for connection: + //delay(10000); + } + + printWifiStatus(); + + // End WiFi section + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password, default_database)) + if (conn.connectNonBlocking(server, server_port, user, password, default_database) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_Default_Database_WiFiNINA/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_Default_Database_WiFiNINA/Credentials.h new file mode 100644 index 0000000..c8f6b7a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_Default_Database_WiFiNINA/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_Default_Database_WiFiNINA/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_Default_Database_WiFiNINA/defines.h new file mode 100644 index 0000000..2f6ab02 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_Default_Database_WiFiNINA/defines.h @@ -0,0 +1,356 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD + #endif + #define WIFININA_USE_SAMD true +#endif + +#if defined(WIFININA_USE_SAMD) + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 + #endif + #define WIFININA_USE_NRF52 true +#endif + +#if defined(WIFININA_USE_NRF52) + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFININA_USE_SAMDUE) + #undef WIFININA_USE_SAMDUE + #endif + #define WIFININA_USE_SAMDUE true +#endif + +#if defined(WIFININA_USE_SAMDUE) + + // For SAM DUE + #if defined(ARDUINO_SAM_DUE) + #define BOARD_TYPE "SAM DUE" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM SAM3X8E" + #else + #define BOARD_TYPE "SAM Unknown" + #endif + +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 + #endif + #define WIFININA_USE_STM32 true +#endif + +#if defined(WIFININA_USE_STM32) + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#endif + +#ifdef CORE_TEENSY + + #if defined(WIFININA_USE_TEENSY) + #undef WIFININA_USE_TEENSY + #endif + #define WIFININA_USE_TEENSY true + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#endif + +#if ( defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_MEGA) ) + #if defined(ARDUINO_AVR_MEGA2560) + #define BOARD_TYPE "AVR Mega 2560" + #elif defined(ARDUINO_AVR_MEGA) + #define BOARD_TYPE "AVR Mega" + #endif +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFININA_USE_RP2040) + #undef WIFININA_USE_RP2040 + #undef WIFI_USE_RP2040 + #endif + #define WIFININA_USE_RP2040 true + #define WIFI_USE_RP2040 true +#endif + + +#if defined(WIFININA_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#endif + +#ifndef BOARD_TYPE + #define BOARD_TYPE "Unknown Board" +#endif + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#define DEBUG_WIFININA_PORT Serial +// Debug Level from 0 to 4 +#define _WIFININA_LOGLEVEL_ 1 + +#define USING_WIFININA_GENERIC true +#define USING_WIFININA false + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_Disconnect_WiFiNINA/Connect_Disconnect_WiFiNINA.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_Disconnect_WiFiNINA/Connect_Disconnect_WiFiNINA.ino new file mode 100644 index 0000000..df3116e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_Disconnect_WiFiNINA/Connect_Disconnect_WiFiNINA.ino @@ -0,0 +1,151 @@ +/********************************************************************************************************************************* + Connect_Disconnect_WiFiNINA.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : connect and disconnect (close) + + This example demonstrates how to use the connection to open at the start + of a loop, perform some query, then close the connection. Use this technique + for solutions that must sleep for a long period or otherwise require + additional processing or delays. The connect/close pair allow you to + control how long the connection is open and thus reduce the amount of + time a connection is held open. It also helps for lossy connections. + + This example demonstrates how to connect to a MySQL server and specifying + the default database when connecting. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +MySQL_Connection conn((Client *)&client); +MySQL_Query query = MySQL_Query(&conn); + +int status = WL_IDLE_STATUS; + +void printWifiStatus() +{ + // print the SSID and IP address of the network you're attached to: + MYSQL_DISPLAY3("SSID:", WiFi.SSID(), "IP Address:", WiFi.localIP()); + + // print the received signal strength: + MYSQL_DISPLAY2("Signal strength (RSSI):", WiFi.RSSI(), "dBm"); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Connect_Disconnect_WiFiNINA on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) + { + MYSQL_DISPLAY("Communication with WiFi module failed!"); + // don't continue + while (true); + } + + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + MYSQL_DISPLAY("Please upgrade the firmware"); + } + + // attempt to connect to Wifi network: + while (status != WL_CONNECTED) + { + MYSQL_DISPLAY1("Attempting to connect to SSID:", ssid); + // Connect to WPA/WPA2 network. Change this line if using open or WEP network: + status = WiFi.begin(ssid, pass); + + // wait 10 seconds for connection: + //delay(10000); + } + + printWifiStatus(); + + // End WiFi section + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); +} + +void runQuery() +{ + MYSQL_DISPLAY("Running a query: SELECT * FROM test_arduino.hello_arduino LIMIT 6;"); + + // Execute the query + // KH, check if valid before fetching + if ( !query.execute("SELECT * FROM test_arduino.hello_arduino LIMIT 6;") ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + query.show_results(); // show the results + query.close(); // close the query +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_Disconnect_WiFiNINA/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_Disconnect_WiFiNINA/Credentials.h new file mode 100644 index 0000000..c8f6b7a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_Disconnect_WiFiNINA/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_Disconnect_WiFiNINA/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_Disconnect_WiFiNINA/defines.h new file mode 100644 index 0000000..2f6ab02 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_Disconnect_WiFiNINA/defines.h @@ -0,0 +1,356 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD + #endif + #define WIFININA_USE_SAMD true +#endif + +#if defined(WIFININA_USE_SAMD) + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 + #endif + #define WIFININA_USE_NRF52 true +#endif + +#if defined(WIFININA_USE_NRF52) + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFININA_USE_SAMDUE) + #undef WIFININA_USE_SAMDUE + #endif + #define WIFININA_USE_SAMDUE true +#endif + +#if defined(WIFININA_USE_SAMDUE) + + // For SAM DUE + #if defined(ARDUINO_SAM_DUE) + #define BOARD_TYPE "SAM DUE" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM SAM3X8E" + #else + #define BOARD_TYPE "SAM Unknown" + #endif + +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 + #endif + #define WIFININA_USE_STM32 true +#endif + +#if defined(WIFININA_USE_STM32) + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#endif + +#ifdef CORE_TEENSY + + #if defined(WIFININA_USE_TEENSY) + #undef WIFININA_USE_TEENSY + #endif + #define WIFININA_USE_TEENSY true + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#endif + +#if ( defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_MEGA) ) + #if defined(ARDUINO_AVR_MEGA2560) + #define BOARD_TYPE "AVR Mega 2560" + #elif defined(ARDUINO_AVR_MEGA) + #define BOARD_TYPE "AVR Mega" + #endif +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFININA_USE_RP2040) + #undef WIFININA_USE_RP2040 + #undef WIFI_USE_RP2040 + #endif + #define WIFININA_USE_RP2040 true + #define WIFI_USE_RP2040 true +#endif + + +#if defined(WIFININA_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#endif + +#ifndef BOARD_TYPE + #define BOARD_TYPE "Unknown Board" +#endif + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#define DEBUG_WIFININA_PORT Serial +// Debug Level from 0 to 4 +#define _WIFININA_LOGLEVEL_ 1 + +#define USING_WIFININA_GENERIC true +#define USING_WIFININA false + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_WiFiNINA/Connect_WiFiNINA.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_WiFiNINA/Connect_WiFiNINA.ino new file mode 100644 index 0000000..5387e76 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_WiFiNINA/Connect_WiFiNINA.ino @@ -0,0 +1,134 @@ +/********************************************************************************************************************************* + Connect_WiFiNINA.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : connect + + This example demonstrates how to connect to a MySQL server from an + Arduino using an Arduino-compatible Ethernet shield. Note that "compatible" + means it must conform to the Ethernet class library or be a derivative + with the same classes and methods. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + If you do not see messages indicating you have a connection, refer to the + manual for troubleshooting tips. The most common issues are the server is + not accessible from the network or the user name and password is incorrect. + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +MySQL_Connection conn((Client *)&client); + +int status = WL_IDLE_STATUS; + +void printWifiStatus() +{ + // print the SSID and IP address of the network you're attached to: + MYSQL_DISPLAY3("SSID:", WiFi.SSID(), "IP Address:", WiFi.localIP()); + + // print the received signal strength: + MYSQL_DISPLAY2("Signal strength (RSSI):", WiFi.RSSI(), "dBm"); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Connect_WiFiNINA on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) + { + MYSQL_DISPLAY("Communication with WiFi module failed!"); + // don't continue + while (true); + } + + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + MYSQL_DISPLAY("Please upgrade the firmware"); + } + + // attempt to connect to Wifi network: + while (status != WL_CONNECTED) + { + MYSQL_DISPLAY1("Attempting to connect to SSID:", ssid); + // Connect to WPA/WPA2 network. Change this line if using open or WEP network: + status = WiFi.begin(ssid, pass); + + // wait 10 seconds for connection: + //delay(10000); + } + + printWifiStatus(); + + // End WiFi section + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + MYSQL_DISPLAY("Closing connection..."); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_WiFiNINA/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_WiFiNINA/Credentials.h new file mode 100644 index 0000000..c8f6b7a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_WiFiNINA/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_WiFiNINA/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_WiFiNINA/defines.h new file mode 100644 index 0000000..2f6ab02 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Connect_WiFiNINA/defines.h @@ -0,0 +1,356 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD + #endif + #define WIFININA_USE_SAMD true +#endif + +#if defined(WIFININA_USE_SAMD) + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 + #endif + #define WIFININA_USE_NRF52 true +#endif + +#if defined(WIFININA_USE_NRF52) + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFININA_USE_SAMDUE) + #undef WIFININA_USE_SAMDUE + #endif + #define WIFININA_USE_SAMDUE true +#endif + +#if defined(WIFININA_USE_SAMDUE) + + // For SAM DUE + #if defined(ARDUINO_SAM_DUE) + #define BOARD_TYPE "SAM DUE" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM SAM3X8E" + #else + #define BOARD_TYPE "SAM Unknown" + #endif + +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 + #endif + #define WIFININA_USE_STM32 true +#endif + +#if defined(WIFININA_USE_STM32) + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#endif + +#ifdef CORE_TEENSY + + #if defined(WIFININA_USE_TEENSY) + #undef WIFININA_USE_TEENSY + #endif + #define WIFININA_USE_TEENSY true + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#endif + +#if ( defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_MEGA) ) + #if defined(ARDUINO_AVR_MEGA2560) + #define BOARD_TYPE "AVR Mega 2560" + #elif defined(ARDUINO_AVR_MEGA) + #define BOARD_TYPE "AVR Mega" + #endif +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFININA_USE_RP2040) + #undef WIFININA_USE_RP2040 + #undef WIFI_USE_RP2040 + #endif + #define WIFININA_USE_RP2040 true + #define WIFI_USE_RP2040 true +#endif + + +#if defined(WIFININA_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#endif + +#ifndef BOARD_TYPE + #define BOARD_TYPE "Unknown Board" +#endif + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#define DEBUG_WIFININA_PORT Serial +// Debug Level from 0 to 4 +#define _WIFININA_LOGLEVEL_ 1 + +#define USING_WIFININA_GENERIC true +#define USING_WIFININA false + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Query_Progmem_WiFiNINA/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Query_Progmem_WiFiNINA/Credentials.h new file mode 100644 index 0000000..c8f6b7a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Query_Progmem_WiFiNINA/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Query_Progmem_WiFiNINA/Query_Progmem_WiFiNINA.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Query_Progmem_WiFiNINA/Query_Progmem_WiFiNINA.ino new file mode 100644 index 0000000..fbdc250 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Query_Progmem_WiFiNINA/Query_Progmem_WiFiNINA.ino @@ -0,0 +1,162 @@ +/********************************************************************************************************************************* + Query_Progmem_WiFiNINA.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : query with PROGMEM strings + + This example demonstrates how to issue queries using strings stored in + PROGMEM. As you will see, you need only add a parameter to the execute() + method in the cursor class, const and PROGMEM to the string declaration + and add the #include directive. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ +#include "defines.h" +#include "Credentials.h" + +#include + +#if !( ESP32 || ESP8266) + #include +#endif + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +// Sample query +const char PROGMEM query[] = "SELECT * FROM world.city LIMIT 12"; + +MySQL_Connection conn((Client *)&client); + +int status = WL_IDLE_STATUS; + +void printWifiStatus() +{ + // print the SSID and IP address of the network you're attached to: + MYSQL_DISPLAY3("SSID:", WiFi.SSID(), "IP Address:", WiFi.localIP()); + + // print the received signal strength: + MYSQL_DISPLAY2("Signal strength (RSSI):", WiFi.RSSI(), "dBm"); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Query_Progmem_WiFiNINA on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) + { + MYSQL_DISPLAY("Communication with WiFi module failed!"); + // don't continue + while (true); + } + + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + MYSQL_DISPLAY("Please upgrade the firmware"); + } + + // attempt to connect to Wifi network: + while (status != WL_CONNECTED) + { + MYSQL_DISPLAY1("Attempting to connect to SSID:", ssid); + // Connect to WPA/WPA2 network. Change this line if using open or WEP network: + status = WiFi.begin(ssid, pass); + + // wait 10 seconds for connection: + //delay(10000); + } + + printWifiStatus(); + + // End WiFi section + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void runQuery() +{ + MYSQL_DISPLAY("\nRunning SELECT from PROGMEM and printing results\n"); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query with the PROGMEM option + // KH, check if valid before fetching + if ( !query_mem.execute(query, true) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + + // Show the results + query_mem.show_results(); + // close the query + query_mem.close(); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Query_Progmem_WiFiNINA/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Query_Progmem_WiFiNINA/defines.h new file mode 100644 index 0000000..2f6ab02 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Query_Progmem_WiFiNINA/defines.h @@ -0,0 +1,356 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD + #endif + #define WIFININA_USE_SAMD true +#endif + +#if defined(WIFININA_USE_SAMD) + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 + #endif + #define WIFININA_USE_NRF52 true +#endif + +#if defined(WIFININA_USE_NRF52) + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFININA_USE_SAMDUE) + #undef WIFININA_USE_SAMDUE + #endif + #define WIFININA_USE_SAMDUE true +#endif + +#if defined(WIFININA_USE_SAMDUE) + + // For SAM DUE + #if defined(ARDUINO_SAM_DUE) + #define BOARD_TYPE "SAM DUE" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM SAM3X8E" + #else + #define BOARD_TYPE "SAM Unknown" + #endif + +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 + #endif + #define WIFININA_USE_STM32 true +#endif + +#if defined(WIFININA_USE_STM32) + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#endif + +#ifdef CORE_TEENSY + + #if defined(WIFININA_USE_TEENSY) + #undef WIFININA_USE_TEENSY + #endif + #define WIFININA_USE_TEENSY true + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#endif + +#if ( defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_MEGA) ) + #if defined(ARDUINO_AVR_MEGA2560) + #define BOARD_TYPE "AVR Mega 2560" + #elif defined(ARDUINO_AVR_MEGA) + #define BOARD_TYPE "AVR Mega" + #endif +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFININA_USE_RP2040) + #undef WIFININA_USE_RP2040 + #undef WIFI_USE_RP2040 + #endif + #define WIFININA_USE_RP2040 true + #define WIFI_USE_RP2040 true +#endif + + +#if defined(WIFININA_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#endif + +#ifndef BOARD_TYPE + #define BOARD_TYPE "Unknown Board" +#endif + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#define DEBUG_WIFININA_PORT Serial +// Debug Level from 0 to 4 +#define _WIFININA_LOGLEVEL_ 1 + +#define USING_WIFININA_GENERIC true +#define USING_WIFININA false + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Query_Results_WiFiNINA/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Query_Results_WiFiNINA/Credentials.h new file mode 100644 index 0000000..c8f6b7a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Query_Results_WiFiNINA/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Query_Results_WiFiNINA/Query_Results_WiFiNINA.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Query_Results_WiFiNINA/Query_Results_WiFiNINA.ino new file mode 100644 index 0000000..919925b --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Query_Results_WiFiNINA/Query_Results_WiFiNINA.ino @@ -0,0 +1,193 @@ +/********************************************************************************************************************************* + Query_Results_WiFiNINA.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ +/* + MySQL Connector/Arduino Example : query results + + This example demonstrates how to issue a SELECT query and how to read columns + and rows from the result set. Study this example until you are familiar with how to + do this before writing your own sketch to read and consume query results. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + NOTICE: You must download and install the World sample database to run + this sketch unaltered. See http://dev.mysql.com/doc/index-other.html. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + Note: The MAC address can be anything so long as it is unique on your network. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +// Sample query +char query[] = "SELECT * FROM world.city LIMIT 12"; + +MySQL_Connection conn((Client *)&client); + +int status = WL_IDLE_STATUS; + +void printWifiStatus() +{ + // print the SSID and IP address of the network you're attached to: + MYSQL_DISPLAY3("SSID:", WiFi.SSID(), "IP Address:", WiFi.localIP()); + + // print the received signal strength: + MYSQL_DISPLAY2("Signal strength (RSSI):", WiFi.RSSI(), "dBm"); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Query_Results_WiFiNINA on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) + { + MYSQL_DISPLAY("Communication with WiFi module failed!"); + // don't continue + while (true); + } + + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + MYSQL_DISPLAY("Please upgrade the firmware"); + } + + // attempt to connect to Wifi network: + while (status != WL_CONNECTED) + { + MYSQL_DISPLAY1("Attempting to connect to SSID:", ssid); + // Connect to WPA/WPA2 network. Change this line if using open or WEP network: + status = WiFi.begin(ssid, pass); + + // wait 10 seconds for connection: + //delay(10000); + } + + printWifiStatus(); + + // End WiFi section + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); +} + +void runQuery() +{ + MYSQL_DISPLAY("\nRunning SELECT and printing results"); + MYSQL_DISPLAY(query); + + // Initiate the query class instance + MySQL_Query query_mem = MySQL_Query(&conn); + + // Execute the query + + // KH, check if valid before fetching + if ( !query_mem.execute(query) ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + ////// + + // Fetch the columns and print them + column_names *cols = query_mem.get_columns(); + + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(cols->fields[f]->name); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(", "); + } + } + + MYSQL_DISPLAY(); + + // Read the rows and print them + row_values *row = NULL; + + do + { + row = query_mem.get_next_row(); + + if (row != NULL) + { + for (int f = 0; f < cols->num_fields; f++) + { + MYSQL_DISPLAY0(row->values[f]); + + if (f < cols->num_fields - 1) + { + MYSQL_DISPLAY0(", "); + } + } + + MYSQL_DISPLAY(); + } + } while (row != NULL); +} + +void loop() +{ + MYSQL_DISPLAY("Connecting..."); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + runQuery(); + conn.close(); // close the connection + } + else + { + MYSQL_DISPLAY("\nConnect failed. Trying again on next iteration."); + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("================================================"); + + delay(60000); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Query_Results_WiFiNINA/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Query_Results_WiFiNINA/defines.h new file mode 100644 index 0000000..2f6ab02 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Query_Results_WiFiNINA/defines.h @@ -0,0 +1,356 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD + #endif + #define WIFININA_USE_SAMD true +#endif + +#if defined(WIFININA_USE_SAMD) + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 + #endif + #define WIFININA_USE_NRF52 true +#endif + +#if defined(WIFININA_USE_NRF52) + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFININA_USE_SAMDUE) + #undef WIFININA_USE_SAMDUE + #endif + #define WIFININA_USE_SAMDUE true +#endif + +#if defined(WIFININA_USE_SAMDUE) + + // For SAM DUE + #if defined(ARDUINO_SAM_DUE) + #define BOARD_TYPE "SAM DUE" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM SAM3X8E" + #else + #define BOARD_TYPE "SAM Unknown" + #endif + +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 + #endif + #define WIFININA_USE_STM32 true +#endif + +#if defined(WIFININA_USE_STM32) + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#endif + +#ifdef CORE_TEENSY + + #if defined(WIFININA_USE_TEENSY) + #undef WIFININA_USE_TEENSY + #endif + #define WIFININA_USE_TEENSY true + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#endif + +#if ( defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_MEGA) ) + #if defined(ARDUINO_AVR_MEGA2560) + #define BOARD_TYPE "AVR Mega 2560" + #elif defined(ARDUINO_AVR_MEGA) + #define BOARD_TYPE "AVR Mega" + #endif +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFININA_USE_RP2040) + #undef WIFININA_USE_RP2040 + #undef WIFI_USE_RP2040 + #endif + #define WIFININA_USE_RP2040 true + #define WIFI_USE_RP2040 true +#endif + + +#if defined(WIFININA_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#endif + +#ifndef BOARD_TYPE + #define BOARD_TYPE "Unknown Board" +#endif + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#define DEBUG_WIFININA_PORT Serial +// Debug Level from 0 to 4 +#define _WIFININA_LOGLEVEL_ 1 + +#define USING_WIFININA_GENERIC true +#define USING_WIFININA false + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Reboot_WiFiNINA/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Reboot_WiFiNINA/Credentials.h new file mode 100644 index 0000000..c8f6b7a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Reboot_WiFiNINA/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Reboot_WiFiNINA/Reboot_WiFiNINA.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Reboot_WiFiNINA/Reboot_WiFiNINA.ino new file mode 100644 index 0000000..bc43b2c --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Reboot_WiFiNINA/Reboot_WiFiNINA.ino @@ -0,0 +1,231 @@ +/********************************************************************************************************************************* + Reboot_WiFiNINA.ino + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +/* + MySQL Connector/Arduino Example : reboot if connection lost + + This example demonstrates how to reboot an Arduino if connection to the + server is lost for a period of time. + + For more information and documentation, visit the wiki: + https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki. + + INSTRUCTIONS FOR USE + + 1) Change the address of the server to the IP address of the MySQL server + 2) Change the user and password to a valid MySQL user and password + 3) Connect a USB cable to your Arduino + 4) Select the correct board and port + 5) Compile and upload the sketch to your Arduino + 6) Once uploaded, open Serial Monitor (use 115200 speed) and observe + + To test the reboot, unplug your Ethernet cable once you see "disconnected" + then wait for the timeout. Once the Arduino reboots, plug the cable in again + and you should see the query processing resume. + + Created by: Dr. Charles A. Bell +*/ + +#include "defines.h" +#include "Credentials.h" + +#include + +#define USING_HOST_NAME true + +#if USING_HOST_NAME + // Optional using hostname, and Ethernet built-in DNS lookup + char server[] = "your_account.ddns.net"; // change to your server's hostname/URL +#else + IPAddress server(192, 168, 2, 112); +#endif + +uint16_t server_port = 5698; //3306; + +MySQL_Connection conn((Client *)&client); +MySQL_Query query = MySQL_Query(&conn); + +int status = WL_IDLE_STATUS; + +void printWifiStatus() +{ + // print the SSID and IP address of the network you're attached to: + MYSQL_DISPLAY3("SSID:", WiFi.SSID(), "IP Address:", WiFi.localIP()); + + // print the received signal strength: + MYSQL_DISPLAY2("Signal strength (RSSI):", WiFi.RSSI(), "dBm"); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + MYSQL_DISPLAY1("\nStarting Reboot_WiFiNINA on", BOARD_NAME); + MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION); + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) + { + MYSQL_DISPLAY("Communication with WiFi module failed!"); + // don't continue + while (true); + } + + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + MYSQL_DISPLAY("Please upgrade the firmware"); + } + + // attempt to connect to Wifi network: + while (status != WL_CONNECTED) + { + MYSQL_DISPLAY1("Attempting to connect to SSID:", ssid); + // Connect to WPA/WPA2 network. Change this line if using open or WEP network: + status = WiFi.begin(ssid, pass); + + // wait 10 seconds for connection: + //delay(10000); + } + + printWifiStatus(); + + // End WiFi section + + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); + + if (conn.connect(server, server_port, user, password)) + { + delay(1000); + } + else + MYSQL_DISPLAY("Connection failed."); +} + +// Begin reboot code +int num_fails; // variable for number of failure attempts +#define MAX_FAILED_CONNECTS 5 // maximum number of failed connects to MySQL + +void soft_reset() +{ +#if WIFININA_USE_SAMD + #if ( defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) || defined(__SAMD51G19A__) ) + // For SAMD51 + // see Table 17-5 Timeout Period (valid values 0-11) + WDT->CONFIG.reg = 5; + WDT->CTRLA.reg = WDT_CTRLA_ENABLE; + // To check if OK or bit.ENABLE/CLEAR + while (WDT->SYNCBUSY.bit.WEN == 1); + + // use the WDT watchdog timer to force a system reset. + WDT->CLEAR.reg = 0x00; + // To check if OK or bit.ENABLE/CLEAR + while (WDT->SYNCBUSY.bit.WEN == 1); + #else + // For SAMD21, etc + // see Table 17-5 Timeout Period (valid values 0-11) + WDT->CONFIG.reg = 5; + WDT->CTRL.reg = WDT_CTRL_ENABLE; + while (WDT->STATUS.bit.SYNCBUSY == 1); + + // use the WDT watchdog timer to force a system reset. + WDT->CLEAR.reg = 0x00; + while (WDT->STATUS.bit.SYNCBUSY == 1); + #endif +#elif WIFININA_USE_NRF52 + //delay(1000); + // Restart for nRF52 + NVIC_SystemReset(); +#elif WIFININA_USE_SAMDUE + void(*resetFunc)() = 0; + resetFunc(); +#elif WIFININA_USE_STM32 + void(*resetFunc)() = 0; + resetFunc(); + +#elif WIFININA_USE_TEENSY + #if defined(__IMXRT1062__) + // Teensy 4.1/4.0 + SCB_AIRCR = 0x05FA0004; //write value for restart for Teensy + #else + void(*resetFunc)() = 0; + resetFunc(); + #endif + +#elif ( defined(WIFININA_USE_RP2040) && defined(ARDUINO_ARCH_MBED) ) + + NVIC_SystemReset(); + +#endif +} + +// End reboot code + +void loop() +{ + if (conn.connected()) + { + MYSQL_DISPLAY("Running a query: SHOW DATABASES"); + + // Execute the query + + // KH, check if valid before fetching + if ( !query.execute("SHOW DATABASES") ) + { + MYSQL_DISPLAY("Querying error"); + return; + } + ////// + + query.show_results(); // show the results + query.close(); // close the cursor + conn.close(); // close the connection + num_fails = 0; // reset failures + + delay(10000); + } + else + { + MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port); + MYSQL_DISPLAY3("User =", user, ", PW =", password); + + //if (conn.connect(server, server_port, user, password)) + if (conn.connectNonBlocking(server, server_port, user, password) != RESULT_FAIL) + { + delay(500); + } + else + { + num_fails++; + MYSQL_DISPLAY("Connect failed!"); + + if (num_fails == MAX_FAILED_CONNECTS) + { + MYSQL_DISPLAY("Ok, that's it. I'm outta here. Rebooting..."); + delay(2000); + // Here we tell the Arduino to reboot by redirecting the instruction + // pointer to the "top" or position 0. This is a soft reset and may + // not solve all hardware-related lockups. + soft_reset(); + } + } + } + + MYSQL_DISPLAY("\nSleeping..."); + MYSQL_DISPLAY("=========================================="); +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Reboot_WiFiNINA/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Reboot_WiFiNINA/defines.h new file mode 100644 index 0000000..2f6ab02 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/Reboot_WiFiNINA/defines.h @@ -0,0 +1,356 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD + #endif + #define WIFININA_USE_SAMD true +#endif + +#if defined(WIFININA_USE_SAMD) + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 + #endif + #define WIFININA_USE_NRF52 true +#endif + +#if defined(WIFININA_USE_NRF52) + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFININA_USE_SAMDUE) + #undef WIFININA_USE_SAMDUE + #endif + #define WIFININA_USE_SAMDUE true +#endif + +#if defined(WIFININA_USE_SAMDUE) + + // For SAM DUE + #if defined(ARDUINO_SAM_DUE) + #define BOARD_TYPE "SAM DUE" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM SAM3X8E" + #else + #define BOARD_TYPE "SAM Unknown" + #endif + +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 + #endif + #define WIFININA_USE_STM32 true +#endif + +#if defined(WIFININA_USE_STM32) + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#endif + +#ifdef CORE_TEENSY + + #if defined(WIFININA_USE_TEENSY) + #undef WIFININA_USE_TEENSY + #endif + #define WIFININA_USE_TEENSY true + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#endif + +#if ( defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_MEGA) ) + #if defined(ARDUINO_AVR_MEGA2560) + #define BOARD_TYPE "AVR Mega 2560" + #elif defined(ARDUINO_AVR_MEGA) + #define BOARD_TYPE "AVR Mega" + #endif +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFININA_USE_RP2040) + #undef WIFININA_USE_RP2040 + #undef WIFI_USE_RP2040 + #endif + #define WIFININA_USE_RP2040 true + #define WIFI_USE_RP2040 true +#endif + + +#if defined(WIFININA_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#endif + +#ifndef BOARD_TYPE + #define BOARD_TYPE "Unknown Board" +#endif + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#define DEBUG_WIFININA_PORT Serial +// Debug Level from 0 to 4 +#define _WIFININA_LOGLEVEL_ 1 + +#define USING_WIFININA_GENERIC true +#define USING_WIFININA false + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/multiFileProject_WiFiNINA/Credentials.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/multiFileProject_WiFiNINA/Credentials.h new file mode 100644 index 0000000..c8f6b7a --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/multiFileProject_WiFiNINA/Credentials.h @@ -0,0 +1,24 @@ +/**************************************************************************************************************************** + Credentials.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +char ssid[] = "****"; // your network SSID (name) +char pass[] = "12345678"; // your network password + +char user[] = "invited-guest"; // MySQL user login username +char password[] = "the-invited-guest"; // MySQL user login password + +#endif //Credentials_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/multiFileProject_WiFiNINA/defines.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/multiFileProject_WiFiNINA/defines.h new file mode 100644 index 0000000..2f6ab02 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/multiFileProject_WiFiNINA/defines.h @@ -0,0 +1,356 @@ +/**************************************************************************************************************************** + defines.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + **********************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#define MYSQL_DEBUG_PORT Serial + +// Debug Level from 0 to 4 +#define _MYSQL_LOGLEVEL_ 1 + +#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ + || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ + || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ + || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ + || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) + #if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD + #endif + #define WIFININA_USE_SAMD true +#endif + +#if defined(WIFININA_USE_SAMD) + + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif + +#endif + +#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ + defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ + defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) + #if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 + #endif + #define WIFININA_USE_NRF52 true +#endif + +#if defined(WIFININA_USE_NRF52) + + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif + +#endif + +#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) + #if defined(WIFININA_USE_SAMDUE) + #undef WIFININA_USE_SAMDUE + #endif + #define WIFININA_USE_SAMDUE true +#endif + +#if defined(WIFININA_USE_SAMDUE) + + // For SAM DUE + #if defined(ARDUINO_SAM_DUE) + #define BOARD_TYPE "SAM DUE" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM SAM3X8E" + #else + #define BOARD_TYPE "SAM Unknown" + #endif + +#endif + +#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ + defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ + defined(STM32WB) || defined(STM32MP1) ) + #if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 + #endif + #define WIFININA_USE_STM32 true +#endif + +#if defined(WIFININA_USE_STM32) + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif + +#endif + +#ifdef CORE_TEENSY + + #if defined(WIFININA_USE_TEENSY) + #undef WIFININA_USE_TEENSY + #endif + #define WIFININA_USE_TEENSY true + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif + +#endif + +#if ( defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_MEGA) ) + #if defined(ARDUINO_AVR_MEGA2560) + #define BOARD_TYPE "AVR Mega 2560" + #elif defined(ARDUINO_AVR_MEGA) + #define BOARD_TYPE "AVR Mega" + #endif +#endif + +#if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + #if defined(WIFININA_USE_RP2040) + #undef WIFININA_USE_RP2040 + #undef WIFI_USE_RP2040 + #endif + #define WIFININA_USE_RP2040 true + #define WIFI_USE_RP2040 true +#endif + + +#if defined(WIFININA_USE_RP2040) && defined(ARDUINO_ARCH_MBED) + + #warning Using ARDUINO_ARCH_MBED + + #if ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ + defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) + // Only undef known BOARD_NAME to use better one + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #elif defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #else + // Use default BOARD_NAME if exists + #if !defined(BOARD_NAME) + #define BOARD_NAME "MBED Unknown RP2040" + #endif + #endif + +#endif + +#ifndef BOARD_TYPE + #define BOARD_TYPE "Unknown Board" +#endif + +#if defined(ARDUINO_BOARD) + #define BOARD_NAME ARDUINO_BOARD +#else + #ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE + #endif +#endif + +#define DEBUG_WIFININA_PORT Serial +// Debug Level from 0 to 4 +#define _WIFININA_LOGLEVEL_ 1 + +#define USING_WIFININA_GENERIC true +#define USING_WIFININA false + +#endif //defines_h diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/multiFileProject_WiFiNINA/multiFileProject.cpp b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/multiFileProject_WiFiNINA/multiFileProject.cpp new file mode 100644 index 0000000..e1f0fe7 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/multiFileProject_WiFiNINA/multiFileProject.cpp @@ -0,0 +1,17 @@ +/**************************************************************************************************************************** + multiFileProject.cpp + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#include "multiFileProject.h" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/multiFileProject_WiFiNINA/multiFileProject.h b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/multiFileProject_WiFiNINA/multiFileProject.h new file mode 100644 index 0000000..5811a68 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/multiFileProject_WiFiNINA/multiFileProject.h @@ -0,0 +1,20 @@ +/**************************************************************************************************************************** + multiFileProject.h + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#pragma once + +// Can be included as many times as necessary, without `Multiple Definitions` Linker Error +#include "MySQL_Generic.hpp" diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/multiFileProject_WiFiNINA/multiFileProject_WiFiNINA.ino b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/multiFileProject_WiFiNINA/multiFileProject_WiFiNINA.ino new file mode 100644 index 0000000..b0188b0 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/examples/WiFiNINA/multiFileProject_WiFiNINA/multiFileProject_WiFiNINA.ino @@ -0,0 +1,48 @@ +/**************************************************************************************************************************** + multiFileProject_WiFiNINA.ino + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet, + WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi. + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license +*****************************************************************************************************************************/ + +// To demo how to include files in multi-file Projects + +#include "defines.h" +#include "Credentials.h" + +#define MYSQL_MARIADB_GENERIC_VERSION_MIN_TARGET "MySQL_MariaDB_Generic v1.7.0" +#define MYSQL_MARIADB_GENERIC_VERSION_MIN 1007000 + +#include "multiFileProject.h" + +// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error +#include "MySQL_Generic.h" + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); // wait for serial port to connect + + Serial.println("\nStart multiFileProject_WiFiNINA"); + Serial.println(MYSQL_MARIADB_GENERIC_VERSION); + +#if defined(MYSQL_MARIADB_GENERIC_VERSION_MIN) + if (MYSQL_MARIADB_GENERIC_VERSION_INT < MYSQL_MARIADB_GENERIC_VERSION_MIN) + { + Serial.print("Warning. Must use this example on Version equal or later than : "); + Serial.println(MYSQL_MARIADB_GENERIC_VERSION_MIN_TARGET); + } +#endif +} + +void loop() +{ + // put your main code here, to run repeatedly: +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/keywords.txt b/libraries/MySQL_MariaDB_Generic-1.7.2/keywords.txt new file mode 100644 index 0000000..f26c482 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/keywords.txt @@ -0,0 +1,120 @@ +####################################### +# Data types (KEYWORD1) +####################################### + +MySQL_Connection KEYWORD1 +MySQL_Packet KEYWORD1 +MySQL_Query KEYWORD1 +Encrypt_SHA1 KEYWORD1 + +Connection_Result KEYWORD1 +field_struct KEYWORD1 +column_names KEYWORD1 +row_values KEYWORD1 +_buffer KEYWORD1 +_state KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +############################## +# MySQL_Generic_Connection +############################## + +SQL_IPAddressToString KEYWORD2 +connect KEYWORD2 +connectNonBlocking KEYWORD2 +connected KEYWORD2 +version KEYWORD2 +close KEYWORD2 + +############################## +# MySQL_Generic_Packet +############################## + +complete_handshake KEYWORD2 +send_authentication_packet KEYWORD2 +parse_handshake_packet KEYWORD2 +scramble_password KEYWORD2 +read_packet KEYWORD2 +get_packet_type KEYWORD2 +parse_error_packet KEYWORD2 +get_lcb_len KEYWORD2 +read_int KEYWORD2 +store_int KEYWORD2 +read_lcb_int KEYWORD2 +wait_for_bytes KEYWORD2 +print_packet KEYWORD2 + + +############################## +# MySQL_Generic_Query +############################## + +execute KEYWORD2 +close KEYWORD2 +get_columns KEYWORD2 +get_next_row KEYWORD2 +show_results KEYWORD2 +get_rows_affected KEYWORD2 +get_last_insert_id KEYWORD2 + + +############################## +# MySQL_Generic_Encrypt_Sha1 +############################## + +init KEYWORD2 +initHmac KEYWORD2 +result KEYWORD2 +write KEYWORD2 + +####################################### +# Literals (LITERAL1) +####################################### + +Sha1 KEYWORD3 +CONNECTED KEYWORD3 +DISCONNECTED KEYWORD3 +MEMORY_ERROR KEYWORD3 +PACKET_ERROR KEYWORD3 +READ_TIMEOUT KEYWORD3 +BAD_MOJO KEYWORD3 +ROWS KEYWORD3 +READ_COLS KEYWORD3 +NOT_CONNECTED KEYWORD3 +sha1InitState KEYWORD3 + +####################################### +# Constants (LITERAL1) +####################################### + +MYSQL_GENERIC_VERSION LITERAL1 +MYSQL_MARIADB_GENERIC_VERSION LITERAL1 +MYSQL_MARIADB_GENERIC_VERSION_MAJOR LITERAL1 +MYSQL_MARIADB_GENERIC_VERSION_MINOR LITERAL1 +MYSQL_MARIADB_GENERIC_VERSION_PATCH LITERAL1 +MYSQL_MARIADB_GENERIC_VERSION_INT LITERAL1 + +MYSQL_OK_PACKET LITERAL1 +MYSQL_EOF_PACKET LITERAL1 +MYSQL_ERROR_PACKET LITERAL1 + +MAX_TRANSMISSION_UNIT LITERAL1 + +MYSQL_DATA_TIMEOUT LITERAL1 +MYSQL_WAIT_INTERVAL LITERAL1 + +HASH_LENGTH LITERAL1 +BLOCK_LENGTH LITERAL1 + +MYSQL_SHA1_K0 LITERAL1 +MYSQL_SHA1_K20 LITERAL1 +MYSQL_SHA1_K40 LITERAL1 +MYSQL_SHA1_K60 LITERAL1 + +HMAC_IPAD LITERAL1 +HMAC_OPAD LITERAL1 + + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/library.json b/libraries/MySQL_MariaDB_Generic-1.7.2/library.json new file mode 100644 index 0000000..e628ce2 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/library.json @@ -0,0 +1,99 @@ +{ + "name": "MySQL_MariaDB_Generic", + "version": "1.7.2", + "keywords": "Communication, Database, Storage, MySQL, MariaDB, wt32-eth01, Teensy, SAMD, nRF52, W5x00, Ethernet, wifi, wifinina, lan8720, rp2040, nano-33-iot, nano-rp2040-connect, QNEthernet, native-ethernet, Portenta-H7, SAM DUE, ENC28J60, rpi-pico, Arduino, AVR", + "description": "Connects to MySQL or MariaDB using ESP8266/ESP32, WT32_ETH01 (ESP32 + LAN8720A), nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, SAM DUE, Mega, RP2040-based boards, Portenta_H7, etc. with W5x00, ENC28J60 Ethernet, Teensy 4.1 NativeEthernet/QNEthernet, WiFiNINA modules/shields or Portenta_H7 WiFi/Ethernet. W5x00 can use Ethernet, EthernetLarge, Ethernet2 or Ethernet3 library. ENC28J60 can use either EthernetENC or UIPEthernet Library. Now accepting server's hostname, besides IPAddress. Ethernet_Generic library is used as default for W5x00", + "authors": [ + { + "name": "Dr. Charles Bell", + "url": "https://github.com/ChuckBell", + "email": "chuck.bell@oracle.com" + }, + { + "name": "Khoi Hoang", + "url": "https://github.com/khoih-prog", + "email": "khoih-prog@gmail.com", + "maintainer": true + } + ], + "repository": + { + "type": "git", + "url": "https://github.com/khoih-prog/MySQL_MariaDB_Generic" + }, + "homepage": "https://github.com/khoih-prog/MySQL_MariaDB_Generic", + "export": { + "exclude": [ + "linux", + "extras", + "tests" + ] + }, + "dependencies": + [ + { + "owner": "khoih-prog", + "name": "WiFiNINA_Generic", + "version": "^1.8.14-3", + "platforms": ["*"] + }, + { + "owner": "khoih-prog", + "name": "WebServer_WT32_ETH01", + "version": ">=1.4.1", + "platforms": ["*"] + }, + { + "owner": "khoih-prog", + "name": "ESP8266_AT_WebServer", + "version": "^1.5.3", + "platforms": ["*"] + }, + { + "owner": "stm32duino", + "name": "STM32duino LwIP", + "version": ">=2.1.2", + "platforms": ["ststm32"] + }, + { + "owner": "stm32duino", + "name": "STM32Ethernet", + "version": ">=1.2.0", + "platforms": ["ststm32"] + }, + { + "owner": "uipethernet", + "name": "UIPEthernet", + "version": ">=2.0.8", + "platforms": ["*"] + }, + { + "owner": "jandrassy", + "name": "EthernetENC", + "version": ">=2.0.2", + "platforms": ["*"] + }, + { + "owner": "jandrassy", + "name": "WiFiEspAT", + "version": ">=1.3.2", + "platforms": ["*"] + }, + { + "owner": "khoih-prog", + "name": "Ethernet_Generic", + "version": "^2.0.1" + }, + { + "owner": "ssilverman", + "name": "QNEthernet", + "version": ">=0.14.0", + "platforms": ["teensy"] + } + ], + "license": "MIT", + "frameworks": "*", + "platforms": "*", + "examples": "examples/*/*/*.ino", + "headers": ["MySQL_Generic.h", "MySQL_Generic.hpp"] +} diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/library.properties b/libraries/MySQL_MariaDB_Generic-1.7.2/library.properties new file mode 100644 index 0000000..febd4c4 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/library.properties @@ -0,0 +1,11 @@ +name=MySQL_MariaDB_Generic +version=1.7.2 +author=Dr. Charles Bell , Khoi Hoang +maintainer=Khoi Hoang +sentence=Connects to MySQL or MariaDB using ESP8266/ESP32, WT32_ETH01 (ESP32 + LAN8720A), nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, SAM DUE, Mega, RP2040-based boards, Portenta_H7, etc. with W5x00, ENC28J60 Ethernet, Teensy 4.1 NativeEthernet/QNEthernet, WiFiNINA modules/shields or Portenta_H7 WiFi/Ethernet. W5x00 can use Ethernet_Generic library. ENC28J60 can use either EthernetENC or UIPEthernet Library. +paragraph=You can use this library to connect your Arduino project directly to a MySQL / MariaDB server without using an intermediate computer or a web-based or cloud-based service. Having direct access to a database server means you can store data acquired from your project as well as check values stored in tables on the server. This also means you can setup your own, local MySQL / MariaDB server to store your data further removing the need for Internet connectivity. If that is not an issue, you can still connect to and store data on a MySQL / MariaDB server via your network, Internet, or even in the cloud! Now accepting server hostname, besides IPAddress. Ethernet_Generic library is used as default for W5x00 +category=Communication +url=https://github.com/khoih-prog/MySQL_MariaDB_Generic +architectures=* +depends=WiFiNINA_Generic, WebServer_WT32_ETH01, Ethernet_Generic, EthernetENC, UIPEthernet, WiFiEspAT, NativeEthernet, QNEthernet +includes=MySQL_Generic.h, MySQL_Generic.hpp diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/pics/Basic_Insert_ESP32_S2.png b/libraries/MySQL_MariaDB_Generic-1.7.2/pics/Basic_Insert_ESP32_S2.png new file mode 100644 index 0000000..93642b1 Binary files /dev/null and b/libraries/MySQL_MariaDB_Generic-1.7.2/pics/Basic_Insert_ESP32_S2.png differ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/pics/ENC28J60.jpg b/libraries/MySQL_MariaDB_Generic-1.7.2/pics/ENC28J60.jpg new file mode 100644 index 0000000..eff427e Binary files /dev/null and b/libraries/MySQL_MariaDB_Generic-1.7.2/pics/ENC28J60.jpg differ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/pics/ICSP_connector.jpg b/libraries/MySQL_MariaDB_Generic-1.7.2/pics/ICSP_connector.jpg new file mode 100644 index 0000000..54bda5c Binary files /dev/null and b/libraries/MySQL_MariaDB_Generic-1.7.2/pics/ICSP_connector.jpg differ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/pics/MySQL_MariaDB_Generic_v.1.0.2.png b/libraries/MySQL_MariaDB_Generic-1.7.2/pics/MySQL_MariaDB_Generic_v.1.0.2.png new file mode 100644 index 0000000..764f6e4 Binary files /dev/null and b/libraries/MySQL_MariaDB_Generic-1.7.2/pics/MySQL_MariaDB_Generic_v.1.0.2.png differ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/pics/Portenta_Vision.jpg b/libraries/MySQL_MariaDB_Generic-1.7.2/pics/Portenta_Vision.jpg new file mode 100644 index 0000000..a129e27 Binary files /dev/null and b/libraries/MySQL_MariaDB_Generic-1.7.2/pics/Portenta_Vision.jpg differ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/pics/RP2040-Pinout.png b/libraries/MySQL_MariaDB_Generic-1.7.2/pics/RP2040-Pinout.png new file mode 100644 index 0000000..6129592 Binary files /dev/null and b/libraries/MySQL_MariaDB_Generic-1.7.2/pics/RP2040-Pinout.png differ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/pics/W5100.jpg b/libraries/MySQL_MariaDB_Generic-1.7.2/pics/W5100.jpg new file mode 100644 index 0000000..dbd0294 Binary files /dev/null and b/libraries/MySQL_MariaDB_Generic-1.7.2/pics/W5100.jpg differ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/pics/W5500.jpg b/libraries/MySQL_MariaDB_Generic-1.7.2/pics/W5500.jpg new file mode 100644 index 0000000..4395729 Binary files /dev/null and b/libraries/MySQL_MariaDB_Generic-1.7.2/pics/W5500.jpg differ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/pics/W5500_1.jpg b/libraries/MySQL_MariaDB_Generic-1.7.2/pics/W5500_1.jpg new file mode 100644 index 0000000..35fd095 Binary files /dev/null and b/libraries/MySQL_MariaDB_Generic-1.7.2/pics/W5500_1.jpg differ diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/platformio/platformio.ini b/libraries/MySQL_MariaDB_Generic-1.7.2/platformio/platformio.ini new file mode 100644 index 0000000..8452548 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/platformio/platformio.ini @@ -0,0 +1,503 @@ +;PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +; ============================================================ +; chose environment: +; ESP8266 +; ESP32 +; SAMD +; DUE +; NRF52 +; STM32 +; AVR +; TEENSY +; pico +;portenta_h7_m7 +;portenta_h7_m4 + +; ============================================================ +;default_envs = ESP8266 +;default_envs = ESP32 +default_envs = SAMD +;default_envs = DUE +;default_envs = NRF52 +;default_envs = STM32 +;default_envs = AVR +;default_envs = TEENSY +;default_envs = pico +;default_envs = portenta_h7_m7 +;default_envs = portenta_h7_m4 + +[env] +; ============================================================ +; Serial configuration +; choose upload speed, serial-monitor speed +; ============================================================ +upload_speed = 921600 +;upload_port = COM11 +;monitor_speed = 9600 +;monitor_port = COM11 + +; Checks for the compatibility with frameworks and dev/platforms +lib_compat_mode = strict + +lib_deps = +; PlatformIO 4.x +; WiFiNINA_Generic@~1.8.14-3 +; WebServer_WT32_ETH01@~1.4.1 +; Ethernet_Generic@>=2.0.1 +; EthernetENC@~2.0.0 +; UIPEthernet@~2.0.8 +; WiFiEspAT@~1.3.2 +; ESP8266_AT_WebServer@~1.5.3 +; QNEthernet@>=0.14.0 +; STM32duino STM32Ethernet@~1.2.0 +; STM32duino LwIP@~2.1.2 +; +; PlatformIO 5.x + khoih-prog/WiFiNINA_Generic@~1.8.14-3 + khoih-prog/WebServer_WT32_ETH01@~1.4.1 + khoih-prog/Ethernet_Generic@~2.0.1 + jandrassy/EthernetENC@~2.0.0 + UIPEthernet/UIPEthernet@~2.0.8 + jandrassy/WiFiEspAT@~1.3.2 + khoih-prog/ESP8266_AT_WebServer@~1.5.3 +; stm32duino/STM32duino LwIP@~2.1.2 +; stm32duino/STM32duino STM32Ethernet@~1.2.0 + ssilverman/QNEthernet@>=0.14.0 + + +build_flags = +; set your debug output (default=Serial) +; -D DEBUG_ESP_PORT=Serial +; comment the folowing line to enable WiFi debugging +; -D NDEBUG + +[env:DUE] +platform = atmelsam +framework = arduino +board = due + +; change microcontroller +board_build.mcu = at91sam3x8e + +; change MCU frequency +board_build.f_cpu = 84000000L + +; ============================================================ +; ============================================================ + +[env:ESP8266] +platform = espressif8266 +framework = arduino +; ============================================================ +; Board configuration +; choose your board by uncommenting one of the following lines +; ============================================================ +;board = gen4iod +;board = huzzah +;board = oak +;board = esp_wroom_02 +;board = espduino +;board = espectro +;board = espino +;board = espresso_lite_v1 +;board = espresso_lite_v2 +;board = esp12e +;board = esp01_1m +;board = esp01 +;board = esp07 +;board = esp8285 +;board = heltec_wifi_kit_8 +;board = inventone +;board = nodemcu +board = nodemcuv2 +;board = modwifi +;board = phoenix_v1 +;board = phoenix_v2 +;board = sparkfunBlynk +;board = thing +;board = thingdev +;board = esp210 +;board = espinotee +;board = d1 +;board = d1_mini +;board = d1_mini_lite +;board = d1_mini_pro +;board = wifi_slot +;board = wifiduino +;board = wifinfo +;board = wio_link +;board = wio_node +;board = xinabox_cw01 +;board = esp32doit-devkit-v1 + +; ============================================================ +; ============================================================ + +[env:ESP32] +platform = espressif32 +framework = arduino +; ============================================================ +; Board configuration +; choose your board by uncommenting one of the following lines +; ============================================================ +;board = esp32cam +;board = alksesp32 +;board = featheresp32 +;board = espea32 +;board = bpi-bit +;board = d-duino-32 +board = esp32doit-devkit-v1 +;board = pocket_32 +;board = fm-devkit +;board = pico32 +;board = esp32-evb +;board = esp32-gateway +;board = esp32-pro +;board = esp32-poe +;board = oroca_edubot +;board = onehorse32dev +;board = lopy +;board = lopy4 +;board = wesp32 +;board = esp32thing +;board = sparkfun_lora_gateway_1-channel +;board = ttgo-lora32-v1 +;board = ttgo-t-beam +;board = turta_iot_node +;board = lolin_d32 +;board = lolin_d32_pro +;board = lolin32 +;board = wemosbat +;board = widora-air +;board = xinabox_cw02 +;board = iotbusio +;board = iotbusproteus +;board = nina_w10 + +; ============================================================ +; ============================================================ + +[env:SAMD] +platform = atmelsam +framework = arduino +; ============================================================ +; Choose your board by uncommenting one of the following lines +; ============================================================ +; ============================================================ +; Board configuration Adafruit SAMD +; ============================================================ + +;board = adafruit_feather_m0 +;board = adafruit_feather_m0_express +;board = adafruit_metro_m0 +;board = adafruit_circuitplayground_m0 +;board = adafruit_gemma_m0 +;board = adafruit_trinket_m0 +;board = adafruit_itsybitsy_m0 +;board = adafruit_pirkey +;board = adafruit_hallowing +;board = adafruit_crickit_m0 +;board = adafruit_metro_m4 +;board = adafruit_grandcentral_m4 +board = adafruit_itsybitsy_m4 +;board = adafruit_feather_m4 +;board = adafruit_trellis_m4 +;board = adafruit_pyportal_m4 +;board = adafruit_pyportal_m4_titano +;board = adafruit_pybadge_m4 +;board = adafruit_metro_m4_airliftlite +;board = adafruit_pygamer_m4 +;board = adafruit_pygamer_advance_m4 +;board = adafruit_pybadge_airlift_m4 +;board = adafruit_monster_m4sk +;board = adafruit_hallowing_m4 + +; ============================================================ +; Board configuration Arduino SAMD and SAM +; ============================================================ + +;board = arduino_zero_edbg +;board = arduino_zero_native +;board = mkr1000 +;board = mkrzero +;board = mkrwifi1010 +;board = nano_33_iot +;board = mkrfox1200 +;board = mkrwan1300 +;board = mkrwan1310 +;board = mkrgsm1400 +;board = mkrnb1500 +;board = mkrvidor4000 +;board = adafruit_circuitplayground_m0 +;board = mzero_pro_bl_dbg +;board = mzero_pro_bl +;board = mzero_bl +;board = tian +;board = tian_cons +;board = arduino_due_x_dbg +;board = arduino_due_x + +; ============================================================ +; Board configuration Seeeduino SAMD +; ============================================================ + +;board = seeed_wio_terminal +;board = Seeed_femto_m0 +;board = seeed_XIAO_m0 +;board = Wio_Lite_MG126 +;board = WioGPS +;board = zero +;board = rolawan +;board = seeed_grove_ui_wireless + +; ============================================================ +; ============================================================ + +[env:NRF52] +platform = nordicnrf52 +framework = arduino +; ============================================================ +; Board configuration Adafruit nRF52 +; choose your board by uncommenting one of the following lines +; ============================================================ +;board = feather52832 +board = feather52840 +;board = feather52840sense +;board = itsybitsy52840 +;board = cplaynrf52840 +;board = cluenrf52840 +;board = metro52840 +;board = pca10056 +;board = particle_xenon +;board = mdbt50qrx +;board = ninab302 +;board = ninab112 + +; ============================================================ +; ============================================================ + +[env:STM32] +platform = ststm32 +framework = arduino + +; ============================================================ +; Choose your board by uncommenting one of the following lines +; ============================================================ + +; ============================================================ +; Board configuration Nucleo-144 +; ============================================================ + +;board = nucleo_f207zg +;board = nucleo_f429zi +;board = nucleo_f746zg +;board = nucleo_f756zg +;board = nucleo_f767zi +;board = nucleo_h743zi +;board = nucleo_l496zg +;board = nucleo_l496zg-p +;board = nucleo_l4r5zi +;board = nucleo_l4r5zi-p + +; ============================================================ +; Board configuration Nucleo-64 +; ============================================================ + +;board = nucleo_f030r8 +;board = nucleo_f072rb + +;board = nucleo_f091rc +;board = nucleo_f103rb +;board = nucleo_f302r8 +;board = nucleo_f303re +;board = nucleo_f401re +;board = nucleo_f411re +;board = nucleo_f446re +;board = nucleo_g071rb +;board = nucleo_g431rb +;board = nucleo_g474re +;board = nucleo_l053r8 +;board = nucleo_l073rz +;board = nucleo_l152re +;board = nucleo_l433rc_p +;board = nucleo_l452re +;board = nucleo_l452re-p +;board = nucleo_l476rg +;board = pnucleo_wb55rg + +; ============================================================ +; Board configuration Nucleo-32 +; ============================================================ + +;board = nucleo_f031k6 +;board = nucleo_l031k6 +;board = nucleo_l412kb +;board = nucleo_l432lc +;board = nucleo_f303k8 +;board = nucleo_g431kb + +; ============================================================ +; Board configuration Discovery Boards +; ============================================================ + +;board = disco_f030r8 +;board = disco_f072rb +;board = disco_f030r8 +;board = disco_f100rb +;board = disco_f407vg +;board = disco_f413zh +;board = disco_f746ng +;board = disco_g0316 +;board = disco_l475vg_iot +;board = disco_f072cz-lrwan1 + +; ============================================================ +; Board configuration STM32MP1 Boards +; ============================================================ + +;board = stm32mp157a-dk1 +;board = stm32mp157c-dk2 + +; ============================================================ +; Board configuration Generic Boards +; ============================================================ + +;board = bluepill_f103c6 +;board = bluepill_f103c8 +;board = blackpill_f103c8 +;board = stm32f103cx +;board = stm32f103rx +;board = stm32f103tx +;board = stm32f103vx +;board = stm32f103zx +;board = stm32f103zet6 +;board = maplemini_f103cb +;board = blackpill_f303cc +;board = black_f407ve +;board = black_f407vg +;board = black_f407ze +;board = black_f407zg +;board = blue_f407ve_mini +;board = blackpill_f401cc +;board = blackpill_f411ce +;board = coreboard_f401rc +;board = feather_f405 + +; ============================================================ +; Board configuration Many more Boards to be filled +; ============================================================ + +; ============================================================ +; ============================================================ + +[env:AVR] +platform = atmelavr +framework = arduino + +; ============================================================ +; Board configuration AVR +; ============================================================ + +;board = yun +;board = uno +;board = diecimila +;board = nano +;board = nanoatmega328 +;board = mega +board = megaatmega2560 +;board = megaADK +;board = leonardo +;board = leonardoeth +;board = micro +;board = esplora +;board = mini +;board = ethernet +;board = fio +;board = bt +;board = LilyPadUSB +;board = lilypad +;board = pro +;board = atmegang +;board = robotControl +;board = robotMotor +;board = gemma +;board = circuitplay32u4cat +;board = yunmini +;board = chiwawa +;board = one +;board = unowifi + +; ============================================================ +; ============================================================ + +[env:TEENSY] +platform = teensy +framework = arduino + +; ============================================================ +; Choose your board by uncommenting one of the following lines +; ============================================================ + +; ============================================================ +; Board configuration TEENSY +; ============================================================ + +;board = teensy2 +;board = teensy2pp +;board = teensy30 +;board = teensy31 +;board = teensylc +;board = teensy35 +;board = teensy36 +;board = teensy40 +;board = teensy41 + +; ============================================================ +; Choose your board by uncommenting one of the following lines +; ============================================================ + +; ============================================================ +; Board configuration raspberrypi pico +; ============================================================ + +[env:pico] +; ============================================================ +; Just a sample +; You have to research and fix if there is issue +; ============================================================ +platform = raspberrypi +board = pico +framework = arduino +upload_protocol = picotool + +; ============================================================ +; ============================================================ + +; ============================================================ +; Board configuration portenta_h7_m7 +; ============================================================ + +[env:portenta_h7_m7] +platform = ststm32 +board = portenta_h7_m7 +framework = arduino + +; ============================================================ +; Board configuration portenta_h7_m4 +; ============================================================ + +[env:portenta_h7_m4] +platform = ststm32 +board = portenta_h7_m4 +framework = arduino + diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic.h b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic.h new file mode 100644 index 0000000..b6d8ad7 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic.h @@ -0,0 +1,67 @@ +/********************************************************************************************************************************* + MySQL_Generic.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, WT32_ETH01, Teensy, Portenta_H7, etc. boards + using W5x00, ENC28J60, LAM8742A Ethernet, WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi, Portenta Ethernet/WiFi + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + + Version: 1.7.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/08/2020 Initial coding/porting to support nRF52, SAM DUE and SAMD21/SAMD51 boards using W5x00 Ethernet + (Ethernet, EthernetLarge, Ethernet2, Ethernet3 library), WiFiNINA and ESP8266/ESP32-AT shields + ... + 1.4.0 K Hoang 05/09/2021 Add support to Teensy 4.1 using QNEthernet + 1.5.0 K Hoang 17/09/2021 Add support to Portenta_H7, using either WiFi or Vision-shield Ethernet + 1.5.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json` + 1.5.2 K Hoang 01/12/2021 Auto detect ESP32 core for LittleFS. Fix bug in examples for WT32_ETH01 + 1.6.0 K Hoang 10/03/2022 Fix memory leak bug. Optimize code + 1.6.1 K Hoang 12/03/2022 Fix memory management bug + 1.7.0 K Hoang 12/03/2022 Convert to `h-only` style library + 1.7.1 K Hoang 10/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32 + 1.7.2 K Hoang 11/04/2022 Fix missing paragraph in `library.properties` + **********************************************************************************************************************************/ + +#pragma once + +#ifndef MYSQL_GENERIC_H +#define MYSQL_GENERIC_H + +#if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC || USE_ETHERNET_ESP8266 || USE_UIP_ETHERNET || USE_ETHERNET_LAN8742A || \ + USE_ETHERNET_LAN8720 || USE_NATIVE_ETHERNET || USE_QN_ETHERNET || USE_CUSTOM_ETHERNET || USE_ETHERNET_PORTENTA_H7 || \ + USE_CUSTOM_ETHERNET ) + + #include "MySQL_Generic_Ethernet.h" + +#elif ( USING_WIFININA_GENERIC || USING_WIFININA ) + + #include "MySQL_Generic_WiFiNINA.h" + +#elif ( ESP8266 || ESP32 || USING_WIFI_ESP8266_AT || USING_WIFININA_GENERIC || USING_WIFININA || USING_WIFIESPAT_LIB || \ + USING_WIFI_CUSTOM || USE_WIFI_PORTENTA_H7 ) + + #include "MySQL_Generic_WiFi.h" + + +#else + + #error Must select a Ethernet / WiFi module and Library + +#endif + +#include + +#include +#include +#include +#include + +#endif //MYSQL_GENERIC_H diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic.hpp b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic.hpp new file mode 100644 index 0000000..95f8b49 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic.hpp @@ -0,0 +1,55 @@ +/********************************************************************************************************************************* + MySQL_Generic.hpp + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, WT32_ETH01, Teensy, Portenta_H7, etc. boards + using W5x00, ENC28J60, LAM8742A Ethernet, WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi, Portenta Ethernet/WiFi + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + + Version: 1.7.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/08/2020 Initial coding/porting to support nRF52, SAM DUE and SAMD21/SAMD51 boards using W5x00 Ethernet + (Ethernet, EthernetLarge, Ethernet2, Ethernet3 library), WiFiNINA and ESP8266/ESP32-AT shields + ... + 1.4.0 K Hoang 05/09/2021 Add support to Teensy 4.1 using QNEthernet + 1.5.0 K Hoang 17/09/2021 Add support to Portenta_H7, using either WiFi or Vision-shield Ethernet + 1.5.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json` + 1.5.2 K Hoang 01/12/2021 Auto detect ESP32 core for LittleFS. Fix bug in examples for WT32_ETH01 + 1.6.0 K Hoang 10/03/2022 Fix memory leak bug. Optimize code + 1.6.1 K Hoang 12/03/2022 Fix memory management bug + 1.7.0 K Hoang 12/03/2022 Convert to `h-only` style library + 1.7.1 K Hoang 10/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32 + 1.7.2 K Hoang 11/04/2022 Fix missing paragraph in `library.properties` + **********************************************************************************************************************************/ + +#pragma once + +#ifndef MYSQL_GENERIC_HPP +#define MYSQL_GENERIC_HPP + +#define MYSQL_GENERIC_VERSION "1.7.2" + +#ifndef MYSQL_MARIADB_GENERIC_VERSION + #define MYSQL_MARIADB_GENERIC_VERSION ("MySQL_MariaDB_Generic v" MYSQL_GENERIC_VERSION) + + #define MYSQL_MARIADB_GENERIC_VERSION_MAJOR 1 + #define MYSQL_MARIADB_GENERIC_VERSION_MINOR 7 + #define MYSQL_MARIADB_GENERIC_VERSION_PATCH 2 + + #define MYSQL_MARIADB_GENERIC_VERSION_INT 1007002 +#endif + +#include +#include +#include +#include + +#endif //MYSQL_GENERIC_HPP diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Connection.h b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Connection.h new file mode 100644 index 0000000..c6c7183 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Connection.h @@ -0,0 +1,99 @@ +/********************************************************************************************************************************* + MySQL_Generic_Connection.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, WT32_ETH01, Teensy, Portenta_H7, etc. boards + using W5x00, ENC28J60, LAM8742A Ethernet, WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi, Portenta Ethernet/WiFi + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + + Version: 1.7.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/08/2020 Initial coding/porting to support nRF52, SAM DUE and SAMD21/SAMD51 boards using W5x00 Ethernet + (Ethernet, EthernetLarge, Ethernet2, Ethernet3 library), WiFiNINA and ESP8266/ESP32-AT shields + ... + 1.4.0 K Hoang 05/09/2021 Add support to Teensy 4.1 using QNEthernet + 1.5.0 K Hoang 17/09/2021 Add support to Portenta_H7, using either WiFi or Vision-shield Ethernet + 1.5.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json` + 1.5.2 K Hoang 01/12/2021 Auto detect ESP32 core for LittleFS. Fix bug in examples for WT32_ETH01 + 1.6.0 K Hoang 10/03/2022 Fix memory leak bug. Optimize code + 1.6.1 K Hoang 12/03/2022 Fix memory management bug + 1.7.0 K Hoang 12/03/2022 Convert to `h-only` style library + 1.7.1 K Hoang 10/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32 + 1.7.2 K Hoang 11/04/2022 Fix missing paragraph in `library.properties` + **********************************************************************************************************************************/ + +/********************************************************************************************************************************* + Copyright (c) 2012, 2016 Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + **********************************************************************************************************************************/ + +#pragma once + +#ifndef MYSQL_GENERIC_CONNECTION_H +#define MYSQL_GENERIC_CONNECTION_H + +#include "MySQL_Generic_Debug.h" + +#include + +typedef enum +{ + RESULT_OK = 0, + RESULT_FAIL, + RESULT_PENDING +} Connection_Result; + + +class MySQL_Connection : public MySQL_Packet +{ + public: + MySQL_Connection(Client *client_instance) : MySQL_Packet(client_instance) {} + + virtual ~MySQL_Connection() + { + this->close(); + }; + + bool connect(const IPAddress& server, const uint16_t& port, char *user, char *password, char *db = NULL); + + Connection_Result connectNonBlocking(const IPAddress& server, const uint16_t& port, char *user, char *password, char *db = NULL); + + // KH, add to use hostname. from v1.4.0 + bool connect(const char *hostname, const uint16_t& port, char *user, char *password, char *db = NULL); + + Connection_Result connectNonBlocking(const char *hostname, const uint16_t& port, char *user, char *password, char *db = NULL); + //////// + + int connected() + { + return client->connected(); + } + + const char *version() + { + return MYSQL_GENERIC_VERSION; + } + + void close(); +}; + +//#include + +#endif // MYSQL_GENERIC_CONNECTION_H diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Connection_Impl.h b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Connection_Impl.h new file mode 100644 index 0000000..823328e --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Connection_Impl.h @@ -0,0 +1,284 @@ +/********************************************************************************************************************************* + MySQL_Generic_Connection_Impl.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, WT32_ETH01, Teensy, Portenta_H7, etc. boards + using W5x00, ENC28J60, LAM8742A Ethernet, WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi, Portenta Ethernet/WiFi + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + + Version: 1.7.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/08/2020 Initial coding/porting to support nRF52, SAM DUE and SAMD21/SAMD51 boards using W5x00 Ethernet + (Ethernet, EthernetLarge, Ethernet2, Ethernet3 library), WiFiNINA and ESP8266/ESP32-AT shields + ... + 1.4.0 K Hoang 05/09/2021 Add support to Teensy 4.1 using QNEthernet + 1.5.0 K Hoang 17/09/2021 Add support to Portenta_H7, using either WiFi or Vision-shield Ethernet + 1.5.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json` + 1.5.2 K Hoang 01/12/2021 Auto detect ESP32 core for LittleFS. Fix bug in examples for WT32_ETH01 + 1.6.0 K Hoang 10/03/2022 Fix memory leak bug. Optimize code + 1.6.1 K Hoang 12/03/2022 Fix memory management bug + 1.7.0 K Hoang 12/03/2022 Convert to `h-only` style library + 1.7.1 K Hoang 10/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32 + 1.7.2 K Hoang 11/04/2022 Fix missing paragraph in `library.properties` + **********************************************************************************************************************************/ + +/********************************************************************************************************************************* + Copyright (c) 2012, 2016 Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + **********************************************************************************************************************************/ + +#pragma once + +#ifndef MYSQL_GENERIC_CONNECTION_IMPL_H +#define MYSQL_GENERIC_CONNECTION_IMPL_H + +#include + +#include + +#define MAX_CONNECT_ATTEMPTS 10 +#define CONNECT_DELAY_MS 1000 +#define SUCCESS 1 + +/* + connect - Connect to a MySQL server. + + This method is used to connect to a MySQL server. It will attempt to + connect to the server as a client retrying up to MAX_CONNECT_ATTEMPTS. + This permits the possibility of longer than normal network lag times + for wireless networks. You can adjust MAX_CONNECT_ATTEMPTS to suit + your environment. + + server[in] IP address of the server as IPAddress type + port[in] port number of the server + user[in] user name + password[in] (optional) user password + db[in] (optional) default database + + Returns bool - True = connection succeeded +*/ + + +String SQL_IPAddressToString(const IPAddress& _address) +{ + String str = String(_address[0]); + str += "."; + str += String(_address[1]); + str += "."; + str += String(_address[2]); + str += "."; + str += String(_address[3]); + + return str; +} + +////////////////////////////////////////////////////////////// + +bool MySQL_Connection::connect(const char *hostname, const uint16_t& port, char *user, char *password, char *db) +{ + int connected = 0; + int retries = 0; + bool returnVal = false; + + MYSQL_LOGWARN3("Connecting to Server:", hostname, ", Port = ", port); + + if (db) + MYSQL_LOGWARN1("Using Database:", db); + + // Retry up to MAX_CONNECT_ATTEMPTS times. + while (retries++ < MAX_CONNECT_ATTEMPTS) + { + connected = client->connect(hostname, port); + + MYSQL_LOGDEBUG1("connected =", connected); + + if (connected != SUCCESS) + { + MYSQL_LOGDEBUG1("Can't connect. Retry #", retries); + delay(CONNECT_DELAY_MS); + } + else + { + break; + } + } + + if (connected != SUCCESS) + return false; + + MYSQL_LOGINFO("Connect OK. Try reading packets"); + + if ( !read_packet() ) + { + MYSQL_LOGERROR("Can't connect. Error reading packets"); + return false; + } + + MYSQL_LOGINFO("Try parsing packets"); + + parse_handshake_packet(); + + MYSQL_LOGINFO("Try send_authentication packets"); + + send_authentication_packet(user, password, db); + + if ( !read_packet() ) + { + MYSQL_LOGERROR("Can't connect. Error reading auth packets"); + } + else if (get_packet_type() != MYSQL_OK_PACKET) + { + parse_error_packet(); + } + else + { + MYSQL_LOGWARN1("Connected. Server Version =", server_version); + returnVal = true; + } + + if (server_version) + { + free(server_version); // don't need it anymore + server_version = NULL; + } + + return returnVal; +} + +////////////////////////////////////////////////////////////// + +Connection_Result MySQL_Connection::connectNonBlocking(const char *hostname, const uint16_t& port, char *user, char *password, char *db) +{ + int connected = 0; + int retries = 0; + + Connection_Result returnVal = RESULT_FAIL; + + long now = 0; + + MYSQL_LOGWARN3("Connecting to Server:", hostname, ", Port = ", port); + + if (db) + MYSQL_LOGWARN1("Using Database:", db); + + while (retries < MAX_CONNECT_ATTEMPTS) + { + if ( (now == 0) || ( millis() - now ) > CONNECT_DELAY_MS ) + { + now = millis(); + + connected = client->connect(hostname, port); + + retries++; + + MYSQL_LOGDEBUG1("connected =", connected); + + if (connected == SUCCESS) + { + break; + } + else + { + MYSQL_LOGDEBUG1("Can't connect. Retry #", retries); + } + } + else + { + //delay(CONNECT_DELAY_MS); + yield(); + } + } + + if (connected != SUCCESS) + return RESULT_FAIL; + + MYSQL_LOGINFO("Connect OK. Try reading packets"); + + if ( !read_packet() ) + { + MYSQL_LOGERROR("Can't connect. Error reading packets"); + return RESULT_FAIL; + } + + MYSQL_LOGINFO("Try parsing packets"); + + parse_handshake_packet(); + + MYSQL_LOGINFO("Try send_authentication packets"); + + send_authentication_packet(user, password, db); + + if ( !read_packet() ) + { + MYSQL_LOGERROR("Can't connect. Error reading auth packets"); + } + else if (get_packet_type() != MYSQL_OK_PACKET) + { + parse_error_packet(); + } + else + { + MYSQL_LOGWARN1("Connected. Server Version =", server_version); + returnVal = RESULT_OK; + } + + if (server_version) + { + free(server_version); // don't need it anymore + server_version = NULL; + } + + return returnVal; +} + +////////////////////////////////////////////////////////////// + +bool MySQL_Connection::connect(const IPAddress& server, const uint16_t& port, char *user, char *password, char *db) +{ + return connect(SQL_IPAddressToString(server).c_str(), port, user, password, db); +} + +////////////////////////////////////////////////////////////// + +Connection_Result MySQL_Connection::connectNonBlocking(const IPAddress& server, const uint16_t& port, char *user, char *password, char *db) +{ + return connectNonBlocking(SQL_IPAddressToString(server).c_str(), port, user, password, db); +} + +////////////////////////////////////////////////////////////// + +/* + close - cancel the connection + + This method closes the connection to the server and frees up any memory + used in the buffer. +*/ +void MySQL_Connection::close() +{ + if (connected()) + { + client->flush(); + client->stop(); + + MYSQL_LOGERROR("Disconnected"); + } +} + +#endif // MYSQL_GENERIC_CONNECTION_IMPL_H diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Debug.h b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Debug.h new file mode 100644 index 0000000..fe89a2c --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Debug.h @@ -0,0 +1,151 @@ +/********************************************************************************************************************************* + MySQL_Generic_Debug.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, WT32_ETH01, Teensy, Portenta_H7, etc. boards + using W5x00, ENC28J60, LAM8742A Ethernet, WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi, Portenta Ethernet/WiFi + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + + Version: 1.7.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/08/2020 Initial coding/porting to support nRF52, SAM DUE and SAMD21/SAMD51 boards using W5x00 Ethernet + (Ethernet, EthernetLarge, Ethernet2, Ethernet3 library), WiFiNINA and ESP8266/ESP32-AT shields + ... + 1.4.0 K Hoang 05/09/2021 Add support to Teensy 4.1 using QNEthernet + 1.5.0 K Hoang 17/09/2021 Add support to Portenta_H7, using either WiFi or Vision-shield Ethernet + 1.5.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json` + 1.5.2 K Hoang 01/12/2021 Auto detect ESP32 core for LittleFS. Fix bug in examples for WT32_ETH01 + 1.6.0 K Hoang 10/03/2022 Fix memory leak bug. Optimize code + 1.6.1 K Hoang 12/03/2022 Fix memory management bug + 1.7.0 K Hoang 12/03/2022 Convert to `h-only` style library + 1.7.1 K Hoang 10/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32 + 1.7.2 K Hoang 11/04/2022 Fix missing paragraph in `library.properties` + **********************************************************************************************************************************/ + +/********************************************************************************************************************************* + Copyright (c) 2012, 2016 Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + **********************************************************************************************************************************/ + +#pragma once + +#ifndef MYSQL_GENERIC_DEBUG_H +#define MYSQL_GENERIC_DEBUG_H + +#include + +const char CONNECTED[] /*PROGMEM*/ = "Connected"; +const char DISCONNECTED[] /*PROGMEM*/ = "Disconnected."; + +const char MEMORY_ERROR[] /*PROGMEM*/ = "Memory error."; +const char PACKET_ERROR[] /*PROGMEM*/ = "Packet error."; +const char READ_TIMEOUT[] /*PROGMEM*/ = "ERROR: Timeout waiting for client."; + +const char BAD_MOJO[] /*PROGMEM*/ = "Bad mojo. EOF found reading column header."; +const char ROWS[] /*PROGMEM*/ = " rows in result."; +const char READ_COLS[] /*PROGMEM*/ = "ERROR: You must read the columns first!"; +const char NOT_CONNECTED[] /*PROGMEM*/ = "ERROR: Class requires connected server."; + + +#ifdef MYSQL_DEBUG_PORT + #define MYSQL_DEBUG_OUTPUT MYSQL_DEBUG_PORT +#else + #define MYSQL_DEBUG_OUTPUT Serial +#endif + +// Change _MYSQL_LOGLEVEL_ to set tracing and logging verbosity +// 0: DISABLED: no logging +// 1: ERROR: errors +// 2: WARN: errors and warnings +// 3: INFO: errors, warnings and informational (default) +// 4: DEBUG: errors, warnings, informational and debug + +#ifndef _MYSQL_LOGLEVEL_ +#define _MYSQL_LOGLEVEL_ 0 +#endif + +////////////////////////////////////////// + +const char MYSQL_MARK[] = "[SQL] "; +const char MYSQL_SP[] = " "; + +#define MYSQL_PRINT MYSQL_DEBUG_OUTPUT.print +#define MYSQL_PRINTLN MYSQL_DEBUG_OUTPUT.println + +#define MYSQL_PRINT_MARK MYSQL_PRINT(MYSQL_MARK) +#define MYSQL_PRINT_SP MYSQL_PRINT(MYSQL_SP) + +/////////////////////////////////////////////////// + +#define MYSQL_DISPLAY(x) { MYSQL_PRINTLN(x); } +#define MYSQL_DISPLAY0(x) { MYSQL_PRINT(x); } +#define MYSQL_DISPLAY1(x,y) { MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINTLN(y); } +#define MYSQL_DISPLAY2(x,y,z) { MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINT(y); MYSQL_PRINT_SP; MYSQL_PRINTLN(z); } +#define MYSQL_DISPLAY3(x,y,z,w) { MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINT(y); MYSQL_PRINT_SP; MYSQL_PRINT(z); MYSQL_PRINT_SP; MYSQL_PRINTLN(w); } +#define MYSQL_DISPLAY5(x,y,z,w,xx,yy) { MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINT(y); MYSQL_PRINT_SP; MYSQL_PRINT(z); MYSQL_PRINT_SP; MYSQL_PRINT(w); MYSQL_PRINT_SP; MYSQL_PRINT(xx); MYSQL_PRINT_SP; MYSQL_PRINTLN(yy); } + +/////////////////////////////////////////////////// + +#define MYSQL_LOGERROR(x) if(_MYSQL_LOGLEVEL_>0) { MYSQL_PRINT_MARK; MYSQL_PRINTLN(x); } +#define MYSQL_LOGERROR0(x) if(_MYSQL_LOGLEVEL_>0) { MYSQL_PRINT(x); } +#define MYSQL_LOGERROR0LN(x) if(_MYSQL_LOGLEVEL_>0) { MYSQL_PRINTLN(x); } +#define MYSQL_LOGERROR1(x,y) if(_MYSQL_LOGLEVEL_>0) { MYSQL_PRINT_MARK; MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINTLN(y); } +#define MYSQL_LOGERROR2(x,y,z) if(_MYSQL_LOGLEVEL_>0) { MYSQL_PRINT_MARK; MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINT(y); MYSQL_PRINT_SP; MYSQL_PRINTLN(z); } +#define MYSQL_LOGERROR3(x,y,z,w) if(_MYSQL_LOGLEVEL_>0) { MYSQL_PRINT_MARK; MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINT(y); MYSQL_PRINT_SP; MYSQL_PRINT(z); MYSQL_PRINT_SP; MYSQL_PRINTLN(w); } + +/////////////////////////////////////////////////// + +#define MYSQL_LOGWARN(x) if(_MYSQL_LOGLEVEL_>1) { MYSQL_PRINT_MARK; MYSQL_PRINTLN(x); } +#define MYSQL_LOGWARN0(x) if(_MYSQL_LOGLEVEL_>1) { MYSQL_PRINT(x); } +#define MYSQL_LOGWARN0LN(x) if(_MYSQL_LOGLEVEL_>1) { MYSQL_PRINTLN(x); } +#define MYSQL_LOGWARN1(x,y) if(_MYSQL_LOGLEVEL_>1) { MYSQL_PRINT_MARK; MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINTLN(y); } +#define MYSQL_LOGWARN2(x,y,z) if(_MYSQL_LOGLEVEL_>1) { MYSQL_PRINT_MARK; MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINT(y); MYSQL_PRINT_SP; MYSQL_PRINTLN(z); } +#define MYSQL_LOGWARN3(x,y,z,w) if(_MYSQL_LOGLEVEL_>1) { MYSQL_PRINT_MARK; MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINT(y); MYSQL_PRINT_SP; MYSQL_PRINT(z); MYSQL_PRINT_SP; MYSQL_PRINTLN(w); } + +/////////////////////////////////////////////////// + +#define MYSQL_LOGINFO(x) if(_MYSQL_LOGLEVEL_>2) { MYSQL_PRINT_MARK; MYSQL_PRINTLN(x); } +#define MYSQL_LOGINFO0(x) if(_MYSQL_LOGLEVEL_>2) { MYSQL_PRINT(x); } +#define MYSQL_LOGINFO0LN(x) if(_MYSQL_LOGLEVEL_>2) { MYSQL_PRINTLN(x); } +#define MYSQL_LOGINFO1(x,y) if(_MYSQL_LOGLEVEL_>2) { MYSQL_PRINT_MARK; MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINTLN(y); } +#define MYSQL_LOGINFO2(x,y,z) if(_MYSQL_LOGLEVEL_>2) { MYSQL_PRINT_MARK; MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINT(y); MYSQL_PRINT_SP; MYSQL_PRINTLN(z); } +#define MYSQL_LOGINFO3(x,y,z,w) if(_MYSQL_LOGLEVEL_>2) { MYSQL_PRINT_MARK; MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINT(y); MYSQL_PRINT_SP; MYSQL_PRINT(z); MYSQL_PRINT_SP; MYSQL_PRINTLN(w); } + +/////////////////////////////////////////////////// + +#define MYSQL_LOGDEBUG(x) if(_MYSQL_LOGLEVEL_>3) { MYSQL_PRINT_MARK; MYSQL_PRINTLN(x); } +#define MYSQL_LOGDEBUG0(x) if(_MYSQL_LOGLEVEL_>3) { MYSQL_PRINT(x); } +#define MYSQL_LOGDEBUG0LN(x) if(_MYSQL_LOGLEVEL_>3) { MYSQL_PRINTLN(x); } +#define MYSQL_LOGDEBUG1(x,y) if(_MYSQL_LOGLEVEL_>3) { MYSQL_PRINT_MARK; MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINTLN(y); } +#define MYSQL_LOGDEBUG2(x,y,z) if(_MYSQL_LOGLEVEL_>3) { MYSQL_PRINT_MARK; MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINT(y); MYSQL_PRINT_SP; MYSQL_PRINTLN(z); } +#define MYSQL_LOGDEBUG3(x,y,z,w) if(_MYSQL_LOGLEVEL_>3) { MYSQL_PRINT_MARK; MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINT(y); MYSQL_PRINT_SP; MYSQL_PRINT(z); MYSQL_PRINT_SP; MYSQL_PRINTLN(w); } + +/////////////////////////////////////////////////// + +#define MYSQL_LOGLEVEL5(x) if(_MYSQL_LOGLEVEL_>4) { MYSQL_PRINT_MARK; MYSQL_PRINTLN(x); } +#define MYSQL_LOGLEVEL5_0(x) if(_MYSQL_LOGLEVEL_>4) { MYSQL_PRINT(x); } +#define MYSQL_LOGLEVEL5_0LN(x) if(_MYSQL_LOGLEVEL_>4) { MYSQL_PRINTLN(x); } +#define MYSQL_LOGLEVEL5_1(x,y) if(_MYSQL_LOGLEVEL_>4) { MYSQL_PRINT_MARK; MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINTLN(y); } +#define MYSQL_LOGLEVEL5_2(x,y,z) if(_MYSQL_LOGLEVEL_>4) { MYSQL_PRINT_MARK; MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINT(y); MYSQL_PRINT_SP; MYSQL_PRINTLN(z); } +#define MYSQL_LOGLEVEL5_3(x,y,z,w) if(_MYSQL_LOGLEVEL_>4) { MYSQL_PRINT_MARK; MYSQL_PRINT(x); MYSQL_PRINT_SP; MYSQL_PRINT(y); MYSQL_PRINT_SP; MYSQL_PRINT(z); MYSQL_PRINT_SP; MYSQL_PRINTLN(w); } + +/////////////////////////////////////////////////// + +#endif // MYSQL_GENERIC_DEBUG_H diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Encrypt_Sha1.h b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Encrypt_Sha1.h new file mode 100644 index 0000000..ff328c7 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Encrypt_Sha1.h @@ -0,0 +1,88 @@ +/********************************************************************************************************************************* + MySQL_Generic_Encrypt_Sha1.h + + GNU GPL v3: + This file is part of the code entitled, "cryptosuite" available at https://code.google.com/p/cryptosuite/. The file was copied from that + repository and renamed for use in Connector/Arduino to preserve compatibility and protect against namespace collisions for users who + want to use the full cryptosuite functionality. For Connector/Arduino all that is needed is this one sha1 class. + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, WT32_ETH01, Teensy, Portenta_H7, etc. boards + using W5x00, ENC28J60, LAM8742A Ethernet, WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi, Portenta Ethernet/WiFi + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + + Version: 1.7.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/08/2020 Initial coding/porting to support nRF52, SAM DUE and SAMD21/SAMD51 boards using W5x00 Ethernet + (Ethernet, EthernetLarge, Ethernet2, Ethernet3 library), WiFiNINA and ESP8266/ESP32-AT shields + ... + 1.4.0 K Hoang 05/09/2021 Add support to Teensy 4.1 using QNEthernet + 1.5.0 K Hoang 17/09/2021 Add support to Portenta_H7, using either WiFi or Vision-shield Ethernet + 1.5.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json` + 1.5.2 K Hoang 01/12/2021 Auto detect ESP32 core for LittleFS. Fix bug in examples for WT32_ETH01 + 1.6.0 K Hoang 10/03/2022 Fix memory leak bug. Optimize code + 1.6.1 K Hoang 12/03/2022 Fix memory management bug + 1.7.0 K Hoang 12/03/2022 Convert to `h-only` style library + 1.7.1 K Hoang 10/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32 + 1.7.2 K Hoang 11/04/2022 Fix missing paragraph in `library.properties` + **********************************************************************************************************************************/ + +#pragma once + +#ifndef MYSQL_GENERIC_ENCRYPT_SHA1_H +#define MYSQL_GENERIC_ENCRYPT_SHA1_H + +#include +#include "Print.h" + +#define HASH_LENGTH 20 +#define BLOCK_LENGTH 64 + +union _buffer +{ + uint8_t b [BLOCK_LENGTH]; + uint32_t w [BLOCK_LENGTH / 4]; +}; + +union _state +{ + uint8_t b [HASH_LENGTH]; + uint32_t w [HASH_LENGTH / 4]; +}; + +class Encrypt_SHA1 : public Print +{ + public: + void init(); + void initHmac(const uint8_t* secret, const int& secretLength); + uint8_t* result(); + virtual size_t write(uint8_t data); + virtual size_t write(uint8_t* data, const int& length); + using Print::write; + + private: + void pad(); + void addUncounted(const uint8_t& data); + void hashBlock(); + uint32_t rol32(const uint32_t& number, const uint8_t& bits); + _buffer buffer; + uint8_t bufferOffset; + _state state; + uint32_t byteCount; + uint8_t keyBuffer[BLOCK_LENGTH]; + uint8_t innerHash[HASH_LENGTH]; +}; + +//extern Encrypt_SHA1 Sha1; + +//#include "MySQL_Generic_Encrypt_Sha1_Impl.h" + +#endif // MYSQL_GENERIC_ENCRYPT_SHA1_H diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Encrypt_Sha1_Impl.h b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Encrypt_Sha1_Impl.h new file mode 100644 index 0000000..6edcbc6 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Encrypt_Sha1_Impl.h @@ -0,0 +1,208 @@ +/********************************************************************************************************************************* + MySQL_Generic_Encrypt_Sha1_Impl.h + + GNU GPL v3: + This file is part of the code entitled, "cryptosuite" available at https://code.google.com/p/cryptosuite/. The file was copied from that + repository and renamed for use in Connector/Arduino to preserve compatibility and protect against namespace collisions for users who + want to use the full cryptosuite functionality. For Connector/Arduino all that is needed is this one sha1 class. + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, WT32_ETH01, Teensy, Portenta_H7, etc. boards + using W5x00, ENC28J60, LAM8742A Ethernet, WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi, Portenta Ethernet/WiFi + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + + Version: 1.7.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/08/2020 Initial coding/porting to support nRF52, SAM DUE and SAMD21/SAMD51 boards using W5x00 Ethernet + (Ethernet, EthernetLarge, Ethernet2, Ethernet3 library), WiFiNINA and ESP8266/ESP32-AT shields + ... + 1.4.0 K Hoang 05/09/2021 Add support to Teensy 4.1 using QNEthernet + 1.5.0 K Hoang 17/09/2021 Add support to Portenta_H7, using either WiFi or Vision-shield Ethernet + 1.5.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json` + 1.5.2 K Hoang 01/12/2021 Auto detect ESP32 core for LittleFS. Fix bug in examples for WT32_ETH01 + 1.6.0 K Hoang 10/03/2022 Fix memory leak bug. Optimize code + 1.6.1 K Hoang 12/03/2022 Fix memory management bug + 1.7.0 K Hoang 12/03/2022 Convert to `h-only` style library + 1.7.1 K Hoang 10/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32 + 1.7.2 K Hoang 11/04/2022 Fix missing paragraph in `library.properties` + **********************************************************************************************************************************/ + +#pragma once + +#ifndef MYSQL_GENERIC_ENCRYPT_SHA1_IMPL_H +#define MYSQL_GENERIC_ENCRYPT_SHA1_IMPL_H + +#include + +#define MYSQL_SHA1_K0 0x5a827999 +#define MYSQL_SHA1_K20 0x6ed9eba1 +#define MYSQL_SHA1_K40 0x8f1bbcdc +#define MYSQL_SHA1_K60 0xca62c1d6 + +const uint8_t sha1InitState[] PROGMEM = +{ + 0x01, 0x23, 0x45, 0x67, // H0 + 0x89, 0xab, 0xcd, 0xef, // H1 + 0xfe, 0xdc, 0xba, 0x98, // H2 + 0x76, 0x54, 0x32, 0x10, // H3 + 0xf0, 0xe1, 0xd2, 0xc3 // H4 +}; + +void Encrypt_SHA1::init() +{ + // KH + //memcpy_P(state.b, sha1InitState, HASH_LENGTH); + memcpy(state.b, sha1InitState, HASH_LENGTH); + + byteCount = 0; + bufferOffset = 0; +} + +uint32_t Encrypt_SHA1::rol32(const uint32_t& number, const uint8_t& bits) +{ + return ((number << bits) | (number >> (32 - bits))); +} + +void Encrypt_SHA1::hashBlock() +{ + // SHA1 only for now + uint8_t i; + uint32_t a, b, c, d, e, t; + + a = state.w[0]; + b = state.w[1]; + c = state.w[2]; + d = state.w[3]; + e = state.w[4]; + + for (i = 0; i < 80; i++) + { + if (i >= 16) + { + t = buffer.w[(i + 13) & 15] ^ buffer.w[(i + 8) & 15] ^ buffer.w[(i + 2) & 15] ^ buffer.w[i & 15]; + buffer.w[i & 15] = rol32(t, 1); + } + + if (i < 20) + { + t = (d ^ (b & (c ^ d))) + MYSQL_SHA1_K0; + } + else if (i < 40) + { + t = (b ^ c ^ d) + MYSQL_SHA1_K20; + } + else if (i < 60) + { + t = ((b & c) | (d & (b | c))) + MYSQL_SHA1_K40; + } + else + { + t = (b ^ c ^ d) + MYSQL_SHA1_K60; + } + + t += rol32(a, 5) + e + buffer.w[i & 15]; + e = d; + d = c; + c = rol32(b, 30); + b = a; + a = t; + } + + state.w[0] += a; + state.w[1] += b; + state.w[2] += c; + state.w[3] += d; + state.w[4] += e; +} + +void Encrypt_SHA1::addUncounted(const uint8_t& data) +{ + buffer.b[bufferOffset ^ 3] = data; + bufferOffset++; + + if (bufferOffset == BLOCK_LENGTH) + { + hashBlock(); + bufferOffset = 0; + } +} + +size_t Encrypt_SHA1::write(uint8_t data) +{ + ++byteCount; + addUncounted(data); + + // KH add + return 1; +} + +size_t Encrypt_SHA1::write(uint8_t* data, const int& length) +{ + for (int i = 0; i < length; i++) + { + write(data[i]); + } + + // KH add + return length; +} + +void Encrypt_SHA1::pad() +{ + // Implement SHA-1 padding (fips180-2 §5.1.1) + + // Pad with 0x80 followed by 0x00 until the end of the block + addUncounted(0x80); + + while (bufferOffset != 56) + addUncounted(0x00); + + // Append length in the last 8 bytes + addUncounted(0); // We're only using 32 bit lengths + addUncounted(0); // But SHA-1 supports 64 bit lengths + addUncounted(0); // So zero pad the top bits + addUncounted(byteCount >> 29); // Shifting to multiply by 8 + addUncounted(byteCount >> 21); // as SHA-1 supports bitstreams as well as + addUncounted(byteCount >> 13); // byte. + addUncounted(byteCount >> 5); + addUncounted(byteCount << 3); +} + + +uint8_t* Encrypt_SHA1::result() +{ + // Pad to complete the last block + pad(); + + // Swap byte order back + for (int i = 0; i < 5; i++) + { + uint32_t a, b; + + a = state.w[i]; + b = a << 24; + b |= (a << 8) & 0x00ff0000; + b |= (a >> 8) & 0x0000ff00; + b |= a >> 24; + state.w[i] = b; + } + + // Return pointer to hash (20 characters) + return state.b; +} + + +#define HMAC_IPAD 0x36 +#define HMAC_OPAD 0x5c + +static Encrypt_SHA1 Sha1; + +#endif // MYSQL_GENERIC_ENCRYPT_SHA1_IMPL_H diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Ethernet.h b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Ethernet.h new file mode 100644 index 0000000..1210383 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Ethernet.h @@ -0,0 +1,176 @@ +/********************************************************************************************************************************* + MySQL_Generic_Ethernet.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, WT32_ETH01, Teensy, Portenta_H7, etc. boards + using W5x00, ENC28J60, LAM8742A Ethernet, WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi, Portenta Ethernet/WiFi + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + + Version: 1.7.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/08/2020 Initial coding/porting to support nRF52, SAM DUE and SAMD21/SAMD51 boards using W5x00 Ethernet + (Ethernet, EthernetLarge, Ethernet2, Ethernet3 library), WiFiNINA and ESP8266/ESP32-AT shields + ... + 1.4.0 K Hoang 05/09/2021 Add support to Teensy 4.1 using QNEthernet + 1.5.0 K Hoang 17/09/2021 Add support to Portenta_H7, using either WiFi or Vision-shield Ethernet + 1.5.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json` + 1.5.2 K Hoang 01/12/2021 Auto detect ESP32 core for LittleFS. Fix bug in examples for WT32_ETH01 + 1.6.0 K Hoang 10/03/2022 Fix memory leak bug. Optimize code + 1.6.1 K Hoang 12/03/2022 Fix memory management bug + 1.7.0 K Hoang 12/03/2022 Convert to `h-only` style library + 1.7.1 K Hoang 10/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32 + 1.7.2 K Hoang 11/04/2022 Fix missing paragraph in `library.properties` + **********************************************************************************************************************************/ + +#ifndef MYSQL_GENERIC_ETHERNET_H +#define MYSQL_GENERIC_ETHERNET_H + +#include + +/////////////////////////////////////////////////////// + +#if USE_ETHERNET_PORTENTA_H7 + #include + #include + + EthernetClient client; + + #define SHIELD_TYPE "Ethernet using Portenta_Ethernet Library" + +////////////////////////////////////// + +#elif USE_QN_ETHERNET + #include + using namespace qindesign::network; + + EthernetClient client; + + #define SHIELD_TYPE "Ethernet using Teensy 4.1 QNEthernet Library" + +////////////////////////////////////// + +#elif USE_NATIVE_ETHERNET + #include "NativeEthernet.h" + + EthernetClient client; + + #define SHIELD_TYPE "Ethernet using Teensy 4.1 NativeEthernet Library" + +////////////////////////////////////// + +#elif USE_ETHERNET_LAN8742A + #include + #include + + EthernetClient client; + + #define SHIELD_TYPE "LAN8742A Ethernet & STM32Ethernet Library" + +////////////////////////////////////// + +#elif USE_ETHERNET_LAN8720 + #include + #include + + EthernetClient client; + + #define SHIELD_TYPE "LAN8720 Ethernet & STM32Ethernet Library" + +////////////////////////////////////// + +#elif USE_ETHERNET_GENERIC + #if (ESP32) + #include + + // Optional SPI2 + //#define USING_SPI2 true + + #if USING_SPI2 + #define PIN_MISO HSPI_IOMUX_PIN_NUM_MISO + #define PIN_MOSI HSPI_IOMUX_PIN_NUM_MOSI + #define PIN_SCK HSPI_IOMUX_PIN_NUM_CLK + #define PIN_SS HSPI_IOMUX_PIN_NUM_CS + + #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library on SPI2" + + #else + + #define PIN_MISO MISO + #define PIN_MOSI MOSI + #define PIN_SCK SCK + #define PIN_SS SS + + #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library on SPI" + + #endif + + #else + #if USING_SPI2 + #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library on SPI1" + #else + #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library on SPI0/SPI" + #endif + #endif + + #include "Ethernet_Generic.h" + + EthernetClient client; + +////////////////////////////////////// + +#elif USE_ETHERNET_ESP8266 + #include "Ethernet_ESP8266.h" + + EthernetClient client; + + #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" + +////////////////////////////////////// + +#elif USE_ETHERNET_ENC + #include "EthernetENC.h" + + EthernetClient client; + + #define SHIELD_TYPE "ENC28J60 using EthernetENC Library" + +////////////////////////////////////// + +#elif USE_CUSTOM_ETHERNET + // You have to include an Ethernet library in your program + //#include "Ethernet_XYZ.h" + //#include "EthernetLarge.h" + + EthernetClient client; + + #if !defined(SHIELD_TYPE) + #define SHIELD_TYPE "Custom Ethernet using your choice of Library" + #endif + +////////////////////////////////////// + +#else + + #ifdef USE_ETHERNET_GENERIC + #undef USE_ETHERNET_GENERIC + #endif + #define USE_ETHERNET_GENERIC true + #include "Ethernet_Generic.h" + + EthernetClient client; + + #define SHIELD_TYPE "W5x00 using default Ethernet_Generic Library" + +#endif + +/////////////////////////////////////////////////////// + +#endif //MYSQL_GENERIC_ETHERNET_H diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Packet.h b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Packet.h new file mode 100644 index 0000000..15800a2 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Packet.h @@ -0,0 +1,119 @@ +/********************************************************************************************************************************* + MySQL_Generic_Packet.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, WT32_ETH01, Teensy, Portenta_H7, etc. boards + using W5x00, ENC28J60, LAM8742A Ethernet, WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi, Portenta Ethernet/WiFi + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + + Version: 1.7.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/08/2020 Initial coding/porting to support nRF52, SAM DUE and SAMD21/SAMD51 boards using W5x00 Ethernet + (Ethernet, EthernetLarge, Ethernet2, Ethernet3 library), WiFiNINA and ESP8266/ESP32-AT shields + ... + 1.4.0 K Hoang 05/09/2021 Add support to Teensy 4.1 using QNEthernet + 1.5.0 K Hoang 17/09/2021 Add support to Portenta_H7, using either WiFi or Vision-shield Ethernet + 1.5.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json` + 1.5.2 K Hoang 01/12/2021 Auto detect ESP32 core for LittleFS. Fix bug in examples for WT32_ETH01 + 1.6.0 K Hoang 10/03/2022 Fix memory leak bug. Optimize code + 1.6.1 K Hoang 12/03/2022 Fix memory management bug + 1.7.0 K Hoang 12/03/2022 Convert to `h-only` style library + 1.7.1 K Hoang 10/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32 + 1.7.2 K Hoang 11/04/2022 Fix missing paragraph in `library.properties` + **********************************************************************************************************************************/ + +/********************************************************************************************************************************* + Copyright (c) 2012, 2016 Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + **********************************************************************************************************************************/ + +#pragma once + +#ifndef MYSQL_GENERIC_PACKET_H +#define MYSQL_GENERIC_PACKET_H + +// KH +#include +#include + +#define MYSQL_OK_PACKET 0x00 +#define MYSQL_EOF_PACKET 0xfe +#define MYSQL_ERROR_PACKET 0xff + +// KH, for validating packet size +#define MAX_TRANSMISSION_UNIT 1500 +////// + +class MySQL_Packet +{ + public: + byte *buffer; // buffer for reading packets + + // KH, from v1.0.1 + uint16_t largest_buffer_size = 0; + ////// + + int packet_len; // length of current packet + Client *client; // instance of client class (e.g. EthernetClient) + char *server_version; // save server version from handshake + + MySQL_Packet(Client *client_instance); + virtual ~MySQL_Packet() + { + if (buffer) + { + MYSQL_LOGDEBUG("Free buffer"); + + free(buffer); + } + if (server_version) + { + MYSQL_LOGDEBUG("Free server_version"); + + free(server_version); + } + }; + + bool complete_handshake(char *user, char *password); + void send_authentication_packet(char *user, char *password, char *db = NULL); + void parse_handshake_packet(); + bool scramble_password(char *password, byte *pwd_hash); + + // KH, mod from v1.0.2. Return true if valid packet + bool read_packet(); + + int get_packet_type(); + void parse_error_packet(); + int get_lcb_len(const int& offset); + int read_int(const int& offset, const int& size = 0); + void store_int(byte *buff, const long& value, const int& size); + int read_lcb_int(const int& offset); + int wait_for_bytes(const int& bytes_need); + + void print_packet(); + + private: + byte seed[20]; +}; + +//#include + + +#endif // MYSQL_GENERIC_PACKET_H diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Packet_Impl.h b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Packet_Impl.h new file mode 100644 index 0000000..ca9c2f7 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Packet_Impl.h @@ -0,0 +1,778 @@ +/********************************************************************************************************************************* + MySQL_Generic_Packet_Impl.h + + This file defines the base packet handling code for connecting to a MySQL/MariaDB server and executing queries. + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, WT32_ETH01, Teensy, Portenta_H7, etc. boards + using W5x00, ENC28J60, LAM8742A Ethernet, WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi, Portenta Ethernet/WiFi + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + + Version: 1.7.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/08/2020 Initial coding/porting to support nRF52, SAM DUE and SAMD21/SAMD51 boards using W5x00 Ethernet + (Ethernet, EthernetLarge, Ethernet2, Ethernet3 library), WiFiNINA and ESP8266/ESP32-AT shields + ... + 1.4.0 K Hoang 05/09/2021 Add support to Teensy 4.1 using QNEthernet + 1.5.0 K Hoang 17/09/2021 Add support to Portenta_H7, using either WiFi or Vision-shield Ethernet + 1.5.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json` + 1.5.2 K Hoang 01/12/2021 Auto detect ESP32 core for LittleFS. Fix bug in examples for WT32_ETH01 + 1.6.0 K Hoang 10/03/2022 Fix memory leak bug. Optimize code + 1.6.1 K Hoang 12/03/2022 Fix memory management bug + 1.7.0 K Hoang 12/03/2022 Convert to `h-only` style library + 1.7.1 K Hoang 10/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32 + 1.7.2 K Hoang 11/04/2022 Fix missing paragraph in `library.properties` + **********************************************************************************************************************************/ + +/********************************************************************************************************************************* + Copyright (c) 2012, 2016 Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + **********************************************************************************************************************************/ + +#pragma once + +#ifndef MYSQL_GENERIC_PACKET_IMPL_H +#define MYSQL_GENERIC_PACKET_IMPL_H + +#include + +#include + +// KH, from v1.0.1 +#if ( USE_UIP_ETHERNET || USING_WIFIESPAT_LIB || USING_WIFI_ESP_AT ) + #define MYSQL_DATA_TIMEOUT 10000 // UIPEthernet client wait in milliseconds !!!! +#else + #define MYSQL_DATA_TIMEOUT 6000 // Client wait in milliseconds +#endif +////// + +#define MYSQL_WAIT_INTERVAL 300 // WiFi client wait interval + +/* + Constructor + + Initialize the buffer and store client instance. +*/ +MySQL_Packet::MySQL_Packet(Client *client_instance) +{ + buffer = NULL; + server_version = NULL; + client = client_instance; +} + +/* + send_authentication_packet + + This method builds a response packet used to respond to the server's + challenge packet (called the handshake packet). It includes the user + name and password scrambled using the SHA1 seed from the handshake + packet. It also sets the character set (default is 8 which you can + change to meet your needs). + + Note: you can also set the default database in this packet. See + the code before for a comment on where this happens. + + The authentication packet is defined as follows. + + Bytes Name + ----- ---- + 4 client_flags + 4 max_packet_size + 1 charset_number + 23 (filler) always 0x00... + n (Null-Terminated String) user + n (Length Coded Binary) scramble_buff (1 + x bytes) + n (Null-Terminated String) databasename (optional) + + user[in] User name + password[in] password + db[in] default database +*/ + +void MySQL_Packet::send_authentication_packet(char *user, char *password, char *db) +{ + byte this_buffer[256]; + byte scramble[20]; + + int size_send = 4; + + // client flags + this_buffer[size_send] = byte(0x0D); + this_buffer[size_send + 1] = byte(0xa6); + this_buffer[size_send + 2] = byte(0x03); + this_buffer[size_send + 3] = byte(0x00); + size_send += 4; + + // max_allowed_packet + this_buffer[size_send] = 0; + this_buffer[size_send + 1] = 0; + this_buffer[size_send + 2] = 0; + this_buffer[size_send + 3] = 1; + size_send += 4; + + // charset - default is 8 + this_buffer[size_send] = byte(0x08); + size_send += 1; + + for (int i = 0; i < 24; i++) + this_buffer[size_send + i] = 0x00; + + size_send += 23; + + // user name + memcpy((char *) &this_buffer[size_send], user, strlen(user)); + size_send += strlen(user) + 1; + this_buffer[size_send - 1] = 0x00; + + if (scramble_password(password, scramble)) + { + this_buffer[size_send] = 0x14; + size_send += 1; + + for (int i = 0; i < 20; i++) + this_buffer[i + size_send] = scramble[i]; + + size_send += 20; + this_buffer[size_send] = 0x00; + } + + if (db) + { + memcpy((char *)&this_buffer[size_send], db, strlen(db)); + size_send += strlen(db) + 1; + this_buffer[size_send - 1] = 0x00; + } + else + { + this_buffer[size_send + 1] = 0x00; + size_send += 1; + } + + // Write packet size + int p_size = size_send - 4; + store_int(&this_buffer[0], p_size, 3); + this_buffer[3] = byte(0x01); + + // Write the packet + MYSQL_LOGINFO1("Writing this_buffer, size_send =", size_send); + + client->write((uint8_t*)this_buffer, size_send); + client->flush(); +} + +/* + scramble_password - Build a SHA1 scramble of the user password + + This method uses the password hash seed sent from the server to + form a SHA1 hash of the password. This is used to send back to + the server to complete the challenge and response step in the + authentication handshake. + + password[in] User's password in clear text + pwd_hash[in] Seed from the server + + Returns bool - True = scramble succeeded +*/ +bool MySQL_Packet::scramble_password(char *password, byte *pwd_hash) +{ + byte *digest; + byte hash1[20]; + byte hash2[20]; + byte hash3[20]; + byte pwd_buffer[40]; + + if (strlen(password) == 0) + return false; + + // hash1 + Sha1.init(); + Sha1.print(password); + digest = Sha1.result(); + memcpy(hash1, digest, 20); + + // hash2 + Sha1.init(); + Sha1.write(hash1, 20); + digest = Sha1.result(); + memcpy(hash2, digest, 20); + + // hash3 of seed + hash2 + Sha1.init(); + memcpy(pwd_buffer, &seed, 20); + memcpy(pwd_buffer + 20, hash2, 20); + Sha1.write(pwd_buffer, 40); + digest = Sha1.result(); + memcpy(hash3, digest, 20); + + // XOR for hash4 + for (int i = 0; i < 20; i++) + pwd_hash[i] = hash1[i] ^ hash3[i]; + + return true; +} + +/* + wait_for_bytes - Wait until data is available for reading + + This method is used to permit the connector to respond to servers + that have high latency or execute long queries. The timeout is + set by MYSQL_DATA_TIMEOUT. Adjust this value to match the performance of + your server and network. + + It is also used to read how many bytes in total are available from the + server. Thus, it can be used to know how large a data burst is from + the server. + + bytes_need[in] Bytes count to wait for + + Returns integer - Number of bytes available to read. +*/ +int MySQL_Packet::wait_for_bytes(const int& bytes_need) +{ + const long wait_till = millis() + MYSQL_DATA_TIMEOUT; + int num = 0; + + long now = 0; + + do + { + if ( (now == 0) || ( millis() - now ) > MYSQL_WAIT_INTERVAL ) + { + now = millis(); + num = client->available(); + + MYSQL_LOGLEVEL5_3("MySQL_Packet::wait_for_bytes: Num bytes= ", num, ", need bytes= ", bytes_need); + + if (num >= bytes_need) + break; + } + + yield(); + //delay(0); + } while (now < wait_till); + + if (num == 0 && now >= wait_till) + { + MYSQL_LOGDEBUG("MySQL_Packet::wait_for_bytes: client->stop"); + + //client->stop(); + } + + MYSQL_LOGDEBUG1("MySQL_Packet::wait_for_bytes: OK, Num bytes= ", num); + ////// + + return num; +} + +/* + read_packet - Read a packet from the server and store it in the buffer + + This method reads the bytes sent by the server as a packet. All packets + have a packet header defined as follows. + + Bytes Name + ----- ---- + 3 Packet Length + 1 Packet Number + + Thus, the length of the packet (not including the packet header) can + be found by reading the first 4 bytes from the server then reading + N bytes for the packet payload. +*/ + +//KH, from v1.0.1. Use largest alocated buffer and keep until larger packet is received +// TODO: Pass buffer pointer instead of using global buffer + +// KH, mod from v1.0.2. Return true if valid packet +bool MySQL_Packet::read_packet() +{ + #define PACKET_HEADER_SZ 4 + + byte local[PACKET_HEADER_SZ]; + + MYSQL_LOGLEVEL5("MySQL_Packet::read_packet: step 1"); + + // KH, be sure to safely clear the buffer + if ( largest_buffer_size > 0 ) + memset(buffer, 0, largest_buffer_size); + + // Read packet header + if (wait_for_bytes(PACKET_HEADER_SZ) < PACKET_HEADER_SZ) + { + // KH, add + packet_len = 0; + ////// + + MYSQL_LOGINFO1("MySQL_Packet::read_packet: ", READ_TIMEOUT); + + return false; + } + + MYSQL_LOGLEVEL5("MySQL_Packet::read_packet: step 2"); + + // KH, clear packet_len + packet_len = 0; + + for (int i = 0; i < PACKET_HEADER_SZ; i++) + local[i] = client->read(); + + // Get packet length + packet_len = local[0]; + packet_len += (local[1] << 8); + packet_len += ((uint32_t)local[2] << 16); + + // We must wait for slow arriving packets for Ethernet shields only. + /* + if (wait_for_bytes(packet_len) < packet_len) + { + MYSQL_LOGERROR(READ_TIMEOUT); + return false; + } + */ + + MYSQL_LOGINFO1("MySQL_Packet::read_packet: packet_len= ", packet_len); + + // Check for valid packet. + // KH mod + if ( (packet_len < 0) || ( packet_len > MAX_TRANSMISSION_UNIT ) ) + { + MYSQL_LOGERROR(PACKET_ERROR); + packet_len = 0; + + return false; + } + + if ( largest_buffer_size < packet_len + PACKET_HEADER_SZ ) + { + if (largest_buffer_size == 0 ) + { + // Check if we need to allocate buffer the first time + largest_buffer_size = packet_len + PACKET_HEADER_SZ; + MYSQL_LOGINFO1("MySQL_Packet::read_packet: First time allocate buffer, size = ", largest_buffer_size); + + buffer = (byte *) malloc(largest_buffer_size); + } + else + { + // Check if we need to reallocate buffer + largest_buffer_size = packet_len + PACKET_HEADER_SZ; + MYSQL_LOGINFO1("MySQL_Packet::read_packet: Reallocate buffer, size = ", largest_buffer_size); + + buffer = (byte *) realloc(buffer, largest_buffer_size); + } + } + + if (buffer == NULL) + { + MYSQL_LOGERROR("MySQL_Packet::read_packet: NULL buffer"); + largest_buffer_size = 0; + + return false; + } + else + { + memset(buffer, 0, largest_buffer_size); + } + + for (int i = 0; i < PACKET_HEADER_SZ; i++) + buffer[i] = local[i]; + + for (int i = PACKET_HEADER_SZ; i < packet_len + PACKET_HEADER_SZ; i++) + buffer[i] = client->read(); + + MYSQL_LOGDEBUG("MySQL_Packet::read_packet: exit"); + + return true; +} + + +/* + parse_handshake_packet - Decipher the server's challenge data + + This method reads the server version string and the seed from the + server. The handshake packet is defined as follows. + + Bytes Name + ----- ---- + 1 protocol_version + n (Null-Terminated String) server_version + 4 thread_id + 8 scramble_buff + 1 (filler) always 0x00 + 2 server_capabilities + 1 server_language + 2 server_status + 2 server capabilities (two upper bytes) + 1 length of the scramble seed + 10 (filler) always 0 + n rest of the plugin provided data + (at least 12 bytes) + 1 \0 byte, terminating the second part of + a scramble seed +*/ +// KH, TODO: Pass buffer pointer instead of using global buffer +void MySQL_Packet::parse_handshake_packet() +{ + if (!buffer) + { + MYSQL_LOGERROR("MySQL_Packet::parse_handshake_packet: NULL buffer"); + return; + } + + int i = 5; + + do + { + i++; + } while (buffer[i - 1] != 0x00); + + if (i > 5) + { + server_version = (char *) malloc(i - 5); + + if (server_version) + { + strncpy(server_version, (char *) &buffer[5], i - 5); + server_version[i - 5 - 1] = 0; + } + } + + // Capture the first 8 characters of seed + i += 4; // Skip thread id + + for (int j = 0; j < 8; j++) + { + seed[j] = buffer[i + j]; + } + + // Capture rest of seed + i += 27; // skip ahead + + for (int j = 0; j < 12; j++) + { + seed[j + 8] = buffer[i + j]; + } +} + +/* + parse_error_packet - Display the error returned from the server + + This method parses an error packet from the server and displays the + error code and text via Serial.print. The error packet is defined + as follows. + + Note: the error packet is already stored in the buffer since this + packet is not an expected response. + + Bytes Name + ----- ---- + 1 field_count, always = 0xff + 2 errno + 1 (sqlstate marker), always '#' + 5 sqlstate (5 characters) + n message +*/ +// KH, TODO: Pass buffer pointer instead of using global buffer +void MySQL_Packet::parse_error_packet() +{ + MYSQL_LOGDEBUG2("Error: ", read_int(5, 2), " = "); + + if (!buffer) + { + MYSQL_LOGERROR("MySQL_Packet::parse_error_packet: NULL buffer"); + return; + } + + for (int i = 0; i < packet_len - 9; i++) + { + MYSQL_LOGDEBUG0((char)buffer[i + 13]); + } + + MYSQL_LOGDEBUG0LN("."); +} + + +/* + get_packet_type - Returns the packet type received from the server. + + Bytes Name + ----- ---- + 1 (Length Coded Binary) field_count, always = 0 + 1-9 (Length Coded Binary) affected_rows + 1-9 (Length Coded Binary) insert_id + 2 server_status + 2 warning_count + n (until end of packet) message + + Returns integer - 0 = successful parse, packet type if not an Ok packet +*/ +// KH, TODO: Pass buffer pointer instead of using global buffer +int MySQL_Packet::get_packet_type() +{ + if (!buffer) + { + MYSQL_LOGERROR("MySQL_Packet::get_packet_type: NULL buffer"); + return -1; + } + + int type = buffer[4]; + + MYSQL_LOGDEBUG1("MySQL_Packet::get_packet_type: packet type= ", type); + + if (type == MYSQL_OK_PACKET) + { + MYSQL_LOGDEBUG("MySQL_Packet::get_packet_type: packet type= MYSQL_OK_PACKET"); + } + else if (type == MYSQL_EOF_PACKET) + { + MYSQL_LOGDEBUG("MySQL_Packet::get_packet_type: packet type= MYSQL_EOF_PACKET"); + } + else if (type == MYSQL_ERROR_PACKET) + { + MYSQL_LOGDEBUG("MySQL_Packet::get_packet_type: packet type= MYSQL_ERROR_PACKET"); + } + else + { + MYSQL_LOGDEBUG("MySQL_Packet::get_packet_type: Packet Type Error"); + } + + return type; +} + + +/* + get_lcb_len - Retrieves the length of a length coded binary value + + This reads the first byte from the offset into the buffer and returns + the number of bytes (size) that the integer consumes. It is used in + conjunction with read_int() to read length coded binary integers + from the buffer. + + Returns integer - number of bytes integer consumes +*/ +// KH, TODO: Pass buffer pointer instead of using global buffer +int MySQL_Packet::get_lcb_len(const int& offset) +{ + if (!buffer) + { + MYSQL_LOGERROR("MySQL_Packet::get_lcb_len: NULL buffer"); + return 0; + } + + int read_len = buffer[offset]; + + if (read_len > 250) + { + // read type: + byte type = buffer[offset + 1]; + + if (type == 0xfc) + read_len = 2; + else if (type == 0xfd) + read_len = 3; + else if (type == 0xfe) + read_len = 8; + } + else + { + read_len = 1; + } + + MYSQL_LOGDEBUG1("MySQL_Packet::get_lcb_len: read_len= ", read_len); + + return read_len; +} + +/* + read_int - Retrieve an integer from the buffer in size bytes. + + This reads an integer from the buffer at offset position indicated for + the number of bytes specified (size). + + offset[in] offset from start of buffer + size[in] number of bytes to use to store the integer + + Returns integer - integer from the buffer +*/ +// KH, TODO: Pass buffer pointer instead of using global buffer +int MySQL_Packet::read_int(const int& offset, const int& size) +{ + int value = 0; + int new_size = 0; + + if (!buffer) + { + MYSQL_LOGERROR("MySQL_Packet::read_int: NULL buffer"); + return -1; + } + + if (size == 0) + new_size = get_lcb_len(offset); + + if (size == 1) + return buffer[offset]; + + new_size = size; + int shifter = (new_size - 1) * 8; + + for (int i = new_size; i > 0; i--) + { + value += (buffer[i - 1] << shifter); + shifter -= 8; + } + + return value; +} + + +/* + store_int - Store an integer value into a byte array of size bytes. + + This writes an integer into the buffer at the current position of the + buffer. It will transform an integer of size to a length coded binary + form where 1-3 bytes are used to store the value (set by size). + + buff[in] pointer to location in internal buffer where the + integer will be stored + value[in] integer value to be stored + size[in] number of bytes to use to store the integer +*/ +void MySQL_Packet::store_int(byte *buff, const long& value, const int& size) +{ + if (!buff) + { + MYSQL_LOGERROR("MySQL_Packet::store_int: NULL buffer"); + return; + } + + memset(buff, 0, size); + + if (value <= 0xff) + buff[0] = (byte)value; + else if (value <= 0xffff) + { + buff[0] = (byte)value; + buff[1] = (byte)(value >> 8); + } + else if (value <= 0xffffff) + { + buff[0] = (byte)value; + buff[1] = (byte)(value >> 8); + buff[2] = (byte)(value >> 16); + } + else if (value > 0xffffff) + { + buff[0] = (byte)value; + buff[1] = (byte)(value >> 8); + buff[2] = (byte)(value >> 16); + buff[3] = (byte)(value >> 24); + } +} + +/* + read_lcb_int - Read an integer with len encoded byte + + This reads an integer from the buffer looking at the first byte in the offset + as the encoded length of the integer. + + offset[in] offset from start of buffer + + Returns integer - integer from the buffer +*/ +// KH, TODO: Pass buffer pointer instead of using global buffer +int MySQL_Packet::read_lcb_int(const int& offset) +{ + int len_size = 0; + int value = 0; + + if (!buffer) + { + MYSQL_LOGERROR("MySQL_Packet::read_lcb_int: NULL buffer"); + return -1; + } + + len_size = buffer[offset]; + + if (len_size < 252) + { + return buffer[offset]; + } + else if (len_size == 252) + { + len_size = 2; + } + else if (len_size == 253) + { + len_size = 3; + } + else + { + len_size = 8; + } + + int shifter = (len_size - 1) * 8; + + for (int i = len_size; i > 0; i--) + { + value += (buffer[offset + i] << shifter); + shifter -= 8; + } + + return value; +} + +/* + print_packet - Print the contents of a packet via Serial.print + + This method is a diagnostic method. It is best used to decipher a + packet from the server (or before being sent to the server). If you + are looking for additional program memory space, you can safely + delete this method. +*/ +// KH, TODO: Pass buffer pointer instead of using global buffer +void MySQL_Packet::print_packet() +{ + if (!buffer) + { + MYSQL_LOGERROR("MySQL_Packet::print_packet: NULL buffer"); + return; + } + + MYSQL_LOGDEBUG3("Packet: ", buffer[3], " contains no. bytes = ", packet_len + 3); + + MYSQL_LOGDEBUG0(" HEX: "); + + for (int i = 0; i < packet_len + 3; i++) + { + MYSQL_LOGDEBUG0(String(buffer[i], HEX)); + MYSQL_LOGDEBUG0(" "); + } + + MYSQL_LOGDEBUG0LN(""); + + MYSQL_LOGDEBUG0("ASCII: "); + + for (int i = 0; i < packet_len + 3; i++) + MYSQL_LOGDEBUG0((char)buffer[i]); + + MYSQL_LOGDEBUG0LN(""); +} + +#endif // MYSQL_GENERIC_PACKET_IMPL_H diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Query.h b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Query.h new file mode 100644 index 0000000..fd0d9e5 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Query.h @@ -0,0 +1,146 @@ +/********************************************************************************************************************************* + MySQL_Generic_Query.h + + This header file defines a query class for running queries on a MySQL/MariaDB server. + You can issue any command using SQL statements for inserting or retrieving data. + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, WT32_ETH01, Teensy, Portenta_H7, etc. boards + using W5x00, ENC28J60, LAM8742A Ethernet, WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi, Portenta Ethernet/WiFi + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + + Version: 1.7.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/08/2020 Initial coding/porting to support nRF52, SAM DUE and SAMD21/SAMD51 boards using W5x00 Ethernet + (Ethernet, EthernetLarge, Ethernet2, Ethernet3 library), WiFiNINA and ESP8266/ESP32-AT shields + ... + 1.4.0 K Hoang 05/09/2021 Add support to Teensy 4.1 using QNEthernet + 1.5.0 K Hoang 17/09/2021 Add support to Portenta_H7, using either WiFi or Vision-shield Ethernet + 1.5.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json` + 1.5.2 K Hoang 01/12/2021 Auto detect ESP32 core for LittleFS. Fix bug in examples for WT32_ETH01 + 1.6.0 K Hoang 10/03/2022 Fix memory leak bug. Optimize code + 1.6.1 K Hoang 12/03/2022 Fix memory management bug + 1.7.0 K Hoang 12/03/2022 Convert to `h-only` style library + 1.7.1 K Hoang 10/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32 + 1.7.2 K Hoang 11/04/2022 Fix missing paragraph in `library.properties` + **********************************************************************************************************************************/ + +/********************************************************************************************************************************* + Copyright (c) 2012, 2016 Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + **********************************************************************************************************************************/ + +#pragma once + +#ifndef MYSQL_GENERIC_QUERY_H +#define MYSQL_GENERIC_QUERY_H + +#include "MySQL_Generic_Debug.h" + +#include + +// Comment this if you don't need SELECT queries to reduce memory footprint of the library. +#define WITH_SELECT + +#define MAX_FIELDS 0x20 // Maximum number of fields. Reduce to save memory. Default=32 + +#ifdef WITH_SELECT + +// Structure for retrieving a field (minimal implementation). +typedef struct +{ + char *db; + char *table; + char *name; +} field_struct; + +// Structure for storing result set metadata. +typedef struct +{ + int num_fields; // actual number of fields + field_struct *fields[MAX_FIELDS]; +} column_names; + +// Structure for storing row data. +typedef struct +{ + char *values[MAX_FIELDS]; +} row_values; + +#endif // WITH_SELECT + +class MySQL_Query +{ + public: + MySQL_Query(MySQL_Connection *connection); + ~MySQL_Query(); + bool execute(const char *query, bool progmem = false); + + private: + bool execute_query(const int& query_len); + +#ifdef WITH_SELECT + + public: + void close(); + column_names *get_columns(); + row_values *get_next_row(); + void show_results(); + + int get_rows_affected() + { + return rows_affected; + } + + int get_last_insert_id() + { + return last_insert_id; + } + + private: + void free_columns_buffer(); + void free_row_buffer(); + bool clear_ok_packet(); + + char *read_string(int *offset); + int get_field(field_struct *fs); + int get_row(); + bool get_fields(); + int get_row_values(); + column_names *query_result(); + + bool columns_read; + int num_cols; + + column_names columns; + row_values row; + + int rows_affected; + int last_insert_id; + +#endif + + MySQL_Connection *conn; +}; + +//#include + + +#endif // MYSQL_GENERIC_QUERY_H diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Query_Impl.h b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Query_Impl.h new file mode 100644 index 0000000..7544209 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_Query_Impl.h @@ -0,0 +1,773 @@ +/********************************************************************************************************************************* + MySQL_Generic_Query_Impl.h + + This file defines a query class for running queries on a MySQL/MariaDB server. + You can issue any command using SQL statements for inserting or retrieving data. + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, WT32_ETH01, Teensy, Portenta_H7, etc. boards + using W5x00, ENC28J60, LAM8742A Ethernet, WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi, Portenta Ethernet/WiFi + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + + Version: 1.7.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/08/2020 Initial coding/porting to support nRF52, SAM DUE and SAMD21/SAMD51 boards using W5x00 Ethernet + (Ethernet, EthernetLarge, Ethernet2, Ethernet3 library), WiFiNINA and ESP8266/ESP32-AT shields + ... + 1.4.0 K Hoang 05/09/2021 Add support to Teensy 4.1 using QNEthernet + 1.5.0 K Hoang 17/09/2021 Add support to Portenta_H7, using either WiFi or Vision-shield Ethernet + 1.5.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json` + 1.5.2 K Hoang 01/12/2021 Auto detect ESP32 core for LittleFS. Fix bug in examples for WT32_ETH01 + 1.6.0 K Hoang 10/03/2022 Fix memory leak bug. Optimize code + 1.6.1 K Hoang 12/03/2022 Fix memory management bug + 1.7.0 K Hoang 12/03/2022 Convert to `h-only` style library + 1.7.1 K Hoang 10/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32 + 1.7.2 K Hoang 11/04/2022 Fix missing paragraph in `library.properties` + **********************************************************************************************************************************/ + +/********************************************************************************************************************************* + Copyright (c) 2012, 2016 Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + **********************************************************************************************************************************/ + +#pragma once + +#ifndef MYSQL_GENERIC_QUERY_IMPL_H +#define MYSQL_GENERIC_QUERY_IMPL_H + +#define COMMAND_HEADER_LEN 5 + +/* + Constructor + + Requires an instance of the MySQL_Connection class to communicate with a + MySQL server. + + connection[in] Connection to a MySQL server - must be connected. +*/ +MySQL_Query::MySQL_Query(MySQL_Connection *connection) +{ + conn = connection; + +#ifdef WITH_SELECT + columns.num_fields = 0; + + for (int f = 0; f < MAX_FIELDS; f++) + { + columns.fields[f] = NULL; + row.values[f] = NULL; + } + + columns_read = false; + rows_affected = -1; + last_insert_id = -1; +#endif +} + +/* + Destructor +*/ +MySQL_Query::~MySQL_Query() +{ +#ifdef WITH_SELECT + close(); +#endif +} + +/* + execute - Execute a SQL statement + + This method executes the query specified as a character array. It copies + the query to the local buffer then calls the execute_query() method to + execute the query. + + If a result set is available after the query executes, the field + packets and rows can be read separately using the get_field() and + get_row() methods. + + query[in] SQL statement (using normal memory access) + progmem[in] True if string is in program memory + + Returns bool - True = a result set is available for reading +*/ + +// TODO: Pass buffer pointer instead of using global buffer +bool MySQL_Query::execute(const char *query, bool progmem) +{ + int query_len; // length of query + + if (!conn->connected()) + { + MYSQL_LOGERROR(NOT_CONNECTED); + + return false; + } + + if (progmem) + { + query_len = (int) strlen_P(query); + } + else + { + query_len = (int) strlen(query); + } + + // KH, new from v1.0.1 + if ( conn->largest_buffer_size < query_len + COMMAND_HEADER_LEN ) + { + if ( conn->largest_buffer_size == 0 ) + { + // Check if we need to allocate buffer the first time. Don't need, but to be safe + conn->largest_buffer_size = query_len + COMMAND_HEADER_LEN; + MYSQL_LOGWARN1("MySQL_Query::execute: First time allocate buffer, size = ", conn->largest_buffer_size); + + conn->buffer = (byte *) malloc(conn->largest_buffer_size); + } + else + { + // Check if we need to reallocate buffer + conn->largest_buffer_size = query_len + COMMAND_HEADER_LEN; + MYSQL_LOGWARN1("MySQL_Query::execute: Reallocate buffer, size = ", conn->largest_buffer_size); + + conn->buffer = (byte *) realloc(conn->buffer, conn->largest_buffer_size); + } + } + else + { + MYSQL_LOGDEBUG3("MySQL_Query::execute: Reuse allocated buffer, conn->largest_buffer_size = ", conn->largest_buffer_size, " > ", query_len + COMMAND_HEADER_LEN); + } + + if (conn->buffer == NULL) + { + MYSQL_LOGERROR("MySQL_Query::execute: NULL buffer"); + + return false; + } + else + { + memset(conn->buffer, 0, conn->largest_buffer_size); + } + ////// + + // Write query to packet + if (progmem) + { + for (int c = 0; c < query_len; c++) + conn->buffer[c + COMMAND_HEADER_LEN] = pgm_read_byte_near(query + c); + } + else + { + memcpy(&conn->buffer[COMMAND_HEADER_LEN], query, query_len); + } + + MYSQL_LOGDEBUG1("MySQL_Query::execute: query = ", (char *) &conn->buffer[COMMAND_HEADER_LEN] ); + + // Send the query + return execute_query(query_len); +} + + +/* + execute_query - execute a query + + This method sends the query string to the server and waits for a + response. If the result is a result set, it returns true, if it is + an error, it processes the error packet and prints the error via + Serial.print(). If it is an Ok packet, it parses the packet and + returns false. + + query_len[in] Number of bytes in the query string + + Returns bool - true = result set available, + false = no result set returned. +*/ +// TODO: Pass buffer pointer instead of using global buffer +bool MySQL_Query::execute_query(const int& query_len) +{ + if (!conn->buffer) + { + MYSQL_LOGERROR("MySQL_Query::execute_query: NULL buffer"); + return false; + } + + // Reset the rows affected and last insert id before query. + rows_affected = -1; + last_insert_id = -1; + + conn->store_int(&conn->buffer[0], query_len + 1, 3); + conn->buffer[3] = byte(0x00); + conn->buffer[4] = byte(0x03); // command packet + + // Send the query + MYSQL_LOGDEBUG1("MySQL_Query::execute_query: query = ", (char *) &conn->buffer[COMMAND_HEADER_LEN] ); + + conn->client->write((uint8_t*)conn->buffer, query_len + COMMAND_HEADER_LEN); + conn->client->flush(); + + // Read a response packet and check it for Ok or Error. + // KH mod, check if packet_len is valid. + if ( !conn->read_packet() || ( conn->packet_len <= 0 ) || ( conn->packet_len > MAX_TRANSMISSION_UNIT ) ) + return false; + ////// + + int res = conn->get_packet_type(); + + if (res == MYSQL_ERROR_PACKET) + { + conn->parse_error_packet(); + return false; + } + else if (res == MYSQL_OK_PACKET || res == MYSQL_EOF_PACKET) + { + // Read the rows affected and last insert id. + int loc1 = conn->buffer[5]; // Location of rows affected + int loc2 = 5; + + if (loc1 < 252) + { + loc2++; + } + else if (loc1 == 252) + { + loc2 += 2; + } + else if (loc1 == 253) + { + loc2 += 3; + } + else + { + loc2 += 8; + } + + rows_affected = conn->read_lcb_int(5); + + if (rows_affected > 0) + { + last_insert_id = conn->read_lcb_int(loc2); + } + + return true; + } + + // Not an Ok packet, so we now have the result set to process. +#ifdef WITH_SELECT + columns_read = false; +#endif + return true; +} + +#ifdef WITH_SELECT +/* + Close + + Takes care of removing allocated memory. +*/ +void MySQL_Query::close() +{ + free_columns_buffer(); + free_row_buffer(); +} + + +/* + get_columns - Get a list of the columns (fields) + + This method returns an instance of the column_names structure + that contains an array of fields. + + Note: you should call free_columns_buffer() after consuming + the field data to free memory. +*/ +column_names *MySQL_Query::get_columns() +{ + free_columns_buffer(); + free_row_buffer(); + num_cols = 0; + + if (get_fields()) + { + columns_read = true; + return &columns; + } + + return NULL; +} + + +/* + get_next_row - Iterator for reading rows from a result set + + This method returns an instance of a structure (row_values) + that contains an array of strings representing the row + values returned from the server. + + The caller can use the values however needed - by first + converting them to a specific type or as a string. +*/ +row_values *MySQL_Query::get_next_row() +{ + int res = 0; + + free_row_buffer(); + + // Read the rows + MYSQL_LOGDEBUG("MySQL_Query::get_next_row: get_row_values"); + + res = get_row_values(); + + if (res != MYSQL_EOF_PACKET) + { + return &row; + } + + return NULL; +} + +/* + show_results - Show a result set from the server via Serial.print + + This method reads a result from the server and displays it via the + via the Serial.print methods. It can be used in cases where + you may want to issue a SELECT or SHOW and see the results on your + computer from the Arduino. + + It is also a good example of how to read a result set from the + because it uses the public methods designed to return result + sets from the server. +*/ +void MySQL_Query::show_results() +{ + column_names *cols; + int rows = 0; + + // Get the columns + cols = get_columns(); + + if (cols == NULL) + { + return; + } + + for (int f = 0; f < columns.num_fields; f++) + { + MYSQL_LOGERROR0(columns.fields[f]->name); + + if (f < columns.num_fields - 1) + MYSQL_LOGERROR0(','); + } + + MYSQL_LOGERROR0LN(""); + + // Read the rows + while (get_next_row()) + { + rows++; + + for (int f = 0; f < columns.num_fields; f++) + { + MYSQL_LOGERROR0(row.values[f]); + + if (f < columns.num_fields - 1) + MYSQL_LOGERROR0(','); + } + + free_row_buffer(); + MYSQL_LOGERROR0LN(""); + } + + // Report how many rows were read + MYSQL_LOGERROR0(rows); + MYSQL_LOGERROR0LN(ROWS); + + free_columns_buffer(); + + // Free any post-query messages in queue for stored procedures + clear_ok_packet(); +} + + +/* + clear_ok_packet - clear last Ok packet (if present) + + This method reads the header and status to see if this is an Ok packet. + If it is, it reads the packet and discards it. This is useful for + processing result sets from stored procedures. + + Returns False if the packet was not an Ok packet. +*/ +bool MySQL_Query::clear_ok_packet() +{ + int num = 0; + + do + { + num = conn->client->available(); + + if (num > 0) + { + // KH mod, check if packet_len is valid. + if ( !conn->read_packet() || ( conn->packet_len <= 0 ) || ( conn->packet_len > MAX_TRANSMISSION_UNIT ) ) + return false; + ////// + + if (conn->get_packet_type() != MYSQL_OK_PACKET) + { + conn->parse_error_packet(); + return false; + } + } + } while (num > 0); + + rows_affected = -1; + last_insert_id = -1; + + return true; +} + + +/* + free_columns_buffer - Free memory allocated for column names + + This method frees the memory allocated during the get_columns() + method. + + NOTICE: Failing to call this method after calling get_columns() + and consuming the column names, types, etc. will result + in a memory leak. The size of the leak will depend on + the size of the combined column names (bytes). +*/ +void MySQL_Query::free_columns_buffer() +{ + // clear the columns + for (int f = 0; f < MAX_FIELDS; f++) + { + if (columns.fields[f] != NULL) + { + free(columns.fields[f]->db); + free(columns.fields[f]->table); + free(columns.fields[f]->name); + free(columns.fields[f]); + } + + columns.fields[f] = NULL; + } + + num_cols = 0; + columns_read = false; +} + + +/* + free_row_buffer - Free memory allocated for row values + + This method frees the memory allocated during the get_next_row() + method. + + NOTICE: You must call this method at least once after you + have consumed the values you wish to process. Failing + to do will result in a memory leak equal to the sum + of the length of values and one byte for each max cols. +*/ +void MySQL_Query::free_row_buffer() +{ + // clear the row + for (int f = 0; f < MAX_FIELDS; f++) + { + if (row.values[f] != NULL) + { + free(row.values[f]); + } + + row.values[f] = NULL; + } +} + + +/* + read_string - Retrieve a string from the buffer + + This reads a string from the buffer. It reads the length of the string + as the first byte. + + offset[in] offset from start of buffer + + Returns string - String from the buffer +*/ +char *MySQL_Query::read_string(int *offset) +{ + char *str; + + MYSQL_LOGLEVEL5("MySQL_Query::read_string: step 1"); + + int len_bytes = conn->get_lcb_len(conn->buffer[*offset]); + int len = conn->read_int(*offset, len_bytes); + + MYSQL_LOGINFO1("MySQL_Query::read_string: offset = ", *offset); + MYSQL_LOGINFO3("MySQL_Query::read_string: len = ", len, "len_bytes =", len_bytes); + + if (len == 251) + { + // This is a null field. + str = (char *) malloc(5); + strcpy(str, "NULL"); + str[4] = 0x00; + *offset += len_bytes; + } + + // KH, new from v1.0.1 + if ( (len < 251) && (len > 0) ) + { + // TODO, KH, check where str is freed + str = (char *) malloc(len + 1); + + MYSQL_LOGINFO3("MySQL_Query::read_string: len = ", len, "conn->buffer size =", conn->largest_buffer_size); + + strncpy(str, (char *)&conn->buffer[*offset + len_bytes], len); + str[len] = 0x00; + *offset += len_bytes + len; + + MYSQL_LOGDEBUG1("MySQL_Query::read_string: str = ", str); + + return str; + } + + MYSQL_LOGDEBUG("MySQL_Query::read_string: return NULL"); + + return NULL; + ////// +} + + +/* + get_field - Read a field from the server + + This method reads a field packet from the server. Field packets are + defined as: + + Bytes Name + ----- ---- + n (Length Coded String) catalog + n (Length Coded String) db + n (Length Coded String) table + n (Length Coded String) org_table + n (Length Coded String) name + n (Length Coded String) org_name + 1 (filler) + 2 charsetnr + 4 length + 1 type + 2 flags + 1 decimals + 2 (filler), always 0x00 + n (Length Coded Binary) default + + Note: the sum of all db, column, and field names must be < 255 in length +*/ +int MySQL_Query::get_field(field_struct *fs) +{ + int len_bytes; + int len; + int offset; + + // KH add + if (conn->buffer == NULL) + { + MYSQL_LOGERROR("MySQL_Query::get_field: NULL buffer"); + return MYSQL_ERROR_PACKET; + } + ////// + + // Read field packets until EOF + MYSQL_LOGDEBUG("MySQL_Query::get_field: read_packet"); + + // KH mod, check if packet_len is valid. + if ( !conn->read_packet() || ( conn->packet_len <= 0 ) || ( conn->packet_len > MAX_TRANSMISSION_UNIT ) ) + return MYSQL_ERROR_PACKET; + ////// + + // KH, bug here and read garbage + if (conn->buffer && conn->buffer[4] != MYSQL_EOF_PACKET) + { + // calculate location of db + len_bytes = conn->get_lcb_len(4); + len = conn->read_int(4, len_bytes); + offset = 4 + len_bytes + len; + + MYSQL_LOGDEBUG("MySQL_Query::get_field: read_string to fs->db"); + fs->db = read_string(&offset); + MYSQL_LOGDEBUG1("MySQL_Query::get_field: fs->db = ", fs->db); + + // get table + MYSQL_LOGDEBUG("MySQL_Query::get_field: read_string to fs->table"); + fs->table = read_string(&offset); + MYSQL_LOGDEBUG1("MySQL_Query::get_field: fs->table = ", fs->table); + + // calculate location of name + len_bytes = conn->get_lcb_len(offset); + len = conn->read_int(offset, len_bytes); + offset += len_bytes + len; + + // get name + MYSQL_LOGDEBUG("MySQL_Query::get_field: read_string to fs->name"); + fs->name = read_string(&offset); + MYSQL_LOGDEBUG1("MySQL_Query::get_field: fs->name = ", fs->name); + + //return 0; + return MYSQL_OK_PACKET; + } + else if (conn->buffer && conn->buffer[4] == MYSQL_EOF_PACKET) + return MYSQL_EOF_PACKET; + else + return MYSQL_ERROR_PACKET; + ////// +} + + +/* + get_row - Read a row from the server and store it in the buffer + + This reads a single row and stores it in the buffer. If there are + no more rows, it returns MYSQL_EOF_PACKET. A row packet is defined as + follows. + + Bytes Name + ----- ---- + n (Length Coded String) (column value) + ... + + Note: each column is store as a length coded string concatenated + as a single stream + + Returns integer - MYSQL_EOF_PACKET if no more rows, 0 if more rows available +*/ +int MySQL_Query::get_row() +{ + // Read row packets + // KH mod, check if packet_len is valid.// get row + MYSQL_LOGDEBUG("MySQL_Query::get_row: read_packet"); + + if ( !conn->read_packet() || ( conn->packet_len <= 0 ) || ( conn->packet_len > MAX_TRANSMISSION_UNIT ) ) + return MYSQL_EOF_PACKET; //MYSQL_ERROR_PACKET; + ////// + + if (conn->buffer && conn->buffer[4] != MYSQL_EOF_PACKET) + return MYSQL_OK_PACKET; + + return MYSQL_EOF_PACKET; +} + + +/* + get_fields - reads the fields from the read buffer + + This method is used to read the field names, types, etc. + from the read buffer and store them in the columns structure + in the class. +*/ +bool MySQL_Query::get_fields() +{ + int num_fields = 0; + int res = 0; + + if (conn->buffer == NULL) + { + MYSQL_LOGERROR("MySQL_Query::get_fields: NULL buffer"); + return false; + } + + num_fields = conn->buffer[4]; // From result header packet + columns.num_fields = num_fields; + num_cols = num_fields; // Save this for later use + + for (int f = 0; f < num_fields; f++) + { + field_struct *field = (field_struct *) malloc(sizeof(field_struct)); + res = get_field(field); + + // KH + //if (res == MYSQL_EOF_PACKET) + if ( (res == MYSQL_EOF_PACKET) || (res == MYSQL_ERROR_PACKET) ) + { + MYSQL_LOGERROR(BAD_MOJO); + + return false; + } + + columns.fields[f] = field; + } + + // KH mod, check if packet_len is valid. + // EOF packet + MYSQL_LOGDEBUG("MySQL_Query::get_fields: read_packet"); + + if ( !conn->read_packet() || ( conn->packet_len <= 0 ) || ( conn->packet_len > MAX_TRANSMISSION_UNIT ) ) + return false; + ////// + + return true; +} + +/* + get_row_values - reads the row values from the read buffer + + This method is used to read the row column values + from the read buffer and store them in the row structure + in the class. +*/ +int MySQL_Query::get_row_values() +{ + int res = 0; + int offset = 0; + + // It is an error to try to read rows before columns + // are read. + if (!columns_read) + { + MYSQL_LOGERROR(READ_COLS); + + return MYSQL_EOF_PACKET; + } + + // Drop any row data already read + free_row_buffer(); + + // Read a row + MYSQL_LOGDEBUG("MySQL_Query::get_row_values: get_row"); + + res = get_row(); + + // KH mod + if ( (res != MYSQL_EOF_PACKET) && (res != MYSQL_ERROR_PACKET) ) + { + offset = 4; + + for (int f = 0; f < num_cols; f++) + { + row.values[f] = read_string(&offset); + } + } + + return res; +} + +#endif // WITH_SELECT + +#endif // MYSQL_GENERIC_QUERY_IMPL_H diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_WiFi.h b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_WiFi.h new file mode 100644 index 0000000..e1ba379 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_WiFi.h @@ -0,0 +1,93 @@ +/**************************************************************************************************************************** + MySQL_Generic_WiFi.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, WT32_ETH01, Teensy, Portenta_H7, etc. boards + using W5x00, ENC28J60, LAM8742A Ethernet, WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi, Portenta Ethernet/WiFi + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + + Version: 1.7.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/08/2020 Initial coding/porting to support nRF52, SAM DUE and SAMD21/SAMD51 boards using W5x00 Ethernet + (Ethernet, EthernetLarge, Ethernet2, Ethernet3 library), WiFiNINA and ESP8266/ESP32-AT shields + ... + 1.4.0 K Hoang 05/09/2021 Add support to Teensy 4.1 using QNEthernet + 1.5.0 K Hoang 17/09/2021 Add support to Portenta_H7, using either WiFi or Vision-shield Ethernet + 1.5.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json` + 1.5.2 K Hoang 01/12/2021 Auto detect ESP32 core for LittleFS. Fix bug in examples for WT32_ETH01 + 1.6.0 K Hoang 10/03/2022 Fix memory leak bug. Optimize code + 1.6.1 K Hoang 12/03/2022 Fix memory management bug + 1.7.0 K Hoang 12/03/2022 Convert to `h-only` style library + 1.7.1 K Hoang 10/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32 + 1.7.2 K Hoang 11/04/2022 Fix missing paragraph in `library.properties` + **********************************************************************************************************************************/ + +#pragma once + +#ifndef MYSQL_GENERIC_WIFI_H +#define MYSQL_GENERIC_WIFI_H + +// ESP8266 and ESP32 built-in WiFi have highest priority and will override all other settings +#if (ESP8266) + #warning Using ESP8266 built-in WiFi + #include + WiFiClient client; + +#elif (ESP32) + #warning Using ESP32 built-in WiFi + #include + WiFiClient client; + +#elif USING_WIFI_ESP8266_AT + // Changed from USING_WIFI_ESP_AT to USING_WIFI_ESP8266_AT from v1.0.2 + #error Using ESP8266_AT Library not supported now + // Uncomment to use ESP32-AT commands + //#define USE_ESP32_AT true + + #include + #include + #include + ESP8266_AT_Client client; +#elif (USING_WIFININA_GENERIC) + #warning Using WiFiNINA_Generic Library + #include "WiFiNINA_Generic.h" + #include "WiFiClient_Generic.h" + WiFiClient client; + +#elif (USING_WIFININA) + #warning Using WiFiNINA Library + #include "WiFiNINA.h" + #include "WiFiClient.h" + WiFiClient client; + +#elif (USING_WIFIESPAT_LIB) + #warning Using WiFiEspAT Library + #include "WiFiEspAT.h" + WiFiClient client; + + // KH, from v1.5.0 +#elif USE_WIFI_PORTENTA_H7 + #warning Using Portenta_H7 WiFi Library + #include "WiFi.h" + WiFiClient client; + +#elif (USING_WIFI_CUSTOM) + #warning Using Custom WiFi Library. To modify according to Library. + #include "WiFi_XYZ.h" + #include "WiFi_XYZ_Client.h" + WiFiClient client; + +#else + #error You must specify a WiFi Library to use. + +#endif + +#endif //MYSQL_GENERIC_WIFI_H diff --git a/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_WiFiNINA.h b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_WiFiNINA.h new file mode 100644 index 0000000..f3448c2 --- /dev/null +++ b/libraries/MySQL_MariaDB_Generic-1.7.2/src/MySQL_Generic_WiFiNINA.h @@ -0,0 +1,56 @@ +/**************************************************************************************************************************** + MySQL_Generic_WiFiNINA.h + + Library for communicating with a MySQL or MariaDB Server + + Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino + to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, WT32_ETH01, Teensy, Portenta_H7, etc. boards + using W5x00, ENC28J60, LAM8742A Ethernet, WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi, Portenta Ethernet/WiFi + + The library provides simple and easy Client interface to MySQL or MariaDB Server. + + Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic + Licensed under MIT license + + Version: 1.7.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 13/08/2020 Initial coding/porting to support nRF52, SAM DUE and SAMD21/SAMD51 boards using W5x00 Ethernet + (Ethernet, EthernetLarge, Ethernet2, Ethernet3 library), WiFiNINA and ESP8266/ESP32-AT shields + ... + 1.4.0 K Hoang 05/09/2021 Add support to Teensy 4.1 using QNEthernet + 1.5.0 K Hoang 17/09/2021 Add support to Portenta_H7, using either WiFi or Vision-shield Ethernet + 1.5.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json` + 1.5.2 K Hoang 01/12/2021 Auto detect ESP32 core for LittleFS. Fix bug in examples for WT32_ETH01 + 1.6.0 K Hoang 10/03/2022 Fix memory leak bug. Optimize code + 1.6.1 K Hoang 12/03/2022 Fix memory management bug + 1.7.0 K Hoang 12/03/2022 Convert to `h-only` style library + 1.7.1 K Hoang 10/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32 + 1.7.2 K Hoang 11/04/2022 Fix missing paragraph in `library.properties` + **********************************************************************************************************************************/ + +#pragma once + +#ifndef MYSQL_GENERIC_WIFININA_H +#define MYSQL_GENERIC_WIFININA_H + +#if (ESP8266 || ESP32) + #error This code is not intended to run on the ESP8266/ESP32 platform! Please check your Tools->Board setting +#endif + +#if (USING_WIFININA_GENERIC) + #warning Using WiFiNINA_Generic Library + #include "WiFiNINA_Generic.h" + #include "WiFiClient_Generic.h" + WiFiClient client; // Use this for WiFi instead of EthernetClient +#elif (USING_WIFININA) + #warning Using WiFiNINA Library + #include "WiFiNINA.h" + #include "WiFiClient.h" + WiFiClient client; // Use this for WiFi instead of EthernetClient +#else + #error Must pick a Library +#endif + +#endif //MYSQL_GENERIC_WIFININA_H diff --git a/libraries/esp32cam-main/.clang-format b/libraries/esp32cam-main/.clang-format new file mode 100644 index 0000000..2a701e9 --- /dev/null +++ b/libraries/esp32cam-main/.clang-format @@ -0,0 +1,12 @@ +--- +BasedOnStyle: Mozilla +AllowShortFunctionsOnASingleLine: Empty +BinPackArguments: true +BinPackParameters: true +ColumnLimit: 100 +Cpp11BracedListStyle: true +FixNamespaceComments: true +ReflowComments: false +SortIncludes: true +SortUsingDeclarations: true +SpacesInContainerLiterals: false diff --git a/libraries/esp32cam-main/.github/workflows/build.yml b/libraries/esp32cam-main/.github/workflows/build.yml new file mode 100644 index 0000000..1bc2212 --- /dev/null +++ b/libraries/esp32cam-main/.github/workflows/build.yml @@ -0,0 +1,73 @@ +name: build +on: + push: + pull_request: + workflow_dispatch: +permissions: {} +jobs: + build: + runs-on: ubuntu-20.04 + steps: + - uses: arduino/setup-arduino-cli@v1 + - id: cores + name: Refresh Arduino cores + run: | + echo 'https://espressif.github.io/arduino-esp32/package_esp32_index.json' >~/arduino-cores.txt + arduino-cli version + arduino-cli update --additional-urls "$(<~/arduino-cores.txt)" + echo d=$(sha256sum ~/.arduino15/package_*index.json | sha256sum | cut -d' ' -f1) >> $GITHUB_OUTPUT + - name: Cache Arduino cores + uses: actions/cache@v3 + with: + path: ~/.arduino15/staging/packages + key: cores-${{ steps.cores.outputs.d }} + - name: Install Arduino cores + run: | + arduino-cli core install esp32:esp32 --additional-urls "$(<~/arduino-cores.txt)" + - name: Install dependencies + run: | + sudo apt-get install -y --no-install-recommends clang-format-11 doxygen + - uses: actions/checkout@v3 + - name: Check code style + run: | + mk/format-code.sh + git diff --exit-code + - name: Prepare Arduino libraries + run: | + mkdir -p $HOME/Arduino/libraries + cd $HOME/Arduino/libraries + ln -s $GITHUB_WORKSPACE esp32cam + mkdir -p AsyncTCP ESPAsyncWebServer ODROID-GO + curl -fsLS https://github.com/me-no-dev/AsyncTCP/archive/${ASYNCTCP_VERSION}.tar.gz \ + | tar -C AsyncTCP -xz --strip-components=1 + curl -fsLS https://github.com/me-no-dev/ESPAsyncWebServer/archive/${ESPASYNCWEBSERVER_VERSION}.tar.gz \ + | tar -C ESPAsyncWebServer -xz --strip-components=1 + curl -fsLS https://github.com/hardkernel/ODROID-GO/archive/${ODROIDGO_VERSION}.tar.gz \ + | tar -C ODROID-GO -xz --strip-components=1 --wildcards '*/library.properties' '*/src/odroid_go.*' '*/src/Fonts' '*/src/utility' + env: + ASYNCTCP_VERSION: ca8ac5f919d02bea07b474531981ddbfd64de97c + ESPASYNCWEBSERVER_VERSION: 1d46269cedf477661ca8a29518414f4b74e957d4 + ODROIDGO_VERSION: 4a496e337d16bca4ddedbeca3486d7b60662d017 + - name: Compile examples + run: | + arduino-cli compile -b esp32:esp32:esp32wrover ./examples/WifiCam + arduino-cli compile -b esp32:esp32:esp32wrover ./examples/AsyncCam + arduino-cli compile -b esp32:esp32:odroid_esp32 ./examples/GoDisplay + - name: Build docs + run: docs/build.sh + - name: Deploy docs + uses: nwtgck/actions-netlify@30aa80fe8d5eec30813fc8b17b77e0a6663f09b5 + with: + publish-dir: ./docs/html/ + production-deploy: true + github-token: ${{ secrets.GITHUB_TOKEN }} + deploy-message: ${{ github.sha }} ${{ github.run_id }} + enable-pull-request-comment: false + enable-commit-comment: false + enable-commit-status: false + enable-github-deployment: false + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: 7de100ca-e942-419d-af2c-18e6c528b96e + if: ${{ github.repository == 'yoursunny/esp32cam' && github.event_name == 'push' }} + timeout-minutes: 30 diff --git a/libraries/esp32cam-main/.gitignore b/libraries/esp32cam-main/.gitignore new file mode 100644 index 0000000..12e0396 --- /dev/null +++ b/libraries/esp32cam-main/.gitignore @@ -0,0 +1,3 @@ +/.vscode +/docs/html +/examples/*/build diff --git a/libraries/esp32cam-main/LICENSE b/libraries/esp32cam-main/LICENSE new file mode 100644 index 0000000..18064ca --- /dev/null +++ b/libraries/esp32cam-main/LICENSE @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2020-2023, Junxiao Shi + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/libraries/esp32cam-main/README.md b/libraries/esp32cam-main/README.md new file mode 100644 index 0000000..f59b617 --- /dev/null +++ b/libraries/esp32cam-main/README.md @@ -0,0 +1,20 @@ +# esp32cam: OV2640 camera on ESP32-CAM + +[![GitHub build status](https://img.shields.io/github/actions/workflow/status/yoursunny/esp32cam/build.yml?style=flat)](https://github.com/yoursunny/esp32cam/actions) [![GitHub code size](https://img.shields.io/github/languages/code-size/yoursunny/esp32cam?style=flat)](https://github.com/yoursunny/esp32cam) + +**esp32cam** library provides an object oriented API to use OV2640 camera on ESP32 microcontroller. +It is a wrapper of [esp32-camera library](https://github.com/espressif/esp32-camera). +This library has been tested with AI Thinker [ESP32-CAM](http://www.ai-thinker.com/pro_view-24.html) board and OV2640 camera. + +* [Doxygen documentation](https://esp32cam.yoursunny.dev) +* [#esp32cam on Twitter](https://twitter.com/hashtag/esp32cam) +* [video tutorial](https://youtu.be/Sb08leLWOgA) + +![esp32cam logo](docs/logo.svg) + +## Installation + +1. Clone this repository under `$HOME/Arduino/libraries` directory. +2. Add `#include ` to your sketch. +3. In *Tools* - *Board* menu, select **ESP32 Wrover Module** to enable 4MB external PSRAM. +4. Check out the [examples](examples/) for how to use. diff --git a/libraries/esp32cam-main/docs/Doxyfile b/libraries/esp32cam-main/docs/Doxyfile new file mode 100644 index 0000000..d115cfd --- /dev/null +++ b/libraries/esp32cam-main/docs/Doxyfile @@ -0,0 +1,20 @@ +PROJECT_NAME = esp32cam +PROJECT_BRIEF = "OV2640 camera on ESP32-CAM" +OUTPUT_DIRECTORY = "." +MARKDOWN_SUPPORT = NO +AUTOLINK_SUPPORT = NO +BUILTIN_STL_SUPPORT = YES +EXTRACT_ALL = YES +EXTRACT_PRIV_VIRTUAL = YES +QUIET = YES +INPUT = "../src" "../examples" +FILE_PATTERNS = "*.h" "*.hpp" "*.c" "*.cpp" "*.ino" +EXTENSION_MAPPING = "ino=C++" +RECURSIVE = YES +PREDEFINED = "ARDUINO=100" "ARDUINO_ARCH_ESP32=1" +HTML_COLORSTYLE_HUE = 293 +HTML_COLORSTYLE_SAT = 255 +HTML_COLORSTYLE_GAMMA = 130 +GENERATE_LATEX = NO +CLASS_DIAGRAMS = NO +HAVE_DOT = NO diff --git a/libraries/esp32cam-main/docs/_redirects b/libraries/esp32cam-main/docs/_redirects new file mode 100644 index 0000000..07ae66d --- /dev/null +++ b/libraries/esp32cam-main/docs/_redirects @@ -0,0 +1 @@ +https://esp32cam.netlify.app/* https://esp32cam.yoursunny.dev/:splat 301! diff --git a/libraries/esp32cam-main/docs/build.sh b/libraries/esp32cam-main/docs/build.sh new file mode 100644 index 0000000..b6acf51 --- /dev/null +++ b/libraries/esp32cam-main/docs/build.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -euo pipefail +cd "$( dirname "${BASH_SOURCE[0]}" )" + +doxygen Doxyfile 2>&1 | ./filter-Doxygen-warning.awk 1>&2 + +find html -name '*.html' | xargs sed -i '/<\/head>/ i\' +cp _redirects html/ diff --git a/libraries/esp32cam-main/docs/filter-Doxygen-warning.awk b/libraries/esp32cam-main/docs/filter-Doxygen-warning.awk new file mode 100644 index 0000000..ab23b47 --- /dev/null +++ b/libraries/esp32cam-main/docs/filter-Doxygen-warning.awk @@ -0,0 +1,14 @@ +#!/usr/bin/gawk -f +/warning: The following parameters? of .* not documented:/ { + skip = 1 + next +} +$0 ~ /^ parameter/ { + if (!skip) { + print + } +} +$0 !~ /^ / { + skip = 0 + print +} \ No newline at end of file diff --git a/libraries/esp32cam-main/docs/logo.svg b/libraries/esp32cam-main/docs/logo.svg new file mode 100644 index 0000000..73c94d5 --- /dev/null +++ b/libraries/esp32cam-main/docs/logo.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + esp32 + cam + + + + + + + diff --git a/libraries/esp32cam-main/examples/AsyncCam/AsyncCam.hpp b/libraries/esp32cam-main/examples/AsyncCam/AsyncCam.hpp new file mode 100644 index 0000000..f35e8a7 --- /dev/null +++ b/libraries/esp32cam-main/examples/AsyncCam/AsyncCam.hpp @@ -0,0 +1,16 @@ +#ifndef ASYNCCAM_HPP +#define ASYNCCAM_HPP + +#include + +#include + +extern esp32cam::Resolution initialResolution; +extern esp32cam::Resolution currentResolution; + +extern AsyncWebServer server; + +void +addRequestHandlers(); + +#endif // ASYNCCAM_HPP diff --git a/libraries/esp32cam-main/examples/AsyncCam/AsyncCam.ino b/libraries/esp32cam-main/examples/AsyncCam/AsyncCam.ino new file mode 100644 index 0000000..9ed4504 --- /dev/null +++ b/libraries/esp32cam-main/examples/AsyncCam/AsyncCam.ino @@ -0,0 +1,64 @@ +#include "AsyncCam.hpp" +#include + +static const char* WIFI_SSID = "my-ssid"; +static const char* WIFI_PASS = "my-pass"; + +esp32cam::Resolution initialResolution; +esp32cam::Resolution currentResolution; + +AsyncWebServer server(80); + +void +setup() +{ + Serial.begin(115200); + Serial.println(); + delay(2000); + + WiFi.persistent(false); + WiFi.mode(WIFI_STA); + WiFi.begin(WIFI_SSID, WIFI_PASS); + if (WiFi.waitForConnectResult() != WL_CONNECTED) { + Serial.println("WiFi failure"); + delay(5000); + ESP.restart(); + } + Serial.println("WiFi connected"); + + { + using namespace esp32cam; + + initialResolution = Resolution::find(1024, 768); + currentResolution = initialResolution; + + Config cfg; + cfg.setPins(pins::AiThinker); + cfg.setResolution(initialResolution); + cfg.setJpeg(80); + + bool ok = Camera.begin(cfg); + if (!ok) { + Serial.println("camera initialize failure"); + delay(5000); + ESP.restart(); + } + Serial.println("camera initialize success"); + } + + Serial.println("camera starting"); + Serial.print("http://"); + Serial.println(WiFi.localIP()); + + addRequestHandlers(); + server.begin(); +} + +void +loop() +{ + // esp32cam-asyncweb.h depends on FreeRTOS task API including vTaskDelete, so you must have a + // non-zero delay in the loop() function; otherwise, FreeRTOS kernel memory cannot be freed + // properly and the system would run out of memory. + delay(1); +} diff --git a/libraries/esp32cam-main/examples/AsyncCam/README.md b/libraries/esp32cam-main/examples/AsyncCam/README.md new file mode 100644 index 0000000..180ce66 --- /dev/null +++ b/libraries/esp32cam-main/examples/AsyncCam/README.md @@ -0,0 +1,6 @@ +# AsyncCam: camera on ESPAsyncWebServer + +This example runs on ESP32-CAM board. +It demonstrates how to use esp32cam library with [ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer) library. +The HTTP server supports both JPEG still image and MJPEG stream, and allows changing camera resolution on the fly. +To use this example, modify WiFi SSID+password, then upload to ESP32. diff --git a/libraries/esp32cam-main/examples/AsyncCam/handlers.cpp b/libraries/esp32cam-main/examples/AsyncCam/handlers.cpp new file mode 100644 index 0000000..bbac65a --- /dev/null +++ b/libraries/esp32cam-main/examples/AsyncCam/handlers.cpp @@ -0,0 +1,127 @@ +#include "AsyncCam.hpp" +#include + +static const char FRONTPAGE[] = R"EOT( + +esp32cam AsyncCam example + +

esp32cam AsyncCam example

+

+Resolution + + +

+

+ + + +

+
+ + +)EOT"; + +static String +rewriteFrontpage(const String& var) +{ + StreamString b; + if (var == "RESOLUTION_OPTIONS") { + for (const auto& r : esp32cam::Camera.listResolutions()) { + b.print(" initialResolution) { + b.print(" disabled"); + } + b.print('>'); + b.print(r); + b.print(""); + } + } + return b; +} + +void +addRequestHandlers() +{ + server.on("/", HTTP_GET, [](AsyncWebServerRequest* request) { + request->send_P(200, "text/html", reinterpret_cast(FRONTPAGE), + sizeof(FRONTPAGE), rewriteFrontpage); + }); + + server.on("/robots.txt", HTTP_GET, [](AsyncWebServerRequest* request) { + request->send(200, "text/html", "User-Agent: *\nDisallow: /\n"); + }); + + server.on("/change-resolution.cgi", HTTP_POST, [](AsyncWebServerRequest* request) { + long width = request->arg("width").toInt(); + long height = request->arg("height").toInt(); + auto r = esp32cam::Camera.listResolutions().find(width, height); + if (width == 0 || height == 0 || !r.isValid()) { + request->send(404, "text/plain", "non-existent resolution\n"); + return; + } + if (r.getWidth() != width || r.getHeight() != height) { + request->send(200); + return; + } + + if (!esp32cam::Camera.changeResolution(r, 0)) { + Serial.printf("changeResolution(%ld,%ld) failure\n", width, height); + request->send(500, "text/plain", "changeResolution error\n"); + return; + } + + currentResolution = r; + Serial.printf("changeResolution(%ld,%ld) success\n", width, height); + StreamString b; + b.print(currentResolution); + request->send(b, "text/plain", b.length()); + }); + + server.on("/cam.jpg", esp32cam::asyncweb::handleStill); + server.on("/cam.mjpeg", esp32cam::asyncweb::handleMjpeg); +} diff --git a/libraries/esp32cam-main/examples/GoDisplay/GoDisplay.ino b/libraries/esp32cam-main/examples/GoDisplay/GoDisplay.ino new file mode 100644 index 0000000..9cf053d --- /dev/null +++ b/libraries/esp32cam-main/examples/GoDisplay/GoDisplay.ino @@ -0,0 +1,51 @@ +#include "SpiRamOStream.hpp" + +#include +#include +#include + +static const char* WIFI_SSID = "my-ssid"; +static const char* WIFI_PASS = "my-pass"; +static const char* CAM_SERVER = "192.0.2.1"; +static const uint16_t CAM_PORT = 80; +static const char* CAM_URI = "/320x240.jpg"; + +void +setup() +{ + GO.begin(115200); + + WiFi.persistent(false); + WiFi.mode(WIFI_STA); + WiFi.begin(WIFI_SSID, WIFI_PASS); + if (WiFi.waitForConnectResult() != WL_CONNECTED) { + Serial.println("WiFi failure"); + delay(5000); + ESP.restart(); + } +} + +void +loop() +{ + WiFiClient tcp; + HTTPClient http; + http.begin(tcp, CAM_SERVER, CAM_PORT, CAM_URI); + http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS); + int httpCode = http.GET(); + if (httpCode != 200) { + Serial.printf("HTTP error %d\n", httpCode); + return; + } + + int length = http.getSize(); + if (length <= 0) { + Serial.printf("%lu JPEG length unknown\n", millis()); + return; + } + Serial.printf("%lu JPEG len=%d\n", millis(), length); + + SpiRamOStream os(length); + http.writeToStream(&os); + GO.lcd.drawJpg(os.data(), os.size(), 0, 0, 0, 0, 0, 0, JPEG_DIV_NONE); +} diff --git a/libraries/esp32cam-main/examples/GoDisplay/README.md b/libraries/esp32cam-main/examples/GoDisplay/README.md new file mode 100644 index 0000000..6bec9a3 --- /dev/null +++ b/libraries/esp32cam-main/examples/GoDisplay/README.md @@ -0,0 +1,8 @@ +# GoDisplay: camera image display for ODROID-GO + +This example runs on [ODROID-GO](https://wiki.odroid.com/odroid_go/odroid_go) game console. +It displays images captured by ESP32-CAM (running WifiCam example) and retrieved over HTTP. +To use this example, modify WiFi SSID+password and ESP32-CAM IP address, then upload to ODROID-GO. + +As of 2022-02-06, [ODROID-GO package](https://github.com/hardkernel/ODROID-GO) is incompatible with ESP32 Arduino core v2.0.x. +Deleting `ODROID-GO/src/sensors` and `ODROID-GO/src/web` directories would resolve the compile errors. diff --git a/libraries/esp32cam-main/examples/GoDisplay/SpiRamOStream.hpp b/libraries/esp32cam-main/examples/GoDisplay/SpiRamOStream.hpp new file mode 100644 index 0000000..b32047d --- /dev/null +++ b/libraries/esp32cam-main/examples/GoDisplay/SpiRamOStream.hpp @@ -0,0 +1,67 @@ +#ifndef SPIRAM_OSTREAM_HPP +#define SPIRAM_OSTREAM_HPP + +#include + +/** @brief write-only Stream backed by fixed-size SPIRAM buffer. */ +class SpiRamOStream : public Stream +{ +public: + explicit SpiRamOStream(size_t cap) + : m_buf(reinterpret_cast(heap_caps_malloc(cap, MALLOC_CAP_SPIRAM))) + , m_len(0) + , m_cap(cap) + {} + + ~SpiRamOStream() + { + free(m_buf); + } + + const uint8_t* data() const + { + return m_buf; + } + + const size_t size() const + { + return m_len; + } + + size_t write(const uint8_t* buffer, size_t size) override + { + size_t count = min(size, m_cap - m_len); + memcpy(m_buf + m_len, buffer, count); + m_len += count; + return count; + } + + size_t write(uint8_t data) override + { + return write(&data, 1); + } + + int available() override + { + return 0; + } + + int read() override + { + return -1; + } + + int peek() override + { + return -1; + } + + void flush() override {} + +private: + uint8_t* m_buf; + size_t m_len; + size_t m_cap; +}; + +#endif // SPIRAM_OSTREAM_HPP diff --git a/libraries/esp32cam-main/examples/WifiCam/README.md b/libraries/esp32cam-main/examples/WifiCam/README.md new file mode 100644 index 0000000..ff4d768 --- /dev/null +++ b/libraries/esp32cam-main/examples/WifiCam/README.md @@ -0,0 +1,11 @@ +# WifiCam: WiFi camera HTTP server + +This example runs on ESP32-CAM board. +It provides an HTTP server where you can access BMP, JPG, and MJPEG formats in various resolutions. +To use this example, modify WiFi SSID+password, then upload to ESP32. + +ESP32 `WebServer` can only serve one TCP connection at a time. +If you have accessed an MJPEG stream in a browser, you need to click *Stop* button to terminate the connection. +Otherwise, you won't be able to open another page or picture. + +Due to memory constraints, it's not recommended to access BMP format in high resolution. diff --git a/libraries/esp32cam-main/examples/WifiCam/WifiCam.hpp b/libraries/esp32cam-main/examples/WifiCam/WifiCam.hpp new file mode 100644 index 0000000..94f6516 --- /dev/null +++ b/libraries/esp32cam-main/examples/WifiCam/WifiCam.hpp @@ -0,0 +1,15 @@ +#ifndef WIFICAM_HPP +#define WIFICAM_HPP + +#include + +#include + +extern esp32cam::Resolution initialResolution; + +extern WebServer server; + +void +addRequestHandlers(); + +#endif // WIFICAM_HPP diff --git a/libraries/esp32cam-main/examples/WifiCam/WifiCam.ino b/libraries/esp32cam-main/examples/WifiCam/WifiCam.ino new file mode 100644 index 0000000..57bdb44 --- /dev/null +++ b/libraries/esp32cam-main/examples/WifiCam/WifiCam.ino @@ -0,0 +1,59 @@ +#include "WifiCam.hpp" +#include + +static const char* WIFI_SSID = "my-ssid"; +static const char* WIFI_PASS = "my-pass"; + +esp32cam::Resolution initialResolution; + +WebServer server(80); + +void +setup() +{ + Serial.begin(115200); + Serial.println(); + delay(2000); + + WiFi.persistent(false); + WiFi.mode(WIFI_STA); + WiFi.begin(WIFI_SSID, WIFI_PASS); + if (WiFi.waitForConnectResult() != WL_CONNECTED) { + Serial.println("WiFi failure"); + delay(5000); + ESP.restart(); + } + Serial.println("WiFi connected"); + + { + using namespace esp32cam; + + initialResolution = Resolution::find(1024, 768); + + Config cfg; + cfg.setPins(pins::AiThinker); + cfg.setResolution(initialResolution); + cfg.setJpeg(80); + + bool ok = Camera.begin(cfg); + if (!ok) { + Serial.println("camera initialize failure"); + delay(5000); + ESP.restart(); + } + Serial.println("camera initialize success"); + } + + Serial.println("camera starting"); + Serial.print("http://"); + Serial.println(WiFi.localIP()); + + addRequestHandlers(); + server.begin(); +} + +void +loop() +{ + server.handleClient(); +} diff --git a/libraries/esp32cam-main/examples/WifiCam/handlers.cpp b/libraries/esp32cam-main/examples/WifiCam/handlers.cpp new file mode 100644 index 0000000..8fe35f3 --- /dev/null +++ b/libraries/esp32cam-main/examples/WifiCam/handlers.cpp @@ -0,0 +1,137 @@ +#include "WifiCam.hpp" +#include +#include + +static const char FRONTPAGE[] = R"EOT( + +esp32cam WifiCam example + + +

esp32cam WifiCam example

+ + + +
BMPJPGMJPEG +
loading +
+ + +)EOT"; + +static void +serveStill(bool wantBmp) +{ + auto frame = esp32cam::capture(); + if (frame == nullptr) { + Serial.println("capture() failure"); + server.send(500, "text/plain", "still capture error\n"); + return; + } + Serial.printf("capture() success: %dx%d %zub\n", frame->getWidth(), frame->getHeight(), + frame->size()); + + if (wantBmp) { + if (!frame->toBmp()) { + Serial.println("toBmp() failure"); + server.send(500, "text/plain", "convert to BMP error\n"); + return; + } + Serial.printf("toBmp() success: %dx%d %zub\n", frame->getWidth(), frame->getHeight(), + frame->size()); + } + + server.setContentLength(frame->size()); + server.send(200, wantBmp ? "image/bmp" : "image/jpeg"); + WiFiClient client = server.client(); + frame->writeTo(client); +} + +static void +serveMjpeg() +{ + Serial.println("MJPEG streaming begin"); + WiFiClient client = server.client(); + auto startTime = millis(); + int nFrames = esp32cam::Camera.streamMjpeg(client); + auto duration = millis() - startTime; + Serial.printf("MJPEG streaming end: %dfrm %0.2ffps\n", nFrames, 1000.0 * nFrames / duration); +} + +void +addRequestHandlers() +{ + server.on("/", HTTP_GET, [] { + server.setContentLength(sizeof(FRONTPAGE)); + server.send(200, "text/html"); + server.sendContent(FRONTPAGE, sizeof(FRONTPAGE)); + }); + + server.on("/robots.txt", HTTP_GET, + [] { server.send(200, "text/html", "User-Agent: *\nDisallow: /\n"); }); + + server.on("/resolutions.csv", HTTP_GET, [] { + StreamString b; + for (const auto& r : esp32cam::Camera.listResolutions()) { + b.println(r); + } + server.send(200, "text/csv", b); + }); + + server.on(UriBraces("/{}x{}.{}"), HTTP_GET, [] { + long width = server.pathArg(0).toInt(); + long height = server.pathArg(1).toInt(); + String format = server.pathArg(2); + if (width == 0 || height == 0 || !(format == "bmp" || format == "jpg" || format == "mjpeg")) { + server.send(404); + return; + } + + auto r = esp32cam::Camera.listResolutions().find(width, height); + if (!r.isValid()) { + server.send(404, "text/plain", "non-existent resolution\n"); + return; + } + if (r.getWidth() != width || r.getHeight() != height) { + server.sendHeader("Location", + String("/") + r.getWidth() + "x" + r.getHeight() + "." + format); + server.send(302); + return; + } + + if (!esp32cam::Camera.changeResolution(r)) { + Serial.printf("changeResolution(%ld,%ld) failure\n", width, height); + server.send(500, "text/plain", "changeResolution error\n"); + } + Serial.printf("changeResolution(%ld,%ld) success\n", width, height); + + if (format == "bmp") { + serveStill(true); + } else if (format == "jpg") { + serveStill(false); + } else if (format == "mjpeg") { + serveMjpeg(); + } + }); +} diff --git a/libraries/esp32cam-main/library.properties b/libraries/esp32cam-main/library.properties new file mode 100644 index 0000000..d8fc152 --- /dev/null +++ b/libraries/esp32cam-main/library.properties @@ -0,0 +1,9 @@ +name=esp32cam +version=0.0.20221229 +author=Junxiao Shi +maintainer=Junxiao Shi +sentence=OV2640 camera on ESP32-CAM. +paragraph=This library enables access to OV2640 camera on AI Thinker ESP32-CAM module. +category=Sensors +url=https://yoursunny.com +architectures=esp32 diff --git a/libraries/esp32cam-main/mk/format-code.sh b/libraries/esp32cam-main/mk/format-code.sh new file mode 100644 index 0000000..9a05a65 --- /dev/null +++ b/libraries/esp32cam-main/mk/format-code.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -eo pipefail +cd "$( dirname "${BASH_SOURCE[0]}" )"/.. + +find -name '*.h' -or -name '*.[hc]pp' -or -name '*.ino' | \ + xargs clang-format-11 -i -style=file diff --git a/libraries/esp32cam-main/src/esp32cam-asyncweb.h b/libraries/esp32cam-main/src/esp32cam-asyncweb.h new file mode 100644 index 0000000..80aa0ea --- /dev/null +++ b/libraries/esp32cam-main/src/esp32cam-asyncweb.h @@ -0,0 +1,288 @@ +#ifndef ESP32CAM_ASYNCWEB_H +#define ESP32CAM_ASYNCWEB_H + +#include "esp32cam.h" + +#include +#include +#include + +namespace esp32cam { +/** + * @brief esp32cam integration with ESPAsyncWebServer library. + * @sa https://github.com/me-no-dev/ESPAsyncWebServer + */ +namespace asyncweb { + +/** @brief HTTP response of one still image. */ +class StillResponse : public AsyncAbstractResponse +{ +public: + /** + * @brief Constructor. + * @param frame a frame of still image. + */ + explicit StillResponse(std::unique_ptr frame) + : m_frame(std::move(frame)) + { + _code = 200; + _contentType = determineMineType(*m_frame); + _contentLength = m_frame->size(); + _sendContentLength = true; + } + + bool _sourceValid() const override + { + return true; + } + + size_t _fillBuffer(uint8_t* buf, size_t buflen) override + { + if (m_index >= m_frame->size()) { + return 0; + } + + size_t len = std::min(buflen, m_frame->size() - m_index); + std::copy_n(m_frame->data() + m_index, len, buf); + m_index += len; + return len; + } + +public: + /** + * @brief Capture a frame and respond to the request. + * @param ctx AsyncWebServerRequest* pointer. + * + * This function must run as a FreeRTOS task. It self-deletes upon completion. + */ + static void captureTask(void* ctx) + { + auto request = reinterpret_cast(ctx); + + auto frame = Camera.capture(); + if (frame == nullptr) { + request->send(500); + } else { + request->send(new StillResponse(std::move(frame))); + } + + vTaskDelete(nullptr); + } + +private: + static const char* determineMineType(const Frame& frame) + { + if (frame.isJpeg()) { + return "image/jpeg"; + } + if (frame.isBmp()) { + return "image/bmp"; + } + return "application/octet-stream"; + } + +private: + std::unique_ptr m_frame; + size_t m_index = 0; +}; + +/** + * @brief Handle HTTP request for still image. + * + * Start a FreeRTOS task to capture one frame of still image under the current camera settings, + * and then respond to the HTTP request with the frame. + * If this function is called multiple times with concurrent HTTP requests, each response will + * contain a different image. + * If task creation or image capture fails, respond with HTTP 500 error. + * + * To perform authentication or other operations before image capture, create another HTTP handler + * to do these, and then call this function. + */ +inline void +handleStill(AsyncWebServerRequest* request) +{ + TaskHandle_t task; + auto res = xTaskCreatePinnedToCore(StillResponse::captureTask, "esp32cam-still", 2048, request, 1, + &task, xPortGetCoreID()); + if (res != pdPASS) { + request->send(500); + } +} + +/** + * @brief HTTP response of MJPEG stream. + * + * Start a FreeRTOS task to capture image frames under the current camera settings, + * and respond to the HTTP request as a Motion JPEG stream. + * If multiple MjpegResponse instances are active concurrently, each stream will contain + * different images. + * If task creation fails, respond with HTTP 500 error. + * If image capture fails, the stream is stopped. + */ +class MjpegResponse : public AsyncAbstractResponse +{ +public: + explicit MjpegResponse(const MjpegConfig& cfg = MjpegConfig()) + : m_ctrl(cfg) + { + m_queue = xQueueCreate(4, sizeof(Frame*)); + if (xTaskCreatePinnedToCore(captureTask, "esp32cam-mjpeg", 2048, this, 1, &m_task, + xPortGetCoreID()) != pdPASS) { + m_task = nullptr; + }; + if (m_queue == nullptr || m_task == nullptr) { + _code = 500; + m_ctrl.notifyFail(); + return; + } + + _code = 200; + m_hdr.prepareResponseContentType(); + _contentType = String(m_hdr.buf, m_hdr.size); + _sendContentLength = false; + } + + ~MjpegResponse() override + { + if (m_task != nullptr) { + vTaskDelete(m_task); + m_task = nullptr; + } + + if (m_queue != nullptr) { + Frame* frame = nullptr; + while (xQueueReceive(m_queue, &frame, 0) == pdTRUE) { + delete frame; + } + vQueueDelete(m_queue); + m_queue = nullptr; + } + } + + bool _sourceValid() const override + { + return true; + } + + size_t _fillBuffer(uint8_t* buf, size_t buflen) override + { + auto act = m_ctrl.decideAction(); + switch (act) { + case Ctrl::CAPTURE: { + xTaskNotify(m_task, 1, eSetValueWithOverwrite); + m_ctrl.notifyCapture(); + return RESPONSE_TRY_AGAIN; + } + case Ctrl::RETURN: { + Frame* frame = nullptr; + if (xQueueReceive(m_queue, &frame, 0) == pdTRUE) { + m_ctrl.notifyReturn(std::unique_ptr(frame)); + } + m_sendNext = SIPartHeader; + m_sendRemain = 0; + if (m_ctrl.decideAction() != Ctrl::SEND) { + return RESPONSE_TRY_AGAIN; + } + // fallthrough + } + case Ctrl::SEND: { + size_t len = sendPart(buf, buflen); + if (len == 0 && m_sendNext == SINone) { + m_ctrl.notifySent(true); + return RESPONSE_TRY_AGAIN; + } + return len; + } + case Ctrl::STOP: + return 0; + default: + return RESPONSE_TRY_AGAIN; + } + } + +private: + static void captureTask(void* ctx) + { + auto self = reinterpret_cast(ctx); + while (true) { + uint32_t value = 0; + xTaskNotifyWait(0, UINT32_MAX, &value, pdMS_TO_TICKS(10000)); + if (value == 0) { + continue; + } + + auto frame = Camera.capture().release(); + while (xQueueSend(self->m_queue, &frame, pdMS_TO_TICKS(10000)) != pdTRUE) { + ; + } + } + } + + size_t sendPart(uint8_t* buf, size_t buflen) + { + if (m_sendRemain == 0) { + switch (m_sendNext) { + case SIPartHeader: + m_hdr.preparePartHeader(m_ctrl.getFrame()->size()); + m_sendBuf = reinterpret_cast(m_hdr.buf); + m_sendRemain = m_hdr.size; + m_sendNext = SIFrame; + break; + case SIFrame: + m_sendBuf = m_ctrl.getFrame()->data(); + m_sendRemain = m_ctrl.getFrame()->size(); + m_sendNext = SIPartTrailer; + break; + case SIPartTrailer: + m_hdr.preparePartTrailer(); + m_sendBuf = reinterpret_cast(m_hdr.buf); + m_sendRemain = m_hdr.size; + m_sendNext = SINone; + break; + case SINone: + return 0; + } + } + + size_t len = std::min(m_sendRemain, buflen); + std::copy_n(m_sendBuf, len, buf); + m_sendBuf += len; + m_sendRemain -= len; + return len; + } + +private: + QueueHandle_t m_queue = nullptr; + TaskHandle_t m_task = nullptr; + + using Ctrl = detail::MjpegController; + Ctrl m_ctrl; + detail::MjpegHeader m_hdr; + + enum SendItem + { + SINone, + SIPartHeader, + SIFrame, + SIPartTrailer, + }; + SendItem m_sendNext = SINone; + const uint8_t* m_sendBuf = nullptr; + size_t m_sendRemain = 0; +}; + +/** + * @brief Handle HTTP request for MJPEG stream. + * + * To specify MjpegConfig, construct MjpegResponse directly. + */ +inline void +handleMjpeg(AsyncWebServerRequest* request) +{ + request->send(new MjpegResponse()); +} + +} // namespace asyncweb +} // namespace esp32cam + +#endif // ESP32CAM_ASYNCWEB_H diff --git a/libraries/esp32cam-main/src/esp32cam.cpp b/libraries/esp32cam-main/src/esp32cam.cpp new file mode 100644 index 0000000..c0de13c --- /dev/null +++ b/libraries/esp32cam-main/src/esp32cam.cpp @@ -0,0 +1,110 @@ +#include "esp32cam.h" + +#include +#include + +namespace esp32cam { + +CameraClass Camera; + +bool +CameraClass::begin(const Config& config) +{ + return esp_camera_init(reinterpret_cast(config.m_cfg)) == ESP_OK; +} + +bool +CameraClass::end() +{ + return esp_camera_deinit() == ESP_OK; +} + +ResolutionList +CameraClass::listResolutions() const +{ + sensor_t* sensor = esp_camera_sensor_get(); + if (sensor == nullptr) { + return ResolutionList(); + } + + camera_sensor_info_t* info = esp_camera_sensor_get_info(&sensor->id); + if (info == nullptr) { + return ResolutionList(); + } + + return ResolutionList(info->max_size + 1); +} + +bool +CameraClass::changeResolution(const Resolution& resolution, int sleepFor) +{ + sensor_t* sensor = esp_camera_sensor_get(); + if (sensor == nullptr) { + return false; + } + + framesize_t frameSize = resolution.as(); + if (sensor->status.framesize == frameSize) { + return true; + } + + if (sensor->set_framesize(sensor, frameSize) != 0) { + return false; + } + if (sleepFor > 0) { + delay(sleepFor); + } + return true; +} + +std::unique_ptr +CameraClass::capture() +{ + camera_fb_t* fb = esp_camera_fb_get(); + if (fb == nullptr) { + return nullptr; + } + return std::unique_ptr(new Frame(fb)); +} + +int +CameraClass::streamMjpeg(Client& client, const MjpegConfig& cfg) +{ + detail::MjpegHeader hdr; + hdr.prepareResponseHeaders(); + hdr.writeTo(client); + + using Ctrl = detail::MjpegController; + Ctrl ctrl(cfg); + while (true) { + auto act = ctrl.decideAction(); + switch (act) { + case Ctrl::CAPTURE: { + ctrl.notifyCapture(); + break; + } + case Ctrl::RETURN: { + ctrl.notifyReturn(capture()); + break; + } + case Ctrl::SEND: { + hdr.preparePartHeader(ctrl.getFrame()->size()); + hdr.writeTo(client); + ctrl.notifySent(ctrl.getFrame()->writeTo(client, cfg.frameTimeout)); + hdr.preparePartTrailer(); + hdr.writeTo(client); + break; + } + case Ctrl::STOP: { + client.stop(); + return ctrl.countSentFrames(); + } + default: { + delay(act); + break; + } + } + } +} + +} // namespace esp32cam diff --git a/libraries/esp32cam-main/src/esp32cam.h b/libraries/esp32cam-main/src/esp32cam.h new file mode 100644 index 0000000..e2d0272 --- /dev/null +++ b/libraries/esp32cam-main/src/esp32cam.h @@ -0,0 +1,73 @@ +/** + * @mainpage esp32cam + * + * https://github.com/yoursunny/esp32cam + */ + +#ifndef ESP32CAM_H +#define ESP32CAM_H + +#include "internal/config.hpp" +#include "internal/mjpeg.hpp" + +namespace esp32cam { + +class CameraClass +{ +public: + /** + * @brief Enable camera. + * @return whether success. + */ + bool begin(const Config& config); + + /** + * @brief Disable camera. + * @return whether success. + */ + bool end(); + + /** + * @brief Retrieve list of resolutions (likely) supported by hardware. + * @pre Camera is enabled. + */ + ResolutionList listResolutions() const; + + /** + * @brief Change camera resolution. + * @pre Camera is enabled. + * @param resolution new resolution; must be no higher than initial resolution. + * @param sleepFor how long to wait for stabilization (millis). + */ + bool changeResolution(const Resolution& resolution, int sleepFor = 500); + + /** + * @brief Capture a frame of picture. + * @pre Camera is enabled. + * @return the picture frame, or nullptr on error. + */ + std::unique_ptr capture(); + + struct [[deprecated("use esp32cam::MjpegConfig")]] StreamMjpegConfig : MjpegConfig{}; + + /** + * @brief Stream Motion JPEG. + * @pre The camera has been initialized to JPEG mode. + * @return number of frames streamed. + */ + int streamMjpeg(Client& client, const MjpegConfig& cfg = MjpegConfig()); +}; + +/** @brief ESP32 camera API. */ +extern CameraClass Camera; + +/** @brief Capture a frame with the camera. */ +inline std::unique_ptr +capture() +{ + return Camera.capture(); +} + +} // namespace esp32cam + +#endif // ESP32CAM_H diff --git a/libraries/esp32cam-main/src/internal/config.cpp b/libraries/esp32cam-main/src/internal/config.cpp new file mode 100644 index 0000000..7d4be91 --- /dev/null +++ b/libraries/esp32cam-main/src/internal/config.cpp @@ -0,0 +1,104 @@ +#include "config.hpp" + +#include +#include +#include + +namespace esp32cam { +namespace detail { + +int +convertJpegQuality(int quality) +{ + return std::min(63, std::max(0, 100 - quality)); +} + +} // namespace detail + +class Config::CameraConfigT : public camera_config_t +{}; + +Config::Config() + : m_cfg(new CameraConfigT) +{ + std::memset(m_cfg, 0, sizeof(*m_cfg)); + m_cfg->xclk_freq_hz = 20000000; + m_cfg->ledc_timer = LEDC_TIMER_0; + m_cfg->ledc_channel = LEDC_CHANNEL_0; + m_cfg->pixel_format = PIXFORMAT_RGB565; + m_cfg->frame_size = FRAMESIZE_QQVGA; + m_cfg->fb_count = 2; + m_cfg->grab_mode = CAMERA_GRAB_LATEST; +} + +Config::~Config() +{ + delete m_cfg; +} + +Config& +Config::setPins(const Pins& pins) +{ + m_cfg->pin_pwdn = pins.PWDN; + m_cfg->pin_reset = pins.RESET; + m_cfg->pin_xclk = pins.XCLK; + m_cfg->pin_sscb_sda = pins.SDA; + m_cfg->pin_sscb_scl = pins.SCL; + m_cfg->pin_d7 = pins.D7; + m_cfg->pin_d6 = pins.D6; + m_cfg->pin_d5 = pins.D5; + m_cfg->pin_d4 = pins.D4; + m_cfg->pin_d3 = pins.D3; + m_cfg->pin_d2 = pins.D2; + m_cfg->pin_d1 = pins.D1; + m_cfg->pin_d0 = pins.D0; + m_cfg->pin_vsync = pins.VSYNC; + m_cfg->pin_href = pins.HREF; + m_cfg->pin_pclk = pins.PCLK; + return *this; +} + +Config& +Config::setResolution(const Resolution& resolution) +{ + m_cfg->frame_size = resolution.as(); + return *this; +} + +Config& +Config::setBufferCount(int n) +{ + m_cfg->fb_count = std::max(1, n); + return *this; +} + +Config& +Config::setRgb() +{ + m_cfg->pixel_format = PIXFORMAT_RGB565; + return *this; +} + +Config& +Config::setYuv() +{ + m_cfg->pixel_format = PIXFORMAT_YUV422; + return *this; +} + +Config& +Config::setGrayscale() +{ + m_cfg->pixel_format = PIXFORMAT_GRAYSCALE; + return *this; +} + +Config& +Config::setJpeg(int quality) +{ + m_cfg->pixel_format = PIXFORMAT_JPEG; + m_cfg->jpeg_quality = detail::convertJpegQuality(quality); + return *this; +} + +} // namespace esp32cam diff --git a/libraries/esp32cam-main/src/internal/config.hpp b/libraries/esp32cam-main/src/internal/config.hpp new file mode 100644 index 0000000..bd94dfb --- /dev/null +++ b/libraries/esp32cam-main/src/internal/config.hpp @@ -0,0 +1,58 @@ +#ifndef ESP32CAM_CONFIG_HPP +#define ESP32CAM_CONFIG_HPP + +#include "pins.hpp" +#include "resolution.hpp" + +namespace esp32cam { +namespace detail { + +/** @brief Convert JPEG quality from 0-100 scale to 63-0 scale. */ +int +convertJpegQuality(int quality); + +} // namespace detail + +/** @brief Camera configuration. */ +class Config +{ +public: + Config(); + + ~Config(); + + Config& setPins(const Pins& pins); + + Config& setResolution(const Resolution& resolution); + + /** + * @brief Set number of frame buffers. + * @param n >=1, having more frame buffers allows better streaming fps. + */ + Config& setBufferCount(int n); + + /** @brief Change pixel format to RGB565. */ + Config& setRgb(); + + /** @brief Change pixel format to YUV422. */ + Config& setYuv(); + + /** @brief Change pixel format to grayscale. */ + Config& setGrayscale(); + + /** + * @brief Change pixel format to JPEG. + * @param quality JPEG quality between 0 (worst) and 100 (best). + */ + Config& setJpeg(int quality); + +private: + class CameraConfigT; ///< camera_config_t + CameraConfigT* m_cfg; + + friend class CameraClass; +}; + +} // namespace esp32cam + +#endif // ESP32CAM_CONFIG_HPP diff --git a/libraries/esp32cam-main/src/internal/frame.cpp b/libraries/esp32cam-main/src/internal/frame.cpp new file mode 100644 index 0000000..06ce889 --- /dev/null +++ b/libraries/esp32cam-main/src/internal/frame.cpp @@ -0,0 +1,115 @@ +#include "frame.hpp" +#include "config.hpp" + +#include +#include + +namespace esp32cam { + +static const int PIXFORMAT_BMP = -101; + +struct Frame::CameraFbT : public camera_fb_t +{}; + +Frame::Frame() = default; + +Frame::Frame(void* fb) + : m_fb(static_cast(fb)) + , m_data(m_fb->buf) + , m_size(m_fb->len) + , m_width(m_fb->width) + , m_height(m_fb->height) + , m_pixFormat(m_fb->format) +{} + +Frame::~Frame() +{ + releaseFb(); + if (m_data != nullptr) { + free(m_data); + } +} + +void +Frame::releaseFb() +{ + if (m_fb != nullptr) { + esp_camera_fb_return(m_fb); + m_fb = nullptr; + m_data = nullptr; + } +} + +bool +Frame::writeTo(Print& os, int timeout) +{ + return writeToImpl(os, timeout, nullptr); +} + +bool +Frame::writeTo(Client& os, int timeout) +{ + return writeToImpl(os, timeout, &os); +} + +bool +Frame::writeToImpl(Print& os, int timeout, Client* client) +{ + auto startTime = millis(); + for (size_t i = 0; i < m_size; i += os.write(&m_data[i], m_size - i)) { + if (millis() - startTime > static_cast(timeout) || + (client != nullptr && !client->connected())) { + return false; + } + yield(); + } + return true; +} + +bool +Frame::isJpeg() const +{ + return m_pixFormat == PIXFORMAT_JPEG; +} + +bool +Frame::toJpeg(int quality) +{ + uint8_t* data; + size_t size; + bool ok = fmt2jpg(m_data, m_size, m_width, m_height, static_cast(m_pixFormat), + detail::convertJpegQuality(quality), &data, &size); + if (!ok) { + return false; + } + releaseFb(); + m_data = data; + m_size = size; + m_pixFormat = PIXFORMAT_JPEG; + return true; +} + +bool +Frame::isBmp() const +{ + return m_pixFormat == PIXFORMAT_BMP; +} + +bool +Frame::toBmp() +{ + uint8_t* data; + size_t size; + bool ok = + fmt2bmp(m_data, m_size, m_width, m_height, static_cast(m_pixFormat), &data, &size); + if (!ok) { + return false; + } + releaseFb(); + m_data = data; + m_size = size; + m_pixFormat = PIXFORMAT_BMP; + return true; +} + +} // namespace esp32cam diff --git a/libraries/esp32cam-main/src/internal/frame.hpp b/libraries/esp32cam-main/src/internal/frame.hpp new file mode 100644 index 0000000..8fb343b --- /dev/null +++ b/libraries/esp32cam-main/src/internal/frame.hpp @@ -0,0 +1,93 @@ +#ifndef ESP32CAM_FRAME_HPP +#define ESP32CAM_FRAME_HPP + +#include +#include + +class Client; +class Print; + +namespace esp32cam { + +/** @brief A frame of picture. */ +class Frame +{ +public: // access + ~Frame(); + + uint8_t* data() const + { + return m_data; + } + + size_t size() const + { + return m_size; + } + + int getWidth() const + { + return m_width; + } + + int getHeight() const + { + return m_height; + } + + /** + * @brief Write frame buffer to @p os . + * @param os output stream. + * @param timeout total time limit in millis. + * @retval true writing completed. + * @retval false writing disrupted by timeout. + */ + bool writeTo(Print& os, int timeout = 10000); + + /** + * @brief Write frame buffer to @p os . + * @param os output socket. + * @param timeout total time limit in millis. + * @retval true writing completed. + * @retval false writing disrupted by timeout or socket error. + */ + bool writeTo(Client& os, int timeout = 10000); + +public: // conversion + bool isJpeg() const; + + /** + * @brief Convert frame to JPEG. + * @param quality JPEG quality between 0 (worst) and 100 (best). + */ + bool toJpeg(int quality); + + bool isBmp() const; + + /** @brief Convert frame to BMP. */ + bool toBmp(); + +private: + Frame(); + + explicit Frame(void* fb); + + bool writeToImpl(Print& os, int timeout, Client* client); + + void releaseFb(); + +private: + class CameraFbT; ///< camera_fb_t + CameraFbT* m_fb = nullptr; + uint8_t* m_data = nullptr; + size_t m_size = 0; + int m_width = -1; + int m_height = -1; + int m_pixFormat = -1; + + friend class CameraClass; +}; + +} // namespace esp32cam + +#endif // ESP32CAM_FRAME_HPP diff --git a/libraries/esp32cam-main/src/internal/mjpeg.cpp b/libraries/esp32cam-main/src/internal/mjpeg.cpp new file mode 100644 index 0000000..2bdbdb2 --- /dev/null +++ b/libraries/esp32cam-main/src/internal/mjpeg.cpp @@ -0,0 +1,103 @@ +#include "mjpeg.hpp" + +#include + +namespace esp32cam { +namespace detail { + +MjpegController::MjpegController(MjpegConfig cfg) + : m_cfg(cfg) + , m_nextCaptureTime(millis()) +{} + +int +MjpegController::decideAction() +{ + if (m_nextAction == CAPTURE) { + auto t = static_cast(m_nextCaptureTime - millis()); + if (t > 0) { + return t; + } + return CAPTURE; + } + return m_nextAction; +} + +void +MjpegController::notifyCapture() +{ + m_nextAction = RETURN; + m_nextCaptureTime = millis() + static_cast(m_cfg.minInterval); +} + +void +MjpegController::notifyReturn(std::unique_ptr frame) +{ + if (frame == nullptr) { + notifyFail(); + return; + } + m_frame = std::move(frame); + m_nextAction = SEND; +} + +void +MjpegController::notifySent(bool ok) +{ + ++m_count; + if (!ok) { + notifyFail(); + return; + } + m_frame.reset(); + m_nextAction = m_cfg.maxFrames < 0 || m_count < m_cfg.maxFrames ? CAPTURE : STOP; +} + +void +MjpegController::notifyFail() +{ + m_frame.reset(); + m_nextAction = STOP; +} + +#define BOUNDARY "e8b8c539-047d-4777-a985-fbba6edff11e" + +void +MjpegHeader::prepareResponseHeaders() +{ + size = snprintf(buf, sizeof(buf), + "HTTP/1.1 200 OK\r\n" + "Content-Type: multipart/x-mixed-replace;boundary=" BOUNDARY "\r\n" + "\r\n"); +} + +void +MjpegHeader::prepareResponseContentType() +{ + size = snprintf(buf, sizeof(buf), "multipart/x-mixed-replace;boundary=" BOUNDARY); +} + +void +MjpegHeader::preparePartHeader(size_t contentLength) +{ + size = snprintf(buf, sizeof(buf), + "Content-Type: image/jpeg\r\n" + "Content-Length: %zu\r\n" + "\r\n", + contentLength); +} + +void +MjpegHeader::preparePartTrailer() +{ + size = snprintf(buf, sizeof(buf), "\r\n--" BOUNDARY "\r\n"); +} + +size_t +MjpegHeader::writeTo(Print& os) +{ + return os.write(buf, size); +} + +} // namespace detail +} // namespace esp32cam diff --git a/libraries/esp32cam-main/src/internal/mjpeg.hpp b/libraries/esp32cam-main/src/internal/mjpeg.hpp new file mode 100644 index 0000000..de283d8 --- /dev/null +++ b/libraries/esp32cam-main/src/internal/mjpeg.hpp @@ -0,0 +1,121 @@ +#ifndef ESP32CAM_MJPEG_HPP +#define ESP32CAM_MJPEG_HPP + +#include "frame.hpp" + +#include + +namespace esp32cam { + +struct MjpegConfig +{ + /** @brief minimum interval between frame captures. */ + int minInterval = 0; + /** @brief maximum number of frames before disconnecting. */ + int maxFrames = -1; + /** @brief time limit of writing one frame in millis. */ + int frameTimeout = 10000; +}; + +namespace detail { + +/** @brief Control MJPEG stream timing. */ +class MjpegController +{ +public: + explicit MjpegController(MjpegConfig cfg); + + /** @brief Retrieve config object. */ + const MjpegConfig& getConfig() const + { + return m_cfg; + } + + /** @brief Retrieve number of sent frames. */ + int countSentFrames() const + { + return m_count; + } + + enum + { + CAPTURE = -1, + RETURN = -2, + SEND = -3, + STOP = -4, + }; + + /** + * @brief Decide what to do now. + * @retval CAPTURE capture a frame. + * @retval RETURN return a captured frame. + * @retval SEND send current frame to the client. + * @retval STOP disconnect the client. + * @return if non-negative, how long to delay (millis) before the next action. + */ + int decideAction(); + + /** + * @brief Notify that frame capture has started. + * @post decideAction()==RETURN + */ + void notifyCapture(); + + /** + * @brief Notify that frame capture has completed. + * @param frame captured frame, possibly nullptr. + * @post if frame==nullptr, decideAction()==STOP; otherwise, decideAction()==SEND + */ + void notifyReturn(std::unique_ptr frame); + + /** @brief Retrieve current frame. */ + Frame* getFrame() const + { + return m_frame.get(); + } + + /** + * @brief Notify that a frame is sent to the client. + * @param ok whether sent successfully. + * @post getFrame()==nullptr + */ + void notifySent(bool ok); + + /** + * @brief Notify that an error has occurred. + * @post getFrame()==nullptr + * @post decideAction()==STOP + */ + void notifyFail(); + +private: + MjpegConfig m_cfg; + std::unique_ptr m_frame; + unsigned long m_nextCaptureTime; + int m_nextAction = CAPTURE; + int m_count = 0; +}; + +/** @brief Prepare HTTP headers related to MJPEG streaming. */ +class MjpegHeader +{ +public: + void prepareResponseHeaders(); + + void prepareResponseContentType(); + + void preparePartHeader(size_t contentLength); + + void preparePartTrailer(); + + size_t writeTo(Print& os); + +public: + size_t size = 0; + char buf[160]; +}; + +} // namespace detail +} // namespace esp32cam + +#endif // ESP32CAM_MJPEG_HPP diff --git a/libraries/esp32cam-main/src/internal/pins.hpp b/libraries/esp32cam-main/src/internal/pins.hpp new file mode 100644 index 0000000..970db04 --- /dev/null +++ b/libraries/esp32cam-main/src/internal/pins.hpp @@ -0,0 +1,136 @@ +#ifndef ESP32CAM_PINS_HPP +#define ESP32CAM_PINS_HPP + +namespace esp32cam { + +/** @brief Camera pins definition. */ +struct Pins +{ + int D0; + int D1; + int D2; + int D3; + int D4; + int D5; + int D6; + int D7; + int XCLK; + int PCLK; + int VSYNC; + int HREF; + int SDA; + int SCL; + int RESET; + int PWDN; +}; + +namespace pins { + +/** @brief Pin definition for AI Thinker ESP32-CAM. */ +constexpr Pins AiThinker{ + D0: 5, + D1: 18, + D2: 19, + D3: 21, + D4: 36, + D5: 39, + D6: 34, + D7: 35, + XCLK: 0, + PCLK: 22, + VSYNC: 25, + HREF: 23, + SDA: 26, + SCL: 27, + RESET: -1, + PWDN: 32, +}; + +/** @brief Pin definition for FREENOVE WROVER ESP32-CAM. */ +constexpr Pins FreeNove{ + D0: 4, + D1: 5, + D2: 18, + D3: 19, + D4: 36, + D5: 39, + D6: 34, + D7: 35, + XCLK: 21, + PCLK: 22, + VSYNC: 25, + HREF: 23, + SDA: 26, + SCL: 27, + RESET: -1, + PWDN: -1, +}; + +/** @brief Pin definition for M5Stack M5Camera. */ +constexpr Pins M5Camera{ + D0: 32, + D1: 35, + D2: 34, + D3: 5, + D4: 39, + D5: 18, + D6: 36, + D7: 19, + XCLK: 27, + PCLK: 21, + VSYNC: 25, + HREF: 26, + SDA: 22, + SCL: 23, + RESET: 15, + PWDN: -1, +}; + +/** + * @brief Pin definition for M5Stack M5Camera with LED. + * + * Red LED on GPIO 14, tally light when tied to PWDN + */ +constexpr Pins M5CameraLED{ + D0: 32, + D1: 35, + D2: 34, + D3: 5, + D4: 39, + D5: 18, + D6: 36, + D7: 19, + XCLK: 27, + PCLK: 21, + VSYNC: 25, + HREF: 26, + SDA: 22, + SCL: 23, + RESET: 15, + PWDN: 14, +}; + +/** @brief Pin definition for TTGO ESP32-CAM. */ +constexpr Pins TTGO{ + D0: 5, + D1: 14, + D2: 4, + D3: 15, + D4: 37, + D5: 38, + D6: 36, + D7: 39, + XCLK: 32, + PCLK: 19, + VSYNC: 27, + HREF: 25, + SDA: 13, + SCL: 12, + RESET: -1, + PWDN: -1, +}; + +} // namespace pins +} // namespace esp32cam + +#endif // ESP32CAM_PINS_HPP diff --git a/libraries/esp32cam-main/src/internal/resolution.cpp b/libraries/esp32cam-main/src/internal/resolution.cpp new file mode 100644 index 0000000..be25904 --- /dev/null +++ b/libraries/esp32cam-main/src/internal/resolution.cpp @@ -0,0 +1,86 @@ +#include "resolution.hpp" +#include + +#include + +namespace esp32cam { + +ResolutionList::ResolutionList(int max) + : m_max(max) +{} + +ResolutionList::Iterator +ResolutionList::begin() const +{ + return Iterator(0); +} + +ResolutionList::Iterator +ResolutionList::end() const +{ + return Iterator(m_max); +} + +Resolution +ResolutionList::find(int minWidth, int minHeight) const +{ + for (auto r : *this) { + if (r.getWidth() >= minWidth && r.getHeight() >= minHeight) { + return r; + } + } + return Resolution(); +} + +ResolutionList +Resolution::list() +{ + static ResolutionList list(FRAMESIZE_INVALID); + return list; +} + +Resolution +Resolution::find(int minWidth, int minHeight) +{ + return list().find(minWidth, minHeight); +} + +Resolution::Resolution(int frameSize) + : m_frameSize(frameSize) +{} + +bool +Resolution::isValid() const +{ + return m_frameSize >= 0 && m_frameSize < FRAMESIZE_INVALID; +} + +int +Resolution::getWidth() const +{ + if (!isValid()) { + return -1; + } + return ::resolution[m_frameSize].width; +} + +int +Resolution::getHeight() const +{ + if (!isValid()) { + return -1; + } + return ::resolution[m_frameSize].height; +} + +size_t +Resolution::printTo(Print& p) const +{ + size_t len = 0; + len += p.print(getWidth()); + len += p.print('x'); + len += p.print(getHeight()); + return len; +} + +} // namespace esp32cam diff --git a/libraries/esp32cam-main/src/internal/resolution.hpp b/libraries/esp32cam-main/src/internal/resolution.hpp new file mode 100644 index 0000000..51663d1 --- /dev/null +++ b/libraries/esp32cam-main/src/internal/resolution.hpp @@ -0,0 +1,159 @@ +#ifndef ESP32CAM_RESOLUTION_HPP +#define ESP32CAM_RESOLUTION_HPP + +#include +#include + +namespace esp32cam { + +class ResolutionList; + +/** @brief Picture width and height. */ +class Resolution : public Printable +{ +public: + /** + * @brief Return an iterable collection of possible resolutions. + * + * This list contains all resolutions defined in the esp32-camera library, + * but not necessarily supported by the camera hardware. + * Use @c Camera.listResolutions() to retrieve supported resolutions. + */ + static ResolutionList list(); + + /** + * @brief Find a resolution that satisfies given constraints. + * + * This searches among all resolutions defined in the esp32-camera libary, + * which is not necessarily supported by the camera hardware. + */ + static Resolution find(int minWidth, int minHeight); + + /** + * @brief Constructor. + * @param frameSize framesize_t value. + */ + explicit Resolution(int frameSize = -1); + + /** @brief Determine if this resolution is valid. */ + bool isValid() const; + + /** @brief Return picture width in pixels. */ + int getWidth() const; + + /** @brief Return picture height in pixels. */ + int getHeight() const; + + /** @brief Print WxH to output stream. */ + size_t printTo(Print& p) const override; + + /** + * @brief Convert to framesize_t (internal use). + * @tparam T framesize_t + */ + template + T as() const + { + return static_cast(m_frameSize); + } + +private: + int m_frameSize; ///< framesize_t + + friend bool operator==(const Resolution& lhs, const Resolution& rhs) + { + return (!lhs.isValid() && !rhs.isValid()) || (lhs.m_frameSize == rhs.m_frameSize); + } + + friend bool operator!=(const Resolution& lhs, const Resolution& rhs) + { + return !(lhs == rhs); + } + + friend bool operator<(const Resolution& lhs, const Resolution& rhs) + { + return lhs.m_frameSize < rhs.m_frameSize; + } + + friend bool operator>(const Resolution& lhs, const Resolution& rhs) + { + return lhs.m_frameSize > rhs.m_frameSize; + } +}; + +/** + * @brief A collection of resolutions. + * @code + * for (const auto& resolution : Resolution::list()) { + * Serial.println(resolution); + * } + * @endcode + */ +class ResolutionList +{ +public: + class Iterator + { + public: + using iterator_catagory = std::forward_iterator_tag; + using value_type = const Resolution; + using difference_type = std::ptrdiff_t; + using pointer = void; + using reference = value_type; + + explicit Iterator(int value = -1) + : m_frameSize(value) + {} + + Iterator& operator++() + { + ++m_frameSize; + return *this; + } + + Iterator operator++(int) + { + Iterator copy(*this); + ++*this; + return copy; + } + + reference operator*() + { + return Resolution(m_frameSize); + } + + private: + int m_frameSize; ///< framesize_t + + friend bool operator==(const Iterator& lhs, const Iterator& rhs) + { + return lhs.m_frameSize == rhs.m_frameSize; + } + + friend bool operator!=(const Iterator& lhs, const Iterator& rhs) + { + return !(lhs == rhs); + } + }; + + /** + * @brief Constructor. + * @param max exclusive maximum framesize_t. + */ + explicit ResolutionList(int max = 0); + + Iterator begin() const; + + Iterator end() const; + + /** @brief Find a resolution that satisfies given constraints. */ + Resolution find(int minWidth, int minHeight) const; + +private: + int m_max; +}; + +} // namespace esp32cam + +#endif // ESP32CAM_RESOLUTION_HPP diff --git a/libraries/readme.txt b/libraries/readme.txt new file mode 100644 index 0000000..96ce674 --- /dev/null +++ b/libraries/readme.txt @@ -0,0 +1 @@ +For information on installing libraries, see: http://www.arduino.cc/en/Guide/Libraries