mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
Use direct member initialization instead of ctr initialisation (#7558)
* Use direct member initialization instead of ctr initialisation This removes a bit of code repetition. * Add symbolic names for member initializers
This commit is contained in:
@ -35,17 +35,11 @@ extern "C" uint32_t _EEPROM_start;
|
||||
|
||||
EEPROMClass::EEPROMClass(uint32_t sector)
|
||||
: _sector(sector)
|
||||
, _data(0)
|
||||
, _size(0)
|
||||
, _dirty(false)
|
||||
{
|
||||
}
|
||||
|
||||
EEPROMClass::EEPROMClass(void)
|
||||
: _sector((((uint32_t)&_EEPROM_start - 0x40200000) / SPI_FLASH_SEC_SIZE))
|
||||
, _data(0)
|
||||
, _size(0)
|
||||
, _dirty(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -68,9 +68,9 @@ public:
|
||||
|
||||
protected:
|
||||
uint32_t _sector;
|
||||
uint8_t* _data;
|
||||
size_t _size;
|
||||
bool _dirty;
|
||||
uint8_t* _data = nullptr;
|
||||
size_t _size = 0;
|
||||
bool _dirty = false;
|
||||
};
|
||||
|
||||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_EEPROM)
|
||||
|
@ -47,12 +47,10 @@ extern "C" {
|
||||
#include "include/UdpContext.h"
|
||||
//#define DEBUG_SSDP Serial
|
||||
|
||||
#define SSDP_INTERVAL 1200
|
||||
#define SSDP_PORT 1900
|
||||
#define SSDP_METHOD_SIZE 10
|
||||
#define SSDP_URI_SIZE 2
|
||||
#define SSDP_BUFFER_SIZE 64
|
||||
#define SSDP_MULTICAST_TTL 2
|
||||
|
||||
// ssdp ipv6 is FF05::C
|
||||
// lwip-v2's igmp_joingroup only supports IPv4
|
||||
@ -125,19 +123,8 @@ struct SSDPTimer {
|
||||
ETSTimer timer;
|
||||
};
|
||||
|
||||
SSDPClass::SSDPClass() :
|
||||
_server(0),
|
||||
_timer(0),
|
||||
_port(80),
|
||||
_ttl(SSDP_MULTICAST_TTL),
|
||||
_interval(SSDP_INTERVAL),
|
||||
_respondToAddr(0,0,0,0),
|
||||
_respondToPort(0),
|
||||
_pending(false),
|
||||
_st_is_uuid(false),
|
||||
_delay(0),
|
||||
_process_time(0),
|
||||
_notify_time(0)
|
||||
SSDPClass::SSDPClass()
|
||||
: _respondToAddr(0,0,0,0)
|
||||
{
|
||||
_uuid[0] = '\0';
|
||||
_modelNumber[0] = '\0';
|
||||
|
@ -46,6 +46,9 @@ class UdpContext;
|
||||
#define SSDP_MODEL_VERSION_SIZE 32
|
||||
#define SSDP_MANUFACTURER_SIZE 64
|
||||
#define SSDP_MANUFACTURER_URL_SIZE 128
|
||||
#define SSDP_INTERVAL_SECONDS 1200
|
||||
#define SSDP_MULTICAST_TTL 2
|
||||
#define SSDP_HTTP_PORT 80
|
||||
|
||||
typedef enum {
|
||||
NONE,
|
||||
@ -101,20 +104,20 @@ class SSDPClass{
|
||||
void _stopTimer();
|
||||
static void _onTimerStatic(SSDPClass* self);
|
||||
|
||||
UdpContext* _server;
|
||||
SSDPTimer* _timer;
|
||||
uint16_t _port;
|
||||
uint8_t _ttl;
|
||||
uint32_t _interval;
|
||||
UdpContext* _server = nullptr;
|
||||
SSDPTimer* _timer = nullptr;
|
||||
uint16_t _port = SSDP_HTTP_PORT;
|
||||
uint8_t _ttl = SSDP_MULTICAST_TTL;
|
||||
uint32_t _interval = SSDP_INTERVAL_SECONDS;
|
||||
|
||||
IPAddress _respondToAddr;
|
||||
uint16_t _respondToPort;
|
||||
uint16_t _respondToPort = 0;
|
||||
|
||||
bool _pending;
|
||||
bool _st_is_uuid;
|
||||
unsigned short _delay;
|
||||
unsigned long _process_time;
|
||||
unsigned long _notify_time;
|
||||
bool _pending = false;
|
||||
bool _st_is_uuid = false;
|
||||
unsigned short _delay = 0;
|
||||
unsigned long _process_time = 0;
|
||||
unsigned long _notify_time = 0;
|
||||
|
||||
char _schemaURL[SSDP_SCHEMA_URL_SIZE];
|
||||
char _uuid[SSDP_UUID_SIZE];
|
||||
|
@ -39,47 +39,12 @@ namespace esp8266webserver {
|
||||
template <typename ServerType>
|
||||
ESP8266WebServerTemplate<ServerType>::ESP8266WebServerTemplate(IPAddress addr, int port)
|
||||
: _server(addr, port)
|
||||
, _currentMethod(HTTP_ANY)
|
||||
, _currentVersion(0)
|
||||
, _currentStatus(HC_NONE)
|
||||
, _statusChange(0)
|
||||
, _keepAlive(false)
|
||||
, _currentHandler(nullptr)
|
||||
, _firstHandler(nullptr)
|
||||
, _lastHandler(nullptr)
|
||||
, _currentArgCount(0)
|
||||
, _currentArgs(nullptr)
|
||||
, _currentArgsHavePlain(0)
|
||||
, _postArgsLen(0)
|
||||
, _postArgs(nullptr)
|
||||
, _headerKeysCount(0)
|
||||
, _currentHeaders(nullptr)
|
||||
, _contentLength(0)
|
||||
, _chunked(false)
|
||||
, _corsEnabled(false)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename ServerType>
|
||||
ESP8266WebServerTemplate<ServerType>::ESP8266WebServerTemplate(int port)
|
||||
: _server(port)
|
||||
, _currentMethod(HTTP_ANY)
|
||||
, _currentVersion(0)
|
||||
, _currentStatus(HC_NONE)
|
||||
, _statusChange(0)
|
||||
, _currentHandler(nullptr)
|
||||
, _firstHandler(nullptr)
|
||||
, _lastHandler(nullptr)
|
||||
, _currentArgCount(0)
|
||||
, _currentArgs(nullptr)
|
||||
, _currentArgsHavePlain(0)
|
||||
, _postArgsLen(0)
|
||||
, _postArgs(nullptr)
|
||||
, _headerKeysCount(0)
|
||||
, _currentHeaders(nullptr)
|
||||
, _contentLength(0)
|
||||
, _chunked(false)
|
||||
, _corsEnabled(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -263,35 +263,35 @@ protected:
|
||||
|
||||
ServerType _server;
|
||||
ClientType _currentClient;
|
||||
HTTPMethod _currentMethod;
|
||||
HTTPMethod _currentMethod = HTTP_ANY;
|
||||
String _currentUri;
|
||||
uint8_t _currentVersion;
|
||||
HTTPClientStatus _currentStatus;
|
||||
unsigned long _statusChange;
|
||||
bool _keepAlive;
|
||||
uint8_t _currentVersion = 0;
|
||||
HTTPClientStatus _currentStatus = HC_NONE;
|
||||
unsigned long _statusChange = 0;
|
||||
|
||||
RequestHandlerType* _currentHandler;
|
||||
RequestHandlerType* _firstHandler;
|
||||
RequestHandlerType* _lastHandler;
|
||||
RequestHandlerType* _currentHandler = nullptr;
|
||||
RequestHandlerType* _firstHandler = nullptr;
|
||||
RequestHandlerType* _lastHandler = nullptr;
|
||||
THandlerFunction _notFoundHandler;
|
||||
THandlerFunction _fileUploadHandler;
|
||||
|
||||
int _currentArgCount;
|
||||
RequestArgument* _currentArgs;
|
||||
int _currentArgsHavePlain;
|
||||
int _currentArgCount = 0;
|
||||
RequestArgument* _currentArgs = nullptr;
|
||||
int _currentArgsHavePlain = 0;
|
||||
std::unique_ptr<HTTPUpload> _currentUpload;
|
||||
int _postArgsLen;
|
||||
RequestArgument* _postArgs;
|
||||
int _postArgsLen = 0;
|
||||
RequestArgument* _postArgs = nullptr;
|
||||
|
||||
int _headerKeysCount;
|
||||
RequestArgument* _currentHeaders;
|
||||
int _headerKeysCount = 0;
|
||||
RequestArgument* _currentHeaders = nullptr;
|
||||
|
||||
size_t _contentLength;
|
||||
size_t _contentLength = 0;
|
||||
String _responseHeaders;
|
||||
|
||||
String _hostHeader;
|
||||
bool _chunked;
|
||||
bool _corsEnabled;
|
||||
bool _chunked = false;
|
||||
bool _corsEnabled = false;
|
||||
bool _keepAlive = false;
|
||||
|
||||
String _snonce; // Store noance and opaque for future comparison
|
||||
String _sopaque;
|
||||
|
@ -44,18 +44,12 @@ extern "C" {
|
||||
WiFiServer::WiFiServer(const IPAddress& addr, uint16_t port)
|
||||
: _port(port)
|
||||
, _addr(addr)
|
||||
, _listen_pcb(nullptr)
|
||||
, _unclaimed(nullptr)
|
||||
, _discarded(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
WiFiServer::WiFiServer(uint16_t port)
|
||||
: _port(port)
|
||||
, _addr(IP_ANY_TYPE)
|
||||
, _listen_pcb(nullptr)
|
||||
, _unclaimed(nullptr)
|
||||
, _discarded(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -70,10 +70,10 @@ class WiFiServer : public Server {
|
||||
protected:
|
||||
uint16_t _port;
|
||||
IPAddress _addr;
|
||||
tcp_pcb* _listen_pcb;
|
||||
tcp_pcb* _listen_pcb = nullptr;
|
||||
|
||||
ClientContext* _unclaimed;
|
||||
ClientContext* _discarded;
|
||||
ClientContext* _unclaimed = nullptr;
|
||||
ClientContext* _discarded = nullptr;
|
||||
enum { _ndDefault, _ndFalse, _ndTrue } _noDelay = _ndDefault;
|
||||
|
||||
public:
|
||||
|
Reference in New Issue
Block a user