rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
wifi_screen.h File Reference

WI-FI: the panel's Wi-Fi, for two jobs in a browser – every file on the card to download, and a panel firmware image to upload – and the screen that writes an uploaded image (PANEL UPDATE). More...

#include <stdbool.h>
#include <stdint.h>
#include "ui_screen.h"
#include "ui_textkey.h"

Go to the source code of this file.

Data Structures

struct  wifi_view_t
struct  update_view_t

Macros

#define WIFI_SSID_MAX   32
 The longest network name, in bytes.
#define WIFI_PASS_MAX   63
 The longest password, in characters.
#define WIFI_SCAN_ROWS   16
 The most networks a scan lists.
#define WIFI_VER_MAX   32
 The longest version string an image or a release carries.
#define WIFI_REQ_AP   0x001u
#define WIFI_REQ_JOIN   0x002u
#define WIFI_REQ_OFF   0x004u
#define WIFI_REQ_SCAN   0x008u
#define WIFI_REQ_SAVE_NET   0x010u
#define WIFI_REQ_FORGET   0x020u
#define WIFI_REQ_CODE_ON   0x040u
#define WIFI_REQ_CODE_OFF   0x080u
#define WIFI_REQ_DISCARD   0x100u
#define WIFI_REQ_INSTALL   0x200u

Enumerations

enum  wifi_radio_t {
  WIFI_RADIO_OFF = 0 , WIFI_RADIO_STARTING , WIFI_RADIO_AP , WIFI_RADIO_SCANNING ,
  WIFI_RADIO_JOINING , WIFI_RADIO_ADDRESS , WIFI_RADIO_JOINED
}
enum  wifi_why_t {
  WIFI_WHY_NONE = 0 , WIFI_WHY_ARMED , WIFI_WHY_SUPPLY , WIFI_WHY_RUN ,
  WIFI_WHY_STOP , WIFI_WHY_IDLE , WIFI_WHY_GUESSES , WIFI_WHY_ASKED ,
  WIFI_WHY_INSTALL , WIFI_WHY_FAILED , WIFI_WHY_JOIN , WIFI_WHY_UNAVAILABLE
}
enum  wifi_join_t {
  WIFI_JOIN_OK = 0 , WIFI_JOIN_PASSWORD , WIFI_JOIN_NOT_FOUND , WIFI_JOIN_NO_ADDRESS ,
  WIFI_JOIN_LOST
}
enum  wifi_up_t { WIFI_UP_IDLE = 0 , WIFI_UP_RECEIVING , WIFI_UP_STAGED , WIFI_UP_FAILED }
enum  wifi_offer_t { WIFI_OFFER_NEWER = 0 , WIFI_OFFER_OLDER , WIFI_OFFER_REBUILD , WIFI_OFFER_INSTALLED }
enum  wifi_gate_t {
  WIFI_GATE_OPEN = 0 , WIFI_GATE_ARMED , WIFI_GATE_SUPPLY , WIFI_GATE_RUN ,
  WIFI_GATE_DRAWING , WIFI_GATE_COPROC
}
enum  update_state_t {
  UPDATE_WRITING = 0 , UPDATE_RESTARTING , UPDATE_FAILED , UPDATE_FETCHING ,
  UPDATE_FETCH_FAILED
}
 Where PANEL UPDATE stands. More...

Functions

void wifi_screen_set (const wifi_view_t *v)
void wifi_screen_set_unavailable (void)
const wifi_view_t * wifi_screen_view (void)
unsigned wifi_screen_take (void)
void wifi_screen_net (char ssid[WIFI_SSID_MAX+1], char pass[WIFI_PASS_MAX+1])
void wifi_screen_invalidate (void)
gfx_rect_t wifi_screen_key_area (void)
 Where the keyboard opens: the body less UI_MARGIN at its sides and top, ending 4px above the alert band, 1008 x 484px.
const ui_textkey_t * wifi_screen_textkey (void)
 The screen's keyboard, open or closed; for tests and the renderer, which check what a tap typed.
const ui_screen_t * wifi_screen (void)
 The WI-FI screen, for the router.
int wifi_screen_jobs_lines (void)
void update_screen_set (const update_view_t *v)
 Hand PANEL UPDATE what to show.
bool update_screen_take_close (void)
bool update_screen_take_cancel (void)
void update_screen_invalidate (void)
 Repaint PANEL UPDATE on the next frame.
const ui_screen_t * update_screen (void)
 The PANEL UPDATE screen, for the router.

Detailed Description

WI-FI: the panel's Wi-Fi, for two jobs in a browser – every file on the card to download, and a panel firmware image to upload – and the screen that writes an uploaded image (PANEL UPDATE).

The screen opens from LOGS and runs the radio only while it is open. It offers the panel's own access point always, and the home network when one is kept: chosen from a scan, or typed for a hidden one, the password typed on the Wi-Fi keyboard (ui_textkey_open_wifi()). It shows what a browser needs – network, password, address, name, access code – and why the radio went off when it did.

An uploaded image waits on the panel as a question naming both versions. The browser cannot start the write: INSTALL is a 2s hold here (UI_HOLD_S), and the hold ends unfired when the image goes away under it – a STOP, an ARM, CANCEL – or the install gate closes.

The screen commands nothing itself. The application hands it what to show (wifi_screen_set()) and drains what it asks for (wifi_screen_take()), as it does STOP: the UI (user interface) never calls into hardware. The enums here mirror the Wi-Fi session's and the installer's, which live in other components; the application maps one to the other in one place.

Pure C, no ESP-IDF (Espressif Internet-of-Things Development Framework).

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ WIFI_REQ_AP

#define WIFI_REQ_AP   0x001u

What the screen asks for: bits of wifi_screen_take(). start the access point

◆ WIFI_REQ_CODE_OFF

#define WIFI_REQ_CODE_OFF   0x080u

the page asks for no access code

◆ WIFI_REQ_CODE_ON

#define WIFI_REQ_CODE_ON   0x040u

the page asks for the access code

◆ WIFI_REQ_DISCARD

#define WIFI_REQ_DISCARD   0x100u

drop the staged image

◆ WIFI_REQ_FORGET

#define WIFI_REQ_FORGET   0x020u

forget the kept home network

◆ WIFI_REQ_INSTALL

#define WIFI_REQ_INSTALL   0x200u

the 2s hold completed

◆ WIFI_REQ_JOIN

#define WIFI_REQ_JOIN   0x002u

join the kept home network

◆ WIFI_REQ_OFF

#define WIFI_REQ_OFF   0x004u

radio off

◆ WIFI_REQ_SAVE_NET

#define WIFI_REQ_SAVE_NET   0x010u

keep wifi_screen_net()'s network

◆ WIFI_REQ_SCAN

#define WIFI_REQ_SCAN   0x008u

scan for networks

Enumeration Type Documentation

◆ update_state_t

Where PANEL UPDATE stands.

Enumerator
UPDATE_WRITING 

the image is being written

UPDATE_RESTARTING 

written and checked

UPDATE_FAILED 

nothing changed: the running image stays

UPDATE_FETCHING 

SETUP > UPDATES' download from GitHub, before the write: joining, SHA256SUMS, the image, its checks. CANCEL ends it.

UPDATE_FETCH_FAILED 

nothing written: the running image stays

◆ wifi_gate_t

Whether flash may be written now (fw_gate_t).

Enumerator
WIFI_GATE_DRAWING 

a board drawing is fetched or kept

WIFI_GATE_COPROC 

the IOmcu's update runs

◆ wifi_join_t

How a join failed (wa_join_err_t).

◆ wifi_offer_t

What a staged image is to the running one (fw_offer_t).

Enumerator
WIFI_OFFER_REBUILD 

same version, another build

WIFI_OFFER_INSTALLED 

the build that runs: nothing to install

◆ wifi_radio_t

The radio, as the session has it (wa_state_t).

◆ wifi_up_t

enum wifi_up_t

The upload, as the receiver has it (fw_upload_state_t).

◆ wifi_why_t

enum wifi_why_t

Why the radio is off, or may not start (wa_off_t).

Enumerator
WIFI_WHY_UNAVAILABLE 

The panel's own, with no wa_off_t twin: Wi-Fi could not be set up at start, and nothing on the screen can start it.

Function Documentation

◆ update_screen()

const ui_screen_t * update_screen ( void )

The PANEL UPDATE screen, for the router.

Returns
The screen.

◆ update_screen_set()

void update_screen_set ( const update_view_t * v)

Hand PANEL UPDATE what to show.

Parameters
vThe view, copied.

◆ update_screen_take_cancel()

bool update_screen_take_cancel ( void )

True once CANCEL was tapped on a download; cleared when read.

◆ update_screen_take_close()

bool update_screen_take_close ( void )

True once CLOSE was tapped on a failed write or download; cleared when read.

◆ wifi_screen()

const ui_screen_t * wifi_screen ( void )

The WI-FI screen, for the router.

Returns
The screen.

◆ wifi_screen_invalidate()

void wifi_screen_invalidate ( void )

Repaint on the next frame.

◆ wifi_screen_jobs_lines()

int wifi_screen_jobs_lines ( void )

The lines the card's first sentence takes, WF_JOBS_1 and WF_JOBS_2 joined by a space and wrapped once; for tests.

◆ wifi_screen_key_area()

gfx_rect_t wifi_screen_key_area ( void )

Where the keyboard opens: the body less UI_MARGIN at its sides and top, ending 4px above the alert band, 1008 x 484px.

Returns
The area, in the screen's coordinates.

◆ wifi_screen_net()

void wifi_screen_net ( char ssid[WIFI_SSID_MAX+1],
char pass[WIFI_PASS_MAX+1] )

The network WIFI_REQ_SAVE_NET keeps: its name and its password.

◆ wifi_screen_set()

void wifi_screen_set ( const wifi_view_t * v)

Hand the screen what to show.

◆ wifi_screen_set_unavailable()

void wifi_screen_set_unavailable ( void )

Wi-Fi could not be set up at start: show WIFI_WHY_UNAVAILABLE with every control off. Needs no view from the caller, so it holds when the memory for one is what ran out.

◆ wifi_screen_take()

unsigned wifi_screen_take ( void )

The requests since the last call, as WIFI_REQ_* bits; cleared.

◆ wifi_screen_textkey()

const ui_textkey_t * wifi_screen_textkey ( void )

The screen's keyboard, open or closed; for tests and the renderer, which check what a tap typed.

Returns
The keyboard.

◆ wifi_screen_view()

const wifi_view_t * wifi_screen_view ( void )

What is showing, for the application and the tests.