mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
Wi-Fi client improvements and more (#78)
+ Updated docs + Wi-Fi mock improved + Wi-Fi status icon improved
This commit is contained in:
parent
8b6463d060
commit
e3c8747867
11
README.md
11
README.md
@ -7,13 +7,18 @@ It provides an application framework that is based on code from the [Flipper Zer
|
|||||||
|
|
||||||
**Status: Alpha**
|
**Status: Alpha**
|
||||||
|
|
||||||
Tactility features a desktop with a set of applications:
|
A modern desktop with built-in apps:
|
||||||
|
|
||||||
 
|
 
|
||||||
|
|
||||||
 
|
Configure your Wi-Fi without having to hard-code credentials:
|
||||||
|
|
||||||
|
 
|
||||||
|
|
||||||
|
And much more!
|
||||||
|
|
||||||
|
 
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
|||||||
|
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 |
BIN
docs/pics/screenshot-wifi_connect.png
Normal file
BIN
docs/pics/screenshot-wifi_connect.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.4 KiB |
BIN
docs/pics/screenshot-wifi_manage.png
Normal file
BIN
docs/pics/screenshot-wifi_manage.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
@ -642,7 +642,7 @@ _Noreturn int32_t wifi_main(TT_UNUSED void* parameter) {
|
|||||||
|
|
||||||
WifiMessage message;
|
WifiMessage message;
|
||||||
while (true) {
|
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);
|
TT_LOG_I(TAG, "Processing message of type %d", message.type);
|
||||||
switch (message.type) {
|
switch (message.type) {
|
||||||
case WifiMessageTypeRadioOn:
|
case WifiMessageTypeRadioOn:
|
||||||
|
|||||||
@ -34,6 +34,15 @@ static Wifi* wifi_singleton = NULL;
|
|||||||
static void wifi_lock(Wifi* wifi);
|
static void wifi_lock(Wifi* wifi);
|
||||||
static void wifi_unlock(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
|
// region Alloc
|
||||||
|
|
||||||
static Wifi* wifi_alloc() {
|
static Wifi* wifi_alloc() {
|
||||||
@ -41,7 +50,7 @@ static Wifi* wifi_alloc() {
|
|||||||
instance->mutex = tt_mutex_alloc(MutexTypeRecursive);
|
instance->mutex = tt_mutex_alloc(MutexTypeRecursive);
|
||||||
instance->pubsub = tt_pubsub_alloc();
|
instance->pubsub = tt_pubsub_alloc();
|
||||||
instance->scan_active = false;
|
instance->scan_active = false;
|
||||||
instance->radio_state = WIFI_RADIO_OFF;
|
instance->radio_state = WIFI_RADIO_ON;
|
||||||
instance->secure_connection = false;
|
instance->secure_connection = false;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
@ -84,7 +93,6 @@ void wifi_connect(const char* ssid, _Nullable const char* password) {
|
|||||||
|
|
||||||
void wifi_disconnect() {
|
void wifi_disconnect() {
|
||||||
tt_assert(wifi_singleton);
|
tt_assert(wifi_singleton);
|
||||||
// TODO: implement
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wifi_set_scan_records(uint16_t records) {
|
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(wifi_singleton);
|
||||||
tt_check(result_count);
|
tt_check(result_count);
|
||||||
|
|
||||||
// TODO: implement
|
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;
|
*result_count = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wifi_set_enabled(bool enabled) {
|
void wifi_set_enabled(bool enabled) {
|
||||||
tt_assert(wifi_singleton != NULL);
|
tt_assert(wifi_singleton != NULL);
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
wifi_singleton->radio_state = WIFI_RADIO_CONNECTION_ACTIVE;
|
wifi_singleton->radio_state = WIFI_RADIO_ON;
|
||||||
wifi_singleton->secure_connection = true;
|
wifi_singleton->secure_connection = true;
|
||||||
} else {
|
} else {
|
||||||
wifi_singleton->radio_state = WIFI_RADIO_OFF;
|
wifi_singleton->radio_state = WIFI_RADIO_OFF;
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
#include "services/gui/gui.h"
|
#include "services/gui/gui.h"
|
||||||
#include "services/wifi/wifi_settings.h"
|
#include "services/wifi/wifi_settings.h"
|
||||||
#include "ui/spacer.h"
|
|
||||||
#include "ui/style.h"
|
#include "ui/style.h"
|
||||||
#include "ui/toolbar.h"
|
#include "ui/toolbar.h"
|
||||||
#include "wifi_connect.h"
|
#include "wifi_connect.h"
|
||||||
@ -38,7 +37,6 @@ static void on_connect(lv_event_t* event) {
|
|||||||
strcpy((char*)settings.ssid, ssid);
|
strcpy((char*)settings.ssid, ssid);
|
||||||
settings.auto_connect = TT_WIFI_AUTO_CONNECT; // No UI yet, so use global setting:w
|
settings.auto_connect = TT_WIFI_AUTO_CONNECT; // No UI yet, so use global setting:w
|
||||||
|
|
||||||
|
|
||||||
WifiConnectBindings* bindings = &wifi->bindings;
|
WifiConnectBindings* bindings = &wifi->bindings;
|
||||||
bindings->on_connect_ssid(
|
bindings->on_connect_ssid(
|
||||||
settings.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_grow(wrapper, 1);
|
||||||
lv_obj_set_flex_flow(wrapper, LV_FLEX_FLOW_COLUMN);
|
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:");
|
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_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:");
|
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_one_line(view->password_textarea, true);
|
||||||
lv_textarea_set_password_mode(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);
|
wifi_connect_view_create_bottom_buttons(wifi, wrapper);
|
||||||
|
|
||||||
|
// Keyboard bindings
|
||||||
gui_keyboard_add_textarea(view->ssid_textarea);
|
gui_keyboard_add_textarea(view->ssid_textarea);
|
||||||
gui_keyboard_add_textarea(view->password_textarea);
|
gui_keyboard_add_textarea(view->password_textarea);
|
||||||
|
|
||||||
// Init from app parameters
|
// Init from app parameters
|
||||||
Bundle _Nullable bundle = tt_app_get_parameters(app);
|
_Nullable Bundle bundle = tt_app_get_parameters(app);
|
||||||
if (bundle) {
|
if (bundle) {
|
||||||
char* ssid;
|
char* ssid;
|
||||||
if (tt_bundle_opt_string(bundle, WIFI_CONNECT_PARAM_SSID, &ssid)) {
|
if (tt_bundle_opt_string(bundle, WIFI_CONNECT_PARAM_SSID, &ssid)) {
|
||||||
|
|||||||
@ -26,14 +26,16 @@ typedef struct {
|
|||||||
const char* wifi_get_status_icon_for_rssi(int rssi, bool secured) {
|
const char* wifi_get_status_icon_for_rssi(int rssi, bool secured) {
|
||||||
if (rssi > 0) {
|
if (rssi > 0) {
|
||||||
return TT_ASSETS_ICON_WIFI_CONNECTION_ISSUE;
|
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;
|
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;
|
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;
|
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;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user