三木社区

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 393|回复: 0
打印 上一主题 下一主题

网络

[复制链接]

1657

主题

1684

帖子

5684

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
5684
跳转到指定楼层
楼主
发表于 2017-7-12 08:27:45 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1. import network
  2. wlan = network.WLAN(network.STA_IF) # create station interface
  3. wlan.active(True)       # activate the interface
  4. wlan.scan()             # scan for access points
  5. wlan.isconnected()      # check if the station is connected to an AP
  6. wlan.connect('essid', 'password') # connect to an AP
  7. wlan.config('mac')      # get the interface's MAC adddress
  8. wlan.ifconfig()         # get the interface's IP/netmask/gw/DNS addresses
  9. ap = network.WLAN(network.AP_IF) # create access-point interface
  10. ap.active(True)         # activate the interface
  11. ap.config(essid='ESP-AP') # set the ESSID of the access point
  12. def do_connect():
  13.    import network
  14.    wlan = network.WLAN(network.STA_IF)
  15.    wlan.active(True)
  16.    if not wlan.isconnected():
  17.        print('connecting to network...')
  18.        wlan.connect('essid', 'password')
  19.        while not wlan.isconnected():
  20.            pass
  21.    print('network config:', wlan.ifconfig())
复制代码


回复

使用道具 举报

Archiver|手机版|小黑屋|三木电子社区 ( 辽ICP备11000133号-4 )

辽公网安备 21021702000620号

GMT+8, 2026-3-6 00:08 , Processed in 0.027885 second(s), 23 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表