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

network::TcpServer* _server #162

Open
dmtzs opened this issue Jun 25, 2024 · 3 comments
Open

network::TcpServer* _server #162

dmtzs opened this issue Jun 25, 2024 · 3 comments
Assignees

Comments

@dmtzs
Copy link

dmtzs commented Jun 25, 2024

Describe the bug
receive this error:

In file included from c:\Users\diego\OneDrive\Documentos\Arduino\libraries\ArduinoWebsockets\src/ArduinoWebsockets.h:6:0,
                 from D:\github projects\Arduino\websocket\websocket.ino:2:
c:\Users\diego\OneDrive\Documentos\Arduino\libraries\ArduinoWebsockets\src/tiny_websockets/server.hpp:10:40: error: expected ')' before '*' token
     WebsocketsServer(network::TcpServer* server = new WSDefaultTcpServer);
                                        ^
c:\Users\diego\OneDrive\Documentos\Arduino\libraries\ArduinoWebsockets\src/tiny_websockets/server.hpp:26:14: error: 'TcpServer' in namespace 'websockets::network' does not name a type
     network::TcpServer* _server;
              ^~~~~~~~~

exit status 1

Compilation error: exit status 1

To Reproduce
Only verifying the code used
This should include:

  • The library version you are using: 0.5.4
  • The board you are using: arduino uno R4 WIFI
  • Information about other components in the system (do you use third party client/server software?)

Expected behavior
Subscribed to the topic 1

Code

#include "WiFiS3.h"
#include <ArduinoWebsockets.h>
#include "arduino_secrets.h"  // Just a file to store secrets

char ssid[] = SECRET_SSID;
char pass[] = SECRET_PASS;
int status = WL_IDLE_STATUS;

const char* websockets_server_host = "0.0.0.0:8000/ws/<token>";

using namespace websockets;
WebsocketsClient client;

void onMessageCallback(WebsocketsMessage message) {
    Serial.print("Got Message: ");
    Serial.println(message.data());
}

void onEventsCallback(WebsocketsEvent event, String data) {
    if(event == WebsocketsEvent::ConnectionOpened) {
        Serial.println("Connnection Opened");
    } else if(event == WebsocketsEvent::ConnectionClosed) {
        Serial.println("Connnection Closed");
    } else if(event == WebsocketsEvent::GotPing) {
        Serial.println("Got a Ping!");
    } else if(event == WebsocketsEvent::GotPong) {
        Serial.println("Got a Pong!");
    }
}

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    while (true);
  }
  
  String fv = WiFi.firmwareVersion();
  if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
    Serial.println("Please upgrade the firmware");
  }
  
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    status = WiFi.begin(ssid, pass);
    delay(10000);
  }
  
  printWifiStatus();

  client.connect(websockets_server_host);

  client.send("{\"topic\": \"topic1\", \"content\": \"Subscribing to topic1\"}");

  client.onMessage(handleMessage);
}

void loop() {
  client.poll();
}

void handleMessage(WebsocketsMessage message) {
  Serial.print("Received message: ");
  Serial.println(message.data());
}

void printWifiStatus() {
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

Additional context
Add any other context about the problem here.

@dmtzs
Copy link
Author

dmtzs commented Jun 25, 2024

Please help @gilmaimon , I'm following all the steps if I'm not wrong

@dmtzs
Copy link
Author

dmtzs commented Aug 25, 2024

any updates? @gilmaimon

@MurlidharVarma
Copy link

any updated? @gilmaimon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants