SHA256
v1-RC-1
This commit is contained in:
1 parent
6ca5f7f68d
commit
c1d1f8c8f2
3 files changed
+13
-1
No files matched your search
@@ -3,4 +3,5 @@
|
|||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include <WebSocketsServer.h>
|
#include <WebSocketsServer.h>
|
||||||
|
|
||||||
|
extern volatile bool websocket_connected;
|
||||||
void webSocketEvent( uint8_t num, WStype_t type, uint8_t * payload, size_t length );
|
void webSocketEvent( uint8_t num, WStype_t type, uint8_t * payload, size_t length );
|
||||||
@@ -1,12 +1,17 @@
|
|||||||
#include "WebSocketHandler.h"
|
#include "WebSocketHandler.h"
|
||||||
|
|
||||||
|
extern volatile bool websocket_connected;
|
||||||
|
|
||||||
void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) {
|
void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
|
|
||||||
case WStype_CONNECTED:
|
case WStype_CONNECTED:
|
||||||
|
websocket_connected = true;
|
||||||
Serial.printf("[%u] Cliente conectado\n", num);
|
Serial.printf("[%u] Cliente conectado\n", num);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WStype_DISCONNECTED:
|
case WStype_DISCONNECTED:
|
||||||
|
websocket_connected = false;
|
||||||
Serial.printf("[%u] Cliente desconectado\n", num);
|
Serial.printf("[%u] Cliente desconectado\n", num);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -30,6 +30,7 @@ IPAddress dns2(1,1,1,1);
|
|||||||
|
|
||||||
wifi_conf sta_esp32;
|
wifi_conf sta_esp32;
|
||||||
WebSocketsServer webSocket(81);
|
WebSocketsServer webSocket(81);
|
||||||
|
volatile bool websocket_connected = false;
|
||||||
|
|
||||||
// FreeRTOS
|
// FreeRTOS
|
||||||
TaskHandle_t ADCTaskHandle = NULL;
|
TaskHandle_t ADCTaskHandle = NULL;
|
||||||
@@ -65,7 +66,12 @@ void loop(){
|
|||||||
|
|
||||||
void ADCTask(void *parameter){
|
void ADCTask(void *parameter){
|
||||||
for(;;) {
|
for(;;) {
|
||||||
uint32_t count = adc1_3.read(samples_buffer);
|
|
||||||
|
if (!websocket_connected) {
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(100));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const uint32_t count = adc1_3.read(samples_buffer);
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
if (xRingbufferSend(bufferHandle, samples_buffer, count * sizeof(uint16_t), pdMS_TO_TICKS(1000)) != pdTRUE) {
|
if (xRingbufferSend(bufferHandle, samples_buffer, count * sizeof(uint16_t), pdMS_TO_TICKS(1000)) != pdTRUE) {
|
||||||
Serial.println("Failed to send message to ring buffer!");
|
Serial.println("Failed to send message to ring buffer!");
|
||||||
|
|||||||
Reference in new issue
Block a user