Add Hotspot configuration

This commit is contained in:
Thomas Farstrike
2026-03-17 15:17:38 +01:00
parent ff21743fbb
commit 5b50ce8528
10 changed files with 717 additions and 307 deletions
@@ -0,0 +1,23 @@
{
"name": "Hotspot",
"publisher": "MicroPythonOS",
"short_description": "Configure Wi-Fi hotspot settings.",
"long_description": "Configure and toggle the device Wi-Fi hotspot, including SSID, security, and network options.",
"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.hotspot/icons/com.micropythonos.hotspot_0.1.0_64x64.png",
"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.hotspot/mpks/com.micropythonos.hotspot_0.1.0.mpk",
"fullname": "com.micropythonos.hotspot",
"version": "0.1.0",
"category": "networking",
"activities": [
{
"entrypoint": "assets/hotspot.py",
"classname": "Hotspot",
"intent_filters": [
{
"action": "main",
"category": "launcher"
}
]
}
]
}
@@ -0,0 +1,112 @@
import lvgl as lv
from mpos import Activity, Intent, SettingsActivity, SharedPreferences, WifiService
class Hotspot(SettingsActivity):
"""
Hotspot configuration app.
Uses SettingsActivity to render and edit hotspot preferences stored under
com.micropythonos.system.hotspot.
"""
DEFAULTS = {
"enabled": False,
"ssid": "MicroPythonOS",
"password": "",
"channel": 1,
"hidden": False,
"max_clients": 4,
"authmode": None,
"ip": "192.168.4.1",
"netmask": "255.255.255.0",
"gateway": "192.168.4.1",
"dns": "8.8.8.8",
}
def getIntent(self):
prefs = SharedPreferences("com.micropythonos.system.hotspot", defaults=self.DEFAULTS)
intent = Intent()
intent.putExtra("prefs", prefs)
intent.putExtra(
"settings",
[
{
"title": "Hotspot Enabled",
"key": "enabled",
"ui": "radiobuttons",
"ui_options": [("On", "True"), ("Off", "False")],
"changed_callback": self.toggle_hotspot,
},
{
"title": "Network Name (SSID)",
"key": "ssid",
"placeholder": "Hotspot SSID",
},
{
"title": "Password",
"key": "password",
"placeholder": "Leave empty for open network",
},
{
"title": "Channel",
"key": "channel",
"placeholder": "Wi-Fi channel, e.g. 1",
},
{
"title": "Hidden Network",
"key": "hidden",
"ui": "radiobuttons",
"ui_options": [("Visible", "False"), ("Hidden", "True")],
"changed_callback": self.toggle_hotspot,
},
{
"title": "Max Clients",
"key": "max_clients",
"placeholder": "Max connections, e.g. 4",
},
{
"title": "Auth Mode",
"key": "authmode",
"ui": "dropdown",
"ui_options": [
("Auto", None),
("Open", "open"),
("WPA", "wpa"),
("WPA2", "wpa2"),
("WPA/WPA2", "wpa_wpa2"),
],
"changed_callback": self.toggle_hotspot,
},
{
"title": "IP Address",
"key": "ip",
"placeholder": "Hotspot IP, e.g. 192.168.4.1",
},
{
"title": "Netmask",
"key": "netmask",
"placeholder": "Netmask, e.g. 255.255.255.0",
},
{
"title": "Gateway",
"key": "gateway",
"placeholder": "Gateway, e.g. 192.168.4.1",
},
{
"title": "DNS",
"key": "dns",
"placeholder": "DNS, e.g. 8.8.8.8",
},
],
)
return intent
def toggle_hotspot(self, new_value):
enabled_value = self.prefs.get_string("enabled", "False")
should_enable = str(enabled_value).lower() in ("true", "1", "yes", "on")
if should_enable:
WifiService.enable_hotspot()
else:
WifiService.disable_hotspot()
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

@@ -12,6 +12,12 @@ class LaunchWiFi(Activity):
AppManager.start_app("com.micropythonos.wifi")
class LaunchHotspot(Activity):
def onCreate(self):
AppManager.start_app("com.micropythonos.hotspot")
class Settings(SettingsActivity):
"""Override getIntent to provide prefs and settings via Intent extras"""
@@ -46,6 +52,7 @@ class Settings(SettingsActivity):
intent.putExtra("prefs", SharedPreferences("com.micropythonos.settings"))
intent.putExtra("settings", [
{"title": "Wi-Fi", "key": "wifi_settings", "ui": "activity", "activity_class": LaunchWiFi},
{"title": "Hotspot", "key": "hotspot_settings", "ui": "activity", "activity_class": LaunchHotspot},
# Basic settings, alphabetically:
{"title": "Light/Dark Theme", "key": "theme_light_dark", "ui": "radiobuttons", "ui_options": [("Light", "light"), ("Dark", "dark")], "changed_callback": self.theme_changed},
{"title": "Theme Color", "key": "theme_primary_color", "placeholder": "HTML hex color, like: EC048C", "ui": "dropdown", "ui_options": theme_colors, "changed_callback": self.theme_changed, "default_value": AppearanceManager.DEFAULT_PRIMARY_COLOR},