Android Question Sending clear text via tcp/IP

Tim Chapman

Active Member
Licensed User
Longtime User
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!

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 = "";
        }
      }
 

emexes

Expert
Licensed User
Thank you again for your help on this!

No worries. Is good fun, once I got over the confusion and my head stopped spinning.

Where do you live if you don't mind my asking?

Melbourne, Australia (not Florida, although I've been there too, to watch a shuttle launch in 2001, f**k those things are loud).

Actually, most of my two months in USA was in Falls Church just outside Washington DC, and it is surprising how often that place name pops up on news or in movies or books. Tysons Corner came up last week somewhere, and I'm like, yeah I remember buying a mobile phone at the Tandy there. Nobody believed me. Lol.

Cheyenne obviously rang a bell. Although for some reason, I'd always imagined it as being more north.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…