当前位置:网站首页>树莓派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(需要网络调试助手配合)
边栏推荐
- A file upload tool website written by individuals
- Review of metallurgical physical chemistry ---- gas solid reaction kinetics
- Deep learning medical image model reproduction
- openjudge:判断字符串是否为回文
- 顺序表oj题目
- Merge two ordered arrays of order table OJ
- MySQL uses list as a parameter to query
- Response < t > class
- 关于swagger中的localDateTime
- repackag failed: Unable to find main class
猜你喜欢

c语言:通过一个例子来认识函数栈帧的创建和销毁讲解

shell运行原理

The Monte Carlo method solves the PI and draws points with turtle, and completes the progress bar problem

环形链表问题

Custom JSON return data

Leetcode 随即链表的深拷贝

Multi module packaging: package: XXX does not exist

Mutual conversion between latex and word

Delete specific elements in order table OJ

MySQL adds sequence number to query results
随机推荐
restFul接口使用个人总结
SSM project quick build project configuration file
URL 形式
TopK问题
openjudge:判断字符串是否为回文
Review of Metallurgical Physical Chemistry - gas liquid phase reaction kinetics
Use of IO streams
C语言回顾(修饰词篇)
URL form
ByteBuffer. Position throws exception illegalargumentexception
蒸馏模型图
记录某某小卢的第一篇文章
Openjudge: stone scissors cloth
Openjudge: upper and lower case letters are interchanged
Leetcode 随即链表的深拷贝
蒙特卡罗方法求解圆周率π并用turtle画点,以及完成进度条问题
冶金物理化学复习 --- 金属的电沉积,还原过程
The essence of dynamic convolution
Response<T>类
Merge two ordered arrays of order table OJ