Skip to content

Conversation

@robertlipe
Copy link
Collaborator

Description

Removed UrlEncode third-party dependency.

  • Add include/UrlEncode.h proto and new (better) body in src/network.cpp.
    Uses RFC 1738 style percent-encoding.
  • Guarded the urlEncode function and its usage in src/deviceconfig.cpp with #if ENABLE_WIFI. It may be possible to do better later, but we agree for now that without WIFI, there is no URL.
  • Removed unused includes of UrlEncode.h from PatternStocks.h and PatternSubscribers.h.

Contributing requirements

  • I read the contribution guidelines in CONTRIBUTING.md.
  • I understand the BlinkenPerBit metric, and maximized it in this PR.
  • I selected main as the target branch.
  • All code herein is subjected to the license terms in COPYING.txt.

robertlipe and others added 4 commits January 5, 2026 03:03
…ncode

include/effects/matrix/PatternSubscribers.h: Removed unused include of UrlEncode
platformio: Remove external dependency of UrlEncode
src/deviceconfig.cpp: If we don't have WiFi, we don't have a URL.
src/network.cpp: Add textbook implementaion of urlEncode.

effects/matrix/PatternSubscribers.h: Removed unused include of UrlEncode
Copy link
Collaborator

@rbergen rbergen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may elicit a "yeah, right" from you, but I saw this one coming when we were discussing #788. :)

I have a couple of comments. I expect their phrasing will show I feel (much) more strongly about one than the other.

Comment on lines 108 to 116
DeviceConfig::ValidateResponse DeviceConfig::ValidateOpenWeatherAPIKey(const String &newOpenWeatherAPIKey)
{
#if ENABLE_WIFI
HTTPClient http;

String url = "http://api.openweathermap.org/data/2.5/weather?lat=0&lon=0&appid=" + urlEncode(newOpenWeatherAPIKey);

http.begin(url);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should "if #ENABLE_WIFI" the whole ValidateOpenWeatherAPIKey() function, obviously including its declaration in deviceconfig.h. Anything calling it should also not be enabled when WIFI isn't.

(This may sound like nitpicking, but I just hate a function conditionally not doing what it clearly claims to do.)


#include <Arduino.h>

String urlEncode(const String& str);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we add a comment to indicate where the definition lives, that not being UrlEncode.cpp.
Which is something I was actually going to challenge, but I can see the logic after thinking it through from a few different angles.

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