diff --git a/.github/scripts/install-arduino-cli.sh b/.github/scripts/install-arduino-cli.sh new file mode 100755 index 00000000000..ba7547ccc28 --- /dev/null +++ b/.github/scripts/install-arduino-cli.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +OSBITS=`arch` +if [[ "$OSTYPE" == "linux"* ]]; then + export OS_IS_LINUX="1" + if [[ "$OSBITS" == "i686" ]]; then + OS_NAME="linux32" + elif [[ "$OSBITS" == "x86_64" ]]; then + OS_NAME="linux64" + elif [[ "$OSBITS" == "armv7l" || "$OSBITS" == "aarch64" ]]; then + OS_NAME="linuxarm" + else + OS_NAME="$OSTYPE-$OSBITS" + echo "Unknown OS '$OS_NAME'" + exit 1 + fi +elif [[ "$OSTYPE" == "darwin"* ]]; then + export OS_IS_MACOS="1" + OS_NAME="macosx" +elif [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then + export OS_IS_WINDOWS="1" + OS_NAME="windows" +else + OS_NAME="$OSTYPE-$OSBITS" + echo "Unknown OS '$OS_NAME'" + exit 1 +fi +export OS_NAME + +if [ "$OS_IS_MACOS" == "1" ]; then + export ARDUINO_IDE_PATH="$HOME/bin" + export ARDUINO_USR_PATH="$HOME/Documents/Arduino" +elif [ "$OS_IS_WINDOWS" == "1" ]; then + export ARDUINO_IDE_PATH="$HOME/bin" + export ARDUINO_USR_PATH="$HOME/Documents/Arduino" +else + export ARDUINO_IDE_PATH="$HOME/bin" + export ARDUINO_USR_PATH="$HOME/Arduino" +fi + +if [ ! -d "$ARDUINO_IDE_PATH" ] || [ ! -f "$ARDUINO_IDE_PATH/arduino-cli" ]; then + echo "Installing Arduino CLI on $OS_NAME ..." + mkdir -p "$ARDUINO_IDE_PATH" + curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR="$ARDUINO_IDE_PATH" sh +fi + diff --git a/.github/scripts/install-platformio-esp32.sh b/.github/scripts/install-platformio-esp32.sh index 96cf7330f6b..b3f7b081ba1 100755 --- a/.github/scripts/install-platformio-esp32.sh +++ b/.github/scripts/install-platformio-esp32.sh @@ -3,8 +3,8 @@ export PLATFORMIO_ESP32_PATH="$HOME/.platformio/packages/framework-arduinoespressif32" PLATFORMIO_ESP32_URL="https://github.com/platformio/platform-espressif32.git" -TOOLCHAIN_VERSION="8.4.0+2021r2-patch3" -ESPTOOLPY_VERSION="~1.40201.0" +TOOLCHAIN_VERSION="8.4.0+2021r2-patch5" +ESPTOOLPY_VERSION="~1.40400.0" ESPRESSIF_ORGANIZATION_NAME="espressif" echo "Installing Python Wheel ..." diff --git a/.github/scripts/on-push.sh b/.github/scripts/on-push.sh index 71a92a1021a..0ca5a648fd0 100755 --- a/.github/scripts/on-push.sh +++ b/.github/scripts/on-push.sh @@ -9,7 +9,8 @@ function build(){ local fqbn=$2 local chunk_index=$3 local chunks_cnt=$4 - local sketches=$5 + shift; shift; shift; shift; + local sketches=$* local BUILD_SKETCH="${SCRIPTS_DIR}/sketch_utils.sh build" local BUILD_SKETCHES="${SCRIPTS_DIR}/sketch_utils.sh chunk_build" @@ -24,15 +25,15 @@ function build(){ ${BUILD_SKETCHES} ${args} else for sketch in ${sketches}; do - args+=" -s $(dirname $sketch)" - if [ "$OS_IS_WINDOWS" == "1" ]; then + local sargs="$args -s $(dirname $sketch)" + if [ "$OS_IS_WINDOWS" == "1" ] && [ -d "$ARDUINO_IDE_PATH/tools-builder" ]; then local ctags_version=`ls "$ARDUINO_IDE_PATH/tools-builder/ctags/"` local preprocessor_version=`ls "$ARDUINO_IDE_PATH/tools-builder/arduino-preprocessor/"` win_opts="-prefs=runtime.tools.ctags.path=$ARDUINO_IDE_PATH/tools-builder/ctags/$ctags_version -prefs=runtime.tools.arduino-preprocessor.path=$ARDUINO_IDE_PATH/tools-builder/arduino-preprocessor/$preprocessor_version" - args+=" ${win_opts}" + sargs+=" ${win_opts}" fi - ${BUILD_SKETCH} ${args} + ${BUILD_SKETCH} ${sargs} done fi } @@ -59,7 +60,8 @@ fi SCRIPTS_DIR="./.github/scripts" if [ "$BUILD_PIO" -eq 0 ]; then - source ${SCRIPTS_DIR}/install-arduino-ide.sh + #source ${SCRIPTS_DIR}/install-arduino-ide.sh + source ${SCRIPTS_DIR}/install-arduino-cli.sh source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh FQBN_ESP32="espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app" diff --git a/.github/scripts/on-release.sh b/.github/scripts/on-release.sh index fb595b4df2c..947146ec492 100755 --- a/.github/scripts/on-release.sh +++ b/.github/scripts/on-release.sh @@ -197,10 +197,10 @@ find "$PKG_DIR" -name '*.git*' -type f -delete echo "Generating platform.txt..." cat "$GITHUB_WORKSPACE/platform.txt" | \ sed "s/version=.*/version=$ver$extent/g" | \ -sed 's/runtime.tools.xtensa-esp32-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32-elf//g' | \ -sed 's/runtime.tools.xtensa-esp32s2-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32s2-elf//g' | \ -sed 's/runtime.tools.xtensa-esp32s3-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32s3-elf//g' | \ -sed 's/runtime.tools.riscv32-esp-elf-gcc.path={runtime.platform.path}\/tools\/riscv32-esp-elf//g' | \ +sed 's/tools.xtensa-esp32-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32-elf/tools.xtensa-esp32-elf-gcc.path=\{runtime.tools.xtensa-esp32-elf-gcc.path\}/g' | \ +sed 's/tools.xtensa-esp32s2-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32s2-elf/tools.xtensa-esp32s2-elf-gcc.path=\{runtime.tools.xtensa-esp32s2-elf-gcc.path\}/g' | \ +sed 's/tools.xtensa-esp32s3-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32s3-elf/tools.xtensa-esp32s3-elf-gcc.path=\{runtime.tools.xtensa-esp32s3-elf-gcc.path\}/g' | \ +sed 's/tools.riscv32-esp-elf-gcc.path={runtime.platform.path}\/tools\/riscv32-esp-elf/tools.riscv32-esp-elf-gcc.path=\{runtime.tools.riscv32-esp-elf-gcc.path\}/g' | \ sed 's/tools.esptool_py.path={runtime.platform.path}\/tools\/esptool/tools.esptool_py.path=\{runtime.tools.esptool_py.path\}/g' | \ sed 's/debug.server.openocd.path={runtime.platform.path}\/tools\/openocd-esp32\/bin\/openocd/debug.server.openocd.path=\{runtime.tools.openocd-esp32.path\}\/bin\/openocd/g' | \ sed 's/debug.server.openocd.scripts_dir={runtime.platform.path}\/tools\/openocd-esp32\/share\/openocd\/scripts\//debug.server.openocd.scripts_dir=\{runtime.tools.openocd-esp32.path\}\/share\/openocd\/scripts\//g' | \ diff --git a/.github/scripts/sketch_utils.sh b/.github/scripts/sketch_utils.sh index 3a856202e51..4a8d500bcbc 100755 --- a/.github/scripts/sketch_utils.sh +++ b/.github/scripts/sketch_utils.sh @@ -121,34 +121,65 @@ function build_sketch(){ # build_sketch [ex if [ -n "$ARDUINO_BUILD_DIR" ]; then build_dir="$ARDUINO_BUILD_DIR" elif [ $len -eq 1 ]; then - build_dir="$sketchdir/build" + # build_dir="$sketchdir/build" + build_dir="$HOME/.arduino/build.tmp" fi mkdir -p "$ARDUINO_CACHE_DIR" for i in `seq 0 $(($len - 1))` do if [ $len -ne 1 ]; then - build_dir="$sketchdir/build$i" + # build_dir="$sketchdir/build$i" + build_dir="$HOME/.arduino/build$i.tmp" fi rm -rf $build_dir mkdir -p $build_dir currfqbn=`echo $fqbn | jq -r --argjson i $i '.[$i]'` sketchname=$(basename $sketchdir) - echo "Building $sketchname with FQBN=$currfqbn" - $ide_path/arduino-builder -compile -logger=human -core-api-version=10810 \ - -fqbn=\"$currfqbn\" \ - -warnings="all" \ - -tools "$ide_path/tools-builder" \ - -tools "$ide_path/tools" \ - -built-in-libraries "$ide_path/libraries" \ - -hardware "$ide_path/hardware" \ - -hardware "$user_path/hardware" \ - -libraries "$user_path/libraries" \ - -build-cache "$ARDUINO_CACHE_DIR" \ - -build-path "$build_dir" \ - $xtra_opts "${sketchdir}/${sketchname}.ino" + + if [ -f "$ide_path/arduino-cli" ]; then + echo "Building $sketchname with arduino-cli and FQBN=$currfqbn" + + curroptions=`echo "$currfqbn" | cut -d':' -f4` + currfqbn=`echo "$currfqbn" | cut -d':' -f1-3` + $ide_path/arduino-cli compile \ + --fqbn "$currfqbn" \ + --board-options "$curroptions" \ + --warnings "all" \ + --build-cache-path "$ARDUINO_CACHE_DIR" \ + --build-path "$build_dir" \ + $xtra_opts "${sketchdir}" + elif [ -f "$ide_path/arduino-builder" ]; then + echo "Building $sketchname with arduino-builder and FQBN=$currfqbn" + + $ide_path/arduino-builder -compile -logger=human -core-api-version=10810 \ + -fqbn=\"$currfqbn\" \ + -warnings="all" \ + -tools "$ide_path/tools-builder" \ + -hardware "$user_path/hardware" \ + -libraries "$user_path/libraries" \ + -build-cache "$ARDUINO_CACHE_DIR" \ + -build-path "$build_dir" \ + $xtra_opts "${sketchdir}/${sketchname}.ino" + + # $ide_path/arduino-builder -compile -logger=human -core-api-version=10810 \ + # -fqbn=\"$currfqbn\" \ + # -warnings="all" \ + # -tools "$ide_path/tools-builder" \ + # -tools "$ide_path/tools" \ + # -built-in-libraries "$ide_path/libraries" \ + # -hardware "$ide_path/hardware" \ + # -hardware "$user_path/hardware" \ + # -libraries "$user_path/libraries" \ + # -build-cache "$ARDUINO_CACHE_DIR" \ + # -build-path "$build_dir" \ + # $xtra_opts "${sketchdir}/${sketchname}.ino" + fi done + unset fqbn + unset xtra_opts + unset options } function count_sketches(){ # count_sketches [target] @@ -294,8 +325,7 @@ function build_sketches(){ # build_sketches +#include struct InterruptArgStructure { std::function interruptFunction; diff --git a/libraries/BLE/examples/BLE_client/BLE_client.ino b/libraries/BLE/examples/BLE_client/BLE_client.ino index 5d39c109709..74ae8b7532d 100644 --- a/libraries/BLE/examples/BLE_client/BLE_client.ino +++ b/libraries/BLE/examples/BLE_client/BLE_client.ino @@ -29,7 +29,8 @@ static void notifyCallback( Serial.print(" of data length "); Serial.println(length); Serial.print("data: "); - Serial.println((char*)pData); + Serial.write(pData, length); + Serial.println(); } class MyClientCallback : public BLEClientCallbacks { diff --git a/libraries/Ethernet/src/ETH.cpp b/libraries/Ethernet/src/ETH.cpp index a9be448e6ac..4b9b5edee2f 100644 --- a/libraries/Ethernet/src/ETH.cpp +++ b/libraries/Ethernet/src/ETH.cpp @@ -392,7 +392,7 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ log_e("esp_eth_init error: %d", err); } #endif - // holds a few microseconds to let DHCP start and enter into a good state + // holds a few milliseconds to let DHCP start and enter into a good state // FIX ME -- adresses issue https://github.com/espressif/arduino-esp32/issues/5733 delay(50); diff --git a/libraries/WiFi/examples/WiFiClient/README.md b/libraries/WiFi/examples/WiFiClient/README.md new file mode 100644 index 00000000000..079ed9f29a8 --- /dev/null +++ b/libraries/WiFi/examples/WiFiClient/README.md @@ -0,0 +1,165 @@ +# WiFiClient + +This example demonstrates reading and writing data from and to a web service which can be used for logging data, creating insights and taking actions based on those data. + +# Supported Targets + +Currently, this example supports all SoC with WiFi. + + +| Supported Targets | ESP32 | ESP32-S2 | ESP32-C3 | ESP32-S3 | + + +## How to Use Example + +Flash this example and observe the serial output. You can also take a look at the values at [https://thingspeak.com/channels/2005329](https://thingspeak.com/channels/2005329) + +Please note that this public channel can be accessed by anyone and it is possible that more people will write their values. + +### Configure the Project + +Change `SSID` and `password` to connect to your WiFi. +Default values will allow you to use this example without any changes. If you want to use your own channel and you don't have one already follow these steps: + +* Create an account on [thingspeak.com](https://www.thingspeak.com). +* After logging in, click on the "New Channel" button to create a new channel for your data. This is where your data will be stored and displayed. +* Fill in the Name, Description, and other fields for your channel as desired, then click the "Save Channel" button. +* Take note of the "Write API Key" located in the "API keys" tab, this is the key you will use to send data to your channel. +* Replace the channelID from tab "Channel Settings" and privateKey with "Read API Keys" from "API Keys" tab. +* Replace the host variable with the thingspeak server hostname "api.thingspeak.com" +* Upload the sketch to your ESP32 board and make sure that the board is connected to the internet. The ESP32 should now send data to your Thingspeak channel at the intervals specified by the loop function. +* Go to the channel view page on thingspeak and check the "Field1" for the new incoming data. +* You can use the data visualization and analysis tools provided by Thingspeak to display and process your data in various ways. +* Please note, that Thingspeak accepts only integer values. + +#### Config example: + +You can find the data to be changed at the top of the file: + +```cpp +const char* ssid = "your-ssid"; // Change this to your WiFi SSID +const char* password = "your-password"; // Change this to your WiFi password + +const char* host = "api.thingspeak.com"; // This should not be changed +const int httpPort = 80; // This should not be changed +const String channelID = "2005329"; // Change this to your channel ID +const String writeApiKey = "V6YOTILH9I7D51F9"; // Change this to your Write API key +const String readApiKey = "34W6LGLIFXD56MPM"; // Change this to your Read API key + +// The default example accepts one data filed named "field1" +// For your own server you can ofcourse create more of them. +int field1 = 0; + +int numberOfResults = 3; // Number of results to be read +int fieldNumber = 1; // Field number which will be read out +``` + +#### Using Arduino IDE + +To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits). + +* Before Compile/Verify, select the correct board: `Tools -> Board`. +* Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port. + +#### Using Platform IO + +* Select the COM port: `Devices` or set the `upload_port` option on the `platformio.ini` file. + +## Example Log Output + +The initial output which is common for all examples can be ignored: +``` +SP-ROM:esp32c3-api1-20210207 +Build:Feb 7 2021 +rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT) +SPIWP:0xee +mode:DIO, clock div:1 +load:0x3fcd5810,len:0x438 +load:0x403cc710,len:0x918 +load:0x403ce710,len:0x24e4 +entry 0x403cc710 +``` +Follows the setup output where connection to your WiFi happens: +``` +****************************************************** +Connecting to your-ssid +. +WiFi connected +IP address: +192.168.1.2 +``` +Then you can see the write log: +``` +HTTP/1.1 200 OK +Date: Fri, 13 Jan 2023 13:12:31 GMT +Content-Type: text/plain; charset=utf-8 +Content-Length: 1 +Connection: close +Status: 200 OK +Cache-Control: max-age=0, private, must-revalidate +Access-Control-Allow-Origin: * +Access-Control-Max-Age: 1800 +X-Request-Id: 188e3464-f155-44b0-96f6-0f3614170bb0 +Access-Control-Allow-Headers: origin, content-type, X-Requested-With +Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS, DELETE, PATCH +ETag: W/"5feceb66ffc86f38d952786c6d696c79" +X-Frame-Options: SAMEORIGIN + +0 +Closing connection +``` +Last portion is the read log: +``` +HTTP/1.1 200 OK +Date: Fri, 13 Jan 2023 13:12:32 GMT +Content-Type: application/json; charset=utf-8 +Transfer-Encoding: chunked +Connection: close +Status: 200 OK +Cache-Control: max-age=7, private +Access-Control-Allow-Origin: * +Access-Control-Max-Age: 1800 +X-Request-Id: 91b97016-7625-44f6-9797-1b2973aa57b7 +Access-Control-Allow-Headers: origin, content-type, X-Requested-With +Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS, DELETE, PATCH +ETag: W/"8e9c308fe2c50309f991586be1aff28d" +X-Frame-Options: SAMEORIGIN + +1e3 +{"channel":{"id":2005329,"name":"WiFiCLient example","description":"Default setup for Arduino ESP32 WiFiClient example","latitude":"0.0","longitude":"0.0","field1":"data0","created_at":"2023-01-11T15:56:08Z","updated_at":"2023-01-13T08:13:58Z","last_entry_id":2871},"feeds":[{"created_at":"2023-01-13T13:11:30Z","entry_id":2869,"field1":"359"},{"created_at":"2023-01-13T13:11:57Z","entry_id":2870,"field1":"361"},{"created_at":"2023-01-13T13:12:23Z","entry_id":2871,"field1":"363"}]} +0 + + +Closing connection +``` +After this the write+read log repeat every 10 seconds. + + +## Troubleshooting + +***Important: Make sure you are using a good quality USB cable and that you have a reliable power source*** + +* **WiFi not connected:** Check the SSID and password and also that the signal has sufficient strength. +* **400 Bad Request:** Check the writeApiKey. +* **404 Not Found:** Check the channel ID. +* **No data on chart / reading NULL:** Data must be sent as an integer, without commas. + +If the error persists, you can ask for help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute). + +## Contribute + +To know how to contribute to this project, see [How to contribute.](https://github.com/espressif/arduino-esp32/blob/master/CONTRIBUTING.rst) + +If you have any **feedback** or **issue** to report on this example/library, please open an issue or fix it by creating a new PR. Contributions are more than welcome! + +Before creating a new issue, be sure to try the Troubleshooting and to check if the same issue was already created by someone else. + +## Resources + +* Official ESP32 Forum: [Link](https://esp32.com) +* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32) +* ESP32 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf) +* ESP32-S2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf) +* ESP32-C3 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf) +* ESP32-S3 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-s3_datasheet_en.pdf) +* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com) diff --git a/libraries/WiFi/examples/WiFiClient/WiFiClient.ino b/libraries/WiFi/examples/WiFiClient/WiFiClient.ino index 7dd9c8d0d35..ebd207984a2 100644 --- a/libraries/WiFi/examples/WiFiClient/WiFiClient.ino +++ b/libraries/WiFi/examples/WiFiClient/WiFiClient.ino @@ -1,29 +1,46 @@ /* - * This sketch sends data via HTTP GET requests to data.sparkfun.com service. - * - * You need to get streamId and privateKey at data.sparkfun.com and paste them - * below. Or just customize this script to talk to other HTTP servers. - * + Go to thingspeak.com and create an account if you don't have one already. + After logging in, click on the "New Channel" button to create a new channel for your data. This is where your data will be stored and displayed. + Fill in the Name, Description, and other fields for your channel as desired, then click the "Save Channel" button. + Take note of the "Write API Key" located in the "API keys" tab, this is the key you will use to send data to your channel. + Replace the channelID from tab "Channel Settings" and privateKey with "Read API Keys" from "API Keys" tab. + Replace the host variable with the thingspeak server hostname "api.thingspeak.com" + Upload the sketch to your ESP32 board and make sure that the board is connected to the internet. The ESP32 should now send data to your Thingspeak channel at the intervals specified by the loop function. + Go to the channel view page on thingspeak and check the "Field1" for the new incoming data. + You can use the data visualization and analysis tools provided by Thingspeak to display and process your data in various ways. + Please note, that Thingspeak accepts only integer values. + + You can later check the values at https://thingspeak.com/channels/2005329 + Please note that this public channel can be accessed by anyone and it is possible that more people will write their values. */ #include -const char* ssid = "your-ssid"; -const char* password = "your-password"; +const char* ssid = "your-ssid"; // Change this to your WiFi SSID +const char* password = "your-password"; // Change this to your WiFi password -const char* host = "data.sparkfun.com"; -const char* streamId = "...................."; -const char* privateKey = "...................."; +const char* host = "api.thingspeak.com"; // This should not be changed +const int httpPort = 80; // This should not be changed +const String channelID = "2005329"; // Change this to your channel ID +const String writeApiKey = "V6YOTILH9I7D51F9"; // Change this to your Write API key +const String readApiKey = "34W6LGLIFXD56MPM"; // Change this to your Read API key + +// The default example accepts one data filed named "field1" +// For your own server you can ofcourse create more of them. +int field1 = 0; + +int numberOfResults = 3; // Number of results to be read +int fieldNumber = 1; // Field number which will be read out void setup() { Serial.begin(115200); - delay(10); + while(!Serial){delay(100);} // We start by connecting to a WiFi network Serial.println(); - Serial.println(); + Serial.println("******************************************************"); Serial.print("Connecting to "); Serial.println(ssid); @@ -40,55 +57,52 @@ void setup() Serial.println(WiFi.localIP()); } -int value = 0; - -void loop() -{ - delay(5000); - ++value; - - Serial.print("connecting to "); - Serial.println(host); - - // Use WiFiClient class to create TCP connections - WiFiClient client; - const int httpPort = 80; - if (!client.connect(host, httpPort)) { - Serial.println("connection failed"); - return; +void readResponse(WiFiClient *client){ + unsigned long timeout = millis(); + while(client->available() == 0){ + if(millis() - timeout > 5000){ + Serial.println(">>> Client Timeout !"); + client->stop(); + return; } + } - // We now create a URI for the request - String url = "/input/"; - url += streamId; - url += "?private_key="; - url += privateKey; - url += "&value="; - url += value; - - Serial.print("Requesting URL: "); - Serial.println(url); - - // This will send the request to the server - client.print(String("GET ") + url + " HTTP/1.1\r\n" + - "Host: " + host + "\r\n" + - "Connection: close\r\n\r\n"); - unsigned long timeout = millis(); - while (client.available() == 0) { - if (millis() - timeout > 5000) { - Serial.println(">>> Client Timeout !"); - client.stop(); - return; - } - } - - // Read all the lines of the reply from server and print them to Serial - while(client.available()) { - String line = client.readStringUntil('\r'); - Serial.print(line); - } + // Read all the lines of the reply from server and print them to Serial + while(client->available()) { + String line = client->readStringUntil('\r'); + Serial.print(line); + } - Serial.println(); - Serial.println("closing connection"); + Serial.printf("\nClosing connection\n\n"); } +void loop(){ + WiFiClient client; + String footer = String(" HTTP/1.1\r\n") + "Host: " + String(host) + "\r\n" + "Connection: close\r\n\r\n"; + + // WRITE -------------------------------------------------------------------------------------------- + if (!client.connect(host, httpPort)) { + return; + } + + client.print("GET /update?api_key=" + writeApiKey + "&field1=" + field1 + footer); + readResponse(&client); + + // READ -------------------------------------------------------------------------------------------- + + String readRequest = "GET /channels/" + channelID + "/fields/" + fieldNumber + ".json?results=" + numberOfResults + " HTTP/1.1\r\n" + + "Host: " + host + "\r\n" + + "Connection: close\r\n\r\n"; + + if (!client.connect(host, httpPort)) { + return; + } + + client.print(readRequest); + readResponse(&client); + + // ------------------------------------------------------------------------------------------------- + + ++field1; + delay(10000); +} \ No newline at end of file diff --git a/libraries/WiFi/src/WiFiAP.h b/libraries/WiFi/src/WiFiAP.h index a9d8f551e51..7ac03034b4c 100644 --- a/libraries/WiFi/src/WiFiAP.h +++ b/libraries/WiFi/src/WiFiAP.h @@ -38,6 +38,10 @@ class WiFiAPClass public: bool softAP(const char* ssid, const char* passphrase = NULL, int channel = 1, int ssid_hidden = 0, int max_connection = 4, bool ftm_responder = false); + bool softAP(const String& ssid, const String& passphrase = emptyString, int channel = 1, int ssid_hidden = 0, int max_connection = 4, bool ftm_responder = false) { + return softAP(ssid.c_str(), passphrase.c_str(), channel, ssid_hidden, max_connection, ftm_responder); + } + bool softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dhcp_lease_start = (uint32_t) 0); bool softAPdisconnect(bool wifioff = false); diff --git a/platform.txt b/platform.txt index 7fc48d07115..b6152789e24 100644 --- a/platform.txt +++ b/platform.txt @@ -1,10 +1,10 @@ name=ESP32 Arduino version=2.0.6 -runtime.tools.xtensa-esp32-elf-gcc.path={runtime.platform.path}/tools/xtensa-esp32-elf -runtime.tools.xtensa-esp32s2-elf-gcc.path={runtime.platform.path}/tools/xtensa-esp32s2-elf -runtime.tools.xtensa-esp32s3-elf-gcc.path={runtime.platform.path}/tools/xtensa-esp32s3-elf -runtime.tools.riscv32-esp-elf-gcc.path={runtime.platform.path}/tools/riscv32-esp-elf +tools.xtensa-esp32-elf-gcc.path={runtime.platform.path}/tools/xtensa-esp32-elf +tools.xtensa-esp32s2-elf-gcc.path={runtime.platform.path}/tools/xtensa-esp32s2-elf +tools.xtensa-esp32s3-elf-gcc.path={runtime.platform.path}/tools/xtensa-esp32s3-elf +tools.riscv32-esp-elf-gcc.path={runtime.platform.path}/tools/riscv32-esp-elf debug.server.openocd.path={runtime.platform.path}/tools/openocd-esp32/bin/openocd debug.server.openocd.scripts_dir={runtime.platform.path}/tools/openocd-esp32/share/openocd/scripts/ @@ -27,7 +27,7 @@ tools.gen_esp32part.cmd.windows="{runtime.platform.path}/tools/gen_esp32part.exe tools.gen_insights_pkg.cmd=python3 "{runtime.platform.path}"/tools/gen_insights_package.py tools.gen_insights_pkg.cmd.windows="{runtime.platform.path}/tools/gen_insights_package.exe" -compiler.path={runtime.tools.{build.tarch}-{build.target}-elf-gcc.path}/bin/ +compiler.path={tools.{build.tarch}-{build.target}-elf-gcc.path}/bin/ compiler.sdk.path={runtime.platform.path}/tools/sdk/{build.mcu} compiler.prefix={build.tarch}-{build.target}-elf- diff --git a/variants/VALTRACK_V4_MFW_ESP32_C3/pins_arduino.h b/variants/VALTRACK_V4_MFW_ESP32_C3/pins_arduino.h new file mode 100644 index 00000000000..4e3c771578b --- /dev/null +++ b/variants/VALTRACK_V4_MFW_ESP32_C3/pins_arduino.h @@ -0,0 +1,57 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define EXTERNAL_NUM_INTERRUPTS 22 +#define NUM_DIGITAL_PINS 22 +#define NUM_ANALOG_INPUTS 6 + +#define analogInputToDigitalPin(p) (((p) + +#define EXTERNAL_NUM_INTERRUPTS 22 +#define NUM_DIGITAL_PINS 22 +#define NUM_ANALOG_INPUTS 6 + +#define analogInputToDigitalPin(p) (((p)