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

Example for the AsyncPrinter #30

Closed
ripleyXLR8 opened this issue Oct 23, 2016 · 3 comments
Closed

Example for the AsyncPrinter #30

ripleyXLR8 opened this issue Oct 23, 2016 · 3 comments
Labels

Comments

@ripleyXLR8
Copy link

Hi,

Thank you for your work on this library, it is very usefull.

Do you have any example about using the AsyncPrinter?

Best regards

Richard

@psuter80
Copy link

psuter80 commented Mar 10, 2018

disclaimer: i am not at all proficient in c++, but here is how i got it to work in combination with WiFiManager to establish a wifi connection first:

#include <DNSServer.h>            //Local DNS Server used for redirecting all requests to the configuration portal
#include <ESP8266WebServer.h>     //Local WebServer used to serve the configuration portal
#include <WiFiManager.h>          //https://github.com/tzapu/WiFiManager WiFi Configuration Magic
#include <AsyncPrinter.h>

AsyncPrinter ap;
WiFiManager wifiManager;
 
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  wifiManager.autoConnect();
  ap.connect("192.168.1.122",3333);
  ap.println("hello world");
}
 
void loop() {
  // put your main code here, to run repeatedly:
}

on the computer with ip 192.168.1.122 you need to listen to port 3333 to receive the hello world message. under linux you can use netcat:
nc -l 3333

now upload and run the above sketch and you should see "hello world" printed to your console running netcat.

Update: i noticed only after posting this, that the AsyncPrinter::connect() function blocks forever if it cannot connect to the given IP or Hostname. In order to avoid this you would need to modify the
while(_client->state() < 4)
loop in the connect function, or you simply remove it and then let your sketch handle the waiting.

@stale
Copy link

stale bot commented Sep 21, 2019

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 21, 2019
@stale
Copy link

stale bot commented Oct 5, 2019

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Oct 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants