TA的每日心情 | 衰 2021-6-1 14:25 |
---|
签到天数: 27 天 连续签到: 1 天 [LV.4]偶尔看看III
|
本帖最后由 eefocus_3715263 于 2021-5-27 19:23 编辑
我用Arduino直接开发ESP32进行数据传输但是中文的话就会出问题是什么原因啊?
另附上Aduino代码
// Visual Micro is in vMicro>General>Tutorial Mode
//
/*
Name: esp32test.ino
Created: 2021/5/27 13:36:43
Author: LAPTOP-CSI46943\11417
*/
// Define User Types below here or use a .h file
//
#include <dummy.h>
#include <WiFi.h>
// Define Function Prototypes that use User Types below here or use a .h file
//
WiFiServer server(8888);
// Define Functions below here or use other .ino or cpp files
//
// The setup() function runs once each time the micro-controller starts
void setup()
{
const char ssid[] = "zy_esp32";
const char password[] = "123456789";
//IPAddress ip = ;
Serial.begin(115200);
WiFi.mode(WIFI_MODE_AP);
WiFi.softAP(ssid,password);
WiFi.softAPConfig(IPAddress(192,168,4,1), IPAddress(192, 168, 4, 1), IPAddress(255, 255, 255,0));
WiFi.enableAP(true);
// WiFi.softAPConfig("192.168.4.1","");
server.begin();
server.setNoDelay(true);
}
// Add the main program code into the continuous loop() function
void loop()
{
WiFiClient client = server.available(); //尝试建立客户对象
if (client) //如果当前客户可用
{
Serial.println("[存在客户端连接]");
String readBuff; //读取信息暂存
while (client.connected()) //如果客户端处于连接状态
{
if (client.available()) //如果有可读数据
{
String c = client.readString(); //读取一个字节
//也可以用readLine()等其他方法
readBuff += c;
client.print("已收到: " + readBuff); //向客户端发送
Serial.println("已收到: " + readBuff); //从串口打印
readBuff = "";
}
}
}
}
|
|