Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jesserockz authored Mar 31, 2024
2 parents ed422e1 + 9c2034d commit 1eb5d0e
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/scripts/install-arduino-ide.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ if [ ! -d "$ARDUINO_IDE_PATH" ]; then
echo "Installing Arduino IDE on $OS_NAME ..."
echo "Downloading 'arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT' to 'arduino.$ARCHIVE_FORMAT' ..."
if [ "$OS_IS_LINUX" == "1" ]; then
wget -O "arduino.$ARCHIVE_FORMAT" "https://www.arduino.cc/download.php?f=/arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT" > /dev/null 2>&1
wget -O "arduino.$ARCHIVE_FORMAT" "https://downloads.arduino.cc/arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT" > /dev/null 2>&1
echo "Extracting 'arduino.$ARCHIVE_FORMAT' ..."
tar xf "arduino.$ARCHIVE_FORMAT" > /dev/null
mv arduino-nightly "$ARDUINO_IDE_PATH"
else
curl -o "arduino.$ARCHIVE_FORMAT" -L "https://www.arduino.cc/download.php?f=/arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT" > /dev/null 2>&1
curl -o "arduino.$ARCHIVE_FORMAT" -L "https://downloads.arduino.cc/arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT" > /dev/null 2>&1
echo "Extracting 'arduino.$ARCHIVE_FORMAT' ..."
unzip "arduino.$ARCHIVE_FORMAT" > /dev/null
if [ "$OS_IS_MACOS" == "1" ]; then
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@ jobs:
name: Arduino for ${{ matrix.board }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
board: [esp32, esp8266]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3.0.2
- name: Build Tests
run: bash ./.github/scripts/on-push.sh ${{ matrix.board }} 0 1

build-pio:
name: PlatformIO for ${{ matrix.board }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
board: [esp32, esp8266]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3.0.2
- name: Build Tests
run: bash ./.github/scripts/on-push.sh ${{ matrix.board }} 1 1
6 changes: 3 additions & 3 deletions library.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"type": "git",
"url": "https://github.com/esphome/ESPAsyncWebServer.git"
},
"version": "3.0.0",
"version": "3.1.0",
"license": "LGPL-3.0",
"frameworks": "arduino",
"platforms": ["espressif8266", "espressif32", "libretuya"],
"platforms": ["espressif8266", "espressif32", "libretiny"],
"dependencies": [
{
"owner": "ottowinter",
Expand All @@ -25,7 +25,7 @@
{
"owner": "esphome",
"name": "AsyncTCP-esphome",
"platforms": ["espressif32", "libretuya"]
"platforms": ["espressif32", "libretiny"]
},
{
"name": "Hash",
Expand Down
17 changes: 17 additions & 0 deletions src/AsyncEventSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,17 @@ void AsyncEventSourceClient::send(const char *message, const char *event, uint32
}

void AsyncEventSourceClient::_runQueue(){
#if defined(ESP32)
if(!this->_messageQueue_mutex.try_lock()) {
return;
}
#else
if(this->_messageQueue_processing){
return;
}
this->_messageQueue_processing = true;
#endif // ESP32

while(!_messageQueue.isEmpty() && _messageQueue.front()->finished()){
_messageQueue.remove(_messageQueue.front());
}
Expand All @@ -245,6 +256,12 @@ void AsyncEventSourceClient::_runQueue(){
if(!(*i)->sent())
(*i)->send(_client);
}

#if defined(ESP32)
this->_messageQueue_mutex.unlock();
#else
this->_messageQueue_processing = false;
#endif // ESP32
}


Expand Down
13 changes: 11 additions & 2 deletions src/AsyncEventSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@

#include <Arduino.h>
#include <Arduino.h>
#if defined(ESP32) || defined(LIBRETUYA)
#if defined(ESP32) || defined(LIBRETINY)
#include <AsyncTCP.h>
#else
#include <ESPAsyncTCP.h>
#endif

#if defined(ESP32)
#include <mutex>
#endif // ESP32

#ifndef SSE_MAX_QUEUED_MESSAGES
#define SSE_MAX_QUEUED_MESSAGES 32
#endif
Expand All @@ -43,7 +47,7 @@
#endif
#endif

#if defined(ESP32) || defined(LIBRETUYA)
#if defined(ESP32) || defined(LIBRETINY)
#define DEFAULT_MAX_SSE_CLIENTS 8
#else
#define DEFAULT_MAX_SSE_CLIENTS 4
Expand Down Expand Up @@ -75,6 +79,11 @@ class AsyncEventSourceClient {
AsyncClient *_client;
AsyncEventSource *_server;
uint32_t _lastId;
#if defined(ESP32)
std::mutex _messageQueue_mutex;
#else
bool _messageQueue_processing;
#endif // ESP32
LinkedList<AsyncEventSourceMessage *> _messageQueue;
void _queueMessage(AsyncEventSourceMessage *dataMessage);
void _runQueue();
Expand Down
4 changes: 2 additions & 2 deletions src/AsyncWebSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define ASYNCWEBSOCKET_H_

#include <Arduino.h>
#if defined(ESP32) || defined(LIBRETUYA)
#if defined(ESP32) || defined(LIBRETINY)
#include <AsyncTCP.h>
#ifndef WS_MAX_QUEUED_MESSAGES
#define WS_MAX_QUEUED_MESSAGES 32
Expand All @@ -44,7 +44,7 @@
#endif
#endif

#if defined(ESP32) || defined(LIBRETUYA)
#if defined(ESP32) || defined(LIBRETINY)
#define DEFAULT_MAX_WS_CLIENTS 8
#else
#define DEFAULT_MAX_WS_CLIENTS 4
Expand Down
4 changes: 2 additions & 2 deletions src/AsyncWebSynchronization.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <ESPAsyncWebServer.h>

#if defined(ESP32) || (defined(LIBRETUYA) && LT_HAS_FREERTOS)
#if defined(ESP32) || (defined(LIBRETINY) && LT_HAS_FREERTOS)

// This is the ESP32 version of the Sync Lock, using the FreeRTOS Semaphore
class AsyncWebLock
Expand Down Expand Up @@ -84,4 +84,4 @@ class AsyncWebLockGuard
}
};

#endif // ASYNCWEBSYNCHRONIZATION_H_
#endif // ASYNCWEBSYNCHRONIZATION_H_
2 changes: 1 addition & 1 deletion src/ESPAsyncWebServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include "StringArray.h"

#if defined(ESP32) || defined(LIBRETUYA)
#if defined(ESP32) || defined(LIBRETINY)
#include <WiFi.h>
#include <AsyncTCP.h>
#elif defined(ESP8266)
Expand Down

0 comments on commit 1eb5d0e

Please sign in to comment.