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

Moderator: igrr

User avatar
By inx
#33576 Hi

Thanks for reporting.

Which example do you try to compile?

It is a strange error.
line 190 in ESP8266SocketBase.cpp shows me:
Code: Select allsint8 ESP8266SocketBase::send(const char* data)
User avatar
By canedje
#33581
inx wrote:Hi

Thanks for reporting.

Which example do you try to compile?

It is a strange error.
line 190 in ESP8266SocketBase.cpp shows me:
Code: Select allsint8 ESP8266SocketBase::send(const char* data)



I tried : esp8266ClientTCPExample.ino
Because he routines have to be above the call i changed the routines above the loop.
My used code is:
Code: Select all/// Do not remove the include below
#include "ClientTEST.h"
#include <ESP8266WiFi.h>
#include <ESP8266Client.h>

const char* ssid     = "HogeveenNet";
const char* password = "??????????";

// create a TCP client
ESP8266Client client("192.168.2.185", 222);

unsigned long now = 0;

//------------------------
//------------------------
// general callbacks
void onDataCb(ESP8266Client& client, char *data, unsigned short length)
{
  Serial.write(data, length);
}

//------------------------
//------------------------
// TCP callbacks
void onConnectCb(ESP8266Client& client)
{
  Serial.println("connected to server");
}

void onDisconnectCb()
{
  Serial.println("disconnected from server");
}

void onReconnectCb(ESP8266Client& client, sint8 err)
{
  Serial.print("reconnect CB: ");
  Serial.println(espErrorToStr(err));
  Serial.println(espErrorDesc(err));
}

void setup() {
  Serial.begin(115200);
  delay(10);

  // We start by connecting to a WiFi network

  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  // set callback functions
  client.onData(onDataCb);
  client.onConnected(onConnectCb);
  client.onDisconnected(onDisconnectCb);
  client.onReconnect(onReconnectCb);
}

void loop() {

  if (client.isConnected()) {
    Serial.println("sending to server");
    client.send("ping\r\n");
    delay(1000);
  } else {
    // connect
    boolean res = client.connect();
    if (!res) {
//      Serial.println("could not connect");
    }
  }

  delay(10);
}


User avatar
By inx
#33583 i also came across that the callback functions have to be declared at the top of the code... this is not the case in the OSX version.

i will update the examples.