no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
| — | esp_asyncprinter [16.03.2018 05:42] (current) – created Pascal Suter | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== ESP AsyncPrinter ====== | ||
| + | |||
| + | here is how to use the [[https:// | ||
| + | |||
| + | first we need to install the library: | ||
| + | cd <arduino directory>/ | ||
| + | git clone https:// | ||
| + | |||
| + | for my development machine to receive those messages i need to open a socket with '' | ||
| + | nc -l 3333 | ||
| + | and leave the terminal open. | ||
| + | |||
| + | now we could integrate it as is into our code as you can see in the example [[https:// | ||
| + | <code cpp> | ||
| + | while(_client-> | ||
| + | delay(1); | ||
| + | </ | ||
| + | |||
| + | let's add '' | ||
| + | |||
| + | <code cpp> | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | bool enableOnlineDebugging=true; | ||
| + | const char *debuggerHost=" | ||
| + | |||
| + | AsyncPrinter ap; | ||
| + | WiFiManager wifiManager; | ||
| + | bool debugOnline=false; | ||
| + | bool firstround=true; | ||
| + | |||
| + | void setup() { | ||
| + | // put your setup code here, to run once: | ||
| + | Serial.begin(115200); | ||
| + | wifiManager.autoConnect(); | ||
| + | wifiManager.startWebPortal(); | ||
| + | ap.connect(debuggerHost, | ||
| + | if(enableOnlineDebugging){ | ||
| + | //block for maximum 5 seconds trying to reach the debugger | ||
| + | for ( int i = 0; i < 10 ; i++){ | ||
| + | if(ap.connected()){ | ||
| + | debugOnline=true; | ||
| + | ap.println(" | ||
| + | break; | ||
| + | } else { | ||
| + | delay(500); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | void debug(const char *message){ | ||
| + | if(debugOnline){ | ||
| + | ap.println(message); | ||
| + | } else { | ||
| + | Serial.println(" | ||
| + | } | ||
| + | } | ||
| + | void loop() { | ||
| + | // put your main code here, to run repeatedly: | ||
| + | wifiManager.process(); | ||
| + | if(firstround){ | ||
| + | debug(" | ||
| + | firstround=false; | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | you should now see "setup done" and "hello world" on your terminal with '' | ||