first step for SSL (wss) support

This commit is contained in:
Markus Sattler
2015-12-10 09:36:18 +01:00
parent 7a22dad9d1
commit 093797a815
5 changed files with 205 additions and 72 deletions

View File

@ -27,25 +27,59 @@
#include <Arduino.h>
#ifdef ESP8266
#include <ESP8266WiFi.h>
#else
#include <UIPEthernet.h>
#ifndef UIPETHERNET_H
#include <Ethernet.h>
#include <SPI.h>
#endif
#endif
//#define DEBUG_WEBSOCKETS(...) Serial1.printf( __VA_ARGS__ )
#define DEBUG_WEBSOCKETS(...) Serial1.printf( __VA_ARGS__ )
#ifndef DEBUG_WEBSOCKETS
#define DEBUG_WEBSOCKETS(...)
#endif
#ifdef ESP8266
#define WEBSOCKETS_MAX_DATA_SIZE (15*1024)
#else
//atmega328p has only 2KB ram!
#define WEBSOCKETS_MAX_DATA_SIZE (1024)
#endif
#define WEBSOCKETS_TCP_TIMEOUT (1500)
#define NETWORK_ESP8266 (1)
#define NETWORK_W5100 (2)
#define NETWORK_ENC28J60 (3)
// select Network type based
#ifdef ESP8266
#define WEBSOCKETS_NETWORK_TYPE NETWORK_ESP8266
#else
#define WEBSOCKETS_NETWORK_TYPE NETWORK_W5100
#endif
#if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266)
#ifndef ESP8266
#error "network type ESP8266 only possible on the ESP mcu!"
#endif
#include <ESP8266WiFi.h>
#define WEBSOCKETS_NETWORK_CLASS WiFiClient
#elif (WEBSOCKETS_NETWORK_TYPE == NETWORK_W5100)
#include <Ethernet.h>
#include <SPI.h>
#define WEBSOCKETS_NETWORK_CLASS EthernetClient
#elif (WEBSOCKETS_NETWORK_TYPE == NETWORK_ENC28J60)
#include <UIPEthernet.h>
#define WEBSOCKETS_NETWORK_CLASS UIPClient
#else
#error "no network type selected!"
#endif
typedef enum {
WSC_NOT_CONNECTED,
WSC_HEADER,
@ -75,15 +109,14 @@ typedef struct {
uint8_t num; ///< connection number
WSclientsStatus_t status;
#ifdef ESP8266
WiFiClient tcp;
#else
#ifdef UIPETHERNET_H
UIPClient tcp;
#else
EthernetClient tcp;
#endif
WEBSOCKETS_NETWORK_CLASS * tcp;
#if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266)
bool isSSL; ///< run in ssl mode
WiFiClientSecure * ssl;
#endif
String cUrl; ///< http url
uint16_t cCode; ///< http code