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

The panel's Wi-Fi: the radio, the page's HTTP (hypertext transfer protocol) server, the mDNS (multicast domain name system) name and the NVS (non-volatile storage) entry of the home network. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "esp_err.h"
#include "fw_image.h"
#include "fw_upload.h"
#include "wa_fetch.h"
#include "wa_session.h"

Go to the source code of this file.

Data Structures

struct  wifi_access_state_t

Macros

#define WIFI_ACCESS_AP_CHANNEL   6u
 The access point's channel, 2.4GHz band.

Functions

esp_err_t wifi_access_init (uint32_t slot, const fw_image_info_t *running)
void wifi_access_set_german (bool de)
wa_off_t wifi_access_start (wa_mode_t mode, wa_off_t gate)
void wifi_access_close (wa_off_t why)
 Radio off for why; see wa_close().
bool wifi_access_tick (wa_off_t gate, bool stop, bool may_write)
 Once a frame: the gate, STOP pressed since the last call, the time-outs; and a change to what is kept written when may_write.
void wifi_access_get (wifi_access_state_t *out)
bool wifi_access_down (void)
 Whether the radio is wholly off and no start of it is asked for; from any task, without the lock.
void wifi_access_end_linger (void)
 The radio goes off without waiting for the clock's NTP answer: a session that ended and lingers (wa_lingers()) stops lingering; one that runs goes on. From any task, without the lock.
bool wifi_access_save_net (const char *ssid, const char *pass)
void wifi_access_forget (void)
void wifi_access_set_code (bool on)
void wifi_access_discard (void)
bool wifi_access_take (const uint8_t **img, uint32_t *bytes, fw_image_info_t *info)
void wifi_access_release (void)
wa_got_t wifi_access_fetch_start (wa_job_t job, fw_version_t want, wa_channel_t ch, wa_why_t gate)
void wifi_access_fetch_tick (wa_why_t abort)
void wifi_access_fetch_get (wa_fetch_t *out)
bool wifi_access_home (char *ssid, size_t n)

Detailed Description

The panel's Wi-Fi: the radio, the page's HTTP (hypertext transfer protocol) server, the mDNS (multicast domain name system) name and the NVS (non-volatile storage) entry of the home network.

What the radio may do and when is shared/webaccess (wa_session.h), which the host suite holds; this file carries it out. The radio is off at every start and comes up only on wifi_access_start(). Nothing about it touches the bench: the link and the heartbeat run as before while it is up.

One task brings the radio up and down, so no caller waits for it: the UI (user interface) loop asks, and reads what is (wifi_access_get()). An image the page receives is kept in PSRAM (pseudo-static random-access memory) until the operator installs or drops it; the page never starts a write.

The same radio carries the panel's own requests to GitHub (wa_fetch.h): the release check and the download of a release's image, each on the kept home network, in WA_MODE_FETCH, without page or name. A download leaves its image staged where an upload leaves one, for the same installer.

SPDX-License-Identifier: MIT

Function Documentation

◆ wifi_access_close()

void wifi_access_close ( wa_off_t why)

Radio off for why; see wa_close().

Parameters
whyThe reason.

◆ wifi_access_discard()

void wifi_access_discard ( void )

Drop a received or staged image. Nothing while one is taken.

◆ wifi_access_down()

bool wifi_access_down ( void )

Whether the radio is wholly off and no start of it is asked for; from any task, without the lock.

A start asked for counts as up from the call on, a close until the station or access point is stopped and its interface is gone. A GitHub fetch task still in a name lookup then does not hold it up: it sends nothing while the radio stays off, and no fetch job starts before it ends.

Returns
true when the radio is off and nothing asks for it

◆ wifi_access_fetch_get()

void wifi_access_fetch_get ( wa_fetch_t * out)

The job, as a copy.

◆ wifi_access_fetch_start()

wa_got_t wifi_access_fetch_start ( wa_job_t job,
fw_version_t want,
wa_channel_t ch,
wa_why_t gate )

Start job (wa_fetch_start()) for release want (DOWNLOAD only) on channel ch (CHECK: which releases it looks at) unless gate says why not. WA_GOT_NONE: the radio comes up in WA_MODE_FETCH and the job runs; otherwise it has ended at once. A DOWNLOAD drops an image the page left staged first; while one is taken, or the last job's task has not ended yet, it is BLOCKED for BUSY. Refused on a session another screen runs: the caller starts no job while WI-FI is open.

◆ wifi_access_fetch_tick()

void wifi_access_fetch_tick ( wa_why_t abort)

Once a frame, after wifi_access_tick(): abort as wa_fetch_tick() takes it. Moves the job on, ends it, switches the radio off when it has ended, and starts the task that talks to GitHub once joined.

◆ wifi_access_forget()

void wifi_access_forget ( void )

FORGET: no home network, the access code on.

◆ wifi_access_home()

bool wifi_access_home ( char * ssid,
size_t n )

Whether a home network is kept, and its name into ssid of n bytes (empty for none).

◆ wifi_access_init()

esp_err_t wifi_access_init ( uint32_t slot,
const fw_image_info_t * running )

Read the kept home network and set up the task. slot is the largest image taken, running the build that runs. The radio stays off. On a failure nothing is kept, and no other call of this file may be made: the panel runs without Wi-Fi until the next start.

◆ wifi_access_release()

void wifi_access_release ( void )

After a write that failed: the image is dropped.

◆ wifi_access_save_net()

bool wifi_access_save_net ( const char * ssid,
const char * pass )

Keep a home network; false when wa_conf_set_net() refuses it.

◆ wifi_access_set_german()

void wifi_access_set_german ( bool de)

The page's language.

◆ wifi_access_start()

wa_off_t wifi_access_start ( wa_mode_t mode,
wa_off_t gate )

Start in mode unless gate says why not; see wa_start().

◆ wifi_access_take()

bool wifi_access_take ( const uint8_t ** img,
uint32_t * bytes,
fw_image_info_t * info )

Take the staged image for the installer: it stays where it is, and nothing drops it, until wifi_access_release(). False when none waits.

◆ wifi_access_tick()

bool wifi_access_tick ( wa_off_t gate,
bool stop,
bool may_write )

Once a frame: the gate, STOP pressed since the last call, the time-outs; and a change to what is kept written when may_write.

Parameters
gatewa_gate()'s answer.
stopSTOP pressed since the last call.
may_writeFlash may be written now.
Returns
Whether this call switched the radio off or ended its linger (wa_tick()).