Arduino,从客户端接收数据并将数据的字符放入三个不同的字符串中
Arduino, to receive data from client and put the chars, of data, in three different string
在 Arduino 中我有这个代码:
WiFiClient client = server.available();
if (!client) {
return;
}
while (client.available()){
char d = (char)client.read();
// In this part save to the string
}
我收到这个字符串:
true,167*FFFFD19F/
我想将字符放入三个不同的字符串中,如:
String1 = "true"
String2 = "167"
String3 = "FFFFD19F"
谢谢,我找到解决办法了:
while (client.available()) {
delay(3);
char c = client.read();
readString += c;
}
readString.trim();
int i1 = readString.indexOf(",");
int i2 = readString.indexOf("*");
int i3 = readString.indexOf("/");
String 1= readString.substring(0, i1--);
String 2= readString.substring(i1 + 2, i2);
String 3= readString.substring(i2 + 3, i3--);
在 Arduino 中我有这个代码:
WiFiClient client = server.available();
if (!client) {
return;
}
while (client.available()){
char d = (char)client.read();
// In this part save to the string
}
我收到这个字符串:
true,167*FFFFD19F/
我想将字符放入三个不同的字符串中,如:
String1 = "true"
String2 = "167"
String3 = "FFFFD19F"
谢谢,我找到解决办法了:
while (client.available()) {
delay(3);
char c = client.read();
readString += c;
}
readString.trim();
int i1 = readString.indexOf(",");
int i2 = readString.indexOf("*");
int i3 = readString.indexOf("/");
String 1= readString.substring(0, i1--);
String 2= readString.substring(i1 + 2, i2);
String 3= readString.substring(i2 + 3, i3--);