cryptnox-pos 1.0.0
Standalone USDC payment terminal firmware (ESP32 + Cryptnox smart card)
Loading...
Searching...
No Matches
net.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: LGPL-3.0-or-later
3 * Copyright (c) 2026 Cryptnox SA
4 */
5
13
14#ifndef NET_H
15#define NET_H
16
17/******************************************************************
18 * 1. Included files
19 ******************************************************************/
20
21#include <stdint.h>
22#include <stdbool.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/******************************************************************
29 * 2. Types
30 ******************************************************************/
31
33typedef struct {
34 char ssid[33];
35 int8_t rssi;
36 bool open;
38
39/******************************************************************
40 * 3. Public API
41 ******************************************************************/
42
49void net_wifi_init(void);
50
58uint16_t net_wifi_scan(net_wifi_ap_t *out, uint16_t max);
59
68bool net_wifi_connect(const char *ssid, const char *password);
69
81void net_wifi_disconnect(void);
82
107bool net_ap_start(const char *ssid, const char *pass);
108
117void net_ap_stop(void);
118
129void net_wifi_keep_trying(void);
130
132bool net_wifi_online(void);
133
135bool net_wifi_reconnecting(void);
136
144bool net_wifi_rssi(int8_t *rssi_out);
145
168bool net_time_sync(uint32_t timeout_ms);
169
178void net_time_background(void);
179
180#ifdef __cplusplus
181}
182#endif
183
184#endif // NET_H
bool net_ap_start(const char *ssid, const char *pass)
Raise a WPA2 SoftAP as the radio's only interface, for phone-based configuration.
Definition net.cpp:215
void net_wifi_disconnect(void)
Drop the station association, without the retry loop pulling it back.
Definition net.cpp:268
void net_time_background(void)
Subscribe SNTP without waiting, so the clock is set whenever the network comes back.
Definition net.cpp:529
void net_wifi_keep_trying(void)
Hold on to the network last configured, even though it is down now.
Definition net.cpp:430
bool net_time_sync(uint32_t timeout_ms)
Block until the system clock has been set via SNTP and sanity-checked.
Definition net.cpp:536
void net_ap_stop(void)
Drop the SoftAP, return the radio to station-only, and re-join.
Definition net.cpp:286
bool net_wifi_rssi(int8_t *rssi_out)
Read the RSSI of the currently associated access point.
Definition net.cpp:448
bool net_wifi_online(void)
true while the station holds an IP address.
Definition net.cpp:437
bool net_wifi_connect(const char *ssid, const char *password)
Connect to a WiFi network and block until an IP is obtained (up to 30 s). May be called repeatedly to...
Definition net.cpp:376
uint16_t net_wifi_scan(net_wifi_ap_t *out, uint16_t max)
Scan for nearby access points (blocking).
Definition net.cpp:322
void net_wifi_init(void)
Bring up the WiFi driver in station mode (idempotent).
Definition net.cpp:175
bool net_wifi_reconnecting(void)
true while a kept network is down and the re-join is running.
Definition net.cpp:443
A scanned access point (subset of fields the UI needs).
Definition net.h:33
char ssid[33]
Definition net.h:34
bool open
Definition net.h:36
int8_t rssi
Definition net.h:35