• 【鸿蒙开发板】使用AT命令连接WIFI


    目录:
    1. AT+STARTSTA
    2. AT+SCAN
    3. AT+SCANRESULT
    4. AT+CONN=,08:6b:d1:93:a5:72,3,"12345678"
    5. AT+DHCP=wlan0,1

    使用AT指定将wifi-iot设备连接到WIFI

    工具:sscom

    核心步骤:

    1. 启动station模式
    2. 连接wifi热点
    3. 启动DHCP客户端获取ip

    说明:第3步是必须的,这跟我们平时使用的不太一样,我们使用手机,电脑或其他设备连接到wifi热点时会自动启动DHCP客户端,给我们的感觉就是只有一步,只要连接成功就会获取到ip地址,但其实这是两步,使用AT指令时,这两步都需要执行。下面看一下具体AT指令执行步骤

    1. AT+STARTSTA

    启动station模式

    [12:20:21.994]发→◇AT+STARTSTA
    □
    [12:20:21.998]收←◆AT+STARTSTA
    OK> 
    
    1. AT+SCAN

    扫描周围的热点信息,扫描并不会直接返回扫描到的热点信息,需要执行AT+SCANRESULT进行查看

    [12:20:30.347]发→◇AT+SCAN
    □
    [12:20:30.351]收←◆AT+SCAN
    OK
    
    [12:20:31.128]收←◆+NOTICE:SCANFINISH
    
    1. AT+SCANRESULT

    查看扫描到的热点信息。

    
    [12:20:36.581]发→◇AT+SCANRESULT
    □
    [12:20:36.585]收←◆AT+SCANRESULT
    +SCANRESULT:LAWOFATTRACTION,78:d2:94:11:21:50,6,-40,2
    +SCANRESULT:,32:61:04:fd:d1:e3,6,-49,2
    +SCANRESULT:360WiFi-FDD1E0,2c:61:04:fd:d1:e3,6,-49,3
    +SCANRESULT:CMCC-jesq,44:4c:7e:21:74:e1,1,-53,3
    +SCANRESULT:a7f8f605,24:df:a7:f8:f6:05,6,-60,3
    +SCANRESULT:rzh,50:d2:f5:f2:63:d1,3,-79,3
    +SCANRESULT:XRX-4G,60:3a:7c:67:df:2a,11,-80,3
    +SCANRESULT:WHY1_Wi-Fi5,0c:83:9a:fc:d1:75,11,-80,2
    +SCANRESULT:360WiFi-FDD1E0,2c:61:04:fd:d1:e0,6,-82,3
    OK
    
    1. AT+CONN=,08:6b:d1:93:a5:72,3,"12345678"

    连接到指定的WIFI热点。连接的完整指令是AT+SCAN=,,<auth_type>[,]。

    ssid,即路由器名称

    bssid,即路由器的MAC地址

    auth_type,认证方式。0:OPEN 1:WEP 2:WPA2_PSK 3:WPA_PWA2_PSK

    passwd,即密码

    连接时ssid和bssid选择一个即可,ssid需要使用双引号("")括起来,bssid不需要。auth_type一般选择3

    
    [12:20:45.293]发→◇AT+CONN=,08:6b:d1:93:a5:72,3,"4001000601A"
    □
    [12:20:45.298]收←◆AT+CONN=,08:6b:d1:93:a5:72,3,"4001000601A"
    OK
    
    [12:20:46.079]收←◆+NOTICE:SCANFINISH
    
    [12:20:47.242]收←◆+NOTICE:CONNECTED
    
    1. AT+DHCP=wlan0,1

    获取IP地址。dhcp服务器命令的完整形式为AT+DHCPS=

  • 相关阅读:
    docker是PaaS,与openstack是IaaS的关系
    nuget安装.net standard
    GitHub sync the original repository by pull request
    Is there a way to include commas in CSV columns without breaking the formatting?
    How to determine why visual studio might be skipping projects when building a solution
    IHttpHandler vs IHttpModule
    .NET 3.0 SDK Projects not Loading
    Microsoft Edge version
    Microsoft Edge High CPU and Memory
    Google Analytics
  • 原文地址:https://www.cnblogs.com/HarmonyOS/p/14137271.html
Copyright © 2020-2023  润新知