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

Moderator: igrr

User avatar
By suttop1
#93645 I have a basic websocket code I have used for several years between 8266 d1 minis. I want to use it between d1 mini and a generic 8285 board but when I try the websocket will not connect. I have tried several different boards with the same result. the 8285 is running as client to an 8266 in softap mode running as websocket server.
I am using aurdino IDE.
this is the client end code ( its just a test routine.)


Code: Select all#include <Arduino.h>
#include <ESP8266WiFi.h>
//#include <ESP8266WiFiMulti.h>
 #include <WebSocketsClient.h>
//#include <Hash.h>
IPAddress remoteip(192,168,4,1);
//ESP8266WiFiMulti WiFiMulti;
WebSocketsClient webSocket;

 static uint8_t bssid[]{0xA8, 0x48, 0xFA, 0xDC, 0xAC, 0xB8};
const char *ssid = "Universal";         //Name of the access point
const char *password = "lo******te";    //Password for the access point



IPAddress local_IP(192,168,8,22);
IPAddress gateway(192,168,8,9);
IPAddress subnet(255,255,255,0);


void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
  switch(type) {
    case WStype_DISCONNECTED:
      Serial.printf("[WSc] Disconnected!\n");
      break;
    case WStype_CONNECTED: {
      Serial.printf("[WSc] Connected to url: %s\n", payload);
      // send message to server when Connected
      webSocket.sendTXT("*Dolgoch");
       }
      break;
    case WStype_TEXT:
      Serial.printf("[WSc] get text: %s\n", payload);
       break;
    case WStype_BIN:
       Serial.printf("bin recieved");Serial.println("");
       break;
        case WStype_PING:
            Serial.printf("[WSc] get ping\n");
            break;
        case WStype_PONG:
             Serial.printf("[WSc] get pong\n");
            break;
           }
          }

void setup()
{
  Serial.begin(115200);
  Serial.println();

//  Serial.print("Setting soft-AP configuration ... ");
//  Serial.println(WiFi.softAPConfig(local_IP, gateway, subnet) ? "Ready" : "Failed!");

 // Serial.print("Setting soft-AP ... ");
//  Serial.println(WiFi.softAP("ESPsoftAP_01") ? "Ready" : "Failed!");

//  Serial.print("Soft-AP IP address = ");
//  Serial.println(WiFi.softAPIP());
//  WiFi.begin(ssid, password,11, bssid, true);
   WiFi.begin(ssid, password);
  while (WiFi.status() != 3)
{
  delay(500);
  Serial.print(WiFi.status());
}
delay(100);
  webSocket.begin("192.168.4.1", 701, "/");
  // event handler
  webSocket.onEvent(webSocketEvent);
 // try ever 5000 again if connection has failed
  webSocket.setReconnectInterval(5000);
  // start heartbeat (optional)
  // ping server every 15000 ms
  // expect pong from server within 3000 ms
  // consider connection disconnected if pong is not received 2 times
  webSocket.enableHeartbeat(15000, 3000, 2);
  delay(2000);
}



void loop(){
webSocket.loop();
}


run on 8266 it gives :-
7777773[WSc] Connected to url: /
[WSc] get ping
bin recieved
[WSc] get pong
[WSc] get pong
bin recieved
bin recieved
bin recieved

But on the 8285 with the same 8266 as server it gives:-
7777711111111111111111111
and does not connect.
status 1 is no ssid found
the signal strength is very good (-25db) on both d1 mini and 8285 ( I use a 5/8 dipole as standard.)
I have completely run out of ideas. Any help gladly received.