Git Product home page Git Product logo

Comments (24)

khoih-prog avatar khoih-prog commented on May 27, 2024

This WebSockets2_Generic Library is not currently supporting boards using WiFi101 shield and library.

I already checked and to provide support to this WiFi101 requires drastic changes in both WebSockets2_Generic Library and some changes in WiFi101 library.

Because of the unpopularity of WiFi101 as well as MKR1000, I won't assign this work with high priority. And it'll take weeks to fix / update. Moreover, I don't have this combination MKR1000 + WiFi101 to test.

I suggest you, if urgent. to use another currently-supported combination, such as ESP32, ESP8266, Nano-33-IoT, or even MKR1000 with Ethernet W5x00/EN28J60.

If you're willing to wait, and test within a week or so, I can speed-up the changes for you to test.

Good Luck,

from websockets2_generic.

 avatar commented on May 27, 2024

Hi,
The problem is that they are mkr1000 arduinos already mounted on a special circuit, so I have no choice but to use this combination.
Yes, I could wait a week and test your new version. :)

On the server we have a socket.io, express and nodejs configuration.
I have seen that other products support websockets, but not socket.io.
ArduinoWebSockets (https://github.com/Links2004/arduinoWebSockets) supports socket.io, however it does not support the arduino MKR1000. :(
Socket.io is based on the websockets protocol, but it is a modified and improved protocol, although not compatible with the websockets standard. Socket.io is mostly used with Nodejs.
Do you know if your library is prepared for both the websockets protocol and the improved socket.io?

Thank you very much for all your help.

from websockets2_generic.

khoih-prog avatar khoih-prog commented on May 27, 2024

You can have a look at my WebSockets_Generic Library, based on ArduinoWebSockets and supporting Socket.IO.

For example Generic_WebSocketClientSocketIO_WiFiNINA example.

If OK and you'll spend time to test, I'll add support to MKR1000 and WiFi101 to that WebSockets_Generic Library

from websockets2_generic.

 avatar commented on May 27, 2024

Yes. Of course. I will be doing the test of all the improvements that you are producing to your library. :)
Do you think you can have a preliminary version in 1 week?
Thank you so much for all your help.

from websockets2_generic.

khoih-prog avatar khoih-prog commented on May 27, 2024

Will release tomorrow. Almost done

You can test the Modified WiFi101 library now.

from websockets2_generic.

 avatar commented on May 27, 2024

Do you know if the supported version of socket.io in your library corresponds to the supported version of node socket.io (https://www.npmjs.com/package/socket.io)?

from websockets2_generic.

 avatar commented on May 27, 2024

You are wonderful, you are a crack. :)
I'm going to do tests.
I will tell you something.

from websockets2_generic.

khoih-prog avatar khoih-prog commented on May 27, 2024

No idea yet. Many different implementations out there. But if they stick to the Socket.IO standards, it'll be compatible and OK.

from websockets2_generic.

 avatar commented on May 27, 2024

You have to guide me a bit to do the tests you need to check that everything works correctly.

  1. I overwrite the installation of my standard WiFi101 library with yours.
  2. I check that the WiFi101 library examples continue to work.

Do you want me to do something else for now?

from websockets2_generic.

khoih-prog avatar khoih-prog commented on May 27, 2024

Already publish WebSockets2_Generic Releases v1.3.0

Please test with the Forked WiFi101 library and let me know the result.

Thanks,


Release v1.3.0

  1. Add support to WiFi101. To be used with Forked WiFi101 library
  2. Check compatibility with new ESP8266 core v3.0.0
  3. Suppress warnings

from websockets2_generic.

khoih-prog avatar khoih-prog commented on May 27, 2024

I overwrite the installation of my standard WiFi101 library with yours.
I check that the WiFi101 library examples continue to work.
Do you want me to do something else for now?

Those are enough tests.

from websockets2_generic.

 avatar commented on May 27, 2024

First analysis.
I have overwritten your WiFi101 library on my computer.
I have tried some examples and they still work. :)

With the library manager of the Arduino IDE I have installed your WebSockects_Generic library.
I have modified the Generic_WebSocketClientSocketIO_WiFiNINA example for SAMD21.
Please tell me if I have done this modification correctly or have to do it differently.
When running the example it cannot connect to my WiFi.
Look at the screenshots.

sc11
sc12
sc13

Tell me if I should do some other tests.
Thanks.

from websockets2_generic.

khoih-prog avatar khoih-prog commented on May 27, 2024

WebSockects_Generic library is not supporting WiFi101. That's why you have the same hanging issue because it tries to use WiFiNINA, instead of WiFi101.

Have to fix in next step, if necessary.

from websockets2_generic.

khoih-prog avatar khoih-prog commented on May 27, 2024

Now, just try the WebSockects2_Generic with normal WebSocket server, to see of WiFi101 is working OK.

Use the examples such as SAMD_WiFi101-Minimal-Client.

There are 7 examples

For SAMD21/SAMD51 boards using WiFi101

  1. SAMD_WiFi101-Client
  2. SAMD_WiFi101-Minimal-Client
  3. SAMD_WiFi101-Client_SINRIC
  4. SAMD_WiFi101-Server
  5. SAMD_WiFi101-RepeatingClient
  6. SAMD_WiFi101_ServerAllFunctionsDemo
  7. SAMD_WiFi101-AdvancedWebServer.

from websockets2_generic.

 avatar commented on May 27, 2024

In WebSockects2_Generic now the WiFi works perfectly, thank you very much.
In the examples you can modify the lines that show the Local IP so that they show it correctly.
Look at the following screenshots:

sc14
sc15
sc16

Thank you very much for your work.

Now I would have to try testing it with a normal websocket server, but I don't have any implementation.
I can try to make a nodejs websocket server.
I'll tell you something.

from websockets2_generic.

 avatar commented on May 27, 2024

Hi Khoi Hoang,

I have made a small standard websocket server based on the nodejs websocket library (https://www.npmjs.com/package/websocket).
The connection to the WiFi is successful, the connection to the server is also correct, but when it try to use the server's websocket the following error occurs:
"Specified protocol was not requested by the client"

Also, as you will see in the screenshots, warnings are produced when compiling the arduino program.
Look at the following screenshots:

sc19

Server:
sc17

Client:
sc18

Server Source code:

var WebSocketServer = require('websocket').server;
var http = require('http');

var server = http.createServer(function(request, response) {
    console.log((new Date()) + ' Received request for ' + request.url);
    response.writeHead(404);
    response.end();
});
server.listen(8080, function() {
    console.log((new Date()) + ' Server is listening on port 8080');
});

wsServer = new WebSocketServer({
    httpServer: server,
    // You should not use autoAcceptConnections for production
    // applications, as it defeats all standard cross-origin protection
    // facilities built into the protocol and the browser.  You should
    // *always* verify the connection's origin and decide whether or not
    // to accept it.
    autoAcceptConnections: false
});

function originIsAllowed(origin) {
  // put logic here to detect whether the specified origin is allowed.
  return true;
}

wsServer.on('request', function(request) {
    if (!originIsAllowed(request.origin)) {
      // Make sure we only accept requests from an allowed origin
      request.reject();
      console.log((new Date()) + ' Connection from origin ' + request.origin + ' rejected.');
      return;
    }
    
    var connection = request.accept('echo-protocol', request.origin);
    console.log((new Date()) + ' Connection accepted.');
    connection.on('message', function(message) {
        if (message.type === 'utf8') {
            console.log('Received Message: ' + message.utf8Data);
            connection.sendUTF(message.utf8Data);
        }
        else if (message.type === 'binary') {
            console.log('Received Binary Message of ' + message.binaryData.length + ' bytes');
            connection.sendBytes(message.binaryData);
        }
    });
    connection.on('close', function(reasonCode, description) {
        console.log((new Date()) + ' Peer ' + connection.remoteAddress + ' disconnected.');
    });
});

Any other tests you want me to do, you tell me.

Thank you.

(Edit) New investigations:
If on the server I accept any protocol by modifying the following line:
var connection = request.accept ('echo-protocol', request.origin);
to
var connection = request.accept (null, request.origin);
the connection is successfully established.

With your library, can you use a specific protocol to communicate with the server?

Look at the following screenshots:
sc20
sc21

However, I have observed a problem. When using extended characters (Spanish), for example ñ, ó, ... that are in the middle of the sentence to be sent, the connection is blocked, and this is the fault of:

void onMessageCallback(WebsocketsMessage message) 
{
  Serial.print("Got Message: ");
  String sss = message.data();
  Serial.println(sss);  // <<<< From what I have investigated the problem is in the Serial.println () 
        // Do you make any internal variation of the string received from the server? 
}

void loop() 
{
  client.poll();

  delay(3000);

  c++;
    String numero = (String) c;
    String WS_msg = c + String(" España: Hello to Server from ") + BOARD_NAME;  // **España contains ñ**
   // However, if I send the following:
   // String WS_msg = c + String(" ñ: Hello to Server from ") + BOARD_NAME; 
   // everything works correctly, although it also contains the character ñ 
   // Keep in mind that the same string that is sent to the server, the server sends it back to the client.  
  client.send(WS_msg);
}

Do you have any idea how to solve this problem?

Thank you so much for all your help.

from websockets2_generic.

khoih-prog avatar khoih-prog commented on May 27, 2024

Good news that you can find your way out from now on.

You can try this sophisticated SAMD_WiFi101-Client_SINRIC example and control your device from Amazon's Alexa Voice control and Sinric or SinricPro phone app.

For Spanish character issue, you have to ask on some forums how to solve as I don't have experience with Internationalization.

Now I would have to try testing it with a normal websocket server, but I don't have any implementation.

You can use the SAMD_WiFi101-Server example, or the similar one written for other boards, to create a test WebSocket Server.

from websockets2_generic.

 avatar commented on May 27, 2024

However, for now I cannot use it with our server, since as I mentioned it works with socket.io.
Now, when you have made the compatibility of WebSockets_Generic I will test if it works with our server with nodejs + socket.io

Very interesting what you tell me about control through Alexa and SinRic. I'll keep it in mind in case we need it. :)

To control an industrial encoder, speed measurement by sections, etc ... do you have any library recommendations?
Also, I have seen that you have very interesting libraries, if I want to prevent the sending of information to the server from interrupting in any way the data that is being received from the encoder, could one of your plugins be used for this?

Thank you very much for all your help.

from websockets2_generic.

khoih-prog avatar khoih-prog commented on May 27, 2024

Now, when you have made the compatibility of WebSockets_Generic I will test if it works with our server with nodejs + socket.io

I'll put this in my very long bucket lists

  1. WebSockets_Generic + WiFi101
  2. WebSockets2_Generic + Socket.IO

In the mean time, you can try to merge the code with Socket.IO-client Library to see if OK.

To control an industrial encoder, speed measurement by sections, etc ... do you have any library recommendations?

Try to use my SAMD_TimerInterrupt, especially

  1. ISR_RPM_Measure
  2. RPM_Measure

These examples are using ISR and won't be interrupted by other low priority tasks.

from websockets2_generic.

 avatar commented on May 27, 2024

Ahhh .... I thought you told me that by tomorrow you would have a version of WebSockets_Generic + WiFi101, that is what I had understood, for that reason I had been so happy, however, if it is not possible in all ways you I appreciate your efforts.

from websockets2_generic.

khoih-prog avatar khoih-prog commented on May 27, 2024

Possibly I told you WebSockets2_Generic + WiFi101, not WebSockets_Generic + WiFi101 as this is not in my mind at all. A typo (missing 2 ??)

from websockets2_generic.

khoih-prog avatar khoih-prog commented on May 27, 2024

I'll try finish WebSockets_Generic + WiFi101 next week as this is much simpler to do than last WebSockets2_Generic + WiFi101

from websockets2_generic.

 avatar commented on May 27, 2024

Ohhh ... that would be wonderful ... thank you so much 👍

from websockets2_generic.

khoih-prog avatar khoih-prog commented on May 27, 2024

I'm closing this issue now as there is nothing more to do here on this enhancement.
Please open the new issue in WebSockets_Generic to be consistent.

from websockets2_generic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.