Skip to content

Commit b001b07

Browse files
committed
initial add
1 parent 0c73cc3 commit b001b07

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
`1.` Download and install Arduino IDE 1.6.x from https://www.arduino.cc/en/Main/Software
3+
4+
`2.` Install ESP8266 Arduino support https://github.com/esp8266/Arduino#installing-with-boards-manager
5+
6+
`3.` Install the following libraries:
7+
8+
`3.1:` WifiManager: https://github.com/tzapu/WiFiManager#install-through-library-manager
9+
10+
`4.` Configure your ESP8266 for sketch upload (GIPOs pulled up and down accordingly, USB to serial connected, reset and ready for upload)
11+
12+
`5.` Upload the Sketch contained in telnetserver folder
13+
14+
`6.` Connect the TX of the ESP8266 to RX of grbl arduino board, and RX of the ESP8266 to TX. Power up the ESP and engraver
15+
16+
`7.` Connect to the ESP8266 AP to connect the ESP to your local Wifi, then switch back to your local wifi (Animation below shows the details)
17+
18+
`8.` In LaserGRBL open menu "grbl-settings" and configure for LaserWebESP8266 protocol and connect to the IP of the ESP (Note, I will add an IP scanner soon. For now, check on your DHCP server which IP was dished out)
19+
20+
![Setting Up Wifi](wifibridge.gif)
21+
22+
23+
NOTE: To reset the Wifi settings you can Send `WIFIRESET` via websocket

telnetserver/telnetserver.ino

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#include <Arduino.h>
2+
#include <ESP8266WiFi.h>
3+
#include <Hash.h>
4+
#include <DNSServer.h>
5+
#include <ESP8266WebServer.h>
6+
#include <ESP8266HTTPUpdateServer.h>
7+
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
8+
9+
ESP8266WebServer httpServer(80);
10+
ESP8266HTTPUpdateServer httpUpdater;
11+
const char* update_path = "/firmware";
12+
const char* update_username = "admin";
13+
const char* update_password = "admin";
14+
15+
16+
#define MAX_SRV_CLIENTS 1
17+
WiFiServer server(23);
18+
WiFiClient serverClients[MAX_SRV_CLIENTS];
19+
20+
int RESET_PIN = 0; // = GPIO0 on nodeMCU
21+
WiFiManager wifiManager;
22+
23+
void setup()
24+
{
25+
Serial.begin(115200);
26+
27+
delay(5000); //BOOT WAIT
28+
pinMode(RESET_PIN, INPUT_PULLUP);
29+
wifiManager.autoConnect("ESP8266");
30+
31+
server.begin();
32+
server.setNoDelay(true);
33+
34+
httpUpdater.setup(&httpServer, update_path, update_username, update_password);
35+
httpServer.begin();
36+
37+
WiFi.setSleepMode(WIFI_NONE_SLEEP); // disable WiFi sleep for more performance
38+
}
39+
40+
41+
void loop()
42+
{
43+
httpServer.handleClient();
44+
manage();
45+
}
46+
47+
void manage() {
48+
uint8_t i;
49+
//check if there are any new clients
50+
if (server.hasClient()){
51+
for(i = 0; i < MAX_SRV_CLIENTS; i++){
52+
//find free/disconnected spot
53+
if (!serverClients[i] || !serverClients[i].connected()){
54+
if(serverClients[i]) serverClients[i].stop();
55+
serverClients[i] = server.available();
56+
serverClients[i].write("Connected\n");
57+
continue;
58+
}
59+
}
60+
//no free/disconnected spot so reject
61+
WiFiClient serverClient = server.available();
62+
serverClient.stop();
63+
}
64+
//check clients for data
65+
for(i = 0; i < MAX_SRV_CLIENTS; i++){
66+
if (serverClients[i] && serverClients[i].connected()){
67+
if(serverClients[i].available()){
68+
//get data from the telnet client and push it to the UART
69+
while(serverClients[i].available()) Serial.write(serverClients[i].read());
70+
}
71+
}
72+
}
73+
//check UART for data
74+
if(Serial.available()){
75+
size_t len = Serial.available();
76+
uint8_t sbuf[len];
77+
Serial.readBytes(sbuf, len);
78+
//push UART data to all connected telnet clients
79+
for(i = 0; i < MAX_SRV_CLIENTS; i++){
80+
if (serverClients[i] && serverClients[i].connected()){
81+
serverClients[i].write(sbuf, len);
82+
delay(1);
83+
}
84+
}
85+
}
86+
}

wifibridge.gif

3.43 MB
Loading

0 commit comments

Comments
 (0)