Re-connection issue with Blynk Edgent and NodeMCU

Ok, i have also removed them but still the same issue,

It was just to re-create and show you what and where the issue was as per your suggestions,

i would not like it too but you have seen i just re-produced the issue with fresh .ino files therefore no need to relate anything from the previous posts and replies

I think the language barrier is the cause of misunderstanding, after all those steps have been taken which were recommended by you,

specially after this line :point_up_2:

I am still expecting you would point to some logic where the code is hanging/blocking, it is crystal clear in my last above replies as all those steps were taken under your directions, please tell me what point is not understandable at least.

It is also a good suggestion unfortunately has been tried and no luck, also the piggy-backing timer works fine. BTW i did not understand the word ā€œpiggy-backingā€
as the edgentTimer always run during the different mode changes therefore canā€™t be neglected/left so easily, also the edgentTimer is itself a Blynktimer object therefore it is not problematic in any case.

again repeating blynk.run() in the config.h is blocking the code when ā€œpower on but no internet caseā€, should we declare it the a bug in blynk library dear Pete ?

@PeteKnight Hello Pete, i still have the same issue can you please suggest me something further

Iā€™ve taken a step back from this topic because you havenā€™t taken on board my suggestion to present your aims and the issues you are facing in a clear and concise manner.
All Iā€™m seeing is lots of serial output without any corresponding commentary, and repeated comments that youā€™re simply doing what Iā€™ve asked you to do.

Iā€™ll happily come back to it if you start from the beginning and explain the issue in detail and document what problems you are encountering, with updated code and focussed and well documented serial output which relates to that code and demonstrates these issues.

Pete.

From what I understand, BLYNK Edgent is blocking. That is, without internet it just keeps on trying to connect, and will not allow other parts of the program to run.

Someone please correct me if this has changed, or if I am wrong about this.

I tried a sketch with some offline actions and it worked very well without internet connection.

Well that is good to hear. I may have to give it another try when I get some time. I currently use WIFImanager, and have been for some time.

I will send you the sketch

@John93 Hello John, did you even first of all powered your device when internet was not available ???

@PeteKnight Well, you have taken a step back but you did not point the un-understandable point in my code and serial output i just request you to re-create the problem by using simple code which i have posted. There is only one simple problem

  • That simple code is not executing when i power my ESP12E when internet is not available, thatā€™s it.

I am wondering what part of serial outputs are not understandable in my previous posts, its quite weird, i need your help seriously bro. Iā€™ve mentioned the problem, the piece of code and the serial output, what can i give further more?

I donā€™t think I could be much clearer about the fact that dumping hundreds of lines of serial output into the topic without any commentary isnā€™t helping others to understand what point you are trying to demonstrate with each of these pieces of information.

It wonā€™t. Blynk.begin is a blocking function. The solution is to manage the WiFi connection yourself, then use Blynk.config and Blynk.begin to establish the connection to the Blynk server in a non-blocking way if the connection canā€™t be made.
Blynk.run (or BlynkEdgent.run) will also force Blynk to try to re-connect each time itā€™s called, so a Blynk.connected test is needed to avoid this slowing down the code execution.

Pete.

@Hashmi123

What do you mean exactly ?

@John93 i mean that first of all just make sure that your device has no internet access and then power it up and show me the serial output.

@PeteKnight I told you that i am facing the stopping of code execution at Blynk.run() inside this function void enterConnectCloud() and specifically i would say its a Blynk.connect() inside the Blynk.run() which is cause of stopping the code execution.
Its important, i am using BlynkEdgent.begin() and BlynkEdgent.run() therefore it was assumed that no more blocking will be faced due to newly upgraded Blynk.Edgent libraries,

I would like to try this suggestion also and soon will show you the output, however i supposed these tasks were now taken care completely by the Blynk.Edgent

and so far for this, i am tell you this Blynk.connected test is being very well carried out by Blynk.Edgent, here you can see in Configmode.h file :point_down:

while ((timeoutMs > millis()) && (!Blynk.isTokenInvalid()) && (Blynk.connected() == false))
         {
          delay(10);
          
          Blynk.run();
          app_loop();

          
          if (!BlynkState::is(MODE_CONNECTING_CLOUD)) 
             {Blynk.disconnect();
              return;}
           }

There isnā€™t a Blynk.Edhent library as such. All of the ā€œlibraryā€ files are contained within the sketch, so you have full visibility of what they do and when.

As you can see when you look at the .h tabs within the example file, Blynk.Edgent is simply a wrapper for the underlying Blynk library files, which have changed very little since Blynk Legacy.

Yes, this will try to execute Blynk.run every time itā€™s called and Blynk.connected is false. When using Blynk.config every time Blynk.run is called when Blynk.connected is false, a re-connection attempt to the server will be made. This has a default timeout of 30 seconds, so calling it constantly will in effect block all code execution when a connection is not possibleā€¦

Try reading this topic from here:

Pete.

In Settings.h the new timeout is 60 seconds ā€¦

but in connecting cloud mode Blynk.run() is called in while loop thats why it is blocking ā€¦

please suggest me a way out of this situation ā€¦

We seem to be having a conversation about the same issue in two different places. Maybe you should choose one place and stick to it, and try to phrase your questions/comments way that are easier to follow.

I think weā€™re talking about two different timeouts here. Iā€™m referring to the default that is applied if you donā€™t specify a timeout period in the Blynk.connect() command.

Pete.