ESP8266 NODEMCU v3 hangs main code without WiFi connections

ESP8266 nodemcu v3, blynk server wifi connect, Library version 0.6.1, FlProg program.

In my project I need to run main code with or without wifi connection. Main program is running without any settings from Blynk APP. I just need to send (and maybe receive in another project) some informations to Blynk APP.

The problem is that ESP8266 Nodemcu CAN NOT start without wifi connection when I using blynk. I need start without wifi connection and reconnect when wifi is connected.

I already tried solution from this theme Code isn't working without connected Blynk but it did not helped me or I do not know how to use it

I`m not very good with coding, this code made by compilator of FlProg visual programing, but I understand basic things.

If somebody know how to fix it, please edit my code and I`ll try to understand it. Thanks)

#include <ESP8266WiFi.h>
#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

extern "C" {
#include "user_interface.h";
}
#define BLYNK_PRINT_253055626_1 Serial

char auth_253055626_1[] = "";
unsigned long virt_203190254_1;
float input_OldValue_203190254_1= 0; 
bool ESP8266ControllerWifiClient_HRD = 0;
bool ESP8266ControllerWifiClient_status = 1;
bool ESP8266ControllerWifiClient_isDHCP = 1;
bool ESP8266ControllerWifiClient_IsNeedReconect = 0;
bool ESP8266ControllerWifiClient_workStatus = 1;
char ESP8266ControllerWifiClient_SSID[40] = "wifii";
char ESP8266ControllerWifiClient_password[40] = "pass";
IPAddress ESP8266ControllerWifiClient_ip(0, 0, 0, 0);
 IPAddress  ESP8266ControllerWifiClient_dns (0, 0, 0, 1);
 IPAddress  ESP8266ControllerWifiClient_gateway (0, 0, 0, 1);
IPAddress ESP8266ControllerWifiClient_subnet (255, 255, 255, 0);
 uint8_t ESP8266ControllerWifiClient_mac[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
bool _gen1I = 0;
bool _gen1O = 0;
unsigned long _gen1P = 0UL;
bool _count1I = 0;
unsigned long _count1_Value = 0UL;
bool _gen2I = 0;
bool _gen2O = 0;
unsigned long _gen2P = 0UL;
void setup()
{
WiFi.mode(WIFI_STA);
_esp8266WifiModuleClientReconnect();
pinMode(2, OUTPUT); 

  Blynk.begin(auth_253055626_1, ESP8266ControllerWifiClient_SSID, ESP8266ControllerWifiClient_password);
  
void loop()
{if(ESP8266ControllerWifiClient_IsNeedReconect) {_esp8266WifiModuleClientReconnect(); ESP8266ControllerWifiClient_IsNeedReconect = 0; }
ESP8266ControllerWifiClient_status = WiFi.status() == WL_CONNECTED;
if (ESP8266ControllerWifiClient_status) { if ( ! ESP8266ControllerWifiClient_HRD) { ESP8266ControllerWifiClient_ip =  WiFi.localIP();
ESP8266ControllerWifiClient_subnet =  WiFi.subnetMask();
ESP8266ControllerWifiClient_gateway =  WiFi.gatewayIP();
ESP8266ControllerWifiClient_dns =  WiFi.dnsIP();
WiFi.macAddress(ESP8266ControllerWifiClient_mac);
ESP8266ControllerWifiClient_HRD = 1;
}} else {ESP8266ControllerWifiClient_HRD = 0;}

// I tried this to fix the problem
if (WiFi.status() != WL_CONNECTED) { 
  Blynk.run();
}



//Плата:1
if (1) { if (! _gen2I) { _gen2I = 1; _gen2O = 1; _gen2P = millis(); } } else { _gen2I = 0 ; _gen2O= 0;}
 if (_gen2I) {  if ( _isTimer ( _gen2P , 500 )) { _gen2P = millis(); _gen2O = ! _gen2O;}}
digitalWrite(2, !(_gen2O));


  


//Плата:3
if (1) { if (! _gen1I) { _gen1I = 1; _gen1O = 1; _gen1P = millis(); } } else { _gen1I = 0 ; _gen1O= 0;}
 if (_gen1I) {  if ( _isTimer ( _gen1P , 500 )) { _gen1P = millis(); _gen1O = ! _gen1O;}}
if (_gen1O){
if ( ! _count1I) { 
_count1I = 1;
_count1_Value = _count1_Value + 1;
}} else {
_count1I = 0;}
virt_203190254_1 = _count1_Value;

  Send_203190254_1();




}
bool _isTimer(unsigned long startTime, unsigned long period )
  {
  unsigned long currentTime;
currentTime = millis();
if (currentTime>= startTime) {return (currentTime>=(startTime + period));} else {return (currentTime >=(4294967295-startTime+period));}
  }
void Send_203190254_1()
{
 
  
    if(virt_203190254_1 != input_OldValue_203190254_1)
    {
        Blynk.virtualWrite(V0, virt_203190254_1);
        input_OldValue_203190254_1 = virt_203190254_1;
    }
   
}
int hexStrToInt(String instring)
{
  byte len = instring.length();
  if  (len == 0) return 0;
  int result = 0;
  for (byte i = 0; i < 8; i++)   // только первые 8 цыфар влезуть в uint32
  {
    char ch = instring[i];
    if (ch == 0) break;
    result <<= 4;
    if (isdigit(ch))
      result = result | (ch - '0');
    else result = result | (ch - 'A' + 10);
  }
  return result;
}
 void _esp8266WifiModuleClientReconnect()
{
 if( _checkMacAddres(ESP8266ControllerWifiClient_mac)) {  wifi_set_macaddr(0, const_cast<uint8*>(ESP8266ControllerWifiClient_mac));}
if( ESP8266ControllerWifiClient_isDHCP) { WiFi.config(0U, 0U, 0U, 0U, 0U); } else { 
WiFi.config(ESP8266ControllerWifiClient_ip, ESP8266ControllerWifiClient_gateway, ESP8266ControllerWifiClient_subnet, ESP8266ControllerWifiClient_dns , ESP8266ControllerWifiClient_dns );
}
 WiFi.begin(ESP8266ControllerWifiClient_SSID, ESP8266ControllerWifiClient_password);
}
bool _checkMacAddres(byte array[])
{
  bool result = 0;
  for (byte i = 0; i < 6; i++)
  {
    if (array[i] == 255) {
      return 0;
    }
    if (array[i] > 0 ) {
      result = 1;
    }
  }
  return result;
}

Blynk.begin is blocking function.
Read this:


Use Blynk.config and Blynk.connect

Pete.

Thank you very much! It helped me.