ESP8266与NodeMCU AP网络掩码255.255.255.240

时间:2016-05-14 13:08:08

标签: esp8266 nodemcu

在NodeMCU或ESP8266中是否存在任何问题,我们不允许将255.255.255.240作为AP的网络掩码?我将网络掩码配置为255.255.255.240,当我这样做时

if(wifi.getmode() == wifi.SOFTAP or wifi.getmode() == wifi.STATIONAP ) then
      ip, nm, gw = wifi.ap.getip()
      print("AP IP Info ip nm gw:",ip, nm, gw)
end

打印得像

一样
AP IP Info ip nm gw:    10.100.0.1      255.255.255.240 10.100.0.1

但是,连接到它的计算机(和其他ESP8266)的ifconfig显示网络掩码为255.255.255.0。

从我的笔记本电脑中取样ifconfig

wlp0s20u4u2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.100.0.2  netmask 255.255.255.0 broadcast 10.100.0.255
        inet6 fe80::225:22ff:fe4d:2691  prefixlen 64  scopeid 0x20<link>
        ether xx:xx:xx:xx:xx:xx  txqueuelen 1000  (Ethernet)
        RX packets 121518  bytes 77302112 (73.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 117446  bytes 16933718 (16.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

任何想法或修复?

示例代码

apIPCfg={}
apCfg={}
   apCfg.ssid="abcdefgh"
   apCfg.pwd="abcdefgh12345678"
   apCfg.auth=AUTH_WPA2_PSK
   apIPCfg.ip='10.100.0.1'
   apIPCfg.netmask='255.255.255.240'
   apIPCfg.gateway='10.100.0.1'

   wifi.setmode(wifi.STATIONAP)
   wifi.ap.setip(apIPCfg)
   wifi.ap.config(apCfg)

构建详细信息

NodeMCU custom build by frightanic.com
        branch: dev
        commit: 7d576efed94092916e1a84bccba6319d62b9dedf
        SSL: true
        modules: adc,bit,cjson,coap,crypto,encoder,enduser_setup,file,gpio,http,mqtt,net,node,struct,tmr,uart,wifi
 build  built on: 2016-04-08 07:08
 powered by Lua 5.1.4 on SDK 1.5.1(e67da894)
lua: cannot open init.lua
> apIPCfg={}
> apCfg={}
>    apCfg.ssid="abcdefgh"
>    apCfg.pwd="abcdefgh12345678"
>    apCfg.auth=AUTH_WPA2_PSK
>    apIPCfg.ip='10.100.0.1'
>    apIPCfg.netmask='255.255.255.240'
>    apIPCfg.gateway='10.100.0.1'
>    wifi.setmode(wifi.STATIONAP)
>    wifi.ap.setip(apIPCfg)
>    wifi.ap.config(apCfg)
> ip, nm, gw = wifi.ap.getip()
> print("AP IP Info ip nm gw:",ip, nm, gw)
AP IP Info ip nm gw:    10.100.0.1      255.255.255.240 10.100.0.1
> 

0 个答案:

没有答案