diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2bd0aaa..908c62e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,13 +37,13 @@ jobs: echo -en "matrix=" >> $GITHUB_OUTPUT echo -en "[" >> $GITHUB_OUTPUT - get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples/esp8266_pico esp8266 0.35.0 esp8266:esp8266:generic:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,ResetMethod=nodemcu,CrystalFreq=26,FlashFreq=80,FlashMode=qio,eesz=4M2M,led=2,sdk=nonosdk_190703,ip=lm2f,dbg=Serial1,lvl=SSL,wipe=none,baud=115200 >> $GITHUB_OUTPUT + get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples/esp8266_pico esp8266 0.35.3 esp8266:esp8266:generic:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,ResetMethod=nodemcu,CrystalFreq=26,FlashFreq=80,FlashMode=qio,eesz=4M2M,led=2,sdk=nonosdk_190703,ip=lm2f,dbg=Serial1,lvl=SSL,wipe=none,baud=115200 >> $GITHUB_OUTPUT echo -en "," >> $GITHUB_OUTPUT - get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples/esp8266_pico esp8266 0.35.0 esp8266:esp8266:generic:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,ResetMethod=nodemcu,CrystalFreq=26,FlashFreq=80,FlashMode=qio,eesz=4M2M,led=2,sdk=nonosdk_190703,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=115200 >> $GITHUB_OUTPUT + get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples/esp8266_pico esp8266 0.35.3 esp8266:esp8266:generic:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,ResetMethod=nodemcu,CrystalFreq=26,FlashFreq=80,FlashMode=qio,eesz=4M2M,led=2,sdk=nonosdk_190703,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=115200 >> $GITHUB_OUTPUT echo -en "," >> $GITHUB_OUTPUT - get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples/esp32 esp32 0.35.0 esp32:esp32:esp32:FlashFreq=80 >> $GITHUB_OUTPUT + get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples/esp32 esp32 0.35.3 esp32:esp32:esp32:FlashFreq=80 >> $GITHUB_OUTPUT echo -en "]" >> $GITHUB_OUTPUT echo >> $GITHUB_OUTPUT @@ -55,7 +55,7 @@ jobs: strategy: fail-fast: false matrix: - CLI_VERSION: [0.35.0] + CLI_VERSION: [0.35.3] env: CLI_VERSION: ${{ matrix.CLI_VERSION }} ARDUINO_DIRECTORIES_DATA: /home/runner/arduino_ide @@ -63,10 +63,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Get Date - id: get-date + - name: Get hash + id: get-hash run: | - echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT + echo "hash=$(/bin/date -u "+%Y%m%d")-$(md5sum ".github/workflows/main.yml" | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT shell: bash - uses: actions/cache@v3 @@ -75,7 +75,7 @@ jobs: path: | /home/runner/arduino_ide /home/runner/Arduino - key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ matrix.CLI_VERSION }}-cli + key: ${{ runner.os }}-${{ steps.get-hash.outputs.hash }}-${{ matrix.CLI_VERSION }}-cli - name: download IDE if: steps.cache_all.outputs.cache-hit != 'true' @@ -122,10 +122,10 @@ jobs: run: | sudo apt-get install -y libgtk2.0-0 - - name: Get Date - id: get-date + - name: Get hash + id: get-hash run: | - echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT + echo "hash=$(/bin/date -u "+%Y%m%d")-$(md5sum ".github/workflows/main.yml" | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT shell: bash - uses: actions/cache@v3 @@ -134,7 +134,7 @@ jobs: path: | /home/runner/arduino_ide /home/runner/Arduino - key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ matrix.cliversion }}-cli + key: ${{ runner.os }}-${{ steps.get-hash.outputs.hash }}-${{ matrix.cliversion }}-cli - name: install python serial if: matrix.cpu == 'esp32' diff --git a/README.md b/README.md index fdc4e4c..b5930eb 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ a WebSocket Server and Client for Arduino based on RFC6455. - ATmega328 with enc28j60 (ATmega branch) - ATmega2560 with Ethernet Shield (ATmega branch) - ATmega2560 with enc28j60 (ATmega branch) + - Arduino UNO [R4 WiFi](https://github.com/arduino/ArduinoCore-renesas) ###### Note: ###### diff --git a/examples/arduino_renesas/arduino_uno_r4_wifi/arduino_uno_r4_wifi.ino b/examples/arduino_renesas/arduino_uno_r4_wifi/arduino_uno_r4_wifi.ino new file mode 100644 index 0000000..2168a62 --- /dev/null +++ b/examples/arduino_renesas/arduino_uno_r4_wifi/arduino_uno_r4_wifi.ino @@ -0,0 +1,109 @@ +#include +#include +#include + +#include "WiFiS3.h" +#include + +#define WIFI_SSID "" +#define WIFI_PASS "" + +WebSocketsClient webSocket; + +void webSocketEvent(WStype_t type, uint8_t *payload, size_t length) { + + switch (type) { + case WStype_DISCONNECTED: + Serial.println("[WSc] Disconnected!"); + break; + case WStype_CONNECTED: + Serial.println("[WSc] Connected!"); + + // send message to server when Connected + webSocket.sendTXT("Connected"); + break; + case WStype_TEXT: + Serial.print("[WSc] get text:"); + Serial.println((char *)payload); + + // send message to server + // webSocket.sendTXT("message here"); + break; + case WStype_BIN: + // send data to server + // webSocket.sendBIN(payload, length); + break; + case WStype_ERROR: + case WStype_FRAGMENT_TEXT_START: + case WStype_FRAGMENT_BIN_START: + case WStype_FRAGMENT: + case WStype_FRAGMENT_FIN: + break; + } +} + +void setup() { + Serial.begin(115200); + + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + + Serial.println(); + Serial.println(); + Serial.println(); + + for (uint8_t t = 4; t > 0; t--) { + Serial.println("[SETUP] BOOT WAIT ..."); + Serial.flush(); + delay(1000); + } + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) { + Serial.println("Communication with WiFi module failed!"); + // don't continue + while (true) + ; + } + + String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { + Serial.println("Please upgrade the firmware"); + } + + Serial.println("[Wifi]: Connecting"); + + int status = WL_IDLE_STATUS; + + // attempt to connect to WiFi network: + while (status != WL_CONNECTED) { + Serial.print("[Wifi]: Attempting to connect to SSID: "); + Serial.println(WIFI_SSID); + + // Connect to WPA/WPA2 network. Change this line if using open or WEP network: + status = WiFi.begin(WIFI_SSID, WIFI_PASS); + + delay(1000); + } + + Serial.println("Connected!"); + + // print your board's IP address: + IPAddress ip = WiFi.localIP(); + Serial.print("IP Address: "); + Serial.println(ip); + + // server address, port and URL + webSocket.begin("192.168.0.123", 8011); + + // event handler + webSocket.onEvent(webSocketEvent); + + // try ever 5000 again if connection has failed + webSocket.setReconnectInterval(5000); +} + +void loop() { + webSocket.loop(); +} \ No newline at end of file diff --git a/library.json b/library.json index 3647d91..d51149f 100644 --- a/library.json +++ b/library.json @@ -16,10 +16,10 @@ "keywords": "wifi, http, web, server, client, websocket", "license": "LGPL-2.1", "name": "WebSockets", - "platforms": "atmelavr, espressif8266, espressif32, raspberrypi", + "platforms": "atmelavr, espressif8266, espressif32, raspberrypi, renesas_uno", "repository": { "type": "git", "url": "https://github.com/Links2004/arduinoWebSockets.git" }, - "version": "2.4.1" -} \ No newline at end of file + "version": "2.5.1" +} diff --git a/library.properties b/library.properties index 38aa97b..462efc5 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=WebSockets -version=2.4.1 +version=2.5.1 author=Markus Sattler maintainer=Markus Sattler sentence=WebSockets for Arduino (Server + Client) diff --git a/src/WebSockets.h b/src/WebSockets.h index db6c0e8..56b4988 100644 --- a/src/WebSockets.h +++ b/src/WebSockets.h @@ -93,6 +93,12 @@ #define WEBSOCKETS_YIELD() yield() #define WEBSOCKETS_YIELD_MORE() delay(1) +#elif defined(ARDUINO_UNOWIFIR4) + +#define WEBSOCKETS_MAX_DATA_SIZE (15 * 1024) +#define WEBSOCKETS_YIELD() yield() +#define WEBSOCKETS_YIELD_MORE() delay(1) + #else // atmega328p has only 2KB ram! @@ -114,6 +120,7 @@ #define NETWORK_ESP32 (4) #define NETWORK_ESP32_ETH (5) #define NETWORK_RP2040 (6) +#define NETWORK_UNOWIFIR4 (7) // max size of the WS Message Header #define WEBSOCKETS_MAX_HEADER_SIZE (14) @@ -132,6 +139,9 @@ #elif defined(ARDUINO_ARCH_RP2040) #define WEBSOCKETS_NETWORK_TYPE NETWORK_RP2040 +#elif defined(ARDUINO_UNOWIFIR4) +#define WEBSOCKETS_NETWORK_TYPE NETWORK_UNOWIFIR4 + #else #define WEBSOCKETS_NETWORK_TYPE NETWORK_W5100 @@ -224,6 +234,13 @@ #define WEBSOCKETS_NETWORK_SSL_CLASS WiFiClientSecure #define WEBSOCKETS_NETWORK_SERVER_CLASS WiFiServer +#elif(WEBSOCKETS_NETWORK_TYPE == NETWORK_UNOWIFIR4) + +#include + +#define WEBSOCKETS_NETWORK_CLASS WiFiClient +#define WEBSOCKETS_NETWORK_SERVER_CLASS WiFiServer + #else #error "no network type selected!" #endif diff --git a/src/WebSocketsClient.cpp b/src/WebSocketsClient.cpp index 2488dea..8578f4b 100644 --- a/src/WebSocketsClient.cpp +++ b/src/WebSocketsClient.cpp @@ -49,7 +49,7 @@ void WebSocketsClient::begin(const char * host, uint16_t port, const char * url, _fingerprint = SSL_FINGERPRINT_NULL; _CA_cert = NULL; #ifdef ESP32 - _CA_bundle = NULL; + _CA_bundle = NULL; #endif #endif diff --git a/src/WebSocketsVersion.h b/src/WebSocketsVersion.h index 89dac96..9c69078 100644 --- a/src/WebSocketsVersion.h +++ b/src/WebSocketsVersion.h @@ -1,6 +1,6 @@ /** * @file WebSocketsVersion.h - * @date 01.05.2023 + * @date 17.06.2024 * @author Markus Sattler * * Copyright (c) 2015 Markus Sattler. All rights reserved. @@ -25,12 +25,12 @@ #ifndef WEBSOCKETSVERSION_H_ #define WEBSOCKETSVERSION_H_ -#define WEBSOCKETS_VERSION "2.4.1" +#define WEBSOCKETS_VERSION "2.5.1" #define WEBSOCKETS_VERSION_MAJOR 2 -#define WEBSOCKETS_VERSION_MINOR 4 +#define WEBSOCKETS_VERSION_MINOR 5 #define WEBSOCKETS_VERSION_PATCH 1 -#define WEBSOCKETS_VERSION_INT 2004001 +#define WEBSOCKETS_VERSION_INT 2005001 #endif /* WEBSOCKETSVERSION_H_ */ diff --git a/travis/common.sh b/travis/common.sh index 53df57c..3c270d2 100644 --- a/travis/common.sh +++ b/travis/common.sh @@ -1,6 +1,5 @@ #!/bin/bash - -set -x +set -e function build_sketches() { @@ -106,11 +105,11 @@ function get_sketches_json_matrix() } function get_core_cli() { - export ARDUINO_BOARD_MANAGER_ADDITIONAL_URLS="https://arduino.esp8266.com/stable/package_esp8266com_index.json https://espressif.github.io/arduino-esp32/package_esp32_index.json https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json" + export ARDUINO_BOARD_MANAGER_ADDITIONAL_URLS="https://arduino.esp8266.com/stable/package_esp8266com_index.json https://espressif.github.io/arduino-esp32/package_esp32_index.json https://github.com/earlephilhower/arduino-pico/releases/download/3.9.2/package_rp2040_index.json" arduino-cli core update-index arduino-cli core install esp8266:esp8266 arduino-cli core install esp32:esp32 - arduino-cli core install arduino:mbed_rp2040 + arduino-cli core install rp2040:rp2040 } function get_core()