1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-23 00:00:06 +01:00
libwebsockets/minimal-examples/embedded/pico/pico-sspc-binance/CMakeLists.txt
Andy Green 2cfa260e62 sspc: refactor to allow different transports
This is a NOP for existing usecases.

At the moment the only implemented transport for serialized SS is wsi, it's
typically used with Unix Domain Sockets, but it also works over tcp the
same.

It generalizes the interface between serialized chunks and the
transport, separately for client and proxy.  The wsi transport is migrated
to use the new transport ops structs.

It will then be possible to "bring your own transport", so long as it is
reliable, and in-order, both for proxy and client / sspc.

We also adapt minimal-secure-streams-binance to build the -client variant
via SS proxy as well.

LWS_ONLY_SSPC is added so libwebsockets can be produced with just sspc
client support even for tiny targets.

A new embedded minimal example for rpi pico is also provided that
demonstrates using Serialized SS over a UART to an SS proxy, to implement
the SS Binance example on the pico, even though it has no networking itself.
2021-10-08 09:48:41 +01:00

62 lines
1.7 KiB
CMake

# pico-sspc-binance demo
#
# connects a headless, networkless pico to binance over UART transport, using
# lws-minimal-secure-streams-custom-proxy-transport minimal example on PC
#
# Symlink or git submodule ./libwebsockets/ to main lws
# Build the whole thing with something like
#
# cmake .. -DLWS_ONLY_SSPC=1 -DPICO_SDK_PATH=../../pico-sdk
#
# proxy has to support LWS_ROLE_WS=1 and LWS_WITHOUT_EXTENSIONS=0
# to work with binance itself
cmake_minimum_required(VERSION 3.13)
# initialize the SDK based on PICO_SDK_PATH
# note: this must happen before project()
include(pico_sdk_import.cmake)
project(pico-sspc-binance)
pico_sdk_init()
set(LWS_WITH_SSL 0)
set(LWS_WITH_TLS 0)
set(LWS_WITH_SHARED 0)
set(LWS_PLAT_BAREMETAL 1)
set(LWS_WITH_NETWORK 0)
set(LWS_ONLY_SSPC 1) # remove everything except SSPC pieces from library build
# build lws as part of this
add_subdirectory(libwebsockets)
add_executable(pico-sspc-binance
main.c
system.c
helpers.c
transport-serial.c
binance-ss.c
get-ss.c
)
target_compile_definitions(pico-sspc-binance PUBLIC
PICO_STACK_SIZE=0x2000
LWS_SS_USE_SSPC)
# make sure we can include libwebsockets.h from the lws build
target_include_directories(pico-sspc-binance PRIVATE
# lws_config.h generated into here
${PROJECT_BINARY_DIR}/libwebsockets
# source includes will do for everything else
${PROJECT_SOURCE_DIR}/libwebsockets/include )
target_link_libraries(pico-sspc-binance
pico_stdlib
hardware_uart
websockets)
# logs on USB console /dev/ttyACM
pico_enable_stdio_usb(pico-sspc-binance 1)
# UART0 will be the sspc transport, don't put the console on it
pico_enable_stdio_uart(pico-sspc-binance 0)
pico_add_extra_outputs(pico-sspc-binance)