Go Down

Topic: Incorrect xml tcp packet (Read 520 times) previous topic - next topic

nyqkri

Hi

I am having problem to send a xml message. I want to send the message from the arduino with a http post with the xml Document in the body. Then i expect to get a 200 OK back with a Confirmation HTML in the body.


The xml document is the following:

<AastraIPPhoneConfiguration setType="local">
  <ConfigurationItem>
   <Parameter>ringer volume</Parameter>
   <Value>0</Value>
  </ConfigurationItem>
</AastraIPPhoneConfiguration>

The problem i get is that my tcp packages is split up in multipel packagaes and i only expect this to be in one package.

What am i missing or what have i done incorrectly?

In the attached pcap file is the tcp packaets i get.
Bellow is my code.

#include <SPI.h>
#include <Ethernet.h>
//#include <Ethernet2.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 10, 177);
IPAddress myDns(192, 168, 1, 6);
IPAddress gateway(192, 168, 10, 1);
IPAddress subnet(255, 255, 255, 0);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetClient client;


void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start the Ethernet connection:
  Serial.println("Trying to get an IP address using DHCP");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // initialize the Ethernet device not using DHCP:
    Ethernet.begin(mac, ip, myDns, gateway, subnet);
  }
  // print your local IP address:
  Serial.print("My IP address: ");
  ip = Ethernet.localIP();
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(ip[thisByte], DEC);
    Serial.print(".");
  }
  Serial.println();


}

void post()
{
  //EthernetClient client = server.available();
  Serial.println("void post");


  if (client.connect("192.168.10.106", 80)) {

    Serial.println("connected");
    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/xml");
    client.println("Connection: close");
    client.println();
    client.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    client.println("<AastraIPPhoneConfiguration setType=\"local\">\r\n<ConfigurationItem>\r\n<Parameter>ringer volume</Parameter>\r\n<Value>0</Value>\r\n</ConfigurationItem>\r\n</AastraIPPhoneConfiguration>");
  } else {
    Serial.println("connection failed");
  }
}


void loop() {
  post();
  delay(500);
}


Juraj

what does it matter in how many pieces is it sent?

You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

christop

if (client.connect("192.168.10.106", 80)) {

    Serial.println("connected");
    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/xml");
    client.println("Connection: close");
    client.println();
    client.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    client.println("<AastraIPPhoneConfiguration setType=\"local\">\r\n<ConfigurationItem>\r\n<Parameter>ringer volume</Parameter>\r\n<Value>0</Value>\r\n</ConfigurationItem>\r\n</AastraIPPhoneConfiguration>");
  } else {
    Serial.println("connection failed");
  }
}

This part looks wrong. You're sending an invalid HTTP request to the server (a request doesn't start with "HTTP/1.1 200 OK").

Go Up