安装好了. 编译 AsyncUDPServer, 可以收到来自客户端的数据, 但是不能解析.
UDP Packet Type: Unicast, From: 0.0.0.0:0, To: 0.0.0.0:31540, Length: 4, Data: 1234
packet.remoteIP(),packet.remotePort(),packet.localIP() 全是0. 不知为啥
udp.onPacket([](AsyncUDPPacket packet) {
Serial.print("UDP Packet Type: ");
Serial.print(packet.isBroadcast()?"Broadcast":packet.isMulticast()?"Multicast":"Unicast");
Serial.print(", From: ");
Serial.print(packet.remoteIP());
Serial.print(":");
Serial.print(packet.remotePort());
Serial.print(", To: ");
Serial.print(packet.localIP());
Serial.print(":");
Serial.print(packet.localPort());
Serial.print(", Length: ");
Serial.print(packet.length());
Serial.print(", Data: ");
Serial.write(packet.data(), packet.length());
Serial.println();
//reply to the client
packet.printf("Got %u bytes of data", packet.length());
}); |