当前位置:网站首页>树莓派WIFI一键连接配置
树莓派WIFI一键连接配置
2022-07-28 05:18:00 【最美的愿望一定最疯狂】
开启AP模式,将树莓派变为热点
这个是在网上搜索的教程通过工具create_ap来进行操作。首先安装create_ap
运行 sudo git clone https://github.com/oblique/create_ap.git
运行 cd create_ap/
运行 sudo make install
安装依赖库运行:
sudo apt-get install util-linux procps hostapd iproute2 iw haveged dnsmasq
关于树莓派静态IP的配置
修改/etc/dhcpcd.conf 文件
文件的最后面加入
interface eth0
static ip_address=192.168.0.10/24 (IP)
static routers=192.168.0.1 (网关)
static domain_name_servers=192.168.0.1 (DNS)
具体可以参考下面网址:
http://www.cnblogs.com/taojintianxia/p/6026225.html
Python-wifi下载安装
运行:
sudo wget
运行sudo tar xvjf python-wifi-0.6.1.tar.bz2
运行 cd python-wifi-0.6.1/
运行sudo python setup.py install安装
测试:
>>> from pythonwifi.iwlibs import Wireless
>>> wifi = Wireless('wlan0')
>>> wifi.getEssid()
'scream02'
>>> wifi.getMode()
'Managed'
WIFI调试工具的安装
执行命令 :sudo pip install wifi
参考:https://wifi.readthedocs.io/en/latest/
在使用这个编程的时候用cell = Cell.all('wlan0')对周围wifi进行扫描,经常出现wifi扫描不到,只能扫描到当前正在连接的wifi,后来用root权限运行的时候没有出现这个问题
pywifi模块的安装
这个是网上的一篇文章,内附下载地址
http://www.cnblogs.com/jkkkk/p/6386308.html
下载后解压,解压后需要做一些修改,如果从别的地方下载的话或许可以不用修改。文件/pywifi-msater/pywifi/iface.py需要将""""Get the name of the wifi interfacce."""这句话左边的引号去掉一个,不然程序无法正确运行。然后将文件夹拷贝到树莓派上
运行sudo python setup.py install安装
socket网络编程
例程:
服务器端:
#!/usr/bin/env python
import socket
s=socket.socket()
host=socket.gethostname()
print host
port=12345
s.bind(("192.168.2.141",port)) (绑定地址和端口)
s.listen(5) (最大可连接数,一般为5,最少为1)
while True:
c,addr=s.accept() (阻塞的,一直在等待客户端)
print "client",addr
print c.recv(1024) (注意这里的句柄c ,这个是客户端的。)
客户端:
#!/usr/bin/env python
import socket
s = socket.socket()
port = 12345 (服务器的端口)
s.connect(("192.168.2.141", port))
s.send("1234567")
s.close()
详情参考:http://www.runoob.com/python/python-socket.html
关于端口的一些解释。端口是用来识别不同的服务的。在局域网中,各个主机可以通过端口来相互访问。端口是各个服务的入口。如下图所示,当客户端访问的时候,从外网看,其只能看到端口A1,A2,A3.。。。在路由器端,将计算机A,B,C上的服务器端口B1B2.....C1C2..D1D2..分别映射到了路由器的A1A2A3...上。例如B1和A1是映射关系,如果想通过外网访问服务端口B1,就只能去访问端口A1,因为在外网上智能看到B1的映射端口A1,看不到B1。

经过一天的测试研究,python-wifi 大部分函数都是对状态的获取,只适合wifi 的管理,不适合进行连接。而WIFI尝试进行连接不成功,每次进行连接后,wifi模块就会工作不正常。无法进行连接。最终决定用pywifi连接,wifi扫描
测试源码:https://github.com/IJustLoveMyself/Raspberry-Pi/blob/master/test3/wifi_test.py(需要网络调试助手配合)
边栏推荐
- 蒙特卡罗方法求解圆周率π并用turtle画点,以及完成进度条问题
- openjudge:找出全部子串位置
- Deep learning medical image model reproduction
- 记录某某小卢的第一篇文章
- repackag failed: Unable to find main class
- Operation and use of collection framework
- Feignclient calls the get method and reports an error resultvo{result= unknown exception. Exception details: request method 'post' not supported
- Thesis writing function words
- 多模块打包:程序包:xxx不存在
- visio如何快速生成相同的图案,生成图像矩阵
猜你喜欢

Video twins: the starting point of informatization upgrading of smart Parks

冶金物理化学复习 -- 金属电沉积过程中的阴极极化,超电势以及阳极和阳极过程

ECCV22 最新54篇论文主图整理

蒙特卡罗方法求解圆周率π并用turtle画点,以及完成进度条问题

冶金物理化学复习 --- 金属的电沉积,还原过程

VMware Workstation is incompatible with device/credential guard. Disable device/credential guard

Advanced multi threading: the underlying principle of synchronized, the process of lock optimization and lock upgrade

函数基础知识以及特殊点

Idea uses dev tool to realize hot deployment

Leetcode 随即链表的深拷贝
随机推荐
ByteBuffer. Position throws exception illegalargumentexception
论文模型主图范例
The essence of dynamic convolution
When using deep learning training image, the image is too large for segmentation training prediction
RESNET structure comparison
Arrangement of main drawings of the latest 54 papers of eccv22
openjudge:万年历
Mabtis (I) basic use of framework
C语言回顾(可变参数篇)
导出excel,生成多个sheet页,并命名
openjudge:校园食宿预订系统
Review of metallurgical physical chemistry --- liquid liquid reaction kinetics
Advanced multithreading: the role and implementation principle of volatile
Mabtis(一)框架的基本使用
Mybats foreach multi select query, index loop, and cancel the and/or tag
MySQL adds sequence number to query results
Openjudge: judge whether the string is palindrome
Custom JSON return data
Openjudge: perpetual calendar
JUC notes