Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By TSebastian
#25779 Dear ESP8266 Community,

I have a hardware controller that listens on TCP Port 4000 and i would like to control it over this Port.
I allready have it working on a windows computer by sending a tcp package with the raw bit content like "0f00023200000180010000000000000000".

As i understand the data format/meaning of the bits i would like to implement the same on the ESP via the Arduino IDE.

Until now i have not found a way to do this. Is this possible somehow?
Thanks a lot!!

Thomas
Last edited by TSebastian on Wed Aug 12, 2015 5:36 pm, edited 1 time in total.
User avatar
By igrr
#25840 Once you have connected to WiFi (take a look at ESP8266WiFi library examples if you need to know how to do that), connect to your remote server and send the packet as follows:

Code: Select allWiFiClient tcpClient;
if (tcpClient.connect("host", port)) {
  const unsigned char data[] = {
    0x0f, 0x00, 0x02, 0x32,
    0x00, 0x00, 0x01, 0x80,
    0x01, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00,
    0x00
  };
 
  tcpClient.write(data, sizeof(data));
}


ESP8266WiFi library works much the same way as Arduino WiFi library, which is documented over here:
https://www.arduino.cc/en/Reference/WiFi