Edgent and Merging Old sketch Issues

I know that Edgent is an option but I want to use it to have the OTA and Wifi saving credentials.
I modified the example with the two defines for Blynk Iot, ulpoaded in my ESP32 TTGO T1 and it works fine and I see my device Online.

I also added the 2 defines in my old sketch and it works great.

Now i’m trying to merge my old sketch into the edgnet example.

When I compile I receive errore and can’t go further.

The error comes out after adding the BlynkSimpleEsp32.h in my sketch.

Invalid library found in D:\IoT\Arduino\GitHub\bek\libraries\libraries: no headers files (.h) found in D:\IoT\Arduino\GitHub\bek\libraries\libraries

sketch\blynk_app.cpp.o: In function `blynk_dbg_print(char const*, …)’:

D:\IoT\Arduino\GitHub\bek\libraries\Blynk\src/Blynk/BlynkParam.h:348: multiple definition of `blynk_dbg_print(char const*, …)’

sketch\Edgent_ESP32.ino.cpp.o:D:\IoT\Arduino\GitHub\bek\libraries\Blynk\src/Blynk/BlynkDebug.h:179: first defined here

sketch\blynk_app.cpp.o:(.bss.Blynk+0x0): multiple definition of `Blynk’

sketch\Edgent_ESP32.ino.cpp.o:(.bss.Blynk+0x0): first defined here

sketch\blynk_app.cpp.o:(.literal.BlynkWidgetWrite0+0xc): undefined reference to `g_event_queue_handle’

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for “SD.h”

Used: C:\Users\nasse\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\libraries\SD

Not used: D:\IoT\Arduino\Arduino-nightly\libraries\SD

Multiple libraries were found for “WiFi.h”

Used: C:\Users\nasse\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\libraries\WiFi

Not used: D:\IoT\Arduino\Arduino-nightly\libraries\WiFi

exit status 1

Error compiling for board TTGO T1.

Is there any way to do the reverse, I mean merging Edgent into my Old sketch keeping only the OTA functionality?

thanks

These two statements seem to contradict each other.
Do you want dunamic provisioning and Blynk.Air, or just Blynk.Air ?

As far as your error messages are concerned, start with resolving the first one, then try re-compiling.

Pete.

Why the two statements are in conflict? I need to use Blynk.Air and Wifi Provisioning from Edgent to put them into my old Sketch which has no Blynk.Air.

How to resolve the first one?
The only way to avoid the error is when I comment the EdgentEsp32.Ino in my sketch leaving the rest unchanged, there I get my device online and I canuse Blynk Iot on my mobile but obviously without Blynk.Air and Wifi Provisioning…

Thanks

If you just wanted Blynk.Air (which is what you seemed to say in your latter statement) then there is a way to add this.
But, if you want Blynk Dynamic Provisioning then the Edgent sketch is really the only sensible starting point.

Pete.

Yes, I need to add only Blynk.Air which is included in my Plan… How to add it to my Sketch?

Once again, your contradicting yourself.

FYI, Blynk.Air and Blynk Dynamic provisioning are included in all plans.

Pete.

Tried it and not working, from my Console I can start Blynk.Air and send the bin file but the Live is always blinking and the bin never reach my ESP32… How long it takes to complete the operation?

A few seconds normally.
What does the Blynk.Air log show?

Pete.

Do you mean the report generated in the Consol :slight_smile:
SDP,41916,“2022-05-31 17:20:31”,“STARTED”
SDP,41916,“2022-05-31 17:20:33”,“STARTED”
SDP,41916,“2022-05-31 17:20:33”,“REQUEST_SENT”

Where and when should I declare or place the OTA.h? or just leave it in the sketch as it is ? it is no called from any where…

Please note that Edgent_Esp32 sketch is completely commented to avoid the previously mentioned error when comping…

Your screenshot is unreadable.
Please post your code as text, with triple backticks at the beginning and end.
Triple bill look like this:
```

There is no point in putting this code into the Edgent example sketch. You said that you wanted to…

Pete.

The Edgent is the there but as said is completely commented and can be removed but I keep it there commented for eventual fixing issue and using it… In this way I don’t have the compiler error.

In the Edgent example the OTA.h was called by declaring the Edgent_esp32.h in the main ino sketch which by its turn decalres also the OTA.h.

If I declare it in my main ino sketch I get error…
OTA.h:22:12: error: expected constructor, destructor, or type conversion before ‘(’ token
BLYNK_WRITE(InternalPinOTA) {

#include "main.h"

#include "OTA.h"

 reciever avReceiver;
 sim800L sms; 
 otaUpload ota; 
 blynk myBlynk;
 fireBase fb;

here is the code of OTA.h

#include <Update.h>
#include <HTTPClient.h>
//________________________________________________________________
String overTheAirURL = "";

void reboot()
{
#if defined(ARDUINO_ARCH_MEGAAVR)
  wdt_enable(WDT_PERIOD_8CLK_gc);
#elif defined(__AVR__)
  wdt_enable(WDTO_15MS);
#elif defined(__arm__)
  NVIC_SystemReset();
#elif defined(ESP8266) || defined(ESP32)
  ESP.restart();
#else
  #error "MCU reset procedure not implemented"
#endif
  for (;;) {}
}

BLYNK_WRITE(InternalPinOTA) {
  overTheAirURL = param.asString();
  HTTPClient http;
  http.begin(overTheAirURL);
  int httpCode = http.GET();
  if (httpCode != HTTP_CODE_OK) {return;}
  int contentLength = http.getSize();
  if (contentLength <= 0) {return; }
  bool canBegin = Update.begin(contentLength);
  if (!canBegin) { return;}
  Client& client = http.getStream();
  int written = Update.writeStream(client);
  if (written != contentLength) {return;}
  if (!Update.end()) {return;}
  if (!Update.isFinished()) {return;}
reboot();
}

Once again, you’re making contradictory statements about what your goals are and how you intend to achieve them.

I’m going to take a step back from this topic, it’s too frustrating for my liking.

Good luck with whatever it is you’re trying to achieve.

Pete.

Thanks,

I could figure alone how it works… For any blynker like me who is struggeling to use Blynk.Air inside his old Sketch without the use of Edgent, just put this code anywhere outside of the main loop in your sketch and it works immeditelay… It is like a simple BLYNK_WRITE but not with a virtual or physical Pin but with InternalPinOTA deaclared in the library…

#include <Update.h>
#include <HTTPClient.h>
void reboot()
{
#if defined(ARDUINO_ARCH_MEGAAVR)
  wdt_enable(WDT_PERIOD_8CLK_gc);
#elif defined(__AVR__)
  wdt_enable(WDTO_15MS);
#elif defined(__arm__)
  NVIC_SystemReset();
#elif defined(ESP8266) || defined(ESP32)
  ESP.restart();
#else
  #error "MCU reset procedure not implemented"
#endif
  for (;;) {}
}

BLYNK_WRITE(InternalPinOTA) {
  String overTheAirURL = param.asString();
  HTTPClient http;
  http.begin(overTheAirURL);
  int httpCode = http.GET();
  if (httpCode != HTTP_CODE_OK) {return;}
  int contentLength = http.getSize();
  if (contentLength <= 0) {return; }
  bool canBegin = Update.begin(contentLength);
  if (!canBegin) { return;}
  Client& client = http.getStream();
  int written = Update.writeStream(client);
  if (written != contentLength) {return;}
  if (!Update.end()) {return;}
  if (!Update.isFinished()) {return;}
reboot();
}