当前位置:网站首页>WiFi one click connection configuration of raspberry pie

WiFi one click connection configuration of raspberry pie

2022-07-28 07:12:00 The most beautiful wish must be the craziest

Turn on AP Pattern , Turn raspberry pie into a hot spot

This is the online search tutorial through tools create_ap To operate . First installation create_ap

function  sudo git clone https://github.com/oblique/create_ap.git

function cd create_ap/

function sudo make install

Install dependent library run :

sudo apt-get install util-linux procps hostapd iproute2 iw haveged dnsmasq

 

About raspberry pie static IP Configuration of

modify /etc/dhcpcd.conf  file

The last side of the file is added

interface eth0

 

static ip_address=192.168.0.10/24  IP

static routers=192.168.0.1   ( gateway )

static domain_name_servers=192.168.0.1 DNS

For details, please refer to the following website :

http://www.cnblogs.com/taojintianxia/p/6026225.html

 

Python-wifi Download and install

function :

sudo wget

https://pypi.python.org/packages/bc/ab/c49f97516f78c2b0cacb4f45873abc4ca9872942a9c4c19ded8052c8edda/python-wifi-0.6.1.tar.bz2

function sudo tar xvjf  python-wifi-0.6.1.tar.bz2

function cd python-wifi-0.6.1/

function sudo python setup.py install install

test :

>>> from pythonwifi.iwlibs import Wireless

>>> wifi = Wireless('wlan0')

>>> wifi.getEssid()

'scream02'

>>> wifi.getMode()

'Managed'

 

WIFI Installation of debugging tools

Carry out orders sudo pip install wifi

 

Reference resources :https://wifi.readthedocs.io/en/latest/

 

When using this programming, use cell = Cell.all('wlan0') To the surroundings wifi scan , Often appear wifi Scan not available , You can only scan the currently connected wifi, Later used root This problem does not occur when the permission is running

pywifi Module installation

This is an online article , The download address is attached

http://www.cnblogs.com/jkkkk/p/6386308.html

Decompress after downloading , You need to make some changes after unzipping , If you download it from other places, you may not need to modify it . file /pywifi-msater/pywifi/iface.py Need to put """"Get the name of the wifi interfacce.""" Remove one quotation mark from the left of this sentence , Otherwise, the program will not run correctly . Then copy the folder to raspberry pie

function sudo python setup.py install install

socket Network programming

routine :

Server side :

#!/usr/bin/env python

import socket

s=socket.socket()

host=socket.gethostname()

print host

port=12345

s.bind(("192.168.2.141",port)) ( Bind the address and port )

s.listen(5)  ( Maximum connectable number , It's usually 5, At least 1

while True:

    c,addr=s.accept()  ( Obstructed , Waiting for the client )

    print "client",addr

print c.recv(1024)  ( Notice the handle here c , This is the client side .)

client :

#!/usr/bin/env python

import socket

s = socket.socket()

port = 12345  ( The port of the server )

s.connect(("192.168.2.141", port))

s.send("1234567")

s.close()

 

Details refer to :http://www.runoob.com/python/python-socket.html

 

Some explanations about ports . Ports are used to identify different services . In the LAN , Each host can access each other through ports . The port is the entrance of each service . As shown in the figure below , When the client accesses , From the Internet , It can only see ports A1,A2,A3.... On the router side , Turn the computer A,B,C Server port on B1B2.....C1C2..D1D2.. Mapped to the router A1A2A3... On . for example B1 and A1 Is a mapping relationship , If you want to access the service port through the Internet B1, You can only access the port A1, Because I can see it intelligently on the Internet B1 Mapping port of A1, Out of sight B1.


After a day of testing and research ,python-wifi Most functions are state acquisition , Only suitable wifi Management of , Not suitable for connection . and WIFI The attempt to connect was unsuccessful , After each connection ,wifi The module will not work properly . Unable to connect . Finally decided to use pywifi Connect ,wifi scanning

Test source :https://github.com/IJustLoveMyself/Raspberry-Pi/blob/master/test3/wifi_test.py( Network debugging assistant is required )

原网站

版权声明
本文为[The most beautiful wish must be the craziest]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/209/202207280516579922.html