完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我有一个基本的 websocket 代码,我在 8266 d1 minis 之间使用了几年。我想在 d1 mini 和通用 8285 板之间使用它,但是当我尝试时,websocket 无法连接。我尝试了几种不同的板,结果相同。8285 以 softap 模式作为 websocket 服务器运行的 8266 作为客户端运行。
我正在使用 aurdino IDE。 这是客户端代码(它只是一个测试例程。) 代码:全选#include #include //#include #include //#include 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: %sn", payload); // send message to server when Connected webSocket.sendTXT("*Dolgoch"); } break; case WStype_TEXT: Serial.printf("[WSc] get text: %sn", payload); break; case WStype_BIN: Serial.printf("bin recieved");Serial.println(""); break; case WStype_PING: Serial.printf("[WSc] get pingn"); break; case WStype_PONG: Serial.printf("[WSc] get pongn"); 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(); } 在 8266 上运行它给出:- 7777773[WSc] 连接到 url: / [WSc] get ping bin received [WSc] get pong [WSc] get pong bin received bin recieved bin received 但在 8285 上与服务器相同的 8266给出:- 7777711111111111111111111 并且不连接。 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.) 我完全没有想法了。很高兴收到任何帮助。 |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
733 浏览 1 评论
552浏览 6评论
461浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
445浏览 5评论
446浏览 4评论
417浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 01:12 , Processed in 0.770449 second(s), Total 76, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号