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/private.h
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

44 lines
1.1 KiB
C

/*
* pico-sspc-binance
*
* Written in 2010-2021 by Andy Green <andy@warmcat.com>
*
* This file is made available under the Creative Commons CC0 1.0
* Universal Public Domain Dedication.
*/
/* boilerplate for using PICO_SDK */
#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/types.h"
#include "hardware/uart.h"
#include "hardware/irq.h"
/* boilerplate for LWS_ONLY_SSPC Secure Streams
* LWS_SS_USE_SSPC should be defined by cmake
*/
#undef STANDALONE
#define STANDALONE
#include <libwebsockets.h>
#define RXBUF_SIZE 2048
extern lws_dll2_owner_t scheduler;
extern uint16_t rxh, rxt;
extern uint8_t rxbuf[RXBUF_SIZE];
extern int rx_overflowed;
extern unsigned int actual_baud;
extern lws_transport_mux_t *tm;
/* our transport related apis */
extern int pico_example_open_serial_port(uart_inst_t * const port);
extern const lws_transport_client_ops_t lws_sss_ops_client_serial;
void serial_handle_events(lws_transport_mux_t *tm);
/* our SS bindings */
extern const lws_ss_info_t ssi_binance; /* binance-ss.c */
extern const lws_ss_info_t ssi_get; /* get-ss.c */