Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 5m timeout to captive portal #61

Merged
merged 2 commits into from
Mar 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/OXRS_Rack32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,13 +611,25 @@ void OXRS_Rack32::_initialiseNetwork(byte * mac)
// Ensure we are in the correct WiFi mode
WiFi.mode(WIFI_STA);

// We use WifiManager library from /~https://github.com/tzapu/WiFiManager
// to handle WiFi connection and credential persistence etc.
WiFiManager wm;

// If the captive portal is launched and nothing happens for a while then
// reboot - this helps if we come online before an AP (e.g. power outage)
// and prevents us sitting in captive portal mode indefinitely
wm.setConfigPortalTimeout(WM_CONFIG_PORTAL_TIMEOUT_S);

// Connect using saved creds, or start captive portal if none found
// NOTE: Blocks until connected or the portal is closed
WiFiManager wm;
bool success = wm.autoConnect("OXRS_WiFi", "superhouse");
if (!wm.autoConnect("OXRS_WiFi", "superhouse"))
{
_logger.println(F("[ra32] failed to connect to wifi access point, rebooting"));
ESP.restart();
}

_logger.print(F("[ra32] ip address: "));
_logger.println(success ? WiFi.localIP() : IPAddress(0, 0, 0, 0));
_logger.println(WiFi.localIP());
#else
_logger.print(F("[ra32] ethernet mac address: "));
_logger.println(mac_display);
Expand Down
23 changes: 13 additions & 10 deletions src/OXRS_Rack32.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,28 @@
#include <OXRS_API.h> // For REST API
#include <OXRS_LCD.h> // For LCD runtime displays

// WifiManager
#define WM_CONFIG_PORTAL_TIMEOUT_S 300

// Ethernet
#define ETHERNET_CS_PIN 26
#define WIZNET_RESET_PIN 13
#define DHCP_TIMEOUT_MS 15000
#define DHCP_RESPONSE_TIMEOUT_MS 4000
#define ETHERNET_CS_PIN 26
#define WIZNET_RESET_PIN 13
#define DHCP_TIMEOUT_MS 15000
#define DHCP_RESPONSE_TIMEOUT_MS 4000

// I2C
#define I2C_SDA 21
#define I2C_SCL 22
#define I2C_SDA 21
#define I2C_SCL 22

// REST API
#define REST_API_PORT 80
#define REST_API_PORT 80

// Temperature update internal
#define DEFAULT_TEMP_UPDATE_MS 60000L
#define DEFAULT_TEMP_UPDATE_MS 60000L

// MCP9808 temperature sensor
#define MCP9808_I2C_ADDRESS 0x18
#define MCP9808_MODE 0
#define MCP9808_I2C_ADDRESS 0x18
#define MCP9808_MODE 0
// Mode Resolution SampleTime
// 0 0.5°C 30 ms
// 1 0.25°C 65 ms
Expand Down