For those not familiar with Telnet, it is just a TCP socket in port 23 where you send ASCII data... super simple... can not get simpler than that... I found this example: https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WiFi/examples/WiFiTelnetToSerial doing telnet to serial and pretty much reused that.
This is what I did. At the declarations I added:
- WiFiServer telnet(23);
- WiFiClient telnetClients;
- int disconnectedClient = 1;
- #define DEBUG_LOG_LN(x) { Serial.println(x); if(telnetClients) { telnetClients.println(x); } }
- #define DEBUG_LOG(x) { Serial.print(x); if(telnetClients) { telnetClients.print(x); } }
Basically for declaring the server (line 1), the client (line 2) and a pair of macros for sending logs to serial only or to serial and telnet if there is a telnet client.
In setup:
- telnet.begin();
- telnet.setNoDelay(true);
- DEBUG_LOG_LN("Telnet server started");
Start the telnet server (line 1), enable no delay (line 2) which disables the naggle algorithm that would buffer data before pushing it out on the TCP socket.
In loop:
- if (telnet.hasClient()) {
- if (!telnetClients || !telnetClients.connected()) {
- if (telnetClients) {
- telnetClients.stop();
- DEBUG_LOG_LN("Telnet Client Stop");
- }
- telnetClients = telnet.available();
- DEBUG_LOG_LN("New Telnet client");
- telnetClients.flush(); // clear input buffer, else you get strange characters
- disconnectedClient = 0;
- }
- }
- else {
- if(!telnetClients.connected()) {
- if(disconnectedClient == 0) {
- DEBUG_LOG_LN("Client Not connected");
- telnetClients.stop();
- disconnectedClient = 1;
- }
- }
- }
This will connect to a telnet client if there happens to be one available (lines 1 to 12) and will disconnect the client if the connection gets dropped (lines 14 to 21). With this code, if a client comes in, the current client connection gets dropped (lines 3 to 6).
Lastly, you may notice that I replaced all the Serial.print and Serial.println with DEBUG_LOG and DEBUG_LOG_LN. Those 2 macros are the ones pushing the logs to serial or both to serial and telnet. I will probably extend those in the future to add line number and time.
As with the whole project, the work is being checked in here: https://github.com/desordenado77/esp8266_netatmo_acController
As with the whole project, the work is being checked in here: https://github.com/desordenado77/esp8266_netatmo_acController
Towards a single natural solution for global illumination:
ReplyDelete- GPUs 15 TFLOPS with improved branching
- Denoising using AI for real-time path-tracing
- Optimized early ray termination
- Voxel representation of geometry
- Auto Reflections
- Auto Shadows
- Auto Ambient Occlusions
Realism is what drives GPU advancement.
Imagine GPUs use outside of cinematic and gaming use cases.
LifeVoxel.AI has built a visualization and AI platform using GPUs in the cloud used in diagnostic-quality views for mission-critical care just using a web browser. This patented innovation is recognized by Frost and Sullivan, NSF and NIH (13 patents).
RIS PACS
RIS PACS software