简体   繁体   English

espruino:未触发wifi连线事件

[英]espruino: wifi on connect event not fired

I need to be notified when the ESP8266 get connected to the WiFi network. ESP8266连接到WiFi网络时需要通知我。 To do so I'm listening to the connected event in the WiFi module. 为此,我正在WiFi模块中监听connected事件。 The callback function is never called. 永远不会调用回调函数。

The code: 编码:

var wifi = require("Wifi");

wifi.on('connected', function(details) { 
  console.log('connected to wifi', details);
});

wifi.connect("*****", {password:"****"}, function(err){
    console.log("connected? err=", err, "info=", wifi.getIP());
});

The output: 输出:

>
=undefined
connected? err= null info= {
  "ip": "192.168.1.105",
  "netmask": "255.255.255.0",
  "gw": "192.168.1.1",
  "mac": "5c:**:7f:**:7a:**"
 }

The event is not fired because the ESP8266 was already connected to the WiFi network. 由于ESP8266已连接至WiFi网络,因此未触发该事件。 When you setup your connection you can save the settings in order to get Espruino reconnect to the WiFi automatically at boot time. 设置连接时,可以保存设置,以使Espruino在启动时自动重新连接到WiFi。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM