Hi all
Thanks for the feedback but....
First
When I make a faster serial then 9K6 I got garbage on the serial monitor
Second
The name-1 isn't changed when I put a other name in de UDP string. The "decoder" still came up with name-1
This is with both sketches, while wireshark show a different name...
0000 ff ff ff ff ff ff 00 22 68 73 15 3e 08 00 45 00 ÿÿÿÿÿÿ."hs.>..E.
0010 00 59 56 e3 00 00 80 11 5d 2e c0 a8 02 33 c0 a8 .YVã....].À¨.3À¨
0020 02 ff 26 8f 26 8f 00 45 86 d9 53 54 41 54 55 53 .ÿ&.&..E.ÙSTATUS
0030 3a 20 22 6e 65 74 77 65 72 6b 2d 69 64 22 20 22 : "netwerk-id" "
0040 22 20 30 20 36 20 30 20 30 20 31 38 30 36 38 30 " 0 6 0 0 180680
0050 20 22 30 22 20 30 20 22 31 22 20 20 31 38 30 36 "0" 0 "1" 1806
0060 38 30 20 22 22 d1 00 80 ""Ñ.
The code below gives "name-1found" as output on the serial monitor.
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()
{
Serial.begin(9600 );
}
void loop() {
byte packetBuffer[]={0x02,0xff,0x26,0x8f,0x26,0x8f,0x00,0x3f,0x86,0xd3,0x53,0x54,0x41,0x54,0x55,0x53,0x3a,0x20,0x22,0x6e,0x61,0x6d,0x65,0x2d,0x31,0x22,0x20,0x22,0x22,0x20,0x30,0x20 };
byte * ptr=(byte *)memmem(packetBuffer, sizeof(packetBuffer),"STATUS",6);
if(ptr==NULL)Serial.println("NULL");
else {
Serial.println("found");
do { ptr++; } while(*ptr != '\"'); // search for starting "
while(*(++ptr) != '\"') // print until terminating " found
Serial.print((char)*ptr);
}
}