Skip to content

Commit

Permalink
airrohr-firmware.ino: Moving default IPv4 IP address to global variab…
Browse files Browse the repository at this point in the history
…les; Added back memmory usage table in header comments;
  • Loading branch information
Georgi Vidinski committed Nov 14, 2021
1 parent a7710e7 commit 20aad67
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ esp8266-arduino/.DS_Store
.DS_Store

compile_mac.sh


# Visual Studio Code
.vscode
.vs
31 changes: 28 additions & 3 deletions airrohr-firmware/airrohr-firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@
* *
* Please check Readme.md for other sensors and hardware *
* *
************************************************************************
*
* latest build using lib 3.1.0
* DATA: [==== ] 41.1% (used 33660 bytes from 81920 bytes)
* PROGRAM: [====== ] 57.4% (used 599441 bytes from 1044464 bytes)
*
************************************************************************/

#include <WString.h>
#include <pgmspace.h>

Expand Down Expand Up @@ -125,7 +132,7 @@ String SOFTWARE_VERSION(SOFTWARE_VERSION_STR);
******************************************************************/
namespace cfg {
unsigned debug = DEBUG;

unsigned time_for_wifi_config = 600000;
unsigned sending_intervall_ms = 145000;

Expand Down Expand Up @@ -254,6 +261,12 @@ ESP8266WebServer server(80);
WebServer server(80);
#endif

// default IPv4 address (ex. 192.168.4.1)
const uint8_t default_ip_first_octet = 192;
const uint8_t default_ip_second_octet = 168;
const uint8_t default_ip_third_octet = 4;
const uint8_t default_ip_fourth_octet = 1;

#include "./airrohr-cfg.h"

/*****************************************************************
Expand Down Expand Up @@ -1017,7 +1030,14 @@ static bool webserver_request_auth() {
}

static void sendHttpRedirect() {
server.sendHeader(F("Location"), F("http://192.168.4.1/config"));
const IPAddress defaultIP(
default_ip_first_octet,
default_ip_second_octet,
default_ip_third_octet,
default_ip_fourth_octet);

String defaultAddress = F("http://") + defaultIP.toString() + F("/config");
server.sendHeader(F("Location"), defaultAddress);
server.send(302, FPSTR(TXT_CONTENT_TYPE_TEXT_HTML), emptyString);
}

Expand Down Expand Up @@ -2063,7 +2083,12 @@ static void wifiConfig() {
#endif

WiFi.mode(WIFI_AP);
const IPAddress apIP(192, 168, 4, 1);
const IPAddress apIP(
default_ip_first_octet,
default_ip_second_octet,
default_ip_third_octet,
default_ip_fourth_octet);

WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
WiFi.softAP(cfg::fs_ssid, cfg::fs_pwd, selectChannelForAp());
// In case we create a unique password at first start
Expand Down

0 comments on commit 20aad67

Please sign in to comment.