Send TCP message problem

Okay we have a HUGE STEP in this topic :smiley:
I got a reply from the server !


#include <stdio.h>
#include <stdlib.h>
#include <SPI.h>
#include <UIPEthernet.h>
//#include "packet.h"
String serial_data;
char incomingByte = 0;
char s = 0;
int choice = 0;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(10, 5, 5, 10); // numeric IP for Google (no DNS)
IPAddress ip(10, 5, 5, 106);
EthernetClient client;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  // start the Ethernet connection:
  Ethernet.begin(mac, ip);
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");
  // if you get a connection, report back via serial:
  if (client.connect(server, 9876)) {
    Serial.println("connected");
  }
  else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
  Serial.println("Wcisnij a aby odczytywac pakiety");
  Serial.println("Wcisnij b aby wysylac pakiety");
}


void loop() {
  Ethernet.maintain();
  // Read serial input:
  if (Serial.available() )
  {
    incomingByte = Serial.read();
  }


  switch (incomingByte) {

    case 'a':
      //Serial.print("Logi");


      if (client.available())   {

        char c = client.read();
        int camretLen = client.available();
        Serial.print(camretLen);
        Serial.print("WYNIKI ");
        Serial.print(c);

      }
      if (!client.connected()) {
        client.connect(server, 9876);
      }
      break;

    case 'b':
      if (client.available()) {

        Serial.print("Klient available ");
      }




      delay(100);
      //        client.flush();
      //      client.println('S');
      //      client.println("SCENE");
      //      client.write('S\r');
      //       client.print("SCENE");
      //      client.write("SCENE\r");
      //      client.write("SCENE\r,6");
      client.print("SCENE\x0d");
      client.write("SCENE\x0d");

      Serial.print("SENT");

      delay(2000);
      //      int camretLen = client.available();
      //      Serial.println(camretLen);
      //      const int rsLen = 5;
      //      char retString[rsLen];
      //      retString[5] = '\0';
      char c = client.read();
      //      int tmp;
      //      tmp = (int) c;
      //      itoa (tmp, retString, 16);
      //
      //
      //
      //      Serial.print("Returned char val: ");
      //      Serial.print (retString);
      Serial.println("RESULT");
      Serial.println(c);
      Serial.println("READ BACK");
      /

You see it is "0OK" :smiley:
But it works for No line Ending best and it is in a loop.
So now there are new problems :smiley:

  1. I need to try if it will display well on the OLED display (just like in serial ).
  2. I need to make the results in a more "user friendly " way I want it more like:
    User sends the message
    Message sent " "
    Result: for exampel " 0OK"
    ( not
    0
    O
    K)
  3. I will try also if the command whcih i type from the serial will work.
  4. And it should work like this:
  • User types command
  • gets a reply
    and that's end user can type another command then shouldn't work like sending this one command in a loop

The final project will work with

  1. OLED display 1,5 "
  2. normal pc keyboard to type the commands and use the menu. I bought the arduino DUE to be able to use the normal keyboard because it will be easier (if it works) than programming bare keys.