GithubHelp home page GithubHelp logo

kmomberg / arduinowebsockets Goto Github PK

View Code? Open in Web Editor NEW

This project forked from links2004/arduinowebsockets

0.0 0.0 0.0 618 KB

arduinoWebSockets

License: GNU Lesser General Public License v2.1

Shell 2.06% JavaScript 1.22% C++ 83.72% Python 2.64% C 9.51% HTML 0.83%

arduinowebsockets's Introduction

WebSockets Server and Client for Arduino

a WebSocket Server and Client for Arduino based on RFC6455.

Forked from https://github.com/Links2004/arduinoWebSockets

Supported features of RFC6455

  • text frame
  • binary frame
  • connection close
  • ping
  • pong
  • continuation frame

Limitations

  • max input length is limited to the ram size and the WEBSOCKETS_MAX_DATA_SIZE define
  • max output length has no limit (the hardware is the limit)
  • Client send big frames with mask 0x00000000 (on AVR all frames)
  • continuation frame reassembly need to be handled in the application code

Limitations for Async

  • Functions called from within the context of the websocket event might not honor yield() and/or delay(). See this issue for more info and a potential workaround.
  • wss / SSL is not possible.
  • Current implementation do not perform reconnections. You can handle the proper event if you want to reconnect on error/disconnection.

Supported Hardware

  • ESP8266 Arduino for ESP8266
  • ESP32 Arduino for ESP32
  • ESP31B
  • Particle with STM32 ARM Cortex M3
  • ATmega328 with Ethernet Shield (ATmega branch)
  • ATmega328 with enc28j60 (ATmega branch)
  • ATmega2560 with Ethernet Shield (ATmega branch)
  • ATmega2560 with enc28j60 (ATmega branch)

Note

version 2.0.0 and up is not compatible with AVR/ATmega, check ATmega branch.

version 2.3.0 has API changes for the ESP8266 BareSSL (may brakes existing code)

Arduino for AVR not supports std namespace of c++.

wss / SSL

supported for:

  • wss client on the ESP8266
  • wss / SSL is not natively supported in WebSocketsServer however it is possible to achieve secure websockets by running the device behind an SSL proxy. See Nginx for a sample Nginx server configuration file to enable this.

ESP Async TCP

This libary can run in Async TCP mode on the ESP.

The mode can be activated in the WebSockets.h (see WEBSOCKETS_NETWORK_TYPE define).

ESPAsyncTCP libary is required.

To use ESP8266 in async mode you need to define WEBSOCKETS_NETWORK_TYPE=0.

High Level Client API

  • begin : Initiate connection sequence to the websocket host.
void begin(const char *host, uint16_t port, const char * url = "/", const char * protocol = "arduino");
void begin(String host, uint16_t port, String url = "/", String protocol = "arduino");
  • onEvent: Callback to handle for websocket events
void onEvent(WebSocketClientEvent cbEvent);
  • WebSocketClientEvent: Handler for websocket events
void (*WebSocketClientEvent)(WStype_t type, uint8_t * payload, size_t length)

Where WStype_t type is defined as:

typedef enum {
  WStype_ERROR,
  WStype_DISCONNECTED,
  WStype_CONNECTED,
  WStype_TEXT,
  WStype_BIN,
  WStype_FRAGMENT_TEXT_START,
  WStype_FRAGMENT_BIN_START,
  WStype_FRAGMENT,
  WStype_FRAGMENT_FIN,
  WStype_PING,
  WStype_PONG,
} WStype_t;

Debugging

To have debug output on serial port you need to define DEBUG_ESP_PORT=Serial. If using PlatformIO may also need to define PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48.

License and credits

The library is licensed under LGPLv2.1

libb64 written by Chris Venter. It is distributed under Public Domain see LICENSE.

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.