Upload files to "Shell_Transmitter"
This commit is contained in:
37
Shell_Transmitter/controller_helpers.py
Normal file
37
Shell_Transmitter/controller_helpers.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import wifi
|
||||
import time
|
||||
import controller_config as config
|
||||
|
||||
def rssi_to_percent(rssi):
|
||||
"""Converts RSSI (dBm) to a 0-100% signal strength."""
|
||||
MIN_RSSI = -90; MAX_RSSI = -30
|
||||
if rssi <= MIN_RSSI: return 0
|
||||
if rssi >= MAX_RSSI: return 100
|
||||
percent = ((rssi - MIN_RSSI) * 100) / (MAX_RSSI - MIN_RSSI)
|
||||
return int(percent)
|
||||
|
||||
def setup_wifi_ap(ssid, password, channel):
|
||||
"""
|
||||
Configures the device as a Wi-Fi Access Point (AP).
|
||||
"""
|
||||
print(f"Setting up Wi-Fi AP: {ssid} on channel {channel}")
|
||||
try:
|
||||
wifi.radio.enabled = True
|
||||
wifi.radio.start_ap(ssid=ssid, password=password, channel=channel, max_connections=4)
|
||||
print(f"AP Started. IP: {wifi.radio.ipv4_address_ap}")
|
||||
print(f"Waiting for clients... (SSID is VISIBLE: {ssid})")
|
||||
|
||||
except Exception as ex:
|
||||
print(f"Error starting AP: {ex}")
|
||||
raise
|
||||
|
||||
def print_help_file():
|
||||
"""Reads and prints the help file specified in config."""
|
||||
print("\n--- ⌨️ KBD Bot Command List ---")
|
||||
try:
|
||||
with open(config.HELP_FILE, "r") as f:
|
||||
for line in f:
|
||||
print(line.strip())
|
||||
except OSError:
|
||||
print(f"ERROR: Help file not found: {config.HELP_FILE}")
|
||||
print("---------------------------------")
|
||||
Reference in New Issue
Block a user