Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for external client only scenario #29

Merged
merged 2 commits into from
Feb 8, 2024
Merged

Conversation

domingguss
Copy link
Contributor

@domingguss domingguss commented Feb 7, 2024

Hi, sorry to bug you again, but i did some more debugging after your comment here - then I found out I had to explicitly tell the library to disable wifi and ethernet in src/ESP_Google_Sheet_client_FS_Config.h (I uncommented the following lines):

/* If not use on-board WiFi */
#define ESP_GOOGLE_SHEET_CLIENT_DISABLE_ONBOARD_WIFI

/* If not use native Ethernet (Ethernet interfaces that supported by SDK) */
#define ESP_GOOGLE_SHEET_CLIENT_DISABLE_NATIVE_ETHERNET

But now the library was not compiling properly and I had to change a #ifdef in order for it to compile properly (see changes).

I also took the liberty of updating the README to explicitly underline this feature :)

Again, much kudos to your work on all your ESP libraries, they are really good and helpful!

@mobizt
Copy link
Owner

mobizt commented Feb 7, 2024

I don't think this is the issue because this is the port of my other library project which intensively tested especially networking test and all work fine.

And your changes about build options (native WiFi and ethernet) are not related to gsm network in anyway.

@domingguss
Copy link
Contributor Author

domingguss commented Feb 7, 2024

Ok, I think I may went too fast and did not explain it thoroughly, let me rephrase:

If I define these constants:

#define ESP_GOOGLE_SHEET_CLIENT_DISABLE_ONBOARD_WIFI
#define ESP_GOOGLE_SHEET_CLIENT_DISABLE_NATIVE_ETHERNET

I get this compile error:

/Users/dominggus/Documents/Arduino/libraries/ESP-Google-Sheet-Client/src/ESP_Google_Sheet_Client.cpp: In member function 'void GSheetClass::auth(const char*, const char*, const char*, const char*, esp_google_sheet_file_storage_type, esp_google_sheet_no_eth_module_t*)':
/Users/dominggus/Documents/Arduino/libraries/ESP-Google-Sheet-Client/src/ESP_Google_Sheet_Client.cpp:72:38: error: 'WiFi' was not declared in this scope
     config.internal.reconnect_wifi = WiFi.getAutoReconnect();
                                      ^~~~

To fix this error, I am proposing to change src/ESP_Google_Sheet_Client.cpp (71):

#if defined(ESP32) || defined(ESP8266)
    config.internal.reconnect_wifi = WiFi.getAutoReconnect();
#endif

to

#if defined(ESP_GOOGLE_SHEET_CLIENT_WIFI_IS_AVAILABLE)
    config.internal.reconnect_wifi = WiFi.getAutoReconnect();
#endif

@mobizt
Copy link
Owner

mobizt commented Feb 7, 2024

Actually, WiFi is the ESP32 Arduino Core library. Do you think is it strange?

This is likely you are using outdated ESP32 Core SDK.

@mobizt
Copy link
Owner

mobizt commented Feb 7, 2024

Additionally, the outdate ESP32 Arduino Core WiFi library has the reconnect bugs when this kind of function was called.

@domingguss
Copy link
Contributor Author

domingguss commented Feb 7, 2024

This is likely you are using outdated ESP32 Core SDK.

I'm using the latest version 2.0.11 from espressif, and have not installed the Arduino ESP32 Boards :

Screenshot 2024-02-07 at 16 17 29

How would you fix this compile error in your opinion?

@mobizt
Copy link
Owner

mobizt commented Feb 7, 2024

I don't have any issue for the Arduino IDE with latest ESP32 Core SDK v2.0.14.

The only issue is the forward declarations issue when the ESP_Google_Sheet_Client.h included on the top of TinyGsmClient.h as in GSM.ino example.

If TinyGsmClient.h was include before ESP_Google_Sheet_Client.h, there is no compilation error.

I have to update the GSM.ino example.

Note that from your image, V2.0.13 in the Boards Manager is from Arduino which supports only Arduino made ESP32 module.

@domingguss
Copy link
Contributor Author

domingguss commented Feb 7, 2024

Screenshot 2024-02-07 at 20 54 57

So I think you're missing my point..

If I tell the library to not use ESP's native Wifi nor Ethernet, the code in this function does not honor that, because it will try to use Wifi.getAutoReconnect() without checking whether Wifi should be used or not. In fact, it cannot even compile because Wifi cannot be found because it's inclusion is prevented by defining ESP_GOOGLE_SHEET_CLIENT_DISABLE_ONBOARD_WIFI see here

With my proposal, it will honor that.

I first wrote

#if (defined(ESP32) || defined(ESP8266)) && defined(ESP_GOOGLE_SHEET_CLIENT_WIFI_IS_AVAILABLE))

But then I found that ESP_GOOGLE_SHEET_CLIENT_WIFI_IS_AVAILABLE implies ESP32 or ESP8266 and hence can be simplified by only checking on the second condition.

@mobizt
Copy link
Owner

mobizt commented Feb 8, 2024

I don't miss anything.

Your mentioned about compilation error because of Wifi.getAutoReconnect() in ESP32 which WiFi was already included in GS_Network.h.

Your conclusion about ESP_GOOGLE_SHEET_CLIENT_DISABLE_ONBOARD_WIFI is not correct.

The function Wifi.getAutoReconnect() is only available in ESP32 and ESP8266 WiFi Core library.

There are many WiFi libraries (driver to work with WiFi module) from Arduino for Arduino boards that used u-blox module which don't have this function then we can't just use ESP_GOOGLE_SHEET_CLIENT_DISABLE_ONBOARD_WIFI for guarding.

You have to test on all devices or even compiling it on different platforms that library supported.

"platforms": "espressif32, espressif8266, atmelsam, ststm32, teensy, rp2040, renesas-ra"

@mobizt
Copy link
Owner

mobizt commented Feb 8, 2024

Ok I understand your point if this option is enabled, WiFi will never include because of the following line and cause the compilation error when WiFi function was later used.

#if !defined(ESP_GOOGLE_SHEET_CLIENT_DISABLE_ONBOARD_WIFI)

@mobizt mobizt merged commit 0f2f4f6 into mobizt:master Feb 8, 2024
23 checks passed
@domingguss
Copy link
Contributor Author

Ok I understand your point if this option is enabled, WiFi will never include because of the following line and cause the compilation error when WiFi function was later used.

Yes exactly, thanks for merging 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants