Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Different behaviour using the src_cpp or src_h lib#80

AnsweredbyTwaste
Twaste asked this question inQ&A
Discussion options

Dear Developers,
first of all congrats to that lib! It is a pleasure to see all those opportunities for usage!
Great job!

I did 2 tests with "Async_ConfigOnDoubleReset" example without any change in the example code except using once the new h-Implementation from src_h and in the second test using the old cpp/h implementation from src_cpp

Test 1:
Setup: HW ESP8266EX
IDE: platformio
lib-source: src_h

Test 2:
Setup: HW ESP8266EX
IDE: platformio
lib-source: src_cpp

Using the src_h sources the examples compiles, builds and works after uploading to the device without any problems. Using the src_cpp sources the project compiles, links and can be uploaded, but the ESP hangs up after:

"Starting configuration portal @ 192.168.4.1, SSID = ESP_3D8963, PWD = MyESP_3D8963"

Since I would like to integrate the lib in another project, due to multiple linker warnings, I want to use the src_cpp.

Whats the difference here?

Thanks in advance!

You must be logged in to vote

Sure. I will do tomorrow.

Replies: 6 comments 7 replies

Comment options

Changing ESPAsync_WiFiManager.h accordingly to prevent multiple definition linker error solved the problem in the project and the manager is working.

However this is not solving the problem described above which is just a simple replacement of the sources in the example.

You must be logged in to vote
0 replies
Comment options

Possibly my mistake in copying the files, the only difference betweensrc andsrc_cpp as follows :

Can you try to modify this lineESPAsync_WiFiManager.cpp#L570

to

wifi_ssid_count_t n = WiFi.scanNetworks(false, true);

from

wifi_ssid_count_t n = WiFi.scanNetworks();

then retest / post the result.

You must be logged in to vote
0 replies
Comment options

Thx. I discovered first this difference and tested it before asking here for help. However, unfortunately with the same result. Even after changing ESPAsync_WifiManager.cpp#L570 accordingly the error still exists. :-(

You must be logged in to vote
1 reply
@khoih-prog
Comment options

I also just tested and confirmed the issue.

I found out the culprit is the compiler is not working perfectly, as expected, forcpp files. The definitions in.ino as well as other related.h files are not taken into account. I have to rewrite the library's src_cpp and will publish a new version soon.

For example

/home/kh/Arduino/khoih-prog_working/ESPAsync_WiFiManager_GitHub/examples/Async_ConfigOnDoubleReset_TZ/Async_ConfigOnDoubleReset_TZ.ino:317:2: warning: #warning Using static IP [-Wcpp]  317 | #warning Using static IP      |  ^~~~~~~In file included from /home/kh/Arduino/khoih-prog_working/ESPAsync_WiFiManager_GitHub/examples/Async_ConfigOnDoubleReset_TZ/Async_ConfigOnDoubleReset_TZ.ino:340:/home/kh/Arduino/libraries/ESPAsync_WiFiManager-1.9.8/src/ESPAsync_WiFiManager.h:77:6: warning: #warning USING_ESP8266_CORE_VERSION "3.0.2" [-Wcpp]   77 |     #warning USING_ESP8266_CORE_VERSION "3.0.2"  <=========== Correct ============      |      ^~~~~~~In file included from /home/kh/Arduino/khoih-prog_working/ESPAsync_WiFiManager_GitHub/examples/Async_ConfigOnDoubleReset_TZ/Async_ConfigOnDoubleReset_TZ.ino:340:/home/kh/Arduino/libraries/ESPAsync_WiFiManager-1.9.8/src/ESPAsync_WiFiManager.h:249:6: warning: #warning Forcing USE_CLOUDFLARE_NTP for ESP8266 as low memory can cause blank page [-Wcpp]  249 |     #warning Forcing USE_CLOUDFLARE_NTP for ESP8266 as low memory can cause blank page      |      ^~~~~~~In file included from /home/kh/Arduino/libraries/ESPAsync_WiFiManager-1.9.8/src/ESPAsync_WiFiManager.cpp:52:/home/kh/Arduino/libraries/ESPAsync_WiFiManager-1.9.8/src/ESPAsync_WiFiManager.h:125:6: warning: #warning USING_ESP8266_CORE_VERSION "2.4.2" [-Wcpp]  125 |     #warning USING_ESP8266_CORE_VERSION "2.4.2"  <================ Not correct  ============

That's why I hate the.cpp format, and trying to force the usage ofh-only code.

Hopefully somedayh-only style will be used more widely when people realize the benefit of it. Just think about including.h only when necessary and you'll be OK.

Comment options

I see! Thx for your fast respnse!! Just a few changes in the .h and it can be used even in the "old style" cpp's without the linker warnings and everthing works fine. That's a simple workaraound.

You must be logged in to vote
1 reply
@khoih-prog
Comment options

Just a few changes in the .h and it can be used even in the "old style" cpp's without the linker warnings and everthing works fine.

Could you post thesimple workaraound for other people to use if necessary. Thanks.

Comment options

Sure. I will do tomorrow.

You must be logged in to vote
4 replies
@Twaste
Comment options

The workaround I used for my project is very simple.

Problem description:
Back to origin of the tests, I tried to integrate the lib into my project within a new .h/.cpp class definition which was leading to the well known issue described here:Linker error. I followed the instructions to use the src_cpp sources resulting in a hanging ESP8266. To reproduce the problem without influences of my own code and project I tested the example as described inmy first post with the given result.

Solution for my project:
Within the declaration file e.g. "dummy.h" include theESPAsync_WiFiManager.h and uncommentESPAsync_WiFiManager.h#L819.

In the according implementation file "dummy.cpp" start with#include "dummy.h", as usual ;-), and afterwards#include "ESPAsync_WiFiManager-Impl.h". This impedes the linker error and enables the usage of the pure "h" implmentation without the described hang-up.

This is an obvious workaround for the "multiple definitions" problem and uses the "linear" .h action without the need of the src_cpp files.

Anyway this doesn't solve the problem of the above mentioned "Async_ConfigOnDoubleReset" example. But I used this just for a neutral test. However if you want to use the example there is no need of using the src_cpp files by just using the src_h files without any problem.

@khoih-prog
Comment options

Good test,

I think you can try this way, if OK, we certainly don't need the src_cpp anymore

  1. ReplacingAsync_ConfigOnDoubleReset.ino#L192

from

#include <ESPAsync_WiFiManager.h>               //https://github.com/khoih-prog/ESPAsync_WiFiManager

to

#include <ESPAsync_WiFiManager.h>               //https://github.com/khoih-prog/ESPAsync_WiFiManager#include <ESPAsync_WiFiManager-Impl.h>          //https://github.com/khoih-prog/ESPAsync_WiFiManager
  1. Delete or uncommentESPAsync_WiFiManager.h#L819
#include "ESPAsync_WiFiManager-Impl.h"

This will have the benefit ofh-only implementation, along with your solution.

@khoih-prog
Comment options

I'm testingyour new way and OK. Will change the new release to useyour way. Much cleaner than what I'm trying to do so far.

@Twaste
Comment options

Sounds good. You're solutions for the example seems straight forward. Did not think about it any longer so late in the evening ;-).

Thx for the great support and your libs! I like them and your work including the TimerInterrupt lib which is very helpful!

Answer selected byTwaste
Comment options

The newESPAsync_WiFiManager release v1.10.0 has just been published. Your contribution is noted inContributions and Thanks

Check the edited and new example for how to avoidmultiple-definitions linker error

  1. HOWTO Fix Multiple Definitions Linker Error
  2. Async_ConfigOnDoubleReset_Multi

I'm looking forward to receiving more of your contributions

Best Regards,


Releases v1.10.0

  1. Fixmultiple-definitions linker error and weird bug related tosrc_cpp. CheckDifferent behaviour using the src_cpp or src_h lib #80
  2. Optimize library code by usingreference-passing instead ofvalue-passing
You must be logged in to vote
1 reply
@Twaste
Comment options

Thanks for the new release. It is working now in my project without any errors!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@Twaste@khoih-prog

[8]ページ先頭

©2009-2025 Movatter.jp