Coder Social home page Coder Social logo

Comments (5)

gilmaimon avatar gilmaimon commented on July 24, 2024

This is more of a general programming queshtion, but I am happy to try and help.

Your solution is fine, but it will be a bit hard to extend in the future.

The Websockets protocol defined 2 types of data messages: Binary and Text (UTF8). You could look up the docs on the library you are using on the PC and check what is the method name that checks if a message is binary or text.

A more general approach, is to define some kind of protocol of your own. For example, you could say that before every message you send a text messages that represent the type of data being sent next. For example, Esp code:

if(...) {
   client.send("DETECTION");
   client.sendBinary("Face Detected");
}
client.send("IMAGE");
client.sendBinary((const char *)_jpg_buf, _jpg_buf_len);

Then, on the other side you will accept a message, and use switch or if-elses to act depending on the data you know you are about to get next.

This protocol is not very slim or efficient, but you can apply the general concept however you like :)

Btw, is sending the images working well for you?

from arduinowebsockets.

xgarb avatar xgarb commented on July 24, 2024

Thanks for the advice. Sending images seems to work well at lower resolutions but the WiFi disconnects on the ESP at high resolutions. I'm going to do more testing on streaming the camera output using websockets vs the JPEG HTTP Stream method used here: https://github.com/espressif/esp32-camera/tree/master

from arduinowebsockets.

gilmaimon avatar gilmaimon commented on July 24, 2024

Interesting. You can try using streaming with this library. See this https://github.com/gilmaimon/TinyWebsockets/wiki/Client#Streaming---Sending-Fragmented-Messages

from arduinowebsockets.

gilmaimon avatar gilmaimon commented on July 24, 2024

Hi, can I close the issue?

from arduinowebsockets.

xgarb avatar xgarb commented on July 24, 2024

I'm working on another project that I want to test with this library as an alternative. Hopefully today!

from arduinowebsockets.

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.