ESP8266 as a serial port server, how to save parameters?

Juraj:
look at WiFiManager library

Thanks for the pointer,
but my use case is a bit different:

  1. The ESP8266 is supposed to always run in AP mode because the controlling Android device should connect to the ESP rather than the opposite way. It is a system used in the field and there are no WiFi networks in the neighborhood.
  2. The config web page shall always be present so one can connect to it and modify the system parameters
  3. The "modify" action on the webpage must be password protected, can be as simple as putting a string into an edit box and have this checked server side as a first item in processing a commit.

Given this and after reading the Readme.md file it feels like an overwhelming project for me to cut stuff from this advanced library...
Even the OnDemandConfigPortal seems to assume the basic target of starting a config to allow setting up a connection to an existing WiFi network in station mode...

SPIFFS can be useful for web server static files. I use and maintain a little the arduio.org's orphaned WiFiLink firmware (purpose is network adapter for arduino).

the source code of the WiFi Link firmware is an example of complex web server on esp8266.

I will definitely look at this!
I have had to shut down my experiments with EEPROM storage of parameters, could not get it to work properly and I had to move on with the main task. But going with file storage for the config data is really attractive if it can be done!
A question here: Is there a function to upload files from my PC onto the file system in the ESP8266 using Arduino?

Now I am trying to set up a debug environment where I use PuTTY on my PC to talk to the TCP server at port 2001, but then I had to ifdef using the station mode rather than the AP mode, otherwise my PC would not be able to reach the ESP8266.
Anyway I have this in my code now:

  #ifdef USESTATION 
    WiFi.mode(WIFI_STA);  //WIFI_AP, WIFI_STA, WIFI_AP_STA, WIFI_OFF
    WiFi.begin(STASSID.c_str(), STAPWD.c_str());
    IP2str(ipbuf, WiFi.localIP());
    MsgDbg = "STA ADDR = " + String(ipbuf); SerialDebug.println(MsgDbg); 
  #else
    WiFi.mode(WIFI_AP);  //WIFI_AP, WIFI_STA, WIFI_AP_STA, WIFI_OFF
    WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
    WiFi.softAP(APSSID.c_str(), APPASSWD.c_str());
  #endif

My problem here is that the debug printing of the IP address I need to know to connect PuTTY always sends 0.0.0.0.
I thought that WiFi.localIP should give me the IP address handed out by my router's DHCP but it does not happen.
In fact the printout comes so fast when I reset the module so I think that the WiFi.begin(...) call returns immediately rather than wait until it has connected.
Is there a way to get it to block until it is connected or a timeout happens?

BosseB:
I will definitely look at this!
I have had to shut down my experiments with EEPROM storage of parameters, could not get it to work properly and I had to move on with the main task. But going with file storage for the config data is really attractive if it can be done!
A question here: Is there a function to upload files from my PC onto the file system in the ESP8266 using Arduino?

yes. see WebUpdate example of the ESP8266WiFi library. main goal there is program update, but of course it includes the http upload

BosseB:
My problem here is that the debug printing of the IP address I need to know to connect PuTTY always sends 0.0.0.0.

check the examples
wait for connection

WiFi.waitForConnectResult() == WL_CONNECTED

Juraj,
I am sorry to have bothered you like this but please accept my gratitude because your help has been very good!
Now I have gotten the connection message I need to connect with PuTTY!
But could you tell me if there is some documentation that has all of these methods documented?
I have used the Arduino IDE reference search to find the WiFi documentation but the local WiFi.html does not mention all methods. Same with the online version.
And the web resource for the ESP8266WiFi library is also incomplete.
So then remains asking....

You see the examples in Arduino IDE File menu? There is a section for the ESP8266 libraries.

the esp8266 IDE package is referred as "arduino esp8266 core" so use it this for google searches.

the reference is here

I have had to shut down my experiments with EEPROM storage of parameters, could not get it to work properly and I had to move on with the main task.

This example of using ESP8266 "EEPROM" for configuration information may help. It is designed for a stand-alone test. It has been tested with Arduino ESP8266 core 2.4.0 and an Adafruit Huzzah breakout. You should see the runNumber (variable #2) increase on each new start :

//
//  ESP8266 EEPROM Demo
//  Uses EEPROM.read() and EEPROM.write() because EEPROM.put() and EEPROM.get() dont appear to work for the example structure.
//  magicString[] is so the program recognises its own initialised EEPROM structure,
//  Change this to simulate loading to a 'fresh' eeprom (or incompatible version of eeprom structure )
//

#include "Arduino.h"
#include <EEPROM.h>

const int EEPROMSIZE = 256 ;
const char magicString[] = "te15" ;   // 4 chars - used for EEPROM initialisation / version change

typedef union {
  struct {
    char eepromLayourVersion[5];  // magicString
    unsigned int runNumber ; // incremented on reboot
    bool networkMode ; // false = standalone.

    //screen calibration
    float xScale ;
    float xShift ;
    float yScale ;
    float yShift ;
    //wlan
    char ssid[32];
    char psk[64];
    char remoteHost[32] ;
  } ;
  byte store[EEPROMSIZE] ;
} config_t ;

config_t config ;



void ICACHE_FLASH_ATTR eepromFetch() {
  for ( int i = 0 ; i < EEPROMSIZE ; i++ ) {
    config.store[i] =  EEPROM.read(i);  // one byte at a time
  }
}


void ICACHE_FLASH_ATTR eepromDump() {
  for ( int i = 0 ; i < EEPROMSIZE ; i++ ) {
    EEPROM.write(i, config.store[i] );  // one byte at a time
  }
  EEPROM.commit();
}



void ICACHE_FLASH_ATTR PrintEepromVariables() {

  Serial.println (F("============================")) ;
  Serial.println (F("EEPROM contents:")) ;

  Serial.println ( config.eepromLayourVersion ) ;
  Serial.println ( config.runNumber ) ;
  Serial.println ( config.networkMode ) ;

  Serial.println ( config.ssid ) ;
  Serial.println ( config.psk ) ;
  Serial.println ( config.remoteHost ) ;
  Serial.println ( config.xScale ) ;
  Serial.println ( config.xShift ) ;
  Serial.println ( config.yScale ) ;
  Serial.println ( config.yShift ) ;

  Serial.println (F("============================")) ;
}



void ICACHE_FLASH_ATTR validateInitialiseEeprom( ) {
  /*
     If Eprom unconfigured or at old version level, the Eeprom is reset to 'factory' condition.
     Eeprom has version number.
  */
  Serial.println ( "Validating Eeprom." ) ;
  bool valid = false ;

  if ( strncmp( config.eepromLayourVersion , magicString, 5 ) == 0 ) valid = true ;
  else {
    Serial.print( "eepromCode layout version mismatch. Cleaning Eeprom. Found: " ) ;
    // Serial.print ( config.eepromLayourVersion ) ;
    Serial.println() ;
    Serial.println ( "Restoring Eeprom to factory condition." ) ;
    // 'factory' settings.
    //  Adapt these as required - initialise all config variables.
    //
    strcpy( config.eepromLayourVersion , magicString ) ;
    config.runNumber = 0 ;
    config.networkMode = false;

    // screen model specific - depepdent on rotation / flipping of touch screen
    config.xScale =  1.0 / 11.0  ;
    config.xShift =  170  ;
    config.yScale =  1.0 / 14.9 ;
    config.yShift =  220 ;

    //wlan
    strcpy( config.psk, "PSKabc123" ) ;  //
    strcpy( config.ssid, "mySSID" ) ;  //
    strcpy( config.remoteHost, "www.xyz.com" ) ;  //
    eepromDump() ;
    eepromFetch() ;
  }
}

void setup() {
  Serial.begin(74880) ;
  delay(500) ;
  Serial.println() ;
  Serial.println("eeprom test:") ;
  EEPROM.begin( EEPROMSIZE ) ;
  eepromFetch() ;
  validateInitialiseEeprom( ) ;
  PrintEepromVariables() ;

  config.runNumber++ ;
  eepromDump() ;

}


void loop() {
  // put your main code here, to run repeatedly:

}