打印
[技术讨论]

全志R128基础组件开发指南-WiFi Manager②

[复制链接]
1335|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
神棍地海棠|  楼主 | 2024-1-25 14:30 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Wi-Fi Manager 核心代码各函数说明
[color=rgba(0, 0, 0, 0.87)]该章节主要用于介绍核心代码中各API (需要2 次开发的人员重点关注和查阅)
初始化Wi-Fi Manager
[color=rgba(0, 0, 0, 0.87)]想要使用Wi-Fi Manager 的功能前,必须调用该函数进行Wi-Fi Manager 初始化。
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_init(void)
[color=rgba(0, 0, 0, 0.87)]参数:
  • void
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:Wi-Fi Manager 初始化成功;
  • 0:Wi-Fi Manager 初始化失败。
反初始化Wi-Fi Manager
[color=rgba(0, 0, 0, 0.87)]反初始化Wi-Fi Manager
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_deinit(void)
[color=rgba(0, 0, 0, 0.87)]参数:
  • void
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:Wi-Fi Manager 反初始化成功;
  • 非0:Wi-Fi Manager 反初始化失败。
打开Wi-Fi Manager 某种模式
[color=rgba(0, 0, 0, 0.87)]想要使用Wi-Fi Manager 的功能前,必须调用该函数进行Wi-Fi Manager 初始化。
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_on(wifi_mode_t mode)
[color=rgba(0, 0, 0, 0.87)]参数:
  • wifi_mode_t:需要打开的模式(WIFI_STATION / WIFI_AP / WIFI_MONITOR/WIFI_P2P)
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:Wi-Fi Manager;
  • 非0:Wi-Fi Manager 初始化失败。
关闭Wi-Fi Manager
[color=rgba(0, 0, 0, 0.87)]关闭Wi-Fi Manager 后,要重新使用Wi-Fi Manager 需要重新调用wifi_on
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_off(void);
[color=rgba(0, 0, 0, 0.87)]参数:
  • void
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功
  • 非0:失败
sta 模式下连接ap
[color=rgba(0, 0, 0, 0.87)]连接到某个特定的ap
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_sta_connect(wifi_sta_cn_para_t * cn_para)
[color=rgba(0, 0, 0, 0.87)]参数:
  • wifi_sta_cn_para_t 需要连接的ap 的信息
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
sta 模式下断开与ap 的连接
[color=rgba(0, 0, 0, 0.87)]只有在已连接上某个ap 后调用该接口才有用,否则会返回失败
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_sta_disconnect(void)
[color=rgba(0, 0, 0, 0.87)]参数:
  • void
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
sta 模式下自动连接上某个ap
[color=rgba(0, 0, 0, 0.87)]该功能主要有2 个附加作用
  • 当系统有保存已连接过的ap 信息时,调用该接口后会自动尝试去连接已连接过的ap。
  • 当已连接上某个ap 后,因某些原因导致了与ap 断开,打开了该功能会尝试继续连接该ap;
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_sta_auto_reconnect(wmg_bool_t enable)
[color=rgba(0, 0, 0, 0.87)]参数:
  • wmg_bool_t:打开或关闭该功能;
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
sta 模式下获取当前状态的一些信息
[color=rgba(0, 0, 0, 0.87)]获取当前station 模式状态的一些信息(包括连接上的ap 的ssid,bssid 等)
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_sta_get_info(wifi_sta_info_t * sta_info)
[color=rgba(0, 0, 0, 0.87)]参数:
  • wifi_sta_info_t,station 模式的一些信息
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
sta 模式下列出已保存的ap 的信息
[color=rgba(0, 0, 0, 0.87)]在sta 模式下移除某个ap 信息,R128平台仅列出最后一次连接的ap的信息
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_sta_list_networks(wifi_sta_list_t * sta_list);
[color=rgba(0, 0, 0, 0.87)]参数:
  • wifi_sta_list_t 保存列表信息
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
sta 模式下移除某个ap 信息
[color=rgba(0, 0, 0, 0.87)]该接口主要配合wifi_sta_list_networks 接口使用
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_sta_remove_networks(char * ssid)
[color=rgba(0, 0, 0, 0.87)]参数:
  • ssid:要移除的ap 的ssid
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
ap 模式下使能ap 热点功能
[color=rgba(0, 0, 0, 0.87)]根据 wifi_ap_config_t 的设置不同,启动的热点会不同
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">
[color=rgba(0, 0, 0, 0.87)]参数:
  • wifi_ap_config_t,使能ap 热点时的配置参数
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
ap 模式下关闭ap 热点功能
[color=rgba(0, 0, 0, 0.87)]在ap 模式下关闭ap 热点功能
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_ap_disable(void)
[color=rgba(0, 0, 0, 0.87)]参数:
  • void
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
ap 模式下获取当前ap 热点的配置信息
[color=rgba(0, 0, 0, 0.87)]该接口主要是用于获取当前启动的ap 热点的配置信息
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_ap_get_config(wifi_ap_config_t * ap_config)
[color=rgba(0, 0, 0, 0.87)]参数:
  • ifi_ap_config_t,ap 热点的配置参数
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
monitor 模式使能monitor 功能
[color=rgba(0, 0, 0, 0.87)]在monitor 模式下使能monitor 功能
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_monitor_enable(uint8_t channel)
[color=rgba(0, 0, 0, 0.87)]参数:
  • channel:使能monitor 模式时需要监听的信道
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
monitor 模式下动态切换监听的信道
[color=rgba(0, 0, 0, 0.87)]在monitor 模式下动态切换要监听信道
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_monitor_set_channel(uint8_t channel)
[color=rgba(0, 0, 0, 0.87)]参数:
  • channel:要修改监听的信道
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
monitor 模式下关闭monitor 功能
[color=rgba(0, 0, 0, 0.87)]monitor 模式下关闭monitor 功能
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_monitor_disable(void)
[color=rgba(0, 0, 0, 0.87)]参数:
  • void
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
p2p 模式下使能p2p 功能
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_p2p_enable(wifi_p2p_config_t *p2p_config)
[color=rgba(0, 0, 0, 0.87)]参数:
  • p2p_config_t,使能p2p 时的配置参数
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
p2p 模式下关闭p2p 功能
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_p2p_disable(void);
[color=rgba(0, 0, 0, 0.87)]参数:
  • void
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
p2p 模式下发起扫描
[color=rgba(0, 0, 0, 0.87)]在执行扫描的过程中也需要对端发起扫描,否则扫描不到对端设备
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_p2p_find(wifi_p2p_peers_t *p2p_peers, uint8_t find_second);
[color=rgba(0, 0, 0, 0.87)]参数:
  • p2p_config_t,使能p2p 时的配置参数
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
p2p 模式下连接另外一个p2p 设备
[color=rgba(0, 0, 0, 0.87)]连接的过程中需要对方同意连接,否则会连接失败
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_p2p_connect(uint8_t *p2p_mac_addr);
[color=rgba(0, 0, 0, 0.87)]参数:
  • p2p_mac_addr:需要连接的p2p 设备的mac 地址
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
p2p 模式下断开已连接的p2p 设备
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_p2p_disconnect(uint8_t *p2p_mac_addr);
[color=rgba(0, 0, 0, 0.87)]参数:
  • p2p_mac_addr:需要断开的p2p 设备的mac 地址
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
p2p 模式下获取p2p 设备的某些信息
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">
[color=rgba(0, 0, 0, 0.87)]参数:
  • p2p_info,p2p 设备信息参数
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
任意模式下注册回调函数
[color=rgba(0, 0, 0, 0.87)]该接口可以在任意模式下调用,但必须在调用wifi_on 函数后才能调用,否则会注册回调函数失败。
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_register_msg_cb(wifi_msg_cb_t msg_cb)
[color=rgba(0, 0, 0, 0.87)]参数:
  • wifi_msg_cb_t:要回调的回调函数
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
sta 模式下设置扫描参数
[color=rgba(0, 0, 0, 0.87)]预留接口,功能没有实现
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_set_scan_param(wifi_scan_param_t * scan_param)
[color=rgba(0, 0, 0, 0.87)]参数:
  • 无效
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
sta 模式下获取扫描结果
[color=rgba(0, 0, 0, 0.87)]调用者需要根据具体情况申请内存
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_get_scan_results(wifi_scan_result_t * result, uint32_t *bss_num, uint32_t arr_size)
[color=rgba(0, 0, 0, 0.87)]参数:
  • wifi_scan_result_t,扫描结果保存结构体
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
任意模式下设置mac 地址
[color=rgba(0, 0, 0, 0.87)]该接口可以在任意模式下调用,但必须在调用wifi_on 函数后才能调用,否则会设置失败。
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_set_mac(const char * ifname, uint8_t * mac_addr)
[color=rgba(0, 0, 0, 0.87)]参数:
  • ifname:要设置mac 地址的网卡名
  • mac_addr:要设置mac 地址
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
任意模式下获取mac 地址
[color=rgba(0, 0, 0, 0.87)]该接口可以在任意模式下调用,但必须在调用wifi_on 函数后才能调用,否则会设置失败。需要调用者申请内存来保存mac 地址
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_get_mac(const char * ifname, uint8_t * mac_addr)
[color=rgba(0, 0, 0, 0.87)]参数:
  • ifname:要设置mac 地址的网卡名
  • mac_addr: 获取到的mac 地址
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
配网模式
[color=rgba(0, 0, 0, 0.87)]该接口可以在任意模式下调用,调用后已某种配网模式去获取配网结果(ssid和psk),配网模式根据当前系统的支持
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_linkd_protocol(wifi_linkd_mode_t mode, void params, int second, wifi_linkd_result_t linkd_result);
[color=rgba(0, 0, 0, 0.87)]参数:
  • mode:要使用哪种配网模式params: 配网模式的参数
  • second:配网多少秒
  • linkd_result: 配网获取到的结果(ssid 和psk)
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
任意模式下获取Wi-Fi Manager 的状态信息
[color=rgba(0, 0, 0, 0.87)]该接口可以在任意模式下调用,用于获取Wi-Fi Manager 的状态信息,只有返回值为0 时获取的状态信息才有效
[color=rgba(0, 0, 0, 0.87)]函数原型
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_status_t wifi_get_wmg_state(wifi_wmg_state_t *wmg_state);
[color=rgba(0, 0, 0, 0.87)]参数:
  • wmg_state:获取到的Wi-Fi Manager 的状态信息
[color=rgba(0, 0, 0, 0.87)]返回值:
  • 0:成功;
  • 非0:失败;
Wi-Fi Manager 核心代码函数调用流程介绍
[color=rgba(0, 0, 0, 0.87)]下面提供Wi-Fi Manager 各功能的开发流程(简单介绍api 的调用流程)。更详细的调用流程可以参考wifi_deamon.c 文件里的编写流程。
以某种模式打开Wi-Fi Manager code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">1.wifi_on(WIFI_STATION) ‑‑‑‑> 以station模式打开Wi-Fi Manager2.wifi_on(WIFI_AP) ‑‑‑‑> 以ap模式打开Wi-Fi Manager3.wifi_on(WIFI_MONITOR) ‑‑‑‑> 以monitor模式打开Wi-Fi Manager4.wifi_on(WIFI_P2P) ‑‑‑‑> 以p2p模式打开Wi-Fi Manager在调用libwifimg‑v2.0库中的任何api前都必须调用Wi-Fi Manager_init函数station 模式—关闭Wi-Fi Manager code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_STATION); ‑‑‑‑> 以station模式打开Wi-Fi Managerwifi_off(); ‑‑‑‑> 关闭Wi-Fi Manager1.以station模式打开Wi-Fi Manager2.wifi_off函数只需在不再使用Wi-Fi Manager时调用一次即可,中间无法频繁调用备注:调用wifi_off后想再使用Wi-Fi Manager必须重新再调用一次wifi_on。station 模式—扫描环境中存在哪些ap code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_STATION);wifi_get_scan_results(scan_res, &bss_num, RES_LEN);1.以station模式打开Wi-Fi Manager2.获取扫描结果(1).wifi_scan_result_t scan_res:该参数需要用户申请内存,主要是用于保存扫描结果(2).uint32_t bss_num:该参数用于传到库底层,记录系统能扫到多少条结果。(3).uint32_t RES_LEN:该参数主要是表明scan_res的大小。备注:    假设用户在调用该函数前,申请了一个可以保存5条扫描结果的buff,那么scan_res填写buff指针,RES_LEN填写5,扫描后系统扫到了20条结果。用户只能获取到5条扫描结果,不过可以在bss_num中获取到系统中实际上扫描到20条结果。用户环境ap如果多,可以把buff调大点,如果少可以把buff调小一点。station 模式—连接某个特定的ap code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_STATION);wifi_sta_connect(&cn_para);1.以station模式打开Wi-Fi Manager2.填充好连接参数,调用连接函数即可备注:其中cn_para是一个连接参数配置结构体,只需要填充好ssid,password,sec字段参数即可,fast_connect字段预留字段,暂时没有作用。station 模式—断开与某个ap 的连接 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_STATION);wifi_sta_connect(&cn_para);wifi_sta_disconnect()1.以station模式打开Wi-Fi Manager2.连接某个ap3.断开与ap的连接备注:在连接上某个ap后调用wifi_sta_disconnect函数可以断开与ap的连接。station 模式—设置自动连接功能 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_STATION);wifi_sta_auto_reconnect(true);wifi_sta_connect(&cn_para);wifi_sta_auto_reconnect(false);1.以station模式打开Wi-Fi Manager2.打开自动连接功能3.连接上某个ap4.关闭自动连接功能备注:自动连接功能在底层有2种作用(1).开启自动连接功能后,如果连接上了某个ap,该ap的信息会保存在系统中,下次系统启动后会尝试去连接已连接过的ap(2).开启自动连接功能后,如果已经连上了某个ap,但某些原因与该ap断开了连接,系统会尝试继续与该ap进行连接station 模式—列出已保存的ap 列表信息 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_STATION);wifi_sta_list_networks(&sta_list_networks);1.以station模式打开Wi-Fi Manager2.调用列出ap列表函数备注:    sta_list_networks参数是wifi_sta_list_t类型的结构体,需要用户申请相关的内存,其中list_nod字段用于保存列表信息,list_num字段用于告诉系统列表空间的大小,sys_list_num字段是返回值,调用函数后系统实际列表项数目会保存在该字段。    R128 平台仅列出最后一次连接的ap的信息station 模式—列出连接的ap 信息 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_STATION);wifi_sta_connect(&cn_para);wifi_sta_get_info(&wifi_sta_info);1.以station模式打开Wi-Fi Manager2.连接上某个特定的ap3.获取连接的ap的信息备注:该函数主要是获取连接的ap的信息,因此需要连接上某个ap后才能调用,调用是用户需要自己申请一个wifi_sta_info结构体station 模式—移除某个或全部已保存的ap 信息 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_STATION);wifi_sta_remove_networks(NULL/ssid);1.以station模式打开Wi-Fi Manager2.移除某个ssid或全部已保存的ap的信息备注:该函数要配合wifi_sta_list_networks函数来使用,调用wifi_sta_list_networks函数列出已保存的ap信息,再根据信息来移除不需要的ap。如果wifi_sta_remove_networks传入的参数是一个具体的ssid,那么仅仅移除该ssid的信息,如果传入的参数是一个NULL指针,那么把所有的已保存的ap信息都删掉。ap 模式—启动ap 节点 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_AP);wifi_ap_enable(&ap_config);1.以ap模式打开Wi-Fi Manager2.使能ap功能备注:如果想启动无密码ap,需要把ap_config结构体中的psk字段填充“NULL”字符串。其它字段按实际需求填写ap 模式—获取ap 配置信息 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_AP);wifi_ap_enable(&ap_config);wifi_ap_get_config(&ap_config);1.以ap模式打开Wi-Fi Manager2.使能ap功能3.获取ap模式的配置信息备注:ap 模式—关闭ap 热点 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_AP);wifi_ap_enable(&ap_config);wifi_ap_disable(void);1.以ap模式打开Wi-Fi Manager2.使能ap功能3.关闭ap热点备注:monitor 模式—使用monitor 功能 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_MONITOR);wifi_monitor_enable(channel);1.以monitor模式打开Wi-Fi Manager2.使能monitor功能备注: channel指的是监听哪条信道monitor 模式—切换监听的信道 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_MONITOR);wifi_monitor_enable(channel);wifi_monitor_set_channel(channel);1.以monitor模式打开Wi-Fi Manager2.使能monitor功能3.切换要监听的信道备注:monitor 模式—关闭monitor 功能 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_MONITOR);wifi_monitor_enable(channel);wifi_monitor_disable(void);1.以monitor模式打开Wi-Fi Manager2.使能monitor功能3.关闭monitor功能备注:p2p 模式—启动p2p 功能 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_P2P);wifi_p2p_enable(&p2p_config);1.以p2p模式打开Wi-Fi Manager2.使能p2p功能备注: 启动p2p功能时可以对p2p设备名,协商等级等一下参数进行设置p2p 模式—关闭p2p 功能 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_P2P);wifi_p2p_enable(&p2p_config);wifi_p2p_disable(void);1.以ap模式打开Wi-Fi Manager2.使能ap功能3.获取ap模式的配置信息备注:p2p 模式—扫描周围p2p 设备 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_P2P);wifi_p2p_find(&p2p_peers, find_second);1.以p2p模式打开Wi-Fi Manager2.扫描周围p2p设备备注: 对端设备也必须处于扫描状态才能被发现p2p 模式—连接某个p2p 设备 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_P2P);wifi_p2p_find(&p2p_peers, find_second);wifi_p2p_connect(p2p_mac_addr);1.以p2p模式打开Wi-Fi Manager2.扫描周围p2p设备3.连接某个p2p设备备注: 在连接前必须进行扫描,只有相互发现后才能连接成功p2p 模式—断开与p2p 设备的连接 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_P2P);wifi_p2p_find(&p2p_peers, find_second);wifi_p2p_connect(p2p_mac_addr);wifi_p2p_disconnect(uint8_t *p2p_mac_addr);1.以p2p模式打开Wi-Fi Manager2.扫描周围p2p设备3.连接某个p2p设备4.断开与p2p设备的连接备注:p2p 模式—获取p2p 设备信息 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(WIFI_P2P);wifi_p2p_find(&p2p_peers, find_second);wifi_p2p_connect(p2p_mac_addr);wifi_p2p_get_info(&p2p_info);1.以p2p模式打开Wi-Fi Manager2.扫描周围p2p设备3.连接某个p2p设备4.获取p2p设备信息备注:任意模式—获取mac 地址 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(XXX);wifi_get_mac(ifname, mac_addr);1.打开任意模式2.调用函数获取mac地址备注:用户需要申请空间mac_addr来保存获取到的mac地址,ifname是网卡名,如果传入的网卡名为NULL,那么底层逻辑默认获取wlan0网卡的mac地址任意模式—设置mac 地址 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wifi_on(XXX);wifi_set_mac(ifname, mac_addr);1.打开任意模式2.调用函数设置mac地址备注:用户需要申请空间mac_addr来保存获取到的mac地址,ifname是网卡名,如果传入的网卡名为NULL,那么底层逻辑默认设置wlan0网卡的mac地址,设置网卡的mac地址是临时性的,重启后设置的mac地址会失效。任意模式—获取打印等级 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_get_debug_level();1.获取Wi-Fi Manager的当前打印等级备注:该函数不需要调用wifi_on即可调用任意模式—设置打印等级 code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">wmg_set_debug_level(XXX);1.设置Wi-Fi Manager的当前打印等级备注:该函数不需要调用wifi_on即可调用Wi-Fi Manager 配网模式
[color=rgba(0, 0, 0, 0.87)]wifimager 集成了smartlink 部分的配网功能,便于用户使用,用户只需要使用wifimager 提供的demo 即可进行配网功能,无需额外再使用smartlink。
wifimager 配网模式简介
[color=rgba(0, 0, 0, 0.87)]目前wifimager 支持sofap,蓝牙,xconfig 和声波配网4 种配网模式。所有的配网模式实质上都只包含了2 部分。 1. 获取连接ap 的ssid 和psk
  • 根据获取到的信息进行联网
[color=rgba(0, 0, 0, 0.87)]每种配网模式的第二部分的实现都是一样的,调用libwifimg‑v2.0 里提供的API 进行网络连接。差异化部分只有获取ap 的ssid 和psk 部分。sofap 配网模式是通过开启一个ap 热点,用户通过手机app 连上该ap 热点后把配网信息传送到小机端。蓝牙配网模式是启动蓝牙后,用户通过手机app把配网信息通过蓝牙传送到小机端。xconfig 配网模式是启动了monitor 模式,用户通过手机app发送一些特定的配网包从而达到把配网信息传递到小机端。声波配网模式是启动mic 后,用户通过手机app 发送一段带有配网信息的声波给小机端。
Wi-Fi Manager 扩展模式
[color=rgba(0, 0, 0, 0.87)]Wi-Fi Manager 同样集成了扩展模式,扩展模式主要用于扩展wifi 差异性功能。这些功能与模组或系统有强相关,非通用性。例如A 模组支持使用ioct 或设备节点控制唤醒功能,但B 模组没有这些功能,A 模组的这些差异性功能就会被集成到扩展模式里。扩展功能没有通用性,因此不在此处进行简述,需要自行查看源码,同样也可以根据模组的特性在此处添加模组差异性功能。
[color=rgba(0, 0, 0, 0.87)]core/src/expand_cmd.c 文件是扩展命令屏蔽层,该文件(层) 屏蔽了系统性差异功能。
[color=rgba(0, 0, 0, 0.87)]core/src/os/linux/expand/ –> linux 系统差异性功能具体实现代码(非通用性,自行查阅以及增删)
[color=rgba(0, 0, 0, 0.87)]core/src/os/xrlink/expand/ –> xrlink系统差异性功能具体实现代码(非通用性,自行查阅以及增删)
[color=rgba(0, 0, 0, 0.87)]core/src/os/freertos/expand/ –> freertos 系统差异性功能具体实现代码(非通用性,自行查阅以及增删)
Wi-Fi Manager demo
[color=rgba(0, 0, 0, 0.87)]Wi-Fi Manager demo 是提供给用户的一个参考demo,它提供了基本的网络功能,用户可以直接使用该demo 来进行网络配置,连接等。也可以参考该demo 对核心代码API 的使用方法,把对应的功能集成到用户自己的应用中去。
Wi-Fi Manager demo 目录结构
[color=rgba(0, 0, 0, 0.87)]wifimager demo 在SDK 里的路径如下:
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">Wi-Fi Manager/demo
[color=rgba(0, 0, 0, 0.87)]Wi-Fi Manager demo 的主要目录结构如下:
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">├── wifi.c├── wifi_deamon.c└── wifi_deamon.h
  • wifi.c:wifi 组件主要是提供了一些简单易用的命令行命令给用户。用户可以直接使用这些简单的命令行命令即可连接网络和配网。
  • wifi_deamon.c:wifi_deamon,linux 下的实现,wifi.c 文件通过解析用户输入的命令后通过socket 接口发送给后台组件wifi_deamon,由wifi_deamon 组件实现真正的网络功能。freertos下的实现,直接采用函数调用的方式。
  • wifi_deamon.h:wifi_deamon 头文件
编译 Wi-Fi Manager demo
[color=rgba(0, 0, 0, 0.87)]勾选选项并编译即可
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">> System components > aw components > wireless   
  • wireless common   
  • Wi-Fi Manager ‑‑‑>        
  • Wi-Fi Manager demoWi-Fi Manager demo 快速测试命令简介station 模式常用命令[color=rgba(0, 0, 0, 0.87)]
    测试命令
    解释说明

    wifi ‑o sta以sta 模式打开Wi-Fi Manager
    wifi ‑s扫描周围网络
    wifi ‑c ssid [passwd]以加密或非加密的方式连接指定网络
    wifi ‑d断开已经连接的网络
    wifi ‑l [all]列出保存的网络
    wifi ‑a [enable/disable]重连断开的网络
    wifi ‑r [ssid/all]移除保存的指定网络

    ssid 网络名,passwd 密码,在使用 sta 模式其他命令前先要执行wifi ‑o sta 打开sta 模式。
    ap 模式常用命令[color=rgba(0, 0, 0, 0.87)]
    测试命令
    解释说明

    wifi ‑o ap [ssid] [passwd]以ap 模式打开Wi-Fi Manager
    wifi ‑l列出连接到ap 热点的sta 信息

    ssid 网络名,passwd 密码,在使用ap 模式其他命令前先要执行wifi ‑o ap 打开ap 模式。
    monitor 模式常用命令[color=rgba(0, 0, 0, 0.87)]
    测试命令
    解释说明

    wifi ‑o monitor以monitor 模式打开Wi-Fi Manager

    额外功能常用命令[color=rgba(0, 0, 0, 0.87)]
    测试命令
    解释说明

    wifi ‑f关闭Wi-Fi Manager
    wifi ‑p [softap/ble/xconfig/soundwave]配网
    wifi ‑D [error/warn/info/debug/dump/exce/open/colse]设置打印等级
    wifi ‑g获取mac 地址信息
    wifi ‑i查看网络状态
    wifi ‑m [macaddr]设置mac 地址
    wifi ‑e [freertos: XXX]支持扩展命令
    wifi ‑h打印帮助信息


  • 使用特权

    评论回复
    发新帖 我要提问
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    260

    主题

    268

    帖子

    0

    粉丝