开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (2)
master
review
master
分支 (2)
master
review
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (2)
master
review
microPython
/
docs
/
library
/
network.WLAN.rst
microPython
/
docs
/
library
/
network.WLAN.rst
network.WLAN.rst 4.98 KB
一键复制 编辑 原始数据 按行查看 历史
chenchi 提交于 2021年06月03日 16:44 +08:00 . first commit
.. currentmodule:: network

class WLAN -- control built-in WiFi interfaces

This class provides a driver for WiFi network processors. Example usage:

import network
# enable station interface and connect to WiFi access point
nic = network.WLAN(network.STA_IF)
nic.active(True)
nic.connect('your-ssid', 'your-password')
# now use sockets as usual

Constructors

Create a WLAN network interface object. Supported interfaces are network.STA_IF (station aka client, connects to upstream WiFi access points) and network.AP_IF (access point, allows other WiFi clients to connect). Availability of the methods below depends on interface type. For example, only STA interface may WLAN.connect() to an access point.

Methods

.. method:: WLAN.active([is_active])

 Activate ("up") or deactivate ("down") network interface, if boolean
 argument is passed. Otherwise, query current state if no argument is
 provided. Most other methods require active interface.

.. method:: WLAN.connect(ssid=None, password=None, *, bssid=None)

 Connect to the specified wireless network, using the specified password.
 If *bssid* is given then the connection will be restricted to the
 access-point with that MAC address (the *ssid* must also be specified
 in this case).

.. method:: WLAN.disconnect()

 Disconnect from the currently connected wireless network.

.. method:: WLAN.scan()

 Scan for the available wireless networks.

 Scanning is only possible on STA interface. Returns list of tuples with
 the information about WiFi access points:

 (ssid, bssid, channel, RSSI, authmode, hidden)

 *bssid* is hardware address of an access point, in binary form, returned as
 bytes object. You can use `ubinascii.hexlify()` to convert it to ASCII form.

 There are five values for authmode:

 * 0 -- open
 * 1 -- WEP
 * 2 -- WPA-PSK
 * 3 -- WPA2-PSK
 * 4 -- WPA/WPA2-PSK

 and two for hidden:

 * 0 -- visible
 * 1 -- hidden

.. method:: WLAN.status([param])

 Return the current status of the wireless connection.

 When called with no argument the return value describes the network link status.
 The possible statuses are defined as constants:

 * ``STAT_IDLE`` -- no connection and no activity,
 * ``STAT_CONNECTING`` -- connecting in progress,
 * ``STAT_WRONG_PASSWORD`` -- failed due to incorrect password,
 * ``STAT_NO_AP_FOUND`` -- failed because no access point replied,
 * ``STAT_CONNECT_FAIL`` -- failed due to other problems,
 * ``STAT_GOT_IP`` -- connection successful.

 When called with one argument *param* should be a string naming the status
 parameter to retrieve. Supported parameters in WiFI STA mode are: ``'rssi'``.

.. method:: WLAN.isconnected()

 In case of STA mode, returns ``True`` if connected to a WiFi access
 point and has a valid IP address. In AP mode returns ``True`` when a
 station is connected. Returns ``False`` otherwise.

.. method:: WLAN.ifconfig([(ip, subnet, gateway, dns)])

 Get/set IP-level network interface parameters: IP address, subnet mask,
 gateway and DNS server. When called with no arguments, this method returns
 a 4-tuple with the above information. To set the above values, pass a
 4-tuple with the required information. For example::

 nic.ifconfig(('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8'))

.. method:: WLAN.config('param')
 WLAN.config(param=value, ...)

 Get or set general network interface parameters. These methods allow to work
 with additional parameters beyond standard IP configuration (as dealt with by
 `WLAN.ifconfig()`). These include network-specific and hardware-specific
 parameters. For setting parameters, keyword argument syntax should be used,
 multiple parameters can be set at once. For querying, parameters name should
 be quoted as a string, and only one parameter can be queries at time::

 # Set WiFi access point name (formally known as ESSID) and WiFi channel
 ap.config(essid='My AP', channel=11)
 # Query params one by one
 print(ap.config('essid'))
 print(ap.config('channel'))

 Following are commonly supported parameters (availability of a specific parameter
 depends on network technology type, driver, and :term:`MicroPython port`).

 ============= ===========
 Parameter Description
 ============= ===========
 mac MAC address (bytes)
 essid WiFi access point name (string)
 channel WiFi channel (integer)
 hidden Whether ESSID is hidden (boolean)
 authmode Authentication mode supported (enumeration, see module constants)
 password Access password (string)
 dhcp_hostname The DHCP hostname to use
 ============= ===========
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

HeliosSDK microPython组件
暂无标签
MIT
使用 MIT 开源许可协议
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quecpython/microPython.git
git@gitee.com:quecpython/microPython.git
quecpython
microPython
microPython
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /