Wi-Fi client improvements and more (#78)

+ Updated docs
+ Wi-Fi mock improved
+ Wi-Fi status icon improved
This commit is contained in:
Ken Van Hoeylandt 2024-11-12 23:59:39 +01:00 committed by GitHub
parent 8b6463d060
commit e3c8747867
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 90 additions and 23 deletions

View File

@ -7,13 +7,18 @@ It provides an application framework that is based on code from the [Flipper Zer
**Status: Alpha**
Tactility features a desktop with a set of applications:
A modern desktop with built-in apps:
![screenshot of desktop app](docs/pics/screenshot-desktop.png) ![screenshot of settings app](docs/pics/screenshot-settings.png)
![screenshot of system info app](docs/pics/screenshot-systeminfo.png) ![screenshot of files app](docs/pics/screenshot-files.png)
Configure your Wi-Fi without having to hard-code credentials:
![screenshot of wifi management app](docs/pics/screenshot-wifi_manage.png) ![screenshot of wifi app to connect to wifi](docs/pics/screenshot-wifi_connect.png)
And much more!
![screenshot of GPIO app](docs/pics/screenshot-gpio.png) ![screenshot of files app](docs/pics/screenshot-files.png)
![screenshot of GPIO app](docs/pics/screenshot-gpio.png)
Play with the built-in apps or build your own! Use one of the supported devices or set up the drivers for your own hardware platform.

View File

Before

Width:  |  Height:  |  Size: 451 B

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -642,7 +642,7 @@ _Noreturn int32_t wifi_main(TT_UNUSED void* parameter) {
WifiMessage message;
while (true) {
if (tt_message_queue_get(queue, &message, 5000 / portTICK_PERIOD_MS) == TtStatusOk) {
if (tt_message_queue_get(queue, &message, 10000 / portTICK_PERIOD_MS) == TtStatusOk) {
TT_LOG_I(TAG, "Processing message of type %d", message.type);
switch (message.type) {
case WifiMessageTypeRadioOn:

View File

@ -34,6 +34,15 @@ static Wifi* wifi_singleton = NULL;
static void wifi_lock(Wifi* wifi);
static void wifi_unlock(Wifi* wifi);
// region Static
static void wifi_publish_event_simple(Wifi* wifi, WifiEventType type) {
WifiEvent turning_on_event = {.type = type};
tt_pubsub_publish(wifi->pubsub, &turning_on_event);
}
// endregion Static
// region Alloc
static Wifi* wifi_alloc() {
@ -41,7 +50,7 @@ static Wifi* wifi_alloc() {
instance->mutex = tt_mutex_alloc(MutexTypeRecursive);
instance->pubsub = tt_pubsub_alloc();
instance->scan_active = false;
instance->radio_state = WIFI_RADIO_OFF;
instance->radio_state = WIFI_RADIO_ON;
instance->secure_connection = false;
return instance;
}
@ -84,7 +93,6 @@ void wifi_connect(const char* ssid, _Nullable const char* password) {
void wifi_disconnect() {
tt_assert(wifi_singleton);
// TODO: implement
}
void wifi_set_scan_records(uint16_t records) {
@ -96,14 +104,32 @@ void wifi_get_scan_results(WifiApRecord records[], uint16_t limit, uint16_t* res
tt_check(wifi_singleton);
tt_check(result_count);
// TODO: implement
*result_count = 0;
if (limit >= 5) {
strcpy((char*)records[0].ssid, "Home WiFi");
records[0].auth_mode = WIFI_AUTH_WPA2_PSK;
records[0].rssi = -30;
strcpy((char*)records[1].ssid, "Living Room");
records[1].auth_mode = WIFI_AUTH_WPA2_PSK;
records[1].rssi = -67;
strcpy((char*)records[2].ssid, "No place like 127.0.0.1");
records[2].auth_mode = WIFI_AUTH_WPA2_PSK;
records[2].rssi = -70;
strcpy((char*)records[3].ssid, "Public Wi-Fi");
records[3].auth_mode = WIFI_AUTH_WPA2_PSK;
records[3].rssi = -80;
strcpy((char*)records[4].ssid, "Bad Reception");
records[4].auth_mode = WIFI_AUTH_WPA2_PSK;
records[4].rssi = -90;
*result_count = 5;
} else {
*result_count = 0;
}
}
void wifi_set_enabled(bool enabled) {
tt_assert(wifi_singleton != NULL);
if (enabled) {
wifi_singleton->radio_state = WIFI_RADIO_CONNECTION_ACTIVE;
wifi_singleton->radio_state = WIFI_RADIO_ON;
wifi_singleton->secure_connection = true;
} else {
wifi_singleton->radio_state = WIFI_RADIO_OFF;

View File

@ -4,7 +4,6 @@
#include "lvgl.h"
#include "services/gui/gui.h"
#include "services/wifi/wifi_settings.h"
#include "ui/spacer.h"
#include "ui/style.h"
#include "ui/toolbar.h"
#include "wifi_connect.h"
@ -38,7 +37,6 @@ static void on_connect(lv_event_t* event) {
strcpy((char*)settings.ssid, ssid);
settings.auto_connect = TT_WIFI_AUTO_CONNECT; // No UI yet, so use global setting:w
WifiConnectBindings* bindings = &wifi->bindings;
bindings->on_connect_ssid(
settings.ssid,
@ -91,28 +89,64 @@ void wifi_connect_view_create(App app, void* wifi, lv_obj_t* parent) {
lv_obj_set_flex_grow(wrapper, 1);
lv_obj_set_flex_flow(wrapper, LV_FLEX_FLOW_COLUMN);
lv_obj_t* ssid_label = lv_label_create(wrapper);
// SSID
lv_obj_t* ssid_wrapper = lv_obj_create(wrapper);
lv_obj_set_width(ssid_wrapper, LV_PCT(100));
lv_obj_set_height(ssid_wrapper, LV_SIZE_CONTENT);
tt_lv_obj_set_style_no_padding(ssid_wrapper);
lv_obj_set_style_border_width(ssid_wrapper, 0, 0);
lv_obj_t* ssid_label_wrapper = lv_obj_create(ssid_wrapper);
lv_obj_set_width(ssid_label_wrapper, LV_PCT(50));
lv_obj_set_height(ssid_label_wrapper, LV_SIZE_CONTENT);
lv_obj_align(ssid_label_wrapper, LV_ALIGN_LEFT_MID, 0, 0);
lv_obj_set_style_border_width(ssid_label_wrapper, 0, 0);
lv_obj_set_style_pad_left(ssid_label_wrapper, 0, 0);
lv_obj_set_style_pad_right(ssid_label_wrapper, 0, 0);
lv_obj_t* ssid_label = lv_label_create(ssid_label_wrapper);
lv_label_set_text(ssid_label, "Network:");
view->ssid_textarea = lv_textarea_create(wrapper);
view->ssid_textarea = lv_textarea_create(ssid_wrapper);
lv_textarea_set_one_line(view->ssid_textarea, true);
lv_obj_align(view->ssid_textarea, LV_ALIGN_RIGHT_MID, 0, 0);
lv_obj_set_width(view->ssid_textarea, LV_PCT(50));
tt_lv_spacer_create(wrapper, 1, 8);
// Password
lv_obj_t* password_label = lv_label_create(wrapper);
lv_obj_t* password_wrapper = lv_obj_create(wrapper);
lv_obj_set_width(password_wrapper, LV_PCT(100));
lv_obj_set_height(password_wrapper, LV_SIZE_CONTENT);
tt_lv_obj_set_style_no_padding(password_wrapper);
lv_obj_set_style_border_width(password_wrapper, 0, 0);
lv_obj_t* password_label_wrapper = lv_obj_create(password_wrapper);
lv_obj_set_width(password_label_wrapper, LV_PCT(50));
lv_obj_set_height(password_label_wrapper, LV_SIZE_CONTENT);
lv_obj_align_to(password_label_wrapper, password_wrapper, LV_ALIGN_LEFT_MID, 0, 0);
lv_obj_set_style_border_width(password_label_wrapper, 0, 0);
lv_obj_set_style_pad_left(password_label_wrapper, 0, 0);
lv_obj_set_style_pad_right(password_label_wrapper, 0, 0);
lv_obj_t* password_label = lv_label_create(password_label_wrapper);
lv_label_set_text(password_label, "Password:");
view->password_textarea = lv_textarea_create(wrapper);
view->password_textarea = lv_textarea_create(password_wrapper);
lv_textarea_set_one_line(view->password_textarea, true);
lv_textarea_set_password_mode(view->password_textarea, true);
lv_obj_align(view->password_textarea, LV_ALIGN_RIGHT_MID, 0, 0);
lv_obj_set_width(view->password_textarea, LV_PCT(50));
tt_lv_spacer_create(wrapper, 1, 8);
// Bottom buttons
wifi_connect_view_create_bottom_buttons(wifi, wrapper);
// Keyboard bindings
gui_keyboard_add_textarea(view->ssid_textarea);
gui_keyboard_add_textarea(view->password_textarea);
// Init from app parameters
Bundle _Nullable bundle = tt_app_get_parameters(app);
_Nullable Bundle bundle = tt_app_get_parameters(app);
if (bundle) {
char* ssid;
if (tt_bundle_opt_string(bundle, WIFI_CONNECT_PARAM_SSID, &ssid)) {

View File

@ -26,14 +26,16 @@ typedef struct {
const char* wifi_get_status_icon_for_rssi(int rssi, bool secured) {
if (rssi > 0) {
return TT_ASSETS_ICON_WIFI_CONNECTION_ISSUE;
} else if (rssi > -67) {
} else if (rssi >= -30) {
return secured ? TT_ASSETS_ICON_WIFI_SIGNAL_4_LOCKED : TT_ASSETS_ICON_WIFI_SIGNAL_4;
} else if (rssi > -70) {
} else if (rssi >= -67) {
return secured ? TT_ASSETS_ICON_WIFI_SIGNAL_3_LOCKED : TT_ASSETS_ICON_WIFI_SIGNAL_3;
} else if (rssi > -80) {
} else if (rssi >= -70) {
return secured ? TT_ASSETS_ICON_WIFI_SIGNAL_2_LOCKED : TT_ASSETS_ICON_WIFI_SIGNAL_2;
} else {
} else if (rssi >= -80) {
return secured ? TT_ASSETS_ICON_WIFI_SIGNAL_1_LOCKED : TT_ASSETS_ICON_WIFI_SIGNAL_1;
} else {
return secured ? TT_ASSETS_ICON_WIFI_SIGNAL_0_LOCKED : TT_ASSETS_ICON_WIFI_SIGNAL_0;
}
}