-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWiFiPortal.h
More file actions
62 lines (48 loc) · 2.02 KB
/
Copy pathWiFiPortal.h
File metadata and controls
62 lines (48 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
WiFiPortal.h — multi-network WiFi store, non-blocking connect state machine,
and an AP captive portal for first-time setup.
Up to NET_MAX_CREDS SSID/password pairs live in NVS. When the WiFi CAT
transport is switched on the state machine walks the saved list; if the list is
empty, or nothing on it answers, it raises a soft AP with a captive portal so
credentials can be entered from a phone or laptop.
Nothing here blocks: netPoll() must be called from loop() and returns
immediately. Scans are asynchronous.
*/
#ifndef WIFIPORTAL_H
#define WIFIPORTAL_H
#include <Arduino.h>
#define NET_MAX_CREDS 5
#define NET_AP_SSID "T-Embed-CAT"
#define NET_DEFAULT_PORT 1234
enum NetState
{
NET_OFF = 0, // transport disabled, radio silent
NET_CONNECTING, // trying a saved network
NET_CONNECTED, // station up, CAT TCP server listening
NET_PORTAL // soft AP + captive portal running
};
void netBegin();
void netPoll();
bool netEnabled(); // the user's persisted preference
void netSetEnabled(bool en); // persisted
// Suspend powers the WiFi hardware down without touching the stored preference, so
// it comes back by itself. Used while a USB host is attached: tethered, the radio
// does not need WiFi for control, and the RF is better off quiet.
void netSetSuspended(bool sus);
bool netSuspended();
NetState netGetState();
// Human-readable one-liners for the radio's screen.
String netStatusShort(); // "192.168.1.42", "connecting", "AP setup", "off"
String netStatusDetail();
String netIP();
String netApIP(); // soft-AP address, for the setup banner
String netSSID();
uint8_t netCredCount();
uint16_t netGetCatPort();
void netStartPortal(); // force the setup portal up
void netOpenSetup(); // portal for configuration only: does not enable the
// transport, and powers WiFi back down on close
void netStopPortal();
bool netPortalActive();
bool netRadioOn(); // is the WiFi hardware powered at all?
#endif