rpi-networking
Control wifi, hotspot and hostname of Raspberry Pi
Requirments
Python3.10+
Installation
Using pip:
pip3 install rpi-networking
Using poetry
poetry add rpi-networking
Prepare system
Automatically
Via curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/MarkParker5/rpi-networking/master/setup.sh)"
Or via wget
sh -c "$(wget https://raw.githubusercontent.com/MarkParker5/rpi-networking/master/setup.sh -O -)"
Manually
Dependencies
sudo apt update ; \
sudo apt upgrade -y ; \
sudo apt install dnsmasq hostapd dhcpd -y
Give permissions to edit configuration files (optional)
Give user permission to edit configuration files so python doesn't have to be run as root (sudo)
files=(
"/etc/dnsmasq.conf"
"/etc/hosts"
"/etc/default/hostapd"
"/etc/hostapd/hostapd.conf"
"/etc/network/interfaces"
"/etc/network/interfaces.d"
"/etc/wpa_supplicant/wpa_supplicant.conf"
)
for file in "${files[@]}"; do
sudo chown "$USER" "$file"
sudo chmod 644 "$file"
done;
Docs
Configuration
There are functions for initial configuration setup.
# rpi_networking.configuraion
def write_interfaces():
def write_default_hostapd():
def write_hostapd_conf():
def write_dnsmasq_conf():
def write_wpa_supplicant(country: str = "GB"):
def write_hosts():
def write_all(): # calls all functions above
In most cases you only need to call write_all() once to setup all configuration files.
Hostname
# rpi_networking.hostname
def set_hostname(hostname: str):
def restart_interfaces(): # apply new hostname without reboot
Hotspot
# rpi_networking.hotspot
def is_hotspot_up() -> bool:
def start_hotspot() -> bool:
def stop_hotspot() -> bool:
The bool return value is True if function finished without errors (exit code 0), else False
Status
# rpi_networking.status
def is_wlan_connected() -> bool:
def is_eth_connected() -> bool:
def is_wlan_global_connected() -> bool: # 'global' means internet access
def is_eth_global_connected() -> bool:
def is_wps_running() -> bool:
WiFi
# rpi_networking.wifi
country: str = 'GB' # country code for wpa_supplicant
class InterfaceBusyException(Exception):
pass
class Cell:
ssid: str
quality: float
frequency: str
encrypted: bool
class Network:
ssid: str
psk: str
id_str: str
# Functions
def read_networks() -> list[Network]:
def write_networks(networks: list[Network]):
def add_network(ssid: str, psk: str):
def reconnect() -> bool: # connect to the best available network
def scan() -> Generator[Cell, None, None]:
def start_wps() -> bool:
Metadata
Release files for rpi-networking 0.1.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| rpi_networking-0.1.10.tar.gz | 5.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rpi_networking-0.1.10-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.4 kB
Release files / rpi_networking-0.1.10.tar.gz
| Download URL | rpi_networking-0.1.10.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8cc66c862ea25ed4f81a2f7def0faad238d6e534290e63f485a8a7bd009c3c34
|
|
BLAKE2b-256 checksum How to use checksums |
275d4c5cc3935a3921ab9fda13ea7586bbf4d68227cbdec738a5c94e523de877
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / rpi_networking-0.1.10-py3-none-any.whl
| Download URL | rpi_networking-0.1.10-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5945337a39d111e9645f2d54648ec55d38f22591835844c02f3e75ff6110c50e
|
|
BLAKE2b-256 checksum How to use checksums |
546e1142b91bfc8c1261cdcc6e28b777cf3d02e5bcf183b6acc069048679f97e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for rpi-networking 0.1.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.