<commit_before>#include "CommLgc.h"
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include "Configuration.h"

#include <FS.h>
#include <ArduinoJson.h>
#include <Hash.h>
#include <ESP8266WebServer.h>

int ledState = LOW;             // used to set the LED state
long previousMillis = 0;        // will store last time LED was updated
long bl_interval = 200;
IPAddress default_IP(192,168,240,1);  //defaul IP Address
String HOSTNAME = DEF_HOSTNAME;

ESP8266WebServer server(80);    //server UI

void setup() {

  pinMode(WIFI_LED, OUTPUT);      //initialize wifi LED
  digitalWrite(WIFI_LED, LOW);
  ArduinoOTA.begin();             //OTA ESP
  CommunicationLogic.begin();
  SPIFFS.begin();
  initHostname();
  initWebServer();                 //UI begin
  setWiFiConfig();
  initMDNS();

}

void loop() {

  ArduinoOTA.handle();
  CommunicationLogic.handle();
  handleWebServer();
  wifiLed();

}

void initMDNS(){

  MDNS.begin(HOSTNAME.c_str());
  MDNS.setInstanceName(HOSTNAME);
  MDNS.addServiceTxt("arduino", "tcp", "fw_name", FW_NAME);
  MDNS.addServiceTxt("arduino", "tcp", "fw_version", FW_VERSION);

}

void initHostname(){
  //retrieve user defined hostname
  String tmpHostname = Config.getParam("hostname");
  if( tmpHostname!="" )
    HOSTNAME = tmpHostname;
  WiFi.hostname(HOSTNAME);

}

void wifiLed(){

  unsigned long currentMillis = millis();
  int wifi_status = WiFi.status();
  if ((WiFi.getMode() == 1 || WiFi.getMode() == 3) && wifi_status == WL_CONNECTED) {
    if (currentMillis - previousMillis > bl_interval) {
      previousMillis = currentMillis;
      if (ledState == LOW)
        ledState = HIGH;
      else
        ledState = LOW;
      digitalWrite(WIFI_LED, ledState);
    }
  }
  else if (WiFi.softAPgetStationNum() > 0 ) {   //LED on in AP mode
    digitalWrite(WIFI_LED, HIGH);
  }
  else //if (wifi_status !=WL_CONNECTED){
    digitalWrite(WIFI_LED, LOW);

}

void setWiFiConfig(){

  //set AP+STA mode
  WiFi.mode(WIFI_AP_STA);
<commit_msg>upd: change wifi led behavior<commit_after>#include "CommLgc.h"
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include "Configuration.h"

#include <FS.h>
#include <ArduinoJson.h>
#include <Hash.h>
#include <ESP8266WebServer.h>

int ledState = LOW;             // used to set the LED state
long previousMillis = 0;        // will store last time LED was updated
long ap_interval = 50;         //blink interval in ap mode
IPAddress default_IP(192,168,240,1);  //defaul IP Address
String HOSTNAME = DEF_HOSTNAME;

ESP8266WebServer server(80);    //server UI

void setup() {

  pinMode(WIFI_LED, OUTPUT);      //initialize wifi LED
  digitalWrite(WIFI_LED, LOW);
  ArduinoOTA.begin();             //OTA ESP
  CommunicationLogic.begin();
  SPIFFS.begin();
  initHostname();
  initWebServer();                 //UI begin
  setWiFiConfig();
  initMDNS();

}

void loop() {

  ArduinoOTA.handle();
  CommunicationLogic.handle();
  handleWebServer();
  wifiLed();

}

void initMDNS(){

  MDNS.begin(HOSTNAME.c_str());
  MDNS.setInstanceName(HOSTNAME);
  MDNS.addServiceTxt("arduino", "tcp", "fw_name", FW_NAME);
  MDNS.addServiceTxt("arduino", "tcp", "fw_version", FW_VERSION);

}

void initHostname(){
  //retrieve user defined hostname
  String tmpHostname = Config.getParam("hostname");
  if( tmpHostname!="" )
    HOSTNAME = tmpHostname;
  WiFi.hostname(HOSTNAME);

}

void wifiLed(){

  unsigned long currentMillis = millis();
  int wifi_status = WiFi.status();
  if ((WiFi.getMode() == 1 || WiFi.getMode() == 3) && wifi_status == WL_CONNECTED) {    //wifi LED in STA MODE
    if (currentMillis - previousMillis > ap_interval) {
      previousMillis = currentMillis;
      if (ledState == LOW){
        ledState = HIGH;
        ap_interval = 200;    //time wifi led ON
      }
      else{
        ledState = LOW;
        ap_interval = 2800;   //time wifi led OFF
      }
      digitalWrite(WIFI_LED, ledState);
    }
  }
  else{ //if (WiFi.softAPgetStationNum() > 0 ) {   //wifi LED on in AP mode
    if (currentMillis - previousMillis > ap_interval) {
      previousMillis = currentMillis;
      if (ledState == LOW){
        ledState = HIGH;
        ap_interval = 950;
      }
      else{
        ledState = LOW;
        ap_interval = 50;
      }
      digitalWrite(WIFI_LED, ledState);
    }
  }

}

void setWiFiConfig(){

  //set AP+STA mode
  WiFi.mode(WIFI_AP_STA);

{'fraction_non_alphanumeric': 0.13526896241278416, 'fraction_numerical': 0.01823092505064146, 'mean_word_length': 3.172769953051643, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6332440', 'n_tokens_mistral': 1681, 'n_tokens_neox': 1603, 'n_words': 361}