Below is the C++ code on ESP32 that will be receiving the text. It is looking for a { curly brace character as the starting character. See line 41.
If I user the AsyncStreams and send bytes, the text is not transmitted in the clear as I understand it so the receiving code is not seeing the curly brace character.
What am I missing here?
Thank you in advance for helping!
If I user the AsyncStreams and send bytes, the text is not transmitted in the clear as I understand it so the receiving code is not seeing the curly brace character.
What am I missing here?
Thank you in advance for helping!
Receiving Code:
/*
* @Descripttion:
* @version:
* @Author: Elegoo
* @Date: 2023-10-11
* @LastEditors: Changhua
* @LastEditTime: 2023-10-23
*/
//#include <EEPROM.h>
#include "CameraWebServer_AP.h"
#include <WiFi.h>
#include "esp_camera.h"
WiFiServer server(100);
#define RXD2 3
#define TXD2 40
CameraWebServer_AP CameraWebServerAP;
bool WA_en = false;
void SocketServer_Test(void)
{
static bool ED_client = true;
WiFiClient client = server.available(); //尝试建立客户对象 Try to create a client object
if (client) //如果当前客户可用 If the current client is available
{
WA_en = true;
ED_client = true;
Serial.println("[Client connected]");
String readBuff;
String sendBuff;
uint8_t Heartbeat_count = 0;
bool Heartbeat_status = false;
bool data_begin = true;
while (client.connected()) //如果客户端处于连接状态 If the client is connected
{
if (client.available()) //如果有可读数据 If there is readable data
{
char c = client.read(); //读取一个字节 Read a byte
Serial.print(c); //从串口打印 Printing from the serial port
if (true == data_begin && c == '{') //接收到开始字符 Received start character
{
data_begin = false;
}
if (false == data_begin && c != ' ') //去掉空格 Remove spaces
{
readBuff += c;
}
if (false == data_begin && c == '}') //接收到结束字符 End character received
{
data_begin = true;
if (true == readBuff.equals("{Heartbeat}"))
{
Heartbeat_status = true;
}
else
{
Serial2.print(readBuff);
}
//Serial2.print(readBuff);
readBuff = "";
}
}