Difficulty trying to build "websocket" from LaserGRBL webpage

OK I'm trying to build the project shown on WiFi with ESP8266 – LaserGRBL but this isn't really the way I was originally planning to do this. Anyway even though I'm not editing ANYTHING (just building the sketch for "Generic ESP8266 board" after setting up the libraries as specified on that page) I'm still getting lots of error messages, does anyone know if I could be using the wrong version of a library or something?

webserver:90:34: error: 'WStype_t' has not been declared
   90 | void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght)
      |                                  ^~~~~~~~
webserver:162:6: error: redefinition of 'void setup()'
  162 | void setup()
      |      ^~~~~
C:\Users\New\AppData\Local\Temp\untitled457104433.tmp\sketch_mar01a\sketch_mar01a.ino:1:6: note: 'void setup()' previously defined here
    1 | void setup() {
      |      ^~~~~
C:\Users\New\AppData\Local\Temp\untitled457104433.tmp\sketch_mar01a\webserver.ino: In function 'void setup()':
webserver:169:37: error: cannot convert '<unresolved overloaded function type>' to 'WebSocketsServerCore::WebSocketServerEvent' {aka 'std::function<void(unsigned char, WStype_t, unsigned char*, unsigned int)>'}
  169 |     webSocket.onEvent(webSocketEvent);
      |                                     ^
In file included from C:\Users\New\AppData\Local\Temp\untitled457104433.tmp\sketch_mar01a\webserver.ino:5:
C:\Users\New\Documents\Arduino\libraries\WebSockets\src/WebSocketsServer.h:50:39: note:   initializing argument 1 of 'void WebSocketsServerCore::onEvent(WebSocketsServerCore::WebSocketServerEvent)'
   50 |     void onEvent(WebSocketServerEvent cbEvent);
      |                  ~~~~~~~~~~~~~~~~~~~~~^~~~~~~
C:\Users\New\AppData\Local\Temp\untitled457104433.tmp\sketch_mar01a\webserver.ino: At global scope:
webserver:180:6: error: redefinition of 'void loop()'
  180 | void loop()
      |      ^~~~
C:\Users\New\AppData\Local\Temp\untitled457104433.tmp\sketch_mar01a\sketch_mar01a.ino:6:6: note: 'void loop()' previously defined here
    6 | void loop() {
      |      ^~~~
exit status 1
'WStype_t' has not been declared

Have you got more than one tab open?

I've done a fair amount of project development but I'm not interested in learning all that much about Arduino.

It seems that whatever resources you are tapping aren’t going to meet you even half way. I don’t think there will be a way around learning some things about Arduino and the development method that is used by most who play with it.

In particular, you must already know that having two functions with the same name is gonna be a problem to work out in just about any language…

And one hopes you have search functions that might help you find you more obvious errors.

In the end, you may have to come to more of an understanding of the code you are trying to black box offa some shelf than you thought.

Perhaps this isn’t quite ready for casual hackers to pick up and go with.

a7

OK THAT makes sense, but now I've still got

webserver:90:34: error: 'WStype_t' has not been declared
90 | void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght)
| ^~~~~~~~
C:\Users\New\Documents\Arduino\sketch_mar01a\webserver.ino: In function 'void setup()':
webserver:169:37: error: cannot convert '' to 'WebSocketsServerCore::WebSocketServerEvent' {aka 'std::function<void(unsigned char, WStype_t, unsigned char*, unsigned int)>'}
169 | webSocket.onEvent(webSocketEvent);
| ^
In file included from C:\Users\New\Documents\Arduino\sketch_mar01a\webserver.ino:5:
C:\Users\New\Documents\Arduino\libraries\WebSockets\src/WebSocketsServer.h:50:39: note: initializing argument 1 of 'void WebSocketsServerCore::onEvent(WebSocketsServerCore::WebSocketServerEvent)'
50 | void onEvent(WebSocketServerEvent cbEvent);
| ~^
exit status 1
'WStype_t' has not been declared
C:\Users\New\Documents\Arduino\sketch_mar01a\webserver.ino: In function 'void webSocketEvent(uint8_t, WStype_t, uint8_t*, size_t)':
webserver:124:17: error: 'SendFormat' was not declared in this scope
124 | SendFormat(num, "Connected to: %s\n", WiFi.SSID().c_str());
| ^
~
webserver:136:5: error: 'SendFormat' was not declared in this scope
136 | SendFormat(num,"CPU Freq: %uMHz\n", ESP.getCpuFreqMHz());
| ^
~~~
exit status 1
'SendFormat' was not declared in this scope

What file would those be declared in, is something obvious missing?

FWIW, it compiles for me - with some warnings. Arduino IDE v1.18.15, ES8266 Core 3.0.2.

Wow, that's an actual CLUE, thank you sir! Let me replicate the instructions from GitHub where this sketch comes from:

1. Download and install Arduino IDE 1.6.x from https://www.arduino.cc/en/Main/Software

2. Install ESP8266 Arduino support GitHub - esp8266/Arduino: ESP8266 core for Arduino

3. Install the following libraries:

3.1: WifiManager: GitHub - tzapu/WiFiManager: ESP8266 WiFi Connection manager with web captive portal

3.2: arduinoWebSockets: GitHub - Links2004/arduinoWebSockets: arduinoWebSockets

4. Configure your ESP8266 for sketch upload (GIPOs pulled up and down accordingly, USB to serial connected, reset and ready for upload)

5. Upload the Sketch contained in websocketserver folder.

Now Arduino IDE 1.6.x is a bit old to say the least, you used 1.8.15, I got the latest which is 1.8.19, no biggie. I don't see anything in there that says "ESP8266 Core 3.0.2",
is that comment directed at step #2? Is it the same as what I used or is it perhaps something I can substitute, might it be newer than what he suggested? What do you think I ought to do, if I might ask? This could let me move this WAY forward!

I'd start with ESP8266 v3.0.2 since that worked for me.

According to "boards manager" ESP8266 3.0.2 is what's loaded (I would have thought that might have been it too). Using "generic ESP8266 board". What else in that list would be likely changed? WiFi Manager? WebSockets? or is the problem with the websocket sketch?

Dunno -- arduinoWebSockets came from the link provided in the project. I used WiFiManager 2.0.9-beta.

This looks better...

webserver:90:34: error: 'WStype_t' has not been declared
90 | void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght)
| ^~~~~~~~
C:\Users\New\Documents\Arduino\sketch_mar01a\webserver.ino: In function 'void setup()':
webserver:169:37: error: cannot convert '' to 'WebSocketsServerCore::WebSocketServerEvent' {aka 'std::function<void(unsigned char, WStype_t, unsigned char*, unsigned int)>'}
169 | webSocket.onEvent(webSocketEvent);
| ^
In file included from C:\Users\New\Documents\Arduino\sketch_mar01a\webserver.ino:5:
C:\Users\New\Documents\Arduino\libraries\WebSockets\src/WebSocketsServer.h:50:39: note: initializing argument 1 of 'void WebSocketsServerCore::onEvent(WebSocketsServerCore::WebSocketServerEvent)'
50 | void onEvent(WebSocketServerEvent cbEvent);
| ~~~~~~~~~~~~~~~^
exit status 1
Exception in thread "Thread-18" java.lang.NullPointerException
at org.fife.ui.rsyntaxtextarea.TokenMakerBase.addToken(TokenMakerBase.java:136)
at processing.app.syntax.SketchTokenMaker.addToken(SketchTokenMaker.java:59)
at org.fife.ui.rsyntaxtextarea.TokenMakerBase.addToken(TokenMakerBase.java:110)
at org.fife.ui.rsyntaxtextarea.modes.CPlusPlusTokenMaker.addToken(CPlusPlusTokenMaker.java:1868)
at org.fife.ui.rsyntaxtextarea.modes.CPlusPlusTokenMaker.addToken(CPlusPlusTokenMaker.java:1852)
at org.fife.ui.rsyntaxtextarea.modes.CPlusPlusTokenMaker.yylex(CPlusPlusTokenMaker.java:2251)
at org.fife.ui.rsyntaxtextarea.modes.CPlusPlusTokenMaker.getTokenList(CPlusPlusTokenMaker.java:1919)
at org.fife.ui.rsyntaxtextarea.RSyntaxDocument.getTokenListForLine(RSyntaxDocument.java:431)
at org.fife.ui.rsyntaxtextarea.SyntaxView.getLineWidth(SyntaxView.java:306)
at org.fife.ui.rsyntaxtextarea.SyntaxView.calculateLongestLine(SyntaxView.java:110)
at org.fife.ui.rsyntaxtextarea.SyntaxView.updateMetrics(SyntaxView.java:903)
at org.fife.ui.rsyntaxtextarea.SyntaxView.lineToRect(SyntaxView.java:503)
at org.fife.ui.rsyntaxtextarea.SyntaxView.modelToView(SyntaxView.java:542)
at javax.swing.plaf.basic.BasicTextUI$RootView.modelToView(BasicTextUI.java:1509)
at javax.swing.plaf.basic.BasicTextUI.modelToView(BasicTextUI.java:1047)
at javax.swing.plaf.basic.BasicTextUI.modelToView(BasicTextUI.java:1022)
at javax.swing.text.JTextComponent.modelToView(JTextComponent.java:1377)
at org.fife.ui.rtextarea.RTextAreaBase.possiblyUpdateCurrentLineHighlightLocation(RTextAreaBase.java:778)
at org.fife.ui.rtextarea.RTextArea.fireCaretUpdate(RTextArea.java:614)
at org.fife.ui.rsyntaxtextarea.RSyntaxTextArea.fireCaretUpdate(RSyntaxTextArea.java:835)
at javax.swing.text.JTextComponent$MutableCaretEvent.fire(JTextComponent.java:4394)
at javax.swing.text.JTextComponent$MutableCaretEvent.stateChanged(JTextComponent.java:4416)
at javax.swing.text.DefaultCaret.fireStateChanged(DefaultCaret.java:802)
at javax.swing.text.DefaultCaret.changeCaretPosition(DefaultCaret.java:1274)
at javax.swing.text.DefaultCaret.handleSetDot(DefaultCaret.java:1173)
at javax.swing.text.DefaultCaret$DefaultFilterBypass.setDot(DefaultCaret.java:1913)
at javax.swing.text.NavigationFilter.setDot(NavigationFilter.java:64)
at org.fife.ui.rtextarea.ConfigurableCaret$FoldAwareNavigationFilter.setDot(ConfigurableCaret.java:724)
at javax.swing.text.DefaultCaret.setDot(DefaultCaret.java:1151)
at javax.swing.text.DefaultCaret.setDot(DefaultCaret.java:1051)
at javax.swing.text.JTextComponent.setCaretPosition(JTextComponent.java:1631)
at processing.app.Editor.addLineHighlight(Editor.java:1671)
at processing.app.Editor.statusError(Editor.java:2552)
at processing.app.Editor$BuildHandler.run(Editor.java:1646)
at java.lang.Thread.run(Thread.java:748)

I'm using WiFiManager 2.0.9 beta and WebSocket 2.3.5. It looks like the websocket event type needs to come from somewhere, and the websocket.onEvent needs to come from somewhere too. There's an "Arduino WebSocket - Fast" and "Arduino Websockets 0.5.3" as options. Is it more reasonable to just keep trying different libraries to see if anything will build error-free? Or is it time to try and figure out what needs to be "built into" the sketch? (Bear in mind I have to familiarity with this programming so don't know which level these variables should be set in.) Or did you really get a "clean" build? There are also WiFiMan or WiFiConnect or WiFiConnect_Lite as options for WiFiManager, I'm inclibed to try those too...

Actually I just had to add a function declaration to WFM 2.0.9 and WS 2.3.5, it now builds. I expect it to work fine, I'll test it tomorrow. Thank you profusely for being a gentleman and helping me out, I definitely owe you one!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.