mbed3: sayonara
authorAndy Green <andy@warmcat.com>
Wed, 22 Feb 2017 01:50:11 +0000 (09:50 +0800)
committerAndy Green <andy@warmcat.com>
Wed, 22 Feb 2017 01:50:11 +0000 (09:50 +0800)
The port was technically worthwhile and laid the groundwork for ESP support.

But now it is just useless cruft like mbed3 itself...

CMakeLists.txt
README.build.md
lib/libwebsockets.h
lib/lws-plat-mbed3.c [deleted file]
lib/lws-plat-mbed3.cpp [deleted file]
lib/pollfd.c
lib/private-libwebsockets.h
lib/server.c

index 4fd9fc6..8971759 100644 (file)
@@ -95,7 +95,6 @@ option(LWS_WITHOUT_DAEMONIZE "Don't build the daemonization api" ON)
 option(LWS_IPV6 "Compile with support for ipv6" OFF)
 option(LWS_UNIX_SOCK "Compile with support for UNIX domain socket" OFF)
 option(LWS_WITH_HTTP2 "Compile with support for http2" OFF)
-option(LWS_MBED3 "Platform is MBED3" OFF)
 option(LWS_SSL_SERVER_WITH_ECDH_CERT "Include SSL server use ECDH certificate" OFF)
 option(LWS_WITH_CGI "Include CGI (spawn process with network-connected stdin/out/err) APIs" OFF)
 option(LWS_WITH_HTTP_PROXY "Support for rewriting HTTP proxying" OFF)
@@ -146,21 +145,6 @@ message(STATUS "LWS_WITH_SMTP --> Enabling LWS_WITH_LIBUV")
  set(LWS_WITH_LIBUV 1)
 endif()
 
-if (DEFINED YOTTA_WEBSOCKETS_VERSION_STRING)
-
-set(LWS_WITH_SHARED OFF)
-set(LWS_WITH_SSL OFF)
-set(LWS_WITH_ZLIB OFF)
-set(LWS_WITHOUT_CLIENT ON)
-set(LWS_WITHOUT_TESTAPPS ON)
-set(LWS_WITHOUT_EXTENSIONS ON)
-set(LWS_WITH_PLUGINS OFF)
-set(LWS_MBED3 ON)
-# this implies no pthreads in the lib
-set(LWS_MAX_SMP 1)
-
-endif()
-
 if (LWS_WITH_ESP8266)
  set(LWS_WITH_SHARED OFF)
  set(LWS_WITH_SSL OFF)
@@ -410,9 +394,6 @@ endif()
 if (LWS_WITH_ESP8266)
 set(CMAKE_C_FLAGS "-nostdlib ${CMAKE_C_FLAGS}")
 endif()
-#if (LWS_MBED3)
-#      set(CMAKE_C_FLAGS "-D_DEBUG ${CMAKE_C_FLAGS}")
-#endif()
 
 if (MINGW)
        set(LWS_MINGW_SUPPORT 1)
@@ -613,26 +594,21 @@ if (WIN32)
        list(APPEND SOURCES
                lib/lws-plat-win.c)
 else()
-       if (LWS_MBED3)
+
+       if (LWS_WITH_ESP8266)
                list(APPEND SOURCES
-                       lib/lws-plat-mbed3.cpp
-                       lib/lws-plat-mbed3.c)
+                       lib/lws-plat-esp8266.c)
        else()
-               if (LWS_WITH_ESP8266)
+               if (LWS_PLAT_OPTEE)
                        list(APPEND SOURCES
-                               lib/lws-plat-esp8266.c)
+                               lib/lws-plat-optee.c)
                else()
-                       if (LWS_PLAT_OPTEE)
+                       if (LWS_WITH_ESP32)
                                list(APPEND SOURCES
-                                       lib/lws-plat-optee.c)
+                                       lib/lws-plat-esp32.c)
                        else()
-                               if (LWS_WITH_ESP32)
-                                       list(APPEND SOURCES
-                                               lib/lws-plat-esp32.c)
-                               else()
-                                       list(APPEND SOURCES
-                                               lib/lws-plat-unix.c)
-                               endif()
+                               list(APPEND SOURCES
+                                       lib/lws-plat-unix.c)
                        endif()
                endif()
        endif()
@@ -1661,7 +1637,6 @@ message(" LWS_USE_LIBUV = ${LWS_USE_LIBUV}")
 message(" LWS_IPV6 = ${LWS_IPV6}")
 message(" LWS_UNIX_SOCK = ${LWS_UNIX_SOCK}")
 message(" LWS_WITH_HTTP2 = ${LWS_WITH_HTTP2}")
-message(" LWS_MBED3 = ${LWS_MBED3}")
 message(" LWS_SSL_SERVER_WITH_ECDH_CERT = ${LWS_SSL_SERVER_WITH_ECDH_CERT}")
 message(" LWS_MAX_SMP = ${LWS_MAX_SMP}")
 message(" LWS_WITH_CGI = ${LWS_WITH_CGI}")
index 58ffcc7..5706fae 100644 (file)
@@ -223,48 +223,6 @@ cmake from scratch.
        $ make install
 ```
 
-@section mbed3 Building on mbed3
-
-MBED3 is a non-posix embedded OS targeted on Cortex M class chips.
-
-https://www.mbed.com/
-
-It's quite unlike any other Posixy platform since the OS is linked statically
-in with lws to form one binary.
-
-At the minute server-only is supported and due to bugs in mbed3 network support,
-the port is of alpha quality.  However it can serve the test html, favicon.ico
-and logo png and may be able to make ws connections.  The binary for that
-including the OS, test app, lws and all the assets is only 117KB.
-
-0) Today mbed3 only properly works on FRDM K64F $35 Freescale Dev Board with
-1MB Flash, 256KB SRAM and Ethernet.
-
-http://www.freescale.com/products/arm-processors/kinetis-cortex-m/k-series/k6x-ethernet-mcus/freescale-freedom-development-platform-for-kinetis-k64-k63-and-k24-mcus:FRDM-K64F
-
-1) Get a working mbed3 environment with arm-none-eabi-cs toolchain
-(available in Fedora, Ubuntu and other distros)
-
-2) Confirm you can build things using yotta by following the getting started guide here
-
-https://docs.mbed.com/docs/getting-started-mbed-os/en/latest/
-
-3)
-
-git clone https://github.com/warmcat/lws-test-server
-
-and cd into it
-
-4) mkdir -p yotta_modules ; cd yotta_modules
-
-5) git clone https://github.com/warmcat/libwebsockets ; mv libwebsockets websockets ; cd ..
-
-6) yotta target frdm-k64f-gcc
-
-7) yotta install
-
-8) yotta build
-
 @section optee Building for OP-TEE
 
 OP-TEE is a "Secure World" Trusted Execution Environment.
index 89becac..a1871b7 100644 (file)
 #ifdef __cplusplus
 #include <cstddef>
 #include <cstdarg>
-#ifdef MBED_OPERATORS
-#include "mbed-drivers/mbed.h"
-#include "sal-iface-eth/EthernetInterface.h"
-#include "sockets/TCPListener.h"
-#include "sal-stack-lwip/lwipv4_init.h"
-
-namespace {
-}
-using namespace mbed::Sockets::v0;
-
-
-struct sockaddr_in;
-struct lws;
-
-class lws_conn {
-       public:
-       lws_conn():
-               ts(NULL),
-               wsi(NULL),
-               writeable(1),
-               awaiting_on_writeable(0)
-       {
-       }
-
-public:
-       void set_wsi(struct lws *_wsi) { wsi = _wsi; }
-       int actual_onRX(Socket *s);
-       void onRX(Socket *s);
-       void onError(Socket *s, socket_error_t err);
-       void onDisconnect(TCPStream *s);
-       void onSent(Socket *s, uint16_t len);
-       void serialized_writeable(struct lws *wsi);
-
-public:
-       TCPStream *ts;
-
-public:
-       struct lws *wsi;
-       char writeable;
-       char awaiting_on_writeable;
-};
-
-class lws_conn_listener : lws_conn {
-public:
-       lws_conn_listener():
-               srv(SOCKET_STACK_LWIP_IPV4)
-       {
-               srv.setOnError(TCPStream::ErrorHandler_t(this,
-                               &lws_conn_listener::onError));
-       }
-
-       void start(const uint16_t port); /**< start listening */
-
-protected:
-       void onRX(Socket *s); /**< incoming data ready */
-       void onError(Socket *s, socket_error_t err); /**< if error occurs */
-       void onIncoming(TCPListener *s, void *impl); /**< new connection */
-       void onDisconnect(TCPStream *s); /**< disconnection */
-
-public:
-       TCPListener srv;
-};
-
-#endif
-
+#
 extern "C" {
 #else
 #include <stdarg.h>
 #endif
 
-#if defined(MBED_OPERATORS) || defined(LWS_WITH_ESP8266)
+#if defined(LWS_WITH_ESP8266)
 struct sockaddr_in;
 #define LWS_POSIX 0
 #else
@@ -167,7 +103,7 @@ struct sockaddr_in;
 #define LWS_INLINE inline
 #define LWS_O_RDONLY O_RDONLY
 
-#if !defined(MBED_OPERATORS) && !defined(LWS_WITH_ESP8266) && !defined(OPTEE_TA) && !defined(LWS_WITH_ESP32)
+#if !defined(LWS_WITH_ESP8266) && !defined(OPTEE_TA) && !defined(LWS_WITH_ESP32)
 #include <poll.h>
 #include <netdb.h>
 #define LWS_INVALID_FILE -1
@@ -447,30 +383,7 @@ struct lws_pollfd {
 #define LWS_POLLOUT (FD_WRITE)
 #else
 
-#if defined(MBED_OPERATORS)
-/* it's a class lws_conn * */
-typedef void * lws_sockfd_type;
-typedef void * lws_filefd_type;
-#define lws_sockfd_valid(sfd) (!!sfd)
-struct pollfd {
-       lws_sockfd_type fd; /**< fd related to */
-       short events; /**< which POLL... events to respond to */
-       short revents; /**< which POLL... events occurred */
-};
-#define POLLIN         0x0001
-#define POLLPRI                0x0002
-#define POLLOUT                0x0004
-#define POLLERR                0x0008
-#define POLLHUP                0x0010
-#define POLLNVAL       0x0020
 
-struct lws;
-
-void * mbed3_create_tcp_stream_socket(void);
-void mbed3_delete_tcp_stream_socket(void *sockfd);
-void mbed3_tcp_stream_bind(void *sock, int port, struct lws *);
-void mbed3_tcp_stream_accept(void *sock, struct lws *);
-#else
 #if defined(LWS_WITH_ESP8266)
 
 #include <user_interface.h>
@@ -622,7 +535,6 @@ typedef int lws_filefd_type;
 #define LWS_POLLIN (POLLIN)
 #define LWS_POLLOUT (POLLOUT)
 #endif
-#endif
 
 /** struct lws_pollargs - argument structure for all external poll related calls
  * passed in via 'in' */
diff --git a/lib/lws-plat-mbed3.c b/lib/lws-plat-mbed3.c
deleted file mode 100644 (file)
index f1ef289..0000000
+++ /dev/null
@@ -1,236 +0,0 @@
-#include "private-libwebsockets.h"
-
-/*
- * included from libwebsockets.c for MBED3 builds
- * MBED3 is an "OS" for very small embedded systems.
- * He doesn't have Posix semantics or apis.
- * But he has things like TCP sockets.
- */
-
-unsigned long long time_in_microseconds(void)
-{
-       return 0;
-}
-
-LWS_VISIBLE int lws_get_random(struct lws_context *context, void *buf, int len)
-{
-       int n = len;
-       unsigned char *b = (unsigned char *)buf;
-
-       (void)context;
-
-       while (n--)
-               b[n]= rand();
-       return len;
-}
-
-/*
- * MBED3 does not have a 'kernel' which takes copies of what userland wants
- * to send.  The user application must hold the tx buffer until it is informed
- * that send of the user buffer was complete.
- *
- * So as soon as you send something the pipe is globally choked.
- *
- * There is no concept of additional sent things being maybe acceptable.
- * You can send one thing up to 64KB at a time and may not try to send
- * anything else until that is completed.
- *
- * You can send things on other sockets, but they cannot complete until they
- * get their turn at the network device.
- */
-
-LWS_VISIBLE int lws_send_pipe_choked(struct lws *wsi)
-{
-#if 0
-       struct lws_pollfd fds;
-
-       /* treat the fact we got a truncated send pending as if we're choked */
-       if (wsi->trunc_len)
-               return 1;
-
-       fds.fd = wsi->sock;
-       fds.events = POLLOUT;
-       fds.revents = 0;
-
-       if (poll(&fds, 1, 0) != 1)
-               return 1;
-
-       if ((fds.revents & POLLOUT) == 0)
-               return 1;
-
-       /* okay to send another packet without blocking */
-#endif
-       (void)wsi;
-       return 0;
-}
-
-LWS_VISIBLE int
-lws_poll_listen_fd(struct lws_pollfd *fd)
-{
-       (void)fd;
-       return -1;
-}
-
-/**
- * lws_cancel_service() - Cancel servicing of pending websocket activity
- * \param context:     Websocket context
- *
- *     This function let a call to lws_service() waiting for a timeout
- *     immediately return.
- *
- *     There is no poll() in MBED3, he will fire callbacks when he feels like
- *     it.
- */
-LWS_VISIBLE void
-lws_cancel_service(struct lws_context *context)
-{
-       (void)context;
-}
-
-LWS_VISIBLE void
-lws_cancel_service_pt(struct lws *wsi)
-{
-       (void)wsi;
-}
-
-LWS_VISIBLE void lwsl_emit_syslog(int level, const char *line)
-{
-       printf("%d: %s", level, line);
-}
-
-LWS_VISIBLE int
-lws_plat_set_socket_options(struct lws_context *context, lws_sockfd_type fd)
-{
-       (void)context;
-       (void)fd;
-       return 0;
-}
-
-LWS_VISIBLE void
-lws_plat_drop_app_privileges(struct lws_context_creation_info *info)
-{
-       (void)info;
-}
-
-LWS_VISIBLE int
-lws_plat_context_early_init(void)
-{
-       return 0;
-}
-
-LWS_VISIBLE void
-lws_plat_context_early_destroy(struct lws_context *context)
-{
-       (void)context;
-}
-
-LWS_VISIBLE void
-lws_plat_context_late_destroy(struct lws_context *context)
-{
-       (void)context;
-}
-
-
-LWS_VISIBLE void
-lws_plat_service_periodic(struct lws_context *context)
-{
-       (void)context;
-}
-
-LWS_VISIBLE const char *
-lws_plat_inet_ntop(int af, const void *src, char *dst, int cnt)
-{
-       (void)af;
-       (void)src;
-       (void)dst;
-       (void)cnt;
-       return "unsupported";
-}
-
-LWS_VISIBLE int
-insert_wsi(struct lws_context *context, struct lws *wsi)
-{
-       (void)context;
-       (void)wsi;
-
-       return 0;
-}
-
-LWS_VISIBLE int
-delete_from_fd(struct lws_context *context, lws_sockfd_type fd)
-{
-       (void)context;
-       (void)fd;
-
-       return 1;
-}
-
-static lws_filefd_type
-_lws_plat_file_open(struct lws *wsi, const char *filename,
-                   unsigned long *filelen, int *flags)
-{
-       (void)wsi;
-       (void)filename;
-       (void)filelen;
-       (void)flags;
-       return NULL;
-}
-
-static int
-_lws_plat_file_close(struct lws *wsi, lws_filefd_type fd)
-{
-       (void)wsi;
-       (void)fd;
-       return -1;
-}
-
-unsigned long
-_lws_plat_file_seek_cur(struct lws *wsi, lws_filefd_type fd, long offset)
-{
-       (void)wsi;
-       (void)fd;
-       (void)offset;
-
-       return -1;
-}
-
-static int
-_lws_plat_file_read(struct lws *wsi, lws_filefd_type fd, unsigned long *amount,
-                   unsigned char *buf, unsigned long len)
-{
-       (void)wsi;
-       (void)amount;
-       (void)fd;
-       (void)buf;
-       (void)len;
-
-       return -1;
-}
-
-static int
-_lws_plat_file_write(struct lws *wsi, lws_filefd_type fd, unsigned long *amount,
-                    unsigned char *buf, unsigned long len)
-{
-       (void)wsi;
-       (void)amount;
-       (void)fd;
-       (void)buf;
-       (void)len;
-
-       return -1;
-}
-
-LWS_VISIBLE int
-lws_plat_init(struct lws_context *context,
-             struct lws_context_creation_info *info)
-{
-       (void)info;
-
-       context->fops.open      = _lws_plat_file_open;
-       context->fops.close     = _lws_plat_file_close;
-       context->fops.seek_cur  = _lws_plat_file_seek_cur;
-       context->fops.read      = _lws_plat_file_read;
-       context->fops.write     = _lws_plat_file_write;
-
-       return 0;
-}
diff --git a/lib/lws-plat-mbed3.cpp b/lib/lws-plat-mbed3.cpp
deleted file mode 100644 (file)
index 8e91c90..0000000
+++ /dev/null
@@ -1,314 +0,0 @@
-#include "private-libwebsockets.h"
-#include "core-util/CriticalSectionLock.h"
-
-extern "C" void *mbed3_create_tcp_stream_socket(void)
-{
-       lws_conn_listener *srv = new lws_conn_listener;
-
-       //lwsl_notice("%s: %p\r\n", __func__, (void *)srv);
-
-       return (void *)srv;
-}
-
-/* this is called by compatible_close() */
-extern "C" void mbed3_delete_tcp_stream_socket(void *sock)
-{
-       lws_conn *conn = (lws_conn *)sock;
-
-       conn->ts->close();
-
-       lwsl_notice("%s: wsi %p: conn %p\r\n", __func__, (void *)conn->wsi, sock);
-       delete conn;
-}
-
-void lws_conn::serialized_writeable(struct lws *_wsi)
-{
-       struct lws *wsi = (struct lws *)_wsi;
-       struct lws_pollfd pollfd;
-       lws_conn *conn = (lws_conn *)wsi->sock;
-
-       conn->awaiting_on_writeable = 0;
-
-       pollfd.fd = wsi->sock;
-       pollfd.events = POLLOUT;
-       pollfd.revents = POLLOUT;
-
-       lwsl_debug("%s: wsi %p\r\n", __func__, (void *)wsi);
-
-       lws_service_fd(lws_get_context(wsi), &pollfd);
-}
-
-extern "C" void mbed3_tcp_stream_bind(void *sock, int port, struct lws *wsi)
-{
-       lws_conn_listener *srv = (lws_conn_listener *)sock;
-
-       lwsl_debug("%s\r\n", __func__);
-       /* associate us with the listening wsi */
-       ((lws_conn *)srv)->set_wsi(wsi);
-
-       mbed::util::FunctionPointer1<void, uint16_t> fp(srv, &lws_conn_listener::start);
-       minar::Scheduler::postCallback(fp.bind(port));
-}
-
-extern "C" void mbed3_tcp_stream_accept(void *sock, struct lws *wsi)
-{
-       lws_conn *conn = (lws_conn *)sock;
-
-       lwsl_debug("%s\r\n", __func__);
-       conn->set_wsi(wsi);
-}
-
-extern "C" LWS_VISIBLE int
-lws_plat_change_pollfd(struct lws_context *context,
-                     struct lws *wsi, struct lws_pollfd *pfd)
-{
-       lws_conn *conn = (lws_conn *)wsi->sock;
-
-       (void)context;
-       if (pfd->events & POLLOUT) {
-               conn->awaiting_on_writeable = 1;
-               if (conn->writeable) {
-                       mbed::util::FunctionPointer1<void, struct lws *> book(conn, &lws_conn::serialized_writeable);
-                       minar::Scheduler::postCallback(book.bind(wsi));
-                       lwsl_debug("%s: wsi %p (booked callback)\r\n", __func__, (void *)wsi);
-               } else {
-
-                       lwsl_debug("%s: wsi %p (set awaiting_on_writeable)\r\n", __func__, (void *)wsi);
-               }
-       } else
-               conn->awaiting_on_writeable = 0;
-
-       return 0;
-}
-
-extern "C" LWS_VISIBLE int
-lws_plat_check_connection_error(struct lws *wsi)
-{
-       return 0;
-}
-
-extern "C" LWS_VISIBLE int
-lws_ssl_capable_read_no_ssl(struct lws *wsi, unsigned char *buf, int len)
-{
-       socket_error_t err;
-       size_t _len = len;
-
-       lwsl_debug("%s\r\n", __func__);
-
-       err = ((lws_conn *)wsi->sock)->ts->recv((char *)buf, &_len);
-       if (err == SOCKET_ERROR_NONE) {
-               lwsl_info("%s: got %d bytes\n", __func__, _len);
-               return _len;
-       }
-#if LWS_POSIX
-       if (LWS_ERRNO == LWS_EAGAIN ||
-           LWS_ERRNO == LWS_EWOULDBLOCK ||
-           LWS_ERRNO == LWS_EINTR)
-#else
-       if (err == SOCKET_ERROR_WOULD_BLOCK)
-#endif
-               return LWS_SSL_CAPABLE_MORE_SERVICE;
-
-       lwsl_warn("error on reading from skt: %d\n", err);
-       return LWS_SSL_CAPABLE_ERROR;
-}
-
-extern "C" LWS_VISIBLE int
-lws_ssl_capable_write_no_ssl(struct lws *wsi, unsigned char *buf, int len)
-{
-       socket_error_t err;
-       lws_conn *conn = (lws_conn *)wsi->sock;
-
-       lwsl_debug("%s: wsi %p: write %d (from %p)\n", __func__, (void *)wsi, len, (void *)buf);
-
-       lwsl_debug("%s: wsi %p: clear writeable\n", __func__, (void *)wsi);
-       conn->writeable = 0;
-
-       err = conn->ts->send((char *)buf, len);
-       if (err == SOCKET_ERROR_NONE)
-               return len;
-
-#if LWS_POSIX
-       if (LWS_ERRNO == LWS_EAGAIN ||
-           LWS_ERRNO == LWS_EWOULDBLOCK ||
-           LWS_ERRNO == LWS_EINTR) {
-               if (LWS_ERRNO == LWS_EWOULDBLOCK)
-                       lws_set_blocking_send(wsi);
-#else
-       if (err == SOCKET_ERROR_WOULD_BLOCK)
-               return LWS_SSL_CAPABLE_MORE_SERVICE;
-#endif
-
-       lwsl_warn("%s: wsi %p: ERROR %d writing len %d to skt\n", __func__, (void *)wsi, err, len);
-       return LWS_SSL_CAPABLE_ERROR;
-}
-
-/*
- * Set the listening socket to listen.
- */
-
-void lws_conn_listener::start(const uint16_t port)
-{
-       socket_error_t err = srv.open(SOCKET_AF_INET4);
-
-       if (srv.error_check(err))
-               return;
-       err = srv.bind("0.0.0.0", port);
-       if (srv.error_check(err))
-               return;
-       err = srv.start_listening(TCPListener::IncomingHandler_t(this,
-                                       &lws_conn_listener::onIncoming));
-       srv.error_check(err);
-}
-
-void lws_conn::onRX(Socket *s)
-{
-       struct lws_pollfd pollfd;
-
-       (void)s;
-
-       pollfd.fd = this;
-       pollfd.events = POLLIN;
-       pollfd.revents = POLLIN;
-
-       lwsl_debug("%s: lws %p\n", __func__, wsi);
-
-       lws_service_fd(lws_get_context(wsi), &pollfd);
-}
-
-/*
- * this gets called from the OS when the TCPListener gets a connection that
- * needs accept()-ing.  LWS needs to run the associated flow.
- */
-
-void lws_conn_listener::onIncoming(TCPListener *tl, void *impl)
-{
-       mbed::util::CriticalSectionLock lock;
-       lws_conn *conn;
-
-       if (!impl) {
-               onError(tl, SOCKET_ERROR_NULL_PTR);
-               return;
-       }
-
-       conn = new(lws_conn);
-       if (!conn) {
-               lwsl_err("OOM\n");
-               return;
-       }
-       conn->ts = srv.accept(impl);
-       if (!conn->ts)
-               return;
-
-       conn->ts->setNagle(0);
-
-       /*
-        * we use the listen socket wsi to get started, but a new wsi is
-        * created.  mbed3_tcp_stream_accept() is also called from
-        * here to bind the conn and new wsi together
-        */
-       lws_server_socket_service(lws_get_context(wsi),
-                                 wsi, (struct pollfd *)conn);
-
-       conn->ts->setOnError(TCPStream::ErrorHandler_t(conn, &lws_conn::onError));
-       conn->ts->setOnDisconnect(TCPStream::DisconnectHandler_t(conn,
-                           &lws_conn::onDisconnect));
-       conn->ts->setOnSent(Socket::SentHandler_t(conn, &lws_conn::onSent));
-       conn->ts->setOnReadable(TCPStream::ReadableHandler_t(conn, &lws_conn::onRX));
-
-       conn->onRX((Socket *)conn->ts);
-
-       lwsl_debug("%s: exit\n", __func__);
-}
-
-extern "C" LWS_VISIBLE struct lws *
-wsi_from_fd(const struct lws_context *context, lws_sockfd_type fd)
-{
-       lws_conn *conn = (lws_conn *)fd;
-       (void)context;
-
-       return conn->wsi;
-}
-
-extern "C" LWS_VISIBLE void
-lws_plat_insert_socket_into_fds(struct lws_context *context,
-                                                      struct lws *wsi)
-{
-       (void)wsi;
-       lws_libev_io(wsi, LWS_EV_START | LWS_EV_READ);
-       context->pt[0].fds[context->pt[0].fds_count++].revents = 0;
-}
-
-extern "C" LWS_VISIBLE void
-lws_plat_delete_socket_from_fds(struct lws_context *context,
-                                               struct lws *wsi, int m)
-{
-       (void)context;
-       (void)wsi;
-       (void)m;
-}
-
-void lws_conn_listener::onDisconnect(TCPStream *s)
-{
-       lwsl_info("%s\r\n", __func__);
-       (void)s;
-       //if (s)
-       //delete this;
-}
-
-extern "C" LWS_VISIBLE int
-lws_plat_service(struct lws_context *context, int timeout_ms)
-{
-       (void)context;
-       (void)timeout_ms;
-
-       return 0;
-}
-
-void lws_conn::onSent(Socket *s, uint16_t len)
-{
-       struct lws_pollfd pollfd;
-
-       (void)s;
-       (void)len;
-
-       if (!awaiting_on_writeable) {
-               lwsl_debug("%s: wsi %p (setting writable=1)\r\n",
-                          __func__, (void *)wsi);
-               writeable = 1;
-               return;
-       }
-
-       writeable = 1;
-
-       pollfd.fd = wsi->sock;
-       pollfd.events = POLLOUT;
-       pollfd.revents = POLLOUT;
-
-       lwsl_debug("%s: wsi %p (servicing now)\r\n", __func__, (void *)wsi);
-
-       lws_service_fd(lws_get_context(wsi), &pollfd);
-}
-
-void lws_conn_listener::onError(Socket *s, socket_error_t err)
-{
-       (void) s;
-       lwsl_notice("Socket Error: %s (%d)\r\n", socket_strerror(err), err);
-       if (ts)
-               ts->close();
-}
-
-void lws_conn::onDisconnect(TCPStream *s)
-{
-       lwsl_notice("%s:\r\n", __func__);
-       (void)s;
-       lws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS);
-}
-
-
-void lws_conn::onError(Socket *s, socket_error_t err)
-{
-       (void) s;
-       lwsl_notice("Socket Error: %s (%d)\r\n", socket_strerror(err), err);
-       s->close();
-}
index f829a8f..c6b658d 100644 (file)
@@ -146,7 +146,7 @@ insert_wsi_socket_into_fds(struct lws_context *context, struct lws *wsi)
                return 1;
        }
 
-#if !defined(_WIN32) && !defined(MBED_OPERATORS) && !defined(LWS_WITH_ESP8266)
+#if !defined(_WIN32) && !defined(LWS_WITH_ESP8266)
        if (wsi->sock >= context->max_fds) {
                lwsl_err("Socket fd %d is too high (%d)\n",
                         wsi->sock, context->max_fds);
@@ -212,7 +212,7 @@ remove_wsi_socket_from_fds(struct lws *wsi)
 #endif
        int m, ret = 0;
 
-#if !defined(_WIN32) && !defined(MBED_OPERATORS) && !defined(LWS_WITH_ESP8266)
+#if !defined(_WIN32) && !defined(LWS_WITH_ESP8266)
        if (wsi->sock > context->max_fds) {
                lwsl_err("fd %d too high (%d)\n", wsi->sock, context->max_fds);
                return 1;
index 82208d3..55dd09d 100644 (file)
@@ -155,7 +155,7 @@ int fork(void);
 #include <strings.h>
 #include <unistd.h>
 #include <sys/types.h>
-#ifndef MBED_OPERATORS
+
 #ifndef __cplusplus
 #include <errno.h>
 #endif
@@ -209,8 +209,6 @@ int kill(int pid, int sig);
 #include <uv.h>
 #endif
 
-#endif /* MBED */
-
 #ifndef LWS_NO_FORK
 #ifdef LWS_HAVE_SYS_PRCTL_H
 #include <sys/prctl.h>
@@ -229,7 +227,7 @@ int kill(int pid, int sig);
 
 #define lws_set_blocking_send(wsi)
 
-#if defined(MBED_OPERATORS) || defined(LWS_WITH_ESP8266)
+#if defined(LWS_WITH_ESP8266)
 #define lws_socket_is_valid(x) ((x) != NULL)
 #define LWS_SOCK_INVALID (NULL)
 struct lws;
@@ -313,20 +311,6 @@ static inline int compatible_close(int fd) { return close(fd); }
 #include <gettimeofday.h>
 #endif
 
-#if defined(MBED_OPERATORS)
-#undef compatible_close
-#define compatible_close(fd) mbed3_delete_tcp_stream_socket(fd)
-#ifndef BIG_ENDIAN
-#define BIG_ENDIAN    4321  /* to show byte order (taken from gcc) */
-#endif
-#ifndef LITTLE_ENDIAN
-#define LITTLE_ENDIAN 1234
-#endif
-#ifndef BYTE_ORDER
-#define BYTE_ORDER LITTLE_ENDIAN
-#endif
-#endif
-
 #if defined(LWS_WITH_ESP8266)
 #undef compatible_close
 #define compatible_close(fd) { fd->state=ESPCONN_CLOSE; espconn_delete(fd); }
@@ -1589,7 +1573,7 @@ lws_b64_selftest(void);
 LWS_EXTERN int
 lws_service_flag_pending(struct lws_context *context, int tsi);
 
-#if defined(_WIN32) || defined(MBED_OPERATORS) || defined(LWS_WITH_ESP8266)
+#if defined(_WIN32) || defined(LWS_WITH_ESP8266)
 LWS_EXTERN struct lws *
 wsi_from_fd(const struct lws_context *context, lws_sockfd_type fd);
 
@@ -1772,7 +1756,7 @@ LWS_EXTERN int get_daemonize_pid();
 #define get_daemonize_pid() (0)
 #endif
 
-#if !defined(MBED_OPERATORS) && !defined(LWS_WITH_ESP8266)
+#if !defined(LWS_WITH_ESP8266)
 LWS_EXTERN int LWS_WARN_UNUSED_RESULT
 interface_to_sa(struct lws_vhost *vh, const char *ifname,
                struct sockaddr_in *addr, size_t addrlen);
index 62832a4..5448468 100644 (file)
@@ -87,10 +87,6 @@ lws_context_init_server(struct lws_context_creation_info *info,
 #if defined(LWS_WITH_ESP8266)
        sockfd = esp8266_create_tcp_listen_socket(vhost);
        if (!lws_sockfd_valid(sockfd)) {
-
-#else
-       sockfd = mbed3_create_tcp_stream_socket();
-       if (!lws_sockfd_valid(sockfd)) {
 #endif
 #endif
                lwsl_err("ERROR opening socket\n");
@@ -177,8 +173,6 @@ lws_context_init_server(struct lws_context_creation_info *info,
 #else
 #if defined(LWS_WITH_ESP8266)
        esp8266_tcp_stream_bind(wsi->sock, info->port, wsi);
-#else
-       mbed3_tcp_stream_bind(wsi->sock, info->port, wsi);
 #endif
 #endif
        if (!lws_check_opt(info->options, LWS_SERVER_OPTION_EXPLICIT_VHOSTS)) {
@@ -1717,8 +1711,6 @@ lws_adopt_socket_vhost2(struct lws_vhost *vh, lws_sockfd_type accept_fd,
 #if LWS_POSIX == 0
 #if defined(LWS_WITH_ESP8266)
        esp8266_tcp_stream_accept(accept_fd, new_wsi);
-#else
-       mbed3_tcp_stream_accept(accept_fd, new_wsi);
 #endif
 #endif
        /*