WSS, Libwebsockets

js1234
Posts: 18
Joined: Thu Jan 26, 2017 1:16 pm

WSS, Libwebsockets

Postby js1234 » Mon Feb 06, 2017 12:28 pm

Hello,

I need a WSS-Server Implementation for the ESP32. Looking through the Internet I did not find any complete example of it(Server,with SSL/TLS, websocket). The best thing I found was the SSL-Server Implementation in the examples, but this has no websockets.

Furthermore I tried to compile the libwebsockets library (https://libwebsockets.org/) with cmake and the xtensa-esp32-elf-gcc Compiler, but this is not very easy and cant find a lot of the include files/libraries.

I wonder how hard it is to port the library for the esp32 (I dont really have experience with this). Does anyone have experience with this or is it even possible?

I would appreciate any help!

This is the cmake command:
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_TOOLCHAIN_FILE=../cross-xtensa-esp32-elf.cmake -DWITHOUT_EXTENSIONS=1 -DWITH_SSL=0


The output of it:
-- The C compiler identification is GNU 5.2.0
-- Check for working C compiler: /home/js/esp/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
-- Check for working C compiler: /home/js/esp/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- CMAKE_TOOLCHAIN_FILE='/home/js/esp/libwebsockets/cross-xtensa-esp32-elf.cmake'
-- Found Git: /usr/bin/git
Git commit hash: root@js-VirtualBox-v2.0.0-237-gc220864
-- Performing Test LWS_HAVE_inline
-- Performing Test LWS_HAVE_inline - Success
-- Performing Test LWS_HAVE___inline__
-- Performing Test LWS_HAVE___inline__ - Success
-- Performing Test LWS_HAVE___inline
-- Performing Test LWS_HAVE___inline - Success
-- Looking for bzero
-- Looking for bzero - not found
-- Looking for fork
-- Looking for fork - not found
-- Looking for getenv
-- Looking for getenv - not found
-- Looking for malloc
-- Looking for malloc - not found
-- Looking for memset
-- Looking for memset - not found
-- Looking for realloc
-- Looking for realloc - not found
-- Looking for socket
-- Looking for socket - not found
-- Looking for strerror
-- Looking for strerror - not found
-- Looking for vfork
-- Looking for vfork - not found
-- Looking for execvpe
-- Looking for execvpe - not found
-- Looking for getifaddrs
-- Looking for getifaddrs - not found
-- Looking for snprintf
-- Looking for snprintf - not found
-- Looking for _snprintf
-- Looking for _snprintf - not found
-- Looking for _vsnprintf
-- Looking for _vsnprintf - not found
-- Looking for getloadavg
-- Looking for getloadavg - not found
-- Looking for dlfcn.h
-- Looking for dlfcn.h - not found
-- Looking for fcntl.h
-- Looking for fcntl.h - found
-- Looking for in6addr.h
-- Looking for in6addr.h - not found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for memory.h
-- Looking for memory.h - not found
-- Looking for netinet/in.h
-- Looking for netinet/in.h - not found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stdlib.h
-- Looking for stdlib.h - found
-- Looking for strings.h
-- Looking for strings.h - found
-- Looking for string.h
-- Looking for string.h - found
-- Looking for sys/prctl.h
-- Looking for sys/prctl.h - not found
-- Looking for sys/socket.h
-- Looking for sys/socket.h - not found
-- Looking for sys/sockio.h
-- Looking for sys/sockio.h - not found
-- Looking for sys/stat.h
-- Looking for sys/stat.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for vfork.h
-- Looking for vfork.h - not found
-- Looking for zlib.h
-- Looking for zlib.h - not found
-- Looking for 4 include files stdlib.h, ..., float.h
-- Looking for 4 include files stdlib.h, ..., float.h - found
-- Performing Test LWS_HAVE_VISIBILITY
-- Performing Test LWS_HAVE_VISIBILITY - Success
CMake Warning (dev) at CMakeLists.txt:754 (add_library):
ADD_LIBRARY called with SHARED option but the target platform does not
support dynamic linking. Building a STATIC library instead. This may lead
to problems.
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.5/Modules/FindZLIB.cmake:124 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:832 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/js/esp/libwebsockets/build/CMakeFiles/CMakeOutput.log".
See also "/home/js/esp/libwebsockets/build/CMakeFiles/CMakeError.log".
And the config file for cmake (cross-xtensa-esp32-elf.cmake):

Code: Select all

#
# CMake Toolchain file for crosscompiling on ESP32.
#
# This can be used when running cmake in the following way:
#  cd build/
#  cmake .. -DCMAKE_TOOLCHAIN_FILE=../cross-arm-linux-gnueabihf.cmake
#

INCLUDE(CMakeForceCompiler)

set(CROSS_PATH /home/js/esp/xtensa-esp32-elf/bin)
set(ESP_PATH /home/js/esp/esp-idf)

# Target operating system name.
set(CMAKE_SYSTEM_NAME Generic)
set(BUILD_SHARED_LIBS OFF)

# Name of C compiler.
set(CMAKE_C_COMPILER "${CROSS_PATH}/xtensa-esp32-elf-gcc")
set(CMAKE_CXX_COMPILER "${CROSS_PATH}/xtensa-esp32-elf-g++")

set(CMAKE_C_FLAGS "-nostdlib -Wall -Werror -I/home/esp/esp-idf/components/lwip/include/lwip/posix ${LWS_C_FLAGS} -Os" CACHE STRING "" FORCE)


#-I${ESP_PATH}/components/lwip/include/lwip/lwip 
# -I${ESP_PATH}/components/newlib/include


# Where to look for the target environment. (More paths can be added here)
set(CMAKE_FIND_ROOT_PATH "/home/js/esp/esp-idf/components/lwip/include/lwip/posix")

# Adjust the default behavior of the FIND_XXX() commands:
# search programs in the host environment only.
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# Search headers and libraries in the target environment only.
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: WSS, Libwebsockets

Postby WiFive » Mon Feb 06, 2017 12:49 pm

If you start with the esp8266 port it should be reasonable.

Otherwise you can look at mongoose-os if GPL is OK.

ThomasB
Posts: 38
Joined: Sun Dec 25, 2016 12:11 am

Re: WSS, Libwebsockets

Postby ThomasB » Mon Feb 06, 2017 7:40 pm

Not sure if this is something that might help, I wrote a WebSocket Server for the ESP32:
http://esp32.com/viewtopic.php?f=17&t=977


User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: WSS, Libwebsockets

Postby kolban » Sat Feb 11, 2017 6:59 pm

See also this relatively current issue:

https://github.com/warmcat/libwebsockets/issues/776
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

js1234
Posts: 18
Joined: Thu Jan 26, 2017 1:16 pm

Re: WSS, Libwebsockets

Postby js1234 » Mon Feb 13, 2017 4:22 pm

Ok, thanks for all the replies!

I will look into the port for the Esp32.

Best regards

Scalpel78
Posts: 51
Joined: Sun Feb 26, 2017 7:31 am

Re: WSS, Libwebsockets

Postby Scalpel78 » Sat May 06, 2017 10:24 pm

FYI, v2.2 of libwebsockets which was released on 8th march contains ESP32 support.

Has anyone tried it out?

js1234
Posts: 18
Joined: Thu Jan 26, 2017 1:16 pm

Re: WSS, Libwebsockets

Postby js1234 » Mon May 08, 2017 6:55 am

Yes there is support now. But Esp-IDF has some problems with Access Point.

See: https://github.com/warmcat/lws-esp32-factory/issues/3

tedwood
Posts: 11
Joined: Thu Mar 16, 2017 2:02 pm

Re: WSS, Libwebsockets

Postby tedwood » Wed May 10, 2017 2:05 pm

The AP problems appear to be fixed in the current version of ESP-IDF.

I still need some help creating a simple web server using libwebsockets. Has anyone done this yet?

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 133 guests