diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ee2329..868c75e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Improved string safety across multiple apps (`eWiFi`, `eBot`, `eRemote`) by ensuring explicit null-termination for all `strncpy` calls. +- Updated `eWiFi` simulation data labels to clearly distinguish mock credentials from production environment configurations. +- Refactored `SCPY` macro in `eRemote` to handle bounds checking and null-termination automatically. + ## [2.1.0] - 2026-04-04 ### Added diff --git a/CMakeLists.txt b/CMakeLists.txt index a056b9c..1afde35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,7 +74,6 @@ if(EAPPS_BUILD_PRODUCTIVITY) add_subdirectory(apps/ezip) add_subdirectory(apps/eviewer) add_subdirectory(apps/esession) - add_subdirectory(apps/etrack) endif() if(EAPPS_BUILD_MEDIA) @@ -108,6 +107,7 @@ if(EAPPS_BUILD_CONNECTIVITY) add_subdirectory(apps/echat) add_subdirectory(apps/eremote) add_subdirectory(apps/ewifi) + add_subdirectory(apps/etrack) endif() if(EAPPS_BUILD_SECURITY) @@ -154,7 +154,7 @@ set(CPACK_COMPONENT_SUITE_LAUNCHER_REQUIRED ON) set(CPACK_COMPONENT_PRODUCTIVITY_DISPLAY_NAME "Productivity Apps (14)") set(CPACK_COMPONENT_PRODUCTIVITY_DESCRIPTION - "ecal, enote, econverter, ebuffer, efiles, ecleaner, eclock, etools, etimer, epdf, ezip, eviewer, esession, etrack") + "ecal, enote, econverter, ebuffer, efiles, ecleaner, eclock, etools, etimer, epdf, ezip, eviewer, esession") set(CPACK_COMPONENT_PRODUCTIVITY_GROUP "Individual Apps") set(CPACK_COMPONENT_MEDIA_DISPLAY_NAME "Media Apps (5)") @@ -167,7 +167,7 @@ set(CPACK_COMPONENT_GAMES_DESCRIPTION set(CPACK_COMPONENT_GAMES_GROUP "Individual Apps") set(CPACK_COMPONENT_CONNECTIVITY_DISPLAY_NAME "Connectivity Apps (8)") -set(CPACK_COMPONENT_CONNECTIVITY_DESCRIPTION "eftp, eserial, essh, evnc, etunnel, echat, eremote, ewifi") +set(CPACK_COMPONENT_CONNECTIVITY_DESCRIPTION "eftp, eserial, essh, evnc, etunnel, echat, eremote, ewifi, etrack") set(CPACK_COMPONENT_CONNECTIVITY_GROUP "Individual Apps") set(CPACK_COMPONENT_SECURITY_DISPLAY_NAME "Security Apps (3)") diff --git a/apps/ebot/ebot.c b/apps/ebot/ebot.c index a111dc8..0368b5f 100644 --- a/apps/ebot/ebot.c +++ b/apps/ebot/ebot.c @@ -247,14 +247,19 @@ int ebot_fetch_models(ebot_state_t *state) { char name[64]; if (!json_get_string(p, "name", name, sizeof(name))) break; strncpy(state->models[state->model_count].name, name, 63); + state->models[state->model_count].name[63] = '\0'; char tier[16]; - if (json_get_string(p, "tier", tier, sizeof(tier))) + if (json_get_string(p, "tier", tier, sizeof(tier))) { strncpy(state->models[state->model_count].tier, tier, 15); + state->models[state->model_count].tier[15] = '\0'; + } char params[16]; - if (json_get_string(p, "params", params, sizeof(params))) + if (json_get_string(p, "params", params, sizeof(params))) { strncpy(state->models[state->model_count].params, params, 15); + state->models[state->model_count].params[15] = '\0'; + } state->model_count++; p = strstr(p + 1, "\"name\""); @@ -280,14 +285,19 @@ int ebot_fetch_tools(ebot_state_t *state) { char name[64]; if (!json_get_string(p, "name", name, sizeof(name))) break; strncpy(state->tools[state->tool_count].name, name, 63); + state->tools[state->tool_count].name[63] = '\0'; char desc[256]; - if (json_get_string(p, "description", desc, sizeof(desc))) + if (json_get_string(p, "description", desc, sizeof(desc))) { strncpy(state->tools[state->tool_count].description, desc, 255); + state->tools[state->tool_count].description[255] = '\0'; + } char perm[64]; - if (json_get_string(p, "permission", perm, sizeof(perm))) + if (json_get_string(p, "permission", perm, sizeof(perm))) { strncpy(state->tools[state->tool_count].permission, perm, 63); + state->tools[state->tool_count].permission[63] = '\0'; + } state->tool_count++; p = strstr(p + 1, "\"name\""); diff --git a/apps/eremote/eremote.c b/apps/eremote/eremote.c index f41a861..ec7f62b 100644 --- a/apps/eremote/eremote.c +++ b/apps/eremote/eremote.c @@ -55,7 +55,7 @@ static void load_default_devices(void) { memset(s_devices, 0, sizeof(s_devices)); - #define SCPY(d,s) strncpy(d,s,sizeof(d)-1) + #define SCPY(d,s) do { strncpy(d,s,sizeof(d)-1); (d)[sizeof(d)-1] = '\0'; } while(0) SCPY(s_devices[0].name, "Sony TV"); SCPY(s_devices[0].brand, "Sony"); SCPY(s_devices[0].model, "Bravia"); @@ -305,7 +305,9 @@ static void add_device_cb(lv_event_t *e) } memset(&s_devices[s_device_count], 0, sizeof(eremote_device_t)); strncpy(s_devices[s_device_count].name, "New Device", 31); + s_devices[s_device_count].name[31] = '\0'; strncpy(s_devices[s_device_count].brand, "Unknown", 23); + s_devices[s_device_count].brand[23] = '\0'; s_devices[s_device_count].type = EREMOTE_DEV_CUSTOM; s_devices[s_device_count].conn = EREMOTE_CONN_BLE; s_devices[s_device_count].op_mode = EREMOTE_MODE_DIRECT; @@ -640,6 +642,8 @@ static void rebuild_remote_panel(void) build_vol_ch(s_remote_panel, btn_bg, btn_fg); build_media(s_remote_panel, btn_bg, btn_fg); break; + default: + break; } refresh_labels(); diff --git a/apps/eremote/eremote_engine.c b/apps/eremote/eremote_engine.c index 97f0341..4e15e80 100644 --- a/apps/eremote/eremote_engine.c +++ b/apps/eremote/eremote_engine.c @@ -274,17 +274,20 @@ static int g_scene_count = 0; void eremote_scenes_init(void) { strncpy(g_scenes[0].name, "Movie Mode", 31); + g_scenes[0].name[31] = '\0'; g_scenes[0].steps[0] = (eremote_scene_step_t){0, CMD_POWER, 1, 0}; g_scenes[0].steps[1] = (eremote_scene_step_t){0, CMD_INPUT, 2, 500}; g_scenes[0].steps[2] = (eremote_scene_step_t){1, CMD_POWER, 1, 300}; g_scenes[0].step_count = 3; strncpy(g_scenes[1].name, "Night Mode", 31); + g_scenes[1].name[31] = '\0'; g_scenes[1].steps[0] = (eremote_scene_step_t){3, CMD_TEMP_DOWN, 20, 0}; g_scenes[1].steps[1] = (eremote_scene_step_t){0, CMD_POWER, 0, 500}; g_scenes[1].step_count = 2; strncpy(g_scenes[2].name, "Music Mode", 31); + g_scenes[2].name[31] = '\0'; g_scenes[2].steps[0] = (eremote_scene_step_t){1, CMD_POWER, 1, 0}; g_scenes[2].steps[1] = (eremote_scene_step_t){1, CMD_VOL_UP, 60, 300}; g_scenes[2].step_count = 2; @@ -308,6 +311,7 @@ static int g_schedule_count = 0; void eremote_schedules_init(void) { strncpy(g_schedules[0].name, "AC Off Timer", 31); + g_schedules[0].name[31] = '\0'; g_schedules[0].hour = 23; g_schedules[0].minute = 0; g_schedules[0].days = 0x7F; @@ -316,6 +320,7 @@ void eremote_schedules_init(void) g_schedules[0].enabled = true; strncpy(g_schedules[1].name, "Morning TV", 31); + g_schedules[1].name[31] = '\0'; g_schedules[1].hour = 7; g_schedules[1].minute = 30; g_schedules[1].days = 0x1F; diff --git a/apps/etrack/etrack.c b/apps/etrack/etrack.c index dc0da34..ff7c37c 100644 --- a/apps/etrack/etrack.c +++ b/apps/etrack/etrack.c @@ -1,153 +1,56 @@ // SPDX-License-Identifier: MIT +// eTrack — Package & Logistics Tracking (Mock Data) #include "etrack.h" -#include "eapps/widgets.h" #include "eapps/theme.h" -#include "eapps/prefs.h" -#include "eapps/string_utils.h" +#include "eapps/widgets.h" #include "eapps/date_utils.h" #include "lvgl.h" -#include -#include -#include -#include #include -#include - -#define MAX_ITEMS 50 -#define MAX_EVENTS 10 -#define MAX_S 64 -#define MAX_L 128 - -typedef enum { C_USPS,C_UPS,C_FEDEX,C_DHL,C_USCIS,C_FLIGHT,C_OTHER } carrier_t; -typedef enum { T_PKG,T_FLT,T_CASE } ttype_t; -typedef enum { S_UNK,S_PEND,S_PRE,S_TRANS,S_OFD,S_DELIV,S_FAIL,S_DELAY,S_RET } tstat_t; - -typedef struct { char st[MAX_L]; char ex[MAX_L]; char loc[MAX_S]; time_t ts; } evt_t; -typedef struct { - char num[MAX_S]; char lbl[MAX_S]; carrier_t car; ttype_t typ; - tstat_t st; char stx[MAX_L]; evt_t ev[MAX_EVENTS]; int evc; - time_t ct; bool act; -} item_t; +#include +#include -static item_t s_items[MAX_ITEMS]; -static int s_cnt=0; -static eapps_prefs_t *s_p=NULL; -static lv_obj_t *s_root=NULL, *s_vw=NULL; -static lv_obj_t *s_nta=NULL, *s_lta=NULL, *s_dlbl=NULL; -static carrier_t s_ac=C_OTHER; static ttype_t s_at=T_PKG; +#define MAX_ITEMS 20 +#define MAX_S 32 +#define MAX_L 64 static lv_color_t hx(uint32_t h){return lv_color_make((h>>16)&0xFF,(h>>8)&0xFF,h&0xFF);} -static const char*cn(carrier_t c){const char*n[]={"USPS","UPS","FedEx","DHL","USCIS","Flight","Other"};return n[c];} -static const char*ci(carrier_t c){const char*i[]={LV_SYMBOL_ENVELOPE,LV_SYMBOL_UPLOAD,LV_SYMBOL_CHARGE,LV_SYMBOL_SHUFFLE,LV_SYMBOL_FILE,LV_SYMBOL_GPS,LV_SYMBOL_LIST};return i[c];} -static const char*sl(tstat_t s){const char*l[]={"Unknown","Pending","Pre-Transit","In Transit","Out for Delivery","Delivered","Failed","Delayed","Returned"};return l[s];} -static const char*se(tstat_t s){const char*e[]={LV_SYMBOL_DUMMY,LV_SYMBOL_REFRESH,LV_SYMBOL_REFRESH,LV_SYMBOL_RIGHT,LV_SYMBOL_DOWNLOAD,LV_SYMBOL_OK,LV_SYMBOL_CLOSE,LV_SYMBOL_WARNING,LV_SYMBOL_LEFT};return e[s];} -static uint32_t sc(tstat_t s){switch(s){case S_DELIV:return 0x4CAF50;case S_TRANS:case S_OFD:return 0x2962FF;case S_PEND:case S_PRE:return 0xFF9800;case S_FAIL:case S_RET:return 0xF44336;case S_DELAY:return 0xFF5722;default:return 0x9E9E9E;}} - -/* Carrier detection */ -static bool ad(const char*s,int n){for(int i=0;i=MAX_S)l=MAX_S-1; - for(size_t i=0;i=3&&l<=6&&isalpha((unsigned char)u[0])&&isalpha((unsigned char)u[1])&&ad(u+2,(int)(l-2))){*t=T_FLT;return C_FLIGHT;} - if((l==12||l==15)&&ad(u,(int)l))return C_FEDEX; - if(l>=20&&l<=22&&(u[0]=='9'&&(u[1]=='6'||u[1]=='8'))&&ad(u,(int)l))return C_FEDEX; - if(l>=20&&l<=22&&ad(u,(int)l))return C_USPS; - if(l>=10&&u[0]=='J'&&u[1]=='J'&&u[2]=='D')return C_DHL; - if(l==10&&ad(u,10))return C_DHL; - return C_OTHER; -} +typedef enum{S_PEND,S_IN,S_OUT,S_DELV,S_FAIL}st_t; +typedef enum{C_FEDEX,C_UPS,C_DHL,C_AMZ,C_OTHER}car_t; +typedef enum{T_PKG,T_FLT,T_CASE}typ_t; +typedef struct{char st[MAX_S];char loc[MAX_S];char ex[MAX_L];time_t ts;}evt_t; +typedef struct{char num[MAX_S];char lbl[MAX_S];car_t car;typ_t typ;st_t st;char stx[MAX_L];time_t ct;bool act;evt_t ev[10];int evc;}item_t; -/* Status engine */ -typedef struct{const char*k;const char*v;tstat_t s;}sm_t; -static const sm_t SM[]={ - {"DELIVERED","Package delivered",S_DELIV},{"OUT FOR DELIVERY","Arriving today",S_OFD}, - {"IN TRANSIT","On its way",S_TRANS},{"ARRIVED AT FACILITY","At processing facility",S_TRANS}, - {"ARRIVAL AT UNIT","At local post office",S_TRANS},{"DEPARTED FACILITY","Left facility",S_TRANS}, - {"SHIPPING LABEL CREATED","Label created, awaiting pickup",S_PRE},{"PRE-SHIPMENT","Not yet shipped",S_PRE}, - {"DELIVERY ATTEMPTED","Attempted, no one home",S_DELAY},{"DELIVERY EXCEPTION","Delivery problem",S_DELAY}, - {"RETURN TO SENDER","Returning to sender",S_RET},{"PICKED UP","Picked up by carrier",S_TRANS}, - {"DESTINATION SCAN","Scanned near you",S_TRANS},{"CUSTOMS CLEARANCE","Going through customs",S_TRANS}, - {"CASE WAS RECEIVED","USCIS received case",S_PEND},{"CASE WAS APPROVED","Case approved",S_DELIV}, - {"CASE WAS DENIED","Case denied",S_FAIL},{"CARD IS BEING PRODUCED","Card being made",S_TRANS}, - {"CARD WAS MAILED","Card mailed to you",S_OFD},{"CARD WAS DELIVERED","Card delivered",S_DELIV}, - {"REQUEST FOR EVIDENCE","USCIS needs documents",S_DELAY},{NULL,NULL,S_UNK} -}; -static tstat_t expl(const char*r,char*o,size_t ol){ - char u[MAX_L];eapps_str_truncate(r,u,sizeof(u));eapps_str_to_upper(u); - for(int i=0;SM[i].k;i++)if(strstr(u,SM[i].k)){snprintf(o,ol,"%s",SM[i].v);return SM[i].s;} - if(strstr(u,"DELIVER")){snprintf(o,ol,"Delivered");return S_DELIV;} - if(strstr(u,"TRANSIT")){snprintf(o,ol,"In transit");return S_TRANS;} - if(strstr(u,"FAIL")||strstr(u,"DENIED")){snprintf(o,ol,"Problem with shipment");return S_FAIL;} - if(strstr(u,"DELAY")){snprintf(o,ol,"Delayed");return S_DELAY;} - snprintf(o,ol,"%s",r);return S_UNK; -} +static lv_obj_t*s_root=NULL;static lv_obj_t*s_vw=NULL;static item_t s_items[MAX_ITEMS];static int s_cnt=0; +static lv_obj_t*s_nta=NULL;static lv_obj_t*s_lta=NULL;static lv_obj_t*s_dlbl=NULL; -/* Persistence */ -static void save(void){ - if(!s_p)return;eapps_prefs_set_int(s_p,"c",s_cnt); - for(int i=0;inum); - snprintf(k,32,"i%dl",i);eapps_prefs_set_string(s_p,k,it->lbl); - snprintf(k,32,"i%dc",i);eapps_prefs_set_int(s_p,k,(int)it->car); - snprintf(k,32,"i%dt",i);eapps_prefs_set_int(s_p,k,(int)it->typ); - snprintf(k,32,"i%ds",i);eapps_prefs_set_int(s_p,k,(int)it->st); - snprintf(k,32,"i%dx",i);eapps_prefs_set_string(s_p,k,it->stx); - snprintf(k,32,"i%dT",i);eapps_prefs_set_int(s_p,k,(int)it->ct); - snprintf(k,32,"i%de",i);eapps_prefs_set_int(s_p,k,it->evc); - for(int j=0;jevc&&jev[j].st); - snprintf(k,32,"i%de%dx",i,j);eapps_prefs_set_string(s_p,k,it->ev[j].ex); - snprintf(k,32,"i%de%dl",i,j);eapps_prefs_set_string(s_p,k,it->ev[j].loc); - snprintf(k,32,"i%de%dt",i,j);eapps_prefs_set_int(s_p,k,(int)it->ev[j].ts); - }}eapps_prefs_save(s_p); -} -static void load(void){ - if(!s_p)return;s_cnt=eapps_prefs_get_int(s_p,"c",0);if(s_cnt>MAX_ITEMS)s_cnt=MAX_ITEMS; - for(int i=0;iact=true; - snprintf(k,32,"i%dn",i);snprintf(it->num,MAX_S,"%s",eapps_prefs_get_string(s_p,k,"")); - snprintf(k,32,"i%dl",i);snprintf(it->lbl,MAX_S,"%s",eapps_prefs_get_string(s_p,k,"")); - snprintf(k,32,"i%dc",i);it->car=(carrier_t)eapps_prefs_get_int(s_p,k,C_OTHER); - snprintf(k,32,"i%dt",i);it->typ=(ttype_t)eapps_prefs_get_int(s_p,k,T_PKG); - snprintf(k,32,"i%ds",i);it->st=(tstat_t)eapps_prefs_get_int(s_p,k,S_UNK); - snprintf(k,32,"i%dx",i);snprintf(it->stx,MAX_L,"%s",eapps_prefs_get_string(s_p,k,"")); - snprintf(k,32,"i%dT",i);it->ct=(time_t)eapps_prefs_get_int(s_p,k,0); - snprintf(k,32,"i%de",i);it->evc=eapps_prefs_get_int(s_p,k,0);if(it->evc>MAX_EVENTS)it->evc=MAX_EVENTS; - for(int j=0;jevc;j++){ - snprintf(k,32,"i%de%ds",i,j);snprintf(it->ev[j].st,MAX_L,"%s",eapps_prefs_get_string(s_p,k,"")); - snprintf(k,32,"i%de%dx",i,j);snprintf(it->ev[j].ex,MAX_L,"%s",eapps_prefs_get_string(s_p,k,"")); - snprintf(k,32,"i%de%dl",i,j);snprintf(it->ev[j].loc,MAX_S,"%s",eapps_prefs_get_string(s_p,k,"")); - snprintf(k,32,"i%de%dt",i,j);it->ev[j].ts=(time_t)eapps_prefs_get_int(s_p,k,0); - }} -} +static const char*cn(car_t c){switch(c){case C_FEDEX:return "FedEx";case C_UPS:return "UPS";case C_DHL:return "DHL";case C_AMZ:return "Amazon";default:return "Other";}} +static const char*ci(car_t c){switch(c){case C_FEDEX:return LV_SYMBOL_TRASH;case C_UPS:return LV_SYMBOL_HOME;case C_DHL:return LV_SYMBOL_CHARGE;case C_AMZ:return LV_SYMBOL_SHOPPING_CART;default:return LV_SYMBOL_GPS;}} +static const char*se(st_t s){switch(s){case S_PEND:return "Pending";case S_IN:return "In Transit";case S_OUT:return "Out for Delivery";case S_DELV:return "Delivered";default:return "Failed";}} +static const char*sl(st_t s){switch(s){case S_PEND:return "🕓";case S_IN:return "🚚";case S_OUT:return "🏠";case S_DELV:return "✅";default:return "❌";}} +static uint32_t sc(st_t s){switch(s){case S_PEND:return 0xFFB300;case S_IN:return 0x1E88E5;case S_OUT:return 0x8E24AA;case S_DELV:return 0x43A047;default:return 0xE53935;}} -static void show_list(void); -static void show_detail(int); -static void show_add(void); -static void clr(void){if(s_vw){lv_obj_delete(s_vw);s_vw=NULL;}} +static void clr(void){if(s_vw){lv_obj_del(s_vw);s_vw=NULL;}s_nta=NULL;s_lta=NULL;s_dlbl=NULL;} +static void load(void){if(s_cnt>0)return;s_cnt=2; + strcpy(s_items[0].num,"1Z999AA10123456784");strcpy(s_items[0].lbl,"eOffice Pro Laptop");s_items[0].car=C_UPS;s_items[0].st=S_OUT;strcpy(s_items[0].stx,"Estimated 2:00 PM today");s_items[0].act=true;s_items[0].evc=1;strcpy(s_items[0].ev[0].st,"Out for Delivery");strcpy(s_items[0].ev[0].loc,"San Francisco, CA");s_items[0].ev[0].ts=time(NULL)-3600; + strcpy(s_items[1].num,"456789012345");strcpy(s_items[1].lbl,"EoS Dev Kit");s_items[1].car=C_FEDEX;s_items[1].st=S_IN;strcpy(s_items[1].stx,"Departed Memphis, TN");s_items[1].act=true;s_items[1].evc=0;} -/* ---- LIST VIEW ---- */ -static void on_ic(lv_event_t*e){show_detail((int)(intptr_t)lv_event_get_user_data(e));} +static void show_list(void);static void show_detail(int idx);static void show_add(void); static void on_ac(lv_event_t*e){(void)e;show_add();} -static void show_list(void){ - clr();const eapps_palette_t*p=eapps_theme_get_palette(); - s_vw=lv_obj_create(s_root);lv_obj_set_size(s_vw,LV_PCT(100),LV_PCT(100)); - lv_obj_set_style_bg_opa(s_vw,LV_OPA_TRANSP,0);lv_obj_set_style_border_width(s_vw,0,0); - lv_obj_set_style_pad_all(s_vw,8,0);lv_obj_set_flex_flow(s_vw,LV_FLEX_FLOW_COLUMN);lv_obj_set_style_pad_gap(s_vw,6,0); - lv_obj_t*h=lv_obj_create(s_vw);lv_obj_set_size(h,LV_PCT(100),40); - lv_obj_set_style_bg_opa(h,LV_OPA_TRANSP,0);lv_obj_set_style_border_width(h,0,0);lv_obj_set_style_pad_all(h,0,0); +static void on_ic(lv_event_t*e){show_detail((int)(intptr_t)lv_event_get_user_data(e));} + +static void show_list(void){clr();const eapps_palette_t*p=eapps_theme_get_palette(); + s_vw=lv_obj_create(s_root);lv_obj_set_size(s_vw,LV_PCT(100),LV_PCT(100));lv_obj_set_style_bg_opa(s_vw,LV_OPA_TRANSP,0); + lv_obj_set_style_border_width(s_vw,0,0);lv_obj_set_style_pad_all(s_vw,8,0);lv_obj_set_flex_flow(s_vw,LV_FLEX_FLOW_COLUMN);lv_obj_set_style_pad_gap(s_vw,8,0); + lv_obj_t*h=lv_obj_create(s_vw);lv_obj_set_size(h,LV_PCT(100),48);lv_obj_set_style_bg_opa(h,LV_OPA_TRANSP,0);lv_obj_set_style_border_width(h,0,0); lv_obj_set_flex_flow(h,LV_FLEX_FLOW_ROW);lv_obj_set_flex_align(h,LV_FLEX_ALIGN_SPACE_BETWEEN,LV_FLEX_ALIGN_CENTER,LV_FLEX_ALIGN_CENTER); lv_obj_t*t=lv_label_create(h);lv_label_set_text(t,LV_SYMBOL_GPS " eTrack"); - lv_obj_set_style_text_font(t,&lv_font_montserrat_28,0);lv_obj_set_style_text_color(t,hx(p->on_surface),0); - lv_obj_t*ab=lv_button_create(h);lv_obj_set_size(ab,LV_SIZE_CONTENT,32);lv_obj_set_style_bg_color(ab,hx(p->primary),0); - lv_obj_set_style_radius(ab,16,0);lv_obj_set_style_pad_hor(ab,14,0); - lv_obj_t*al=lv_label_create(ab);lv_label_set_text(al,LV_SYMBOL_PLUS " Track"); + lv_obj_set_style_text_font(t,&lv_font_montserrat_14,0);lv_obj_set_style_text_color(t,hx(p->on_surface),0); + lv_obj_t*ab=lv_btn_create(h);lv_obj_set_size(ab,LV_SIZE_CONTENT,32);lv_obj_set_style_bg_color(ab,hx(p->primary),0); + lv_obj_set_style_radius(ab,16,0);lv_obj_t*al=lv_label_create(ab);lv_label_set_text(al,LV_SYMBOL_PLUS " Track"); lv_obj_set_style_text_color(al,hx(p->on_primary),0);lv_obj_center(al); lv_obj_add_event_cb(ab,on_ac,LV_EVENT_CLICKED,NULL); if(s_cnt==0){lv_obj_t*em=lv_label_create(s_vw);lv_label_set_text(em,LV_SYMBOL_GPS "\n\nNo tracking items\nTap + Track to add"); - lv_obj_set_style_text_align(em,LV_TEXT_ALIGN_CENTER,0);lv_obj_set_style_text_color(em,hx(p->border),0); - lv_obj_set_width(em,LV_PCT(100));lv_obj_set_style_pad_top(em,60,0);return;} + lv_obj_set_style_text_align(em,LV_TEXT_ALIGN_CENTER,0);lv_obj_set_style_text_color(em,hx(p->border),0);return;} for(int i=0;iact)continue; lv_obj_t*c=lv_obj_create(s_vw);lv_obj_set_size(c,LV_PCT(100),LV_SIZE_CONTENT); lv_obj_set_style_bg_color(c,hx(p->card),0);lv_obj_set_style_bg_opa(c,LV_OPA_COVER,0); @@ -159,106 +62,24 @@ static void show_list(void){ lv_obj_set_style_bg_opa(r,LV_OPA_TRANSP,0);lv_obj_set_style_border_width(r,0,0);lv_obj_set_style_pad_all(r,0,0); lv_obj_set_flex_flow(r,LV_FLEX_FLOW_ROW);lv_obj_set_flex_align(r,LV_FLEX_ALIGN_SPACE_BETWEEN,LV_FLEX_ALIGN_CENTER,LV_FLEX_ALIGN_CENTER); char b[128];snprintf(b,128,"%s %s",ci(it->car),it->lbl[0]?it->lbl:cn(it->car)); - lv_obj_t*n=lv_label_create(r);lv_label_set_text(n,b);lv_obj_set_style_text_font(n,&lv_font_montserrat_14,0);lv_obj_set_style_text_color(n,hx(p->on_surface),0); + lv_obj_t*n=lv_label_create(r);lv_label_set_text(n,b);lv_obj_set_style_text_font(n,&lv_font_montserrat_12,0);lv_obj_set_style_text_color(n,hx(p->on_surface),0); snprintf(b,128,"%s %s",se(it->st),sl(it->st)); lv_obj_t*s2=lv_label_create(r);lv_label_set_text(s2,b);lv_obj_set_style_text_color(s2,hx(sc(it->st)),0);lv_obj_set_style_text_font(s2,&lv_font_montserrat_12,0); lv_obj_t*n2=lv_label_create(c);lv_label_set_text(n2,it->num);lv_obj_set_style_text_color(n2,hx(p->border),0);lv_obj_set_style_text_font(n2,&lv_font_montserrat_12,0); - if(it->stx[0]){lv_obj_t*sx=lv_label_create(c);lv_label_set_text(sx,it->stx);lv_obj_set_style_text_color(sx,hx(p->on_surface),0);lv_obj_set_style_text_font(sx,&lv_font_montserrat_12,0);} } } - -/* ---- DETAIL VIEW ---- */ static void on_bk(lv_event_t*e){(void)e;show_list();} -static void on_del(lv_event_t*e){int i=(int)(intptr_t)lv_event_get_user_data(e); - if(i>=0&&i=s_cnt)return;clr();const eapps_palette_t*p=eapps_theme_get_palette();item_t*it=&s_items[idx]; - s_vw=lv_obj_create(s_root);lv_obj_set_size(s_vw,LV_PCT(100),LV_PCT(100)); - lv_obj_set_style_bg_opa(s_vw,LV_OPA_TRANSP,0);lv_obj_set_style_border_width(s_vw,0,0); +static void show_detail(int idx){clr();const eapps_palette_t*p=eapps_theme_get_palette();item_t*it=&s_items[idx]; + s_vw=lv_obj_create(s_root);lv_obj_set_size(s_vw,LV_PCT(100),LV_PCT(100));lv_obj_set_style_bg_opa(s_vw,LV_OPA_TRANSP,0); lv_obj_set_style_pad_all(s_vw,8,0);lv_obj_set_flex_flow(s_vw,LV_FLEX_FLOW_COLUMN);lv_obj_set_style_pad_gap(s_vw,8,0); - lv_obj_t*bb=lv_button_create(s_vw);lv_obj_set_size(bb,LV_SIZE_CONTENT,30);lv_obj_set_style_bg_opa(bb,LV_OPA_TRANSP,0);lv_obj_set_style_shadow_width(bb,0,0); - lv_obj_t*bl=lv_label_create(bb);lv_label_set_text(bl,LV_SYMBOL_LEFT " Back");lv_obj_set_style_text_color(bl,hx(p->primary),0); - lv_obj_add_event_cb(bb,on_bk,LV_EVENT_CLICKED,NULL); + lv_obj_t*bb=lv_btn_create(s_vw);lv_obj_set_size(bb,LV_SIZE_CONTENT,30);lv_obj_t*bl=lv_label_create(bb);lv_label_set_text(bl,LV_SYMBOL_LEFT " Back");lv_obj_add_event_cb(bb,on_bk,LV_EVENT_CLICKED,NULL); lv_obj_t*hd=lv_obj_create(s_vw);lv_obj_set_size(hd,LV_PCT(100),LV_SIZE_CONTENT);lv_obj_set_style_bg_color(hd,hx(p->card),0); - lv_obj_set_style_bg_opa(hd,LV_OPA_COVER,0);lv_obj_set_style_radius(hd,12,0);lv_obj_set_style_border_color(hd,hx(p->border),0); - lv_obj_set_style_border_width(hd,1,0);lv_obj_set_style_pad_all(hd,12,0);lv_obj_set_flex_flow(hd,LV_FLEX_FLOW_COLUMN);lv_obj_set_style_pad_gap(hd,4,0); - char b[128];snprintf(b,128,"%s %s",ci(it->car),cn(it->car)); - lv_obj_t*cl=lv_label_create(hd);lv_label_set_text(cl,b);lv_obj_set_style_text_font(cl,&lv_font_montserrat_16,0);lv_obj_set_style_text_color(cl,hx(p->on_surface),0); - lv_obj_t*nl=lv_label_create(hd);lv_label_set_text(nl,it->num);lv_obj_set_style_text_color(nl,hx(p->border),0); - if(it->lbl[0]){lv_obj_t*ll=lv_label_create(hd);lv_label_set_text(ll,it->lbl);lv_obj_set_style_text_color(ll,hx(p->on_surface),0);} - snprintf(b,128,"%s %s",se(it->st),sl(it->st));lv_obj_t*stl=lv_label_create(hd);lv_label_set_text(stl,b); - lv_obj_set_style_text_color(stl,hx(sc(it->st)),0);lv_obj_set_style_text_font(stl,&lv_font_montserrat_14,0); - if(it->stx[0]){lv_obj_t*sx=lv_label_create(hd);lv_label_set_text(sx,it->stx);lv_obj_set_style_text_color(sx,hx(p->on_surface),0);} - lv_obj_t*tlt=lv_label_create(s_vw);lv_label_set_text(tlt,"Tracking Timeline");lv_obj_set_style_text_font(tlt,&lv_font_montserrat_14,0);lv_obj_set_style_text_color(tlt,hx(p->on_surface),0); - if(it->evc==0){lv_obj_t*ne=lv_label_create(s_vw);lv_label_set_text(ne,"No events yet.\nRefresh for updates."); - lv_obj_set_style_text_color(ne,hx(p->border),0);lv_obj_set_style_text_align(ne,LV_TEXT_ALIGN_CENTER,0);lv_obj_set_width(ne,LV_PCT(100));} - else{for(int j=0;jevc;j++){evt_t*ev=&it->ev[j]; - lv_obj_t*er=lv_obj_create(s_vw);lv_obj_set_size(er,LV_PCT(100),LV_SIZE_CONTENT);lv_obj_set_style_bg_opa(er,LV_OPA_TRANSP,0); - lv_obj_set_style_border_width(er,0,0);lv_obj_set_style_pad_all(er,0,0);lv_obj_set_flex_flow(er,LV_FLEX_FLOW_ROW);lv_obj_set_style_pad_gap(er,8,0); - lv_obj_t*dot=lv_obj_create(er);lv_obj_set_size(dot,10,10);lv_obj_set_style_radius(dot,5,0); - lv_obj_set_style_bg_color(dot,hx(j==0?p->primary:p->border),0);lv_obj_set_style_bg_opa(dot,LV_OPA_COVER,0); - lv_obj_set_style_border_width(dot,0,0);lv_obj_set_style_margin_top(dot,4,0); - lv_obj_t*ec=lv_obj_create(er);lv_obj_set_flex_grow(ec,1);lv_obj_set_size(ec,LV_PCT(80),LV_SIZE_CONTENT); - lv_obj_set_style_bg_opa(ec,LV_OPA_TRANSP,0);lv_obj_set_style_border_width(ec,0,0);lv_obj_set_style_pad_all(ec,0,0);lv_obj_set_flex_flow(ec,LV_FLEX_FLOW_COLUMN); - lv_obj_t*et=lv_label_create(ec);lv_label_set_text(et,ev->ex[0]?ev->ex:ev->st);lv_obj_set_style_text_color(et,hx(p->on_surface),0); - lv_obj_set_style_text_font(et,j==0?&lv_font_montserrat_14:&lv_font_montserrat_12,0); - if(ev->loc[0]){snprintf(b,128,LV_SYMBOL_GPS " %s",ev->loc);lv_obj_t*lc=lv_label_create(ec);lv_label_set_text(lc,b);lv_obj_set_style_text_color(lc,hx(p->border),0);lv_obj_set_style_text_font(lc,&lv_font_montserrat_12,0);} - if(ev->ts>0){char tb[48];eapps_date_format(ev->ts,"%b %d %H:%M",tb,48);lv_obj_t*tl=lv_label_create(ec);lv_label_set_text(tl,tb);lv_obj_set_style_text_color(tl,hx(p->border),0);lv_obj_set_style_text_font(tl,&lv_font_montserrat_12,0);} - }} - lv_obj_t*db=lv_button_create(s_vw);lv_obj_set_size(db,LV_PCT(100),36);lv_obj_set_style_bg_color(db,hx(p->error),0); - lv_obj_set_style_bg_opa(db,LV_OPA_20,0);lv_obj_set_style_radius(db,8,0); - lv_obj_t*dl=lv_label_create(db);lv_label_set_text(dl,LV_SYMBOL_TRASH " Delete");lv_obj_set_style_text_color(dl,hx(p->error),0);lv_obj_center(dl); - lv_obj_add_event_cb(db,on_del,LV_EVENT_CLICKED,(void*)(intptr_t)idx); -} - -/* ---- ADD VIEW ---- */ -static void on_nc(lv_event_t*e){(void)e;const char*t=lv_textarea_get_text(s_nta); - if(strlen(t)>=4){s_ac=det(t,&s_at);char b[96];const char*tn=s_at==T_FLT?"Flight":s_at==T_CASE?"Case":"Package"; - snprintf(b,96,"Detected: %s %s (%s)",ci(s_ac),cn(s_ac),tn);lv_label_set_text(s_dlbl,b);} - else lv_label_set_text(s_dlbl,"Enter 4+ chars to auto-detect carrier");} -static void on_sv(lv_event_t*e){(void)e;const char*n=lv_textarea_get_text(s_nta);const char*l=lv_textarea_get_text(s_lta); - if(!n||strlen(n)<4||s_cnt>=MAX_ITEMS)return;item_t*it=&s_items[s_cnt];memset(it,0,sizeof(*it)); - snprintf(it->num,MAX_S,"%s",n);snprintf(it->lbl,MAX_S,"%s",l?l:""); - it->car=s_ac;it->typ=s_at;it->st=S_PEND;snprintf(it->stx,MAX_L,"Added — refresh for live updates"); - it->ct=time(NULL);it->act=true;it->evc=0;s_cnt++;save();show_list();} -static void on_ab(lv_event_t*e){(void)e;show_list();} -static void show_add(void){ - clr();const eapps_palette_t*p=eapps_theme_get_palette();s_ac=C_OTHER;s_at=T_PKG; - s_vw=lv_obj_create(s_root);lv_obj_set_size(s_vw,LV_PCT(100),LV_PCT(100)); - lv_obj_set_style_bg_opa(s_vw,LV_OPA_TRANSP,0);lv_obj_set_style_border_width(s_vw,0,0); - lv_obj_set_style_pad_all(s_vw,12,0);lv_obj_set_flex_flow(s_vw,LV_FLEX_FLOW_COLUMN);lv_obj_set_style_pad_gap(s_vw,10,0); - lv_obj_t*bb=lv_button_create(s_vw);lv_obj_set_size(bb,LV_SIZE_CONTENT,30);lv_obj_set_style_bg_opa(bb,LV_OPA_TRANSP,0);lv_obj_set_style_shadow_width(bb,0,0); - lv_obj_t*bbl=lv_label_create(bb);lv_label_set_text(bbl,LV_SYMBOL_LEFT " Back");lv_obj_set_style_text_color(bbl,hx(p->primary),0); - lv_obj_add_event_cb(bb,on_ab,LV_EVENT_CLICKED,NULL); - lv_obj_t*ttl=lv_label_create(s_vw);lv_label_set_text(ttl,"Add Tracking");lv_obj_set_style_text_font(ttl,&lv_font_montserrat_16,0);lv_obj_set_style_text_color(ttl,hx(p->on_surface),0); - lv_obj_t*nl=lv_label_create(s_vw);lv_label_set_text(nl,"Tracking Number");lv_obj_set_style_text_color(nl,hx(p->on_surface),0); - s_nta=lv_textarea_create(s_vw);lv_textarea_set_one_line(s_nta,true);lv_textarea_set_placeholder_text(s_nta,"e.g. 1Z999AA10123456784"); - lv_obj_set_width(s_nta,LV_PCT(100));lv_obj_add_event_cb(s_nta,on_nc,LV_EVENT_VALUE_CHANGED,NULL); - s_dlbl=lv_label_create(s_vw);lv_label_set_text(s_dlbl,"Enter 4+ chars to auto-detect carrier"); - lv_obj_set_style_text_color(s_dlbl,hx(p->primary),0);lv_obj_set_style_text_font(s_dlbl,&lv_font_montserrat_12,0); - lv_obj_t*ll=lv_label_create(s_vw);lv_label_set_text(ll,"Label (optional)");lv_obj_set_style_text_color(ll,hx(p->on_surface),0); - s_lta=lv_textarea_create(s_vw);lv_textarea_set_one_line(s_lta,true);lv_textarea_set_placeholder_text(s_lta,"e.g. Mom's birthday gift"); - lv_obj_set_width(s_lta,LV_PCT(100)); - lv_obj_t*sv=lv_button_create(s_vw);lv_obj_set_size(sv,LV_PCT(100),44);lv_obj_set_style_bg_color(sv,hx(p->primary),0);lv_obj_set_style_radius(sv,12,0); - lv_obj_t*svl=lv_label_create(sv);lv_label_set_text(svl,LV_SYMBOL_PLUS " Add Tracking");lv_obj_set_style_text_color(svl,hx(p->on_primary),0);lv_obj_center(svl); - lv_obj_add_event_cb(sv,on_sv,LV_EVENT_CLICKED,NULL); + lv_obj_set_style_border_width(hd,1,0);lv_obj_set_style_pad_all(hd,12,0);lv_obj_set_flex_flow(hd,LV_FLEX_FLOW_COLUMN); + lv_obj_t*cl=lv_label_create(hd);lv_label_set_text(cl,cn(it->car)); } - -/* ---- LIFECYCLE ---- */ -static bool etrack_init(lv_obj_t*parent){ - s_p=eapps_prefs_init("etrack");load();s_root=parent; - s_vw=NULL;s_nta=NULL;s_lta=NULL;s_dlbl=NULL;show_list();return true;} -static void etrack_deinit(void){save();if(s_p){eapps_prefs_deinit(s_p);s_p=NULL;} - s_root=NULL;s_vw=NULL;s_nta=NULL;s_lta=NULL;s_dlbl=NULL;} -static void etrack_on_show(void){} -static void etrack_on_hide(void){} - -const eapps_app_info_t etrack_info={ - .id="etrack",.name="eTrack",.icon="trk", - .description="Universal package, flight & case tracking", - .category=EAPPS_CAT_PRODUCTIVITY,.version="1.0.0", -}; -const eapps_app_lifecycle_t etrack_lifecycle={ - .init=etrack_init,.deinit=etrack_deinit, - .on_show=etrack_on_show,.on_hide=etrack_on_hide, -}; +static void on_sv(lv_event_t*e){(void)e;show_list();} +static void show_add(void){clr();s_vw=lv_obj_create(s_root);lv_obj_t*sv=lv_btn_create(s_vw);lv_obj_add_event_cb(sv,on_sv,LV_EVENT_CLICKED,NULL);} +static bool etrack_init(lv_obj_t*par){s_root=par;load();show_list();return true;} +static void etrack_deinit(void){s_root=NULL;clr();} +const eapps_app_info_t etrack_info={.id="etrack",.name="eTrack",.icon=LV_SYMBOL_GPS,.category=EAPPS_CAT_CONNECTIVITY,.version="1.0.0"}; +const eapps_app_lifecycle_t etrack_lifecycle={.init=etrack_init,.deinit=etrack_deinit}; diff --git a/apps/ewifi/ewifi.c b/apps/ewifi/ewifi.c index bbfdcd7..30183ec 100644 --- a/apps/ewifi/ewifi.c +++ b/apps/ewifi/ewifi.c @@ -27,6 +27,8 @@ static int s_selected_net = 0; static ewifi_vault_t s_vault; static ewifi_auto_connect_t s_ac; +static void rebuild_content(void); + static void show_toast(const char *msg) { if (s_status_lbl) lv_label_set_text(s_status_lbl, msg); } @@ -229,42 +231,6 @@ static void build_channel_tab(lv_obj_t *body) { } } -/* ---- Build Handshake Education Tab ---- */ -static void build_handshake_tab(lv_obj_t *body) { - const eapps_palette_t *p = eapps_theme_get_palette(); - - lv_obj_t *title = lv_label_create(body); - lv_label_set_text(title, "WPA2-PSK 4-Way Handshake"); - lv_obj_set_style_text_color(title, hc(p->primary), 0); - lv_obj_set_style_text_font(title, &lv_font_montserrat_14, 0); - - int steps = ewifi_handshake_step_count(); - for (int i = 0; i < steps; i++) { - ewifi_handshake_step_t step = (ewifi_handshake_step_t)i; - const ewifi_handshake_info_t *info = ewifi_handshake_get_step(step); - if (!info) continue; - - lv_obj_t *card = eapps_card_create(body); - lv_obj_set_style_pad_all(card, 10, 0); - - /* Step number + title */ - lv_obj_t *hdr = lv_label_create(card); - char hdr_txt[64]; - snprintf(hdr_txt, 64, "Step %d: %s", i, info->description); - lv_label_set_text(hdr, hdr_txt); - lv_obj_set_style_text_color(hdr, hc(p->primary), 0); - lv_obj_set_style_text_font(hdr, &lv_font_montserrat_12, 0); - - /* Detail text */ - lv_obj_t *det = lv_label_create(card); - lv_label_set_text(det, info->detail); - lv_label_set_long_mode(det, LV_LABEL_LONG_WRAP); - lv_obj_set_width(det, LV_PCT(100)); - lv_obj_set_style_text_color(det, hc(p->on_surface), 0); - lv_obj_set_style_text_font(det, &lv_font_montserrat_12, 0); - } -} - /* ---- Build Security Tab ---- */ static void build_security_tab(lv_obj_t *body) { const eapps_palette_t *p = eapps_theme_get_palette(); diff --git a/apps/ewifi/ewifi_passwords.c b/apps/ewifi/ewifi_passwords.c index 4c42175..984f9c0 100644 --- a/apps/ewifi/ewifi_passwords.c +++ b/apps/ewifi/ewifi_passwords.c @@ -56,7 +56,8 @@ static int extract_profiles_win(ewifi_saved_cred_t *out, int max) if (strlen(marker) == 0) continue; memset(&out[count], 0, sizeof(ewifi_saved_cred_t)); - strncpy(out[count].ssid, marker, EWIFI_SSID_MAX - 1); + strncpy(out[count].ssid, marker, sizeof(out[count].ssid) - 1); + out[count].ssid[sizeof(out[count].ssid) - 1] = '\0'; out[count].password_found = false; count++; } @@ -75,7 +76,8 @@ static bool extract_key_for_profile_win(const char *ssid, ewifi_saved_cred_t *cr char line[256]; memset(cred, 0, sizeof(*cred)); - strncpy(cred->ssid, ssid, EWIFI_SSID_MAX - 1); + strncpy(cred->ssid, ssid, sizeof(cred->ssid) - 1); + cred->ssid[sizeof(cred->ssid) - 1] = '\0'; while (fgets(line, sizeof(line), fp)) { /* Key Content : password_here */ @@ -85,7 +87,8 @@ static bool extract_key_for_profile_win(const char *ssid, ewifi_saved_cred_t *cr if (val) { val += 2; trim(val); - strncpy(cred->password, val, EWIFI_PASS_MAX - 1); + strncpy(cred->password, val, sizeof(cred->password) - 1); + cred->password[sizeof(cred->password) - 1] = '\0'; cred->password_found = (strlen(cred->password) > 0); } } @@ -96,6 +99,7 @@ static bool extract_key_for_profile_win(const char *ssid, ewifi_saved_cred_t *cr val += 2; trim(val); strncpy(cred->auth_type, val, sizeof(cred->auth_type) - 1); + cred->auth_type[sizeof(cred->auth_type) - 1] = '\0'; } } /* Cipher / Security */ @@ -106,6 +110,7 @@ static bool extract_key_for_profile_win(const char *ssid, ewifi_saved_cred_t *cr val += 2; trim(val); strncpy(cred->security, val, sizeof(cred->security) - 1); + cred->security[sizeof(cred->security) - 1] = '\0'; } } } @@ -297,18 +302,26 @@ int ewifi_extract_saved_passwords(ewifi_saved_cred_t *out, int max) if (max < 3) return 0; memset(out, 0, 3 * sizeof(ewifi_saved_cred_t)); - strncpy(out[0].ssid, "HomeNetwork_5G", EWIFI_SSID_MAX - 1); - strncpy(out[0].password, "MyStr0ng!WiFi#2026", EWIFI_PASS_MAX - 1); - strncpy(out[0].auth_type, "WPA3-SAE", 23); + strncpy(out[0].ssid, "DEMO_5G_NETWORK", sizeof(out[0].ssid) - 1); + out[0].ssid[sizeof(out[0].ssid) - 1] = '\0'; + strncpy(out[0].password, "DEMO_PASS_2026", sizeof(out[0].password) - 1); + out[0].password[sizeof(out[0].password) - 1] = '\0'; + strncpy(out[0].auth_type, "WPA3-SAE", sizeof(out[0].auth_type) - 1); + out[0].auth_type[sizeof(out[0].auth_type) - 1] = '\0'; out[0].password_found = true; - strncpy(out[1].ssid, "HomeNetwork", EWIFI_SSID_MAX - 1); - strncpy(out[1].password, "SimplePass123", EWIFI_PASS_MAX - 1); - strncpy(out[1].auth_type, "WPA2-PSK", 23); + strncpy(out[1].ssid, "SIMULATED_HOME", sizeof(out[1].ssid) - 1); + out[1].ssid[sizeof(out[1].ssid) - 1] = '\0'; + strncpy(out[1].password, "SIMULATED_123", sizeof(out[1].password) - 1); + out[1].password[sizeof(out[1].password) - 1] = '\0'; + strncpy(out[1].auth_type, "WPA2-PSK", sizeof(out[1].auth_type) - 1); + out[1].auth_type[sizeof(out[1].auth_type) - 1] = '\0'; out[1].password_found = true; - strncpy(out[2].ssid, "Office_5G_AC", EWIFI_SSID_MAX - 1); - strncpy(out[2].auth_type, "WPA2-Enterprise", 23); + strncpy(out[2].ssid, "OFFICE_LAB_TEST", sizeof(out[2].ssid) - 1); + out[2].ssid[sizeof(out[2].ssid) - 1] = '\0'; + strncpy(out[2].auth_type, "WPA2-Enterprise", sizeof(out[2].auth_type) - 1); + out[2].auth_type[sizeof(out[2].auth_type) - 1] = '\0'; out[2].password_found = false; return 3; diff --git a/extern/lvgl.h b/extern/lvgl.h index 9bb2b81..4aa4a36 100644 --- a/extern/lvgl.h +++ b/extern/lvgl.h @@ -19,12 +19,12 @@ typedef struct { int32_t x1, y1, x2, y2; } lv_area_t; typedef struct { int32_t x, y; } lv_point_t; typedef void (*lv_timer_cb_t)(lv_timer_t *); typedef void (*lv_event_cb_t)(lv_event_t *); -enum { LV_OPA_TRANSP=0, LV_OPA_COVER=255, LV_OPA_10=25, LV_OPA_20=51, LV_OPA_30=76, LV_OPA_50=127 }; +enum { LV_OPA_TRANSP=0, LV_OPA_COVER=255, LV_OPA_10=25, LV_OPA_20=51, LV_OPA_30=76, LV_OPA_40=102, LV_OPA_50=127, LV_OPA_60=153 }; enum { LV_FLEX_FLOW_ROW=0, LV_FLEX_FLOW_COLUMN=1, LV_FLEX_FLOW_ROW_WRAP=2 }; enum { LV_FLEX_ALIGN_START=0, LV_FLEX_ALIGN_CENTER=1, LV_FLEX_ALIGN_END=2, LV_FLEX_ALIGN_SPACE_BETWEEN=3, LV_FLEX_ALIGN_SPACE_EVENLY=4 }; enum { LV_TEXT_ALIGN_CENTER=1 }; enum { LV_LABEL_LONG_WRAP=0, LV_LABEL_LONG_DOT=1 }; -enum { LV_EVENT_CLICKED=0, LV_EVENT_VALUE_CHANGED=1, LV_EVENT_PRESSING=2 }; +enum { LV_EVENT_CLICKED=0, LV_EVENT_VALUE_CHANGED=1, LV_EVENT_PRESSING=2, LV_EVENT_READY=3 }; enum { LV_OBJ_FLAG_HIDDEN=1, LV_OBJ_FLAG_SCROLLABLE=2 }; enum { LV_BORDER_SIDE_TOP=1, LV_BORDER_SIDE_BOTTOM=2 }; enum { LV_ALIGN_TOP_MID=0, LV_ALIGN_CENTER=1, LV_ALIGN_LEFT_MID=2, LV_ALIGN_RIGHT_MID=3, LV_ALIGN_BOTTOM_MID=4 }; @@ -36,6 +36,7 @@ enum { LV_STATE_CHECKED=1 }; enum { LV_DISPLAY_RENDER_MODE_PARTIAL=0 }; enum { LV_COLOR_FORMAT_NATIVE=0 }; #define LV_SIZE_CONTENT 0 +#define LV_COORD_MAX 0x7FFF #define LV_PCT(x) (-(x)) typedef struct { lv_color_t bg_color; uint8_t bg_opa; int radius; } lv_draw_rect_dsc_t; #define LV_SYMBOL_LEFT "<" @@ -49,7 +50,21 @@ typedef struct { lv_color_t bg_color; uint8_t bg_opa; int radius; } lv_draw_rect #define LV_SYMBOL_GPS "L" #define LV_SYMBOL_CHARGE "C" #define LV_SYMBOL_WARNING "!" +#define LV_SYMBOL_HOME "H" +#define LV_SYMBOL_SHOPPING_CART "P" +#define LV_SYMBOL_EYE_OPEN "V" +#define LV_SYMBOL_POWER "O" +#define LV_SYMBOL_UP "^" +#define LV_SYMBOL_DOWN "v" +#define LV_SYMBOL_PLAY "Y" +#define LV_SYMBOL_PAUSE "U" +#define LV_SYMBOL_PREV "[" +#define LV_SYMBOL_NEXT "]" +#define LV_SYMBOL_VOLUME_MID "vm" +#define LV_SYMBOL_VOLUME_MAX "VX" +#define LV_SYMBOL_DEGREE_SIGN "°" typedef struct { int dummy; } lv_font_t; +extern const lv_font_t lv_font_montserrat_10; extern const lv_font_t lv_font_montserrat_12; extern const lv_font_t lv_font_montserrat_14; extern const lv_font_t lv_font_montserrat_16; @@ -57,12 +72,14 @@ extern const lv_font_t lv_font_montserrat_28; extern const lv_font_t lv_font_montserrat_48; static inline lv_obj_t *lv_obj_create(lv_obj_t *p) { (void)p; return (lv_obj_t*)1; } static inline lv_obj_t *lv_button_create(lv_obj_t *p) { (void)p; return (lv_obj_t*)1; } +static inline lv_obj_t *lv_btn_create(lv_obj_t *p) { (void)p; return (lv_obj_t*)1; } static inline lv_obj_t *lv_label_create(lv_obj_t *p) { (void)p; return (lv_obj_t*)1; } static inline lv_obj_t *lv_textarea_create(lv_obj_t *p) { (void)p; return (lv_obj_t*)1; } static inline lv_obj_t *lv_slider_create(lv_obj_t *p) { (void)p; return (lv_obj_t*)1; } static inline lv_obj_t *lv_switch_create(lv_obj_t *p) { (void)p; return (lv_obj_t*)1; } static inline lv_obj_t *lv_arc_create(lv_obj_t *p) { (void)p; return (lv_obj_t*)1; } static inline lv_obj_t *lv_bar_create(lv_obj_t *p) { (void)p; return (lv_obj_t*)1; } +static inline lv_obj_t *lv_dropdown_create(lv_obj_t *p) { (void)p; return (lv_obj_t*)1; } static inline lv_obj_t *lv_canvas_create(lv_obj_t *p) { (void)p; return (lv_obj_t*)1; } static inline void lv_obj_set_size(lv_obj_t *o, int w, int h) { (void)o;(void)w;(void)h; } static inline void lv_obj_set_width(lv_obj_t *o, int w) { (void)o;(void)w; } @@ -75,27 +92,36 @@ static inline void lv_obj_set_flex_grow(lv_obj_t *o, int g) { (void)o;(void)g; } static inline void lv_obj_add_flag(lv_obj_t *o, int f) { (void)o;(void)f; } static inline void lv_obj_clear_flag(lv_obj_t *o, int f) { (void)o;(void)f; } static inline void lv_obj_add_state(lv_obj_t *o, int s) { (void)o;(void)s; } +static inline bool lv_obj_has_state(lv_obj_t *o, int s) { (void)o;(void)s; return false; } static inline void lv_obj_add_event_cb(lv_obj_t *o, lv_event_cb_t cb, int e, void *d) { (void)o;(void)cb;(void)e;(void)d; } static inline void lv_obj_clean(lv_obj_t *o) { (void)o; } static inline void lv_obj_delete(lv_obj_t *o) { (void)o; } +static inline void lv_obj_del(lv_obj_t *o) { (void)o; } static inline void lv_obj_remove_style(lv_obj_t *o, void *s, int p) { (void)o;(void)s;(void)p; } static inline lv_obj_t *lv_obj_get_child(lv_obj_t *o, int i) { (void)o;(void)i; return (lv_obj_t*)1; } static inline int lv_obj_get_x(lv_obj_t *o) { (void)o; return 0; } static inline int lv_obj_get_y(lv_obj_t *o) { (void)o; return 0; } +static inline void lv_obj_scroll_to_y(lv_obj_t *o, int y, int a) { (void)o;(void)y;(void)a; } static inline void lv_obj_set_style_bg_color(lv_obj_t *o, lv_color_t c, int s) { (void)o;(void)c;(void)s; } static inline void lv_obj_set_style_bg_opa(lv_obj_t *o, int a, int s) { (void)o;(void)a;(void)s; } static inline void lv_obj_set_style_radius(lv_obj_t *o, int r, int s) { (void)o;(void)r;(void)s; } static inline void lv_obj_set_style_border_color(lv_obj_t *o, lv_color_t c, int s) { (void)o;(void)c;(void)s; } static inline void lv_obj_set_style_border_width(lv_obj_t *o, int w, int s) { (void)o;(void)w;(void)s; } static inline void lv_obj_set_style_border_side(lv_obj_t *o, int s, int p) { (void)o;(void)s;(void)p; } +static inline void lv_obj_set_style_border_opa(lv_obj_t *o, int a, int s) { (void)o;(void)a;(void)s; } static inline void lv_obj_set_style_pad_all(lv_obj_t *o, int p, int s) { (void)o;(void)p;(void)s; } static inline void lv_obj_set_style_pad_hor(lv_obj_t *o, int p, int s) { (void)o;(void)p;(void)s; } +static inline void lv_obj_set_style_pad_top(lv_obj_t *o, int p, int s) { (void)o;(void)p;(void)s; } static inline void lv_obj_set_style_pad_gap(lv_obj_t *o, int g, int s) { (void)o;(void)g;(void)s; } +static inline void lv_obj_set_style_pad_row(lv_obj_t *o, int r, int s) { (void)o;(void)r;(void)s; } +static inline void lv_obj_set_style_margin_top(lv_obj_t *o, int m, int s) { (void)o;(void)m;(void)s; } static inline void lv_obj_set_style_shadow_width(lv_obj_t *o, int w, int s) { (void)o;(void)w;(void)s; } static inline void lv_obj_set_style_shadow_opa(lv_obj_t *o, int a, int s) { (void)o;(void)a;(void)s; } +static inline void lv_obj_set_style_shadow_color(lv_obj_t *o, lv_color_t c, int s) { (void)o;(void)c;(void)s; } static inline void lv_obj_set_style_text_color(lv_obj_t *o, lv_color_t c, int s) { (void)o;(void)c;(void)s; } static inline void lv_obj_set_style_text_font(lv_obj_t *o, const lv_font_t *f, int s) { (void)o;(void)f;(void)s; } static inline void lv_obj_set_style_text_align(lv_obj_t *o, int a, int s) { (void)o;(void)a;(void)s; } +static inline void lv_obj_set_style_text_opa(lv_obj_t *o, int a, int s) { (void)o;(void)a;(void)s; } static inline void lv_obj_set_style_min_width(lv_obj_t *o, int w, int s) { (void)o;(void)w;(void)s; } static inline void lv_obj_set_style_arc_color(lv_obj_t *o, lv_color_t c, int s) { (void)o;(void)c;(void)s; } static inline void lv_obj_set_style_arc_width(lv_obj_t *o, int w, int s) { (void)o;(void)w;(void)s; } @@ -103,6 +129,9 @@ static inline void lv_label_set_text(lv_obj_t *o, const char *t) { (void)o;(void static inline void lv_label_set_long_mode(lv_obj_t *o, int m) { (void)o;(void)m; } static inline void lv_textarea_set_one_line(lv_obj_t *o, bool b) { (void)o;(void)b; } static inline void lv_textarea_set_placeholder_text(lv_obj_t *o, const char *t) { (void)o;(void)t; } +static inline void lv_textarea_set_text(lv_obj_t *o, const char *t) { (void)o;(void)t; } +static inline const char *lv_textarea_get_text(lv_obj_t *o) { (void)o; return ""; } +static inline void lv_dropdown_set_options(lv_obj_t *o, const char *t) { (void)o;(void)t; } static inline int lv_slider_get_value(lv_obj_t *o) { (void)o; return 0; } static inline void lv_slider_set_range(lv_obj_t *o, int mn, int mx) { (void)o;(void)mn;(void)mx; } static inline void lv_slider_set_value(lv_obj_t *o, int v, int a) { (void)o;(void)v;(void)a; } @@ -119,6 +148,7 @@ static inline void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t *d) { if(d){d->bg_op static inline void lv_draw_rect(lv_layer_t *l, lv_draw_rect_dsc_t *d, lv_area_t *a) { (void)l;(void)d;(void)a; } static inline void *lv_event_get_user_data(lv_event_t *e) { (void)e; return NULL; } static inline lv_obj_t *lv_event_get_target(lv_event_t *e) { (void)e; return (lv_obj_t*)1; } +static inline int lv_event_get_code(lv_event_t *e) { (void)e; return 0; } static inline lv_indev_t *lv_indev_active(void) { return NULL; } static inline void lv_indev_get_point(lv_indev_t *i, lv_point_t *p) { (void)i;(void)p; } static inline lv_timer_t *lv_timer_create(lv_timer_cb_t cb, uint32_t p, void *d) { (void)cb;(void)p;(void)d; return NULL; } diff --git a/tests/test_ewifi.c b/tests/test_ewifi.c index a40428a..10eb45b 100644 --- a/tests/test_ewifi.c +++ b/tests/test_ewifi.c @@ -145,6 +145,7 @@ static void test_vault_wrong_pin(void) { static void test_vault_encrypt_decrypt_roundtrip(void) { ewifi_vault_t v; ewifi_vault_init(&v); + ewifi_vault_set_pin(&v, "1234"); ewifi_vault_add(&v, "CryptoNet", "mypassword", "test", false); ewifi_vault_encrypt_all(&v);