Hi
I want to strip some data/bytes from a UDP string
With Sharkwire I looked at the sting and the red tekst has the needed info:
0000 ff ff ff ff ff ff 00 22 68 73 15 3e 08 00 45 00 ÿÿÿÿÿÿ."hs.>..E.
0010 00 53 30 dd 00 00 80 11 83 3a c0 a8 02 33 c0 a8 .S0Ý.....:À¨.3À¨
0020 02 ff 26 8f 26 8f 00 3f 86 d3 53 54 41 54 55 53 .ÿ&.&..?.ÓSTATUS
0030 3a 20 22 6e 61 6d 65 2d 31 22 20 22 22 20 30 20 : "name-1" "" 0
0040 33 20 30 20 30 20 37 30 32 31 30 20 22 30 22 20 3 0 0 70210 "0"
0050 30 20 22 31 22 20 20 37 30 33 35 30 20 22 22 de 0 "1" 70350 ""Þ
0060 00 .
On the arduino serial monitor it looks like:
STATUS: "name-1" "" 0 3 0 0 70210 "0" 0 "1" 70350 ""⸮
I want to read the "name-1" that can be up to 10 charaters long.
I used the code of UDPSendReceiveString and modufied it a bit to read the the string
I have no clue what will be the correct way to do this
Peter
#include <SPI.h> // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h> // UDP library from: bjoern@cs.stanford.edu 12/30/2008
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 2, 177);
#define UDP_TX_PACKET_MAX_SIZE 100
unsigned int localPort = 9871; // local port to listen on
// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;
void setup() {
// start the Ethernet and UDP:
Ethernet.begin(mac, ip);
Udp.begin(localPort);
Serial.begin(9600);
}
void loop() {
// if there's data available, read a packet
int packetSize = Udp.parsePacket();
if (packetSize)
{
// read the packet into packetBufffer
Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
Serial.println(packetBuffer);
}
}