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

Cannot use http post method with ethernet.client when ariadne ethernet.reset in use #21

Open
loathingKernel opened this issue May 10, 2017 · 1 comment

Comments

@loathingKernel
Copy link
Owner

From @PhilFluffy on February 10, 2017 7:33

Hi thanks for reading this, I know its been a while since a release, but this bootloader is so useful to me I hope its not just left in a sunset phase now.
I'm trying to use ariadne with its ethernet reset server alongside my sketch for some home automation equipment (saves massively and avoids laptops up ladders to update my controllers in odd locations). One of the tasks that does is send out a http POST to a remote home-assistant automation server with a JSON formatted string so it can keep the master house gui in sync with all the nodes.

When I enable reset.check in the main loop, the following code stops working

if (jsonclient.connect(Configuration.extJsonServer, Configuration.extJsonServerPort)) {
  // Make a HTTP JSON request:
  mylocalJsonData = (F("POST /api/states/switch."));
  Serial.print (F("inner loop json data is "));Serial.print (String(mylocalJsonData)+ "\n");
} else { Serial.print ("Error :- "+String(jsonclient)+ "\n");}

In the serial log I see this
" Error :- 0"
Error code zero indicating failed connection of course. And it also doesn't send the packets out the interface at all on tcpdump output.
My sketch has 2 other ethernet services which function fine, (udp for ntp client, and ethernet server listening on port 80 http use in my sketch which uses GET requests) so it seems its just the outbound POST from my arduino ethernet tcp as a client affected.

If I comment out reset.check(); in the main loop, the json POST starts working. It has to be a POST to authenticate to the remote server in the JSON headers.

I read a post from a few years ago from Stelios Tsampas where he was discussing how to work around a similar sounding issue, is it documented somewhere and this issue now solved?
http://developers.arduino.narkive.com/m4JMgDNs/remotely-resetting-an-arduino

As a workaround, I already have a authenticated section in my configuration web gui, can I call a reset method from that instead of running a whole daemon on a higher port with a check in the main loop just for the reset? I already have a function that calls the following to do a soft reset after updating network config in eeprom, I could just expand that out if so.
asm volatile (" jmp 0");

Copied from original issue: codebndr#37

@loathingKernel
Copy link
Owner Author

From @PhilFluffy on February 10, 2017 9:54

Ok, as a workaround I have the following function in my sketch instead of the ethernet.reset server on high numbered port functionality, in case its of use to anyone else . This code shamelessly stolen from Ethernet::watchdogReset() in EthernetReset.cpp

void reflashReset() {
NetEEPROM.writeImgBad();
delay(10);
wdt_disable();
wdt_enable(WDTO_2S);
while(1);
asm volatile (" jmp 0"); // This is probably pointless as it has to make it past a while (true) statement to get here!
}
Tested and I still have working json AND remote reset functionality. Thanks for writing Ariadne!

I'll leave this open in case the fact that its a POST outgoing helps debug someone else's problem too.

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

No branches or pull requests

1 participant