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

Thingspeak: cleanup #2140

Merged
merged 5 commits into from
Feb 9, 2020
Merged

Thingspeak: cleanup #2140

merged 5 commits into from
Feb 9, 2020

Conversation

mcspr
Copy link
Collaborator

@mcspr mcspr commented Feb 9, 2020

  • fix _tspk_client shadowing in callback code
  • fix sync client configuration, use correct settings chain
  • refactor async client, add enum state variable instead of two bools
  • refactor sync client, drop raw wificlient

@mcspr mcspr merged commit 80bff31 into xoseperez:dev Feb 9, 2020
@mcspr mcspr deleted the cleanup branch February 9, 2020 01:41
@mcspr mcspr mentioned this pull request Feb 10, 2020
Comment on lines +306 to +320
char headers[strlen_P(THINGSPEAK_REQUEST_TEMPLATE) + url.path.length() + url.host.length() + 1];
snprintf_P(headers, sizeof(headers),
THINGSPEAK_REQUEST_TEMPLATE,
url.path.c_str(),
url.host.c_str(),
_tspk_data.length()
);

_tspk_client.print(headers);
_tspk_client.print(_tspk_data);
client->print(headers);
client->print(_tspk_data);

nice_delay(100);
nice_delay(100);

String response = _tspk_client.readString();
int pos = response.indexOf("\r\n\r\n");
unsigned int code = (pos > 0) ? response.substring(pos + 4).toInt() : 0;
DEBUG_MSG_P(PSTR("[THINGSPEAK] Response value: %u\n"), code);
_tspk_client.stop();
const auto response = client->readString();
int pos = response.indexOf("\r\n\r\n");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This whole part should be HTTPClient, since we have it readily available from #include <ESP8266HTTPClient.h>
At least we will know about the status code.

mcspr added a commit that referenced this pull request Feb 18, 2020
- continue #2140 , use the correct implementation for http requests not confuse code readers with our parsing
- fix data sender data duplication, run build test
- add note that this is actually really RAM heavy, some connection failures are not easily distinguishable from any code errors and are simply OOM.

also
- fix arduinoota prototype error when building without it (... ino2cpp, again)
- add comment about 160mhz into the platformio.ini
@mcspr mcspr added this to the 1.14.2 milestone Mar 13, 2020
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.

None yet

1 participant