ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
wifi_hal_core.c File Reference

The example's join+DHCP journey, hardware-free so it is host-testable. More...

#include <stdint.h>
#include "ra8_err.h"
#include "ra8_wifi.h"
#include "wifi_hal_join.h"
Include dependency graph for wifi_hal_core.c:

Go to the source code of this file.

Functions

static bool wifi_hal_settle (ra8_wifi_t *wifi, uint32_t budget)
 Poll the Wi-Fi facade until association or budget exhaustion.
bool wifi_hal_join_run (const wifi_hal_run_cfg_t *cfg, wifi_hal_result_t *out)
 The example's whole network journey, hardware-free: init, join, DHCP.

Variables

const char k_wifi_hal_pass_line []
 The exact PASS line the run prints; the HIL gate keys on it.
const char k_wifi_hal_fail_line []
 The summary FAIL line the run prints when it did not reach an IP.

Detailed Description

The example's join+DHCP journey, hardware-free so it is host-testable.

Tag
[Ring 6 / APP] {World: S}

Implements wifi_hal_join_run – the exact orchestration main.c runs on the board, with every hardware, RTOS and console dependency lifted out to the caller. It drives only the ra8_wifi facade and records what happened in an wifi_hal_result_t, so the same logic runs on silicon (bound to the C6 backend and a NetX DHCP provider) and in tests/mocks/src/test_app_wifi_hal_join.c (bound to a mock backend and a canned provider). No printf, no ThreadX, no board.

Since
0.1.0

Definition in file wifi_hal_core.c.

Function Documentation

◆ wifi_hal_join_run()

bool wifi_hal_join_run ( const wifi_hal_run_cfg_t * cfg,
wifi_hal_result_t * out )
nodiscard

The example's whole network journey, hardware-free: init, join, DHCP.

The wiring this example demonstrates, extracted so it is testable on the host exactly as it runs on the board. It initialises the facade, checks that runtime credentials are non-empty, connects, settles the association, reads the MAC and AP record, and obtains an IP – recording each fact in out and stopping at the first step that fails. It performs no I/O of its own; the caller prints from out.

Parameters
[in]cfgInjected dependencies; must be non-null with a facade config and handle.
[out]outResult to populate; must be non-null.
Returns
true when the journey reached a bound IP (out->passed).
Return values
trueThe station associated and DHCP leased an address.
falseA step failed; out says how far it got.
Precondition
The facade config's backend hardware (or mock) is ready.
cfg->ssid is NUL-terminated.
Postcondition
out is fully populated, including on every failure path.
On success out->ip_bound and out->passed are true.
Note
Not thread-safe; it drives the facade. Touches no hardware, RTOS or console, so it runs unchanged in a host test.
Example:
if (wifi_hal_join_run(&cfg, &res)) { announce(res.lease.ip); }
uint32_t ip
Leased station address, or zero if unbound.
Definition ra8_wifi.h:234
ra8_wifi_lease_t lease
The DHCP lease, once bound.
bool wifi_hal_join_run(const wifi_hal_run_cfg_t *cfg, wifi_hal_result_t *out)
The example's whole network journey, hardware-free: init, join, DHCP.
struct wifi_hal_result wifi_hal_result_t
See also
wifi_hal_result
Since
0.1.0

Definition at line 71 of file wifi_hal_core.c.

References wifi_hal_result::ap, wifi_hal_result::associated, wifi_hal_result::connect_err, wifi_hal_result::init_err, wifi_hal_result::init_ok, wifi_hal_result::ip_bound, wifi_hal_result::ip_err, k_ra8_err_not_initialized, k_ra8_ok, wifi_hal_result::lease, wifi_hal_result::mac, wifi_hal_result::passed, wifi_hal_run_cfg::poll_budget, wifi_hal_run_cfg::psk, ra8_wifi_connect(), ra8_wifi_get_ap(), ra8_wifi_get_mac(), ra8_wifi_init(), ra8_wifi_wait_ip(), wifi_hal_run_cfg::ssid, wifi_hal_run_cfg::wifi, wifi_hal_run_cfg::wifi_cfg, and wifi_hal_settle().

Referenced by wifi_hal_run().

◆ wifi_hal_settle()

bool wifi_hal_settle ( ra8_wifi_t * wifi,
uint32_t budget )
static

Poll the Wi-Fi facade until association or budget exhaustion.

A slow association can outlast ra8_wifi_connect's internal wait, so this helper performs the caller-bounded continuation polls and a final status sample after the last poll.

Parameters
[in,out]wifiInitialized Wi-Fi facade to poll.
[in]budgetMaximum continuation polls.
Returns
Association outcome.
Return values
trueA status sample reported association.
falseNo sample reported association within the budget.
Precondition
wifi is non-null and initialized.
The caller has already issued a connect request.
Postcondition
At most budget continuation polls were issued.
The facade remains initialized and caller-owned.
Note
Not thread-safe; the worker is the sole facade owner.
Since
0.1.0

Definition at line 52 of file wifi_hal_core.c.

References ra8_wifi_status::associated, k_ra8_ok, k_ra8_wifi_link_down, ra8_wifi_poll(), and ra8_wifi_status().

Referenced by wifi_hal_join_run().

Variable Documentation

◆ k_wifi_hal_fail_line

const char k_wifi_hal_fail_line[]
Initial value:
=
"wifi_hal: FAIL Wi-Fi join to a DHCP lease did not complete\r\n"

The summary FAIL line the run prints when it did not reach an IP.

The counterpart to k_wifi_hal_pass_line; specific failures also print a diagnostic sub-line that HIL_EXPECT_NEGATIVE matches.

Since
0.1.0

Definition at line 32 of file wifi_hal_core.c.

Referenced by wifi_hal_worker_entry().

◆ k_wifi_hal_pass_line

const char k_wifi_hal_pass_line[]
Initial value:
=
"wifi_hal: PASS ra8_wifi joined the bench Wi-Fi and DHCP leased an address\r\n"

The exact PASS line the run prints; the HIL gate keys on it.

Shared by the core (which selects it) and main.c (which prints it), so the string the host test asserts is the string that reaches the console on silicon. hil.conf's HIL_EXPECT is a substring of it.

Since
0.1.0

Definition at line 30 of file wifi_hal_core.c.

Referenced by wifi_hal_worker_entry().