So im sending the data,
int _pwmLVal[] = {10, 10, 10, 10, 10, 10, 10, 10, 10};
void sendCommand(IPAddress to, char * data, char delimiter[], char delimiter2[] ) {
//Serial.println(sizeof(data));
Serial.println(data);
Udp.beginPacket(to, clientPort);
Udp.write(delimiter);
Udp.write(data, 4);
Udp.write(delimiter2);
Udp.endPacket();
}
void loop(){
sendCommand(Client1, (char *)&_pwmLVal[0], "NODEC1", "C1NODE");
}
and here i receive the data,
int packetSize = Udp.parsePacket();
if (packetSize) {
char verifyStart[6];
char verifyEnd[6];
char _data[10];
Serial.printf("Received %d bytes from %s, port %d\n", packetSize, Udp.remoteIP().toString().c_str(), Udp.remotePort());
int len = Udp.read(incomingPacket, 800);
strncpy (verifyStart, (char*)incomingPacket, 6);
strncpy (verifyEnd, (char *)incomingPacket + len - 6 , 7 );
strncpy (_data, (char*)incomingPacket + 6, len - 12);
verifyStart[6] = 0;
verifyEnd[6] = 0;
Serial.println(_data);
Serial.println(verifyEnd);
_data[len - 12] = 0;
unsigned long value = atol(_data);
if (strcmp(verifyStart, "NODEC1") == 0) {
if (strcmp(verifyEnd, "C1NODE") == 0) {
Serial.println("command_1");
_EEPROM.array[0] = value;
Serial.println( _EEPROM.array[0]);
}
}
when i receive the data the value shows as 0, where am i going wrong? verifyStart/end are correct but the data is not? please someone help me
Am i not suppose to be using a char pointer here on the receive side?
strncpy (_data, (char*)incomingPacket + 6, len - 12);