Skip to content

Common Configs

suraj inamdar edited this page May 10, 2020 · 3 revisions

Common Configs

Common file contains mostly enable/disable actions for features and services, for example below directives used to enable or disable GPIO / MQTT services are found in common config file

Toggle GPIO / MQTT Service (enabled by default)

/**
 * enable/disable gpio and mqtt feature here
 */
#define ENABLE_MQTT_SERVICE
#define ENABLE_GPIO_SERVICE

Just comment any service line, it will make disappear respective feature/service from front panel.

Toggle Email Service (enabled by default)

To enable/disable mail service in same way use below option

/**
 * enable/disable email service here
 */
#define ENABLE_EMAIL_SERVICE

Enable Serial Log (enabled by default)

/**
 * enable/disable serial log
 */
#define EW_SERIAL_LOG

Enable auto factory reset on invalid config found (enabled by default)

This option enables device to set default config if it finds invalid configurations in database. manually it can be achieved by continue pressing flash key on nodemcu like boards for 6-7 seconds. you can set flash key pin and duration in below FLASH_KEY_PIN config. If you are uploading this framework first time on device then obviously factory reset will trigger since framework will not found any valid configuration on new device

/**
 * enable/disable auto factory reset on invalid database config found
 */
#define AUTO_FACTORY_RESET_ON_INVALID_CONFIGS

Toggle Exception Notifier Service (disabled by default)

We have a exception notifier service which makes use of file system and mail service. whenever exception happens notifier will keep its stack traced data in file system and will send it to user through existing mail channel if mail service is enabled. it is useful in remote application where user can not monitor device exceptions. from received exception we can decode the exception and can find out a immediate solution on it.

/**
 * enable/disable exception notifier
 */
// #define ENABLE_EXCEPTION_NOTIFIER

Toggle HTTP Server (enabled by default)

Let disable server to decrease memory overheads and keep device working in background with their defined tasks

/**
 * enable/disable http server feature here
 */
#define ENABLE_EWING_HTTP_SERVER

Ignore free relay connections (enabled by default)

This is to ignore special case of relay connections. suppose if we create network of more than one esp's with the same ssid and password for every device ( to connect freely to each other ) then the free relay connections starts. This is one of possible case considered when we have to keep internet repeating functionality for any area coverage using more than one esp's devices for single router then based on internet status devices keep disconnecting and connecting to nearby devices within specific provided timeout. To avoid this in normal conditions we have to enable this option. there are still many dependencies configs which needed to this config takes effect

/**
 * ignore free relay connections created by same ssid
 */
#define IGNORE_FREE_RELAY_CONNECTIONS

Toggle subnetting (disabled by default)

As we discussed above about free relay connections using same ssid for esp's in network, this config is used to enable dynamic subnetting.

Now what it does, actually whenever esp change its connections to another router ( due to internet unavailability on existing router ) then whatever sub network ip it gets from router ( another esp can also be router in ap mode ) it takes that idea of routers network and creates its own sub network by adding +1 to its subnet octet

e.g. if device get 192.168.0.1 with subnet mask of 255.255.255.0 then it start its network with 192.168.1.1 with same subnet mask

with this we can also get to know that at which hop a corresponding device is operating

/**
 * enable/disable network subnetting ( dynamically set ap subnet,gateway etc. )
 */
// #define ENABLE_DYNAMIC_SUBNETTING

Toggle Internet Based Connections (disabled by default)

In free relay network discussed above we can enable internet based connection ability by uncommenting below directive. It simply ping google public DNS ip internally to decide whether it has internet or not. If it found not connected to internet around 1 minute then it put current router in block list ( for temporary period ) and then switch to new networks provided by other routers

/**
 * enable/disable internet availability based station connections
 */
// #define ENABLE_INTERNET_BASED_CONNECTIONS

Toggle ESPNOW (disabled by default)

This config will toggle espnow service for framework. it is mostly useful in mesh network scenarios where small amount of data and interconnections in between nearby radio devices are required. Also we can make its use to know network hierarchy of current network i.e. which device connected to which in network

/**
 * enable/disable esp now feature here
 */
// #define ENABLE_ESP_NOW

Flash key Settings

This config used to define flash button pin on device to which switch is connected. Continuous pressing this switch creates flash counts per duration defined. Once switch press continuity reaches counts to its threshold it resets the device to its default settings i.e. all its configs login,wifi,email,mqtt etc will get sets to defaults

/**
 * @define flash key parameters for reset factory
 */
#define FLASH_KEY_PIN             D3
#define FLASH_KEY_PRESS_DURATION  MILLISECOND_DURATION_1000
#define FLASH_KEY_PRESS_COUNT_THR 5

WiFi/Internet Connectivity Duration

WIFI_STATION_CONNECT_ATTEMPT_TIMEOUT decides the amount of timeout seconds for which device will try to connect to station network. WIFI_CONNECTIVITY_CHECK_DURATION decides wifi connectivity check cycle i.e. after every this duration device checks whether it is connected to station or not. If not then it will try to reconnect. INTERNET_CONNECTIVITY_CHECK_DURATION decides duration cycle to check internet availability on connected network

/**
 * @define wifi & internet connectivity check cycle durations
 */
#define WIFI_STATION_CONNECT_ATTEMPT_TIMEOUT 5  // will try to connect within this seconds
#define WIFI_CONNECTIVITY_CHECK_DURATION MILLISECOND_DURATION_10000
#define INTERNET_CONNECTIVITY_CHECK_DURATION WIFI_CONNECTIVITY_CHECK_DURATION

NAPT feature configs

These settings made available on lwip variants. It check which lwip version is running and based on that decides whether to enable napt feature for framework

/**
 * @define network address & port translation feature
 */
#if IP_NAPT && LWIP_VERSION_MAJOR==1
  #define ENABLE_NAPT_FEATURE
#elif IP_NAPT && LWIP_VERSION_MAJOR==2
  #define ENABLE_NAPT_FEATURE_LWIP_V2
#endif

#if defined( ENABLE_NAPT_FEATURE ) || defined( ENABLE_NAPT_FEATURE_LWIP_V2 )
  #define NAPT_INIT_DURATION_AFTER_WIFI_CONNECT MILLISECOND_DURATION_5000
#endif

Username/Password

These are default username and password, you can change them as per yours

/**
 * @define default username/ssid and password
 */
#define USER            "esp8266Stack"
#define PASSPHRASE      "espStack@8266"

Task Scheduler Configs

Here we can define how much task scheduler can keep in their task queues. Factory reset tasks are special tasks which runs only on factory reset event

/**
 * max tasks and callbacks
 */
#define MAX_SCHEDULABLE_TASKS	25
#define MAX_FACTORY_RESET_CALLBACKS	MAX_SCHEDULABLE_TASKS
#define MAX_EVENT_CALLBACK_TASKS	MAX_SCHEDULABLE_TASKS

You can add many other custom common configs which you considered for your application