mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +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:
parent
8b8639e833
commit
4aeb0f5cca
@ -35,17 +35,15 @@
|
|||||||
|
|
||||||
class Print {
|
class Print {
|
||||||
private:
|
private:
|
||||||
int write_error;
|
int write_error = 0;
|
||||||
template<typename T> size_t printNumber(T n, uint8_t base);
|
template<typename T> size_t printNumber(T n, uint8_t base);
|
||||||
template<typename T, typename... P> inline size_t _println(T v, P... args);
|
template<typename T, typename... P> inline size_t _println(T v, P... args);
|
||||||
protected:
|
protected:
|
||||||
void setWriteError(int err = 1) {
|
void setWriteError(int err = 1) {
|
||||||
write_error = err;
|
write_error = err;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
Print() :
|
Print() {}
|
||||||
write_error(0) {
|
|
||||||
}
|
|
||||||
|
|
||||||
int getWriteError() {
|
int getWriteError() {
|
||||||
return write_error;
|
return write_error;
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
class Stream: public Print {
|
class Stream: public Print {
|
||||||
protected:
|
protected:
|
||||||
unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read
|
unsigned long _timeout = 1000; // number of milliseconds to wait for the next char before aborting timed read
|
||||||
unsigned long _startMillis; // used for timeout measurement
|
unsigned long _startMillis; // used for timeout measurement
|
||||||
int timedRead(); // private method to read stream with timeout
|
int timedRead(); // private method to read stream with timeout
|
||||||
int timedPeek(); // private method to peek stream with timeout
|
int timedPeek(); // private method to peek stream with timeout
|
||||||
@ -48,9 +48,7 @@ class Stream: public Print {
|
|||||||
virtual int read() = 0;
|
virtual int read() = 0;
|
||||||
virtual int peek() = 0;
|
virtual int peek() = 0;
|
||||||
|
|
||||||
Stream() {
|
Stream() {}
|
||||||
_timeout = 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
// parsing methods
|
// parsing methods
|
||||||
|
|
||||||
|
@ -27,18 +27,6 @@ extern "C" uint32_t _FS_start;
|
|||||||
extern "C" uint32_t _FS_end;
|
extern "C" uint32_t _FS_end;
|
||||||
|
|
||||||
UpdaterClass::UpdaterClass()
|
UpdaterClass::UpdaterClass()
|
||||||
: _async(false)
|
|
||||||
, _error(0)
|
|
||||||
, _buffer(0)
|
|
||||||
, _bufferLen(0)
|
|
||||||
, _size(0)
|
|
||||||
, _startAddress(0)
|
|
||||||
, _currentAddress(0)
|
|
||||||
, _command(U_FLASH)
|
|
||||||
, _ledPin(-1)
|
|
||||||
, _hash(nullptr)
|
|
||||||
, _verify(nullptr)
|
|
||||||
, _progress_callback(nullptr)
|
|
||||||
{
|
{
|
||||||
#if ARDUINO_SIGNING
|
#if ARDUINO_SIGNING
|
||||||
installSignature(&esp8266::updaterSigningHash, &esp8266::updaterSigningVerifier);
|
installSignature(&esp8266::updaterSigningHash, &esp8266::updaterSigningVerifier);
|
||||||
|
@ -182,27 +182,27 @@ class UpdaterClass {
|
|||||||
|
|
||||||
void _setError(int error);
|
void _setError(int error);
|
||||||
|
|
||||||
bool _async;
|
bool _async = false;
|
||||||
uint8_t _error;
|
uint8_t _error = 0;
|
||||||
uint8_t *_buffer;
|
uint8_t *_buffer = nullptr;
|
||||||
size_t _bufferLen; // amount of data written into _buffer
|
size_t _bufferLen = 0; // amount of data written into _buffer
|
||||||
size_t _bufferSize; // total size of _buffer
|
size_t _bufferSize = 0; // total size of _buffer
|
||||||
size_t _size;
|
size_t _size = 0;
|
||||||
uint32_t _startAddress;
|
uint32_t _startAddress = 0;
|
||||||
uint32_t _currentAddress;
|
uint32_t _currentAddress = 0;
|
||||||
uint32_t _command;
|
uint32_t _command = U_FLASH;
|
||||||
|
|
||||||
String _target_md5;
|
String _target_md5;
|
||||||
MD5Builder _md5;
|
MD5Builder _md5;
|
||||||
|
|
||||||
int _ledPin;
|
int _ledPin = -1;
|
||||||
uint8_t _ledOn;
|
uint8_t _ledOn;
|
||||||
|
|
||||||
// Optional signed binary verification
|
// Optional signed binary verification
|
||||||
UpdaterHashClass *_hash;
|
UpdaterHashClass *_hash = nullptr;
|
||||||
UpdaterVerifyClass *_verify;
|
UpdaterVerifyClass *_verify = nullptr;
|
||||||
// Optional progress callback function
|
// Optional progress callback function
|
||||||
THandlerFunction_Progress _progress_callback;
|
THandlerFunction_Progress _progress_callback = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern UpdaterClass Update;
|
extern UpdaterClass Update;
|
||||||
|
@ -35,17 +35,11 @@ extern "C" uint32_t _EEPROM_start;
|
|||||||
|
|
||||||
EEPROMClass::EEPROMClass(uint32_t sector)
|
EEPROMClass::EEPROMClass(uint32_t sector)
|
||||||
: _sector(sector)
|
: _sector(sector)
|
||||||
, _data(0)
|
|
||||||
, _size(0)
|
|
||||||
, _dirty(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
EEPROMClass::EEPROMClass(void)
|
EEPROMClass::EEPROMClass(void)
|
||||||
: _sector((((uint32_t)&_EEPROM_start - 0x40200000) / SPI_FLASH_SEC_SIZE))
|
: _sector((((uint32_t)&_EEPROM_start - 0x40200000) / SPI_FLASH_SEC_SIZE))
|
||||||
, _data(0)
|
|
||||||
, _size(0)
|
|
||||||
, _dirty(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,9 +68,9 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint32_t _sector;
|
uint32_t _sector;
|
||||||
uint8_t* _data;
|
uint8_t* _data = nullptr;
|
||||||
size_t _size;
|
size_t _size = 0;
|
||||||
bool _dirty;
|
bool _dirty = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_EEPROM)
|
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_EEPROM)
|
||||||
|
@ -47,12 +47,10 @@ extern "C" {
|
|||||||
#include "include/UdpContext.h"
|
#include "include/UdpContext.h"
|
||||||
//#define DEBUG_SSDP Serial
|
//#define DEBUG_SSDP Serial
|
||||||
|
|
||||||
#define SSDP_INTERVAL 1200
|
|
||||||
#define SSDP_PORT 1900
|
#define SSDP_PORT 1900
|
||||||
#define SSDP_METHOD_SIZE 10
|
#define SSDP_METHOD_SIZE 10
|
||||||
#define SSDP_URI_SIZE 2
|
#define SSDP_URI_SIZE 2
|
||||||
#define SSDP_BUFFER_SIZE 64
|
#define SSDP_BUFFER_SIZE 64
|
||||||
#define SSDP_MULTICAST_TTL 2
|
|
||||||
|
|
||||||
// ssdp ipv6 is FF05::C
|
// ssdp ipv6 is FF05::C
|
||||||
// lwip-v2's igmp_joingroup only supports IPv4
|
// lwip-v2's igmp_joingroup only supports IPv4
|
||||||
@ -125,19 +123,8 @@ struct SSDPTimer {
|
|||||||
ETSTimer timer;
|
ETSTimer timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
SSDPClass::SSDPClass() :
|
SSDPClass::SSDPClass()
|
||||||
_server(0),
|
: _respondToAddr(0,0,0,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)
|
|
||||||
{
|
{
|
||||||
_uuid[0] = '\0';
|
_uuid[0] = '\0';
|
||||||
_modelNumber[0] = '\0';
|
_modelNumber[0] = '\0';
|
||||||
|
@ -46,6 +46,9 @@ class UdpContext;
|
|||||||
#define SSDP_MODEL_VERSION_SIZE 32
|
#define SSDP_MODEL_VERSION_SIZE 32
|
||||||
#define SSDP_MANUFACTURER_SIZE 64
|
#define SSDP_MANUFACTURER_SIZE 64
|
||||||
#define SSDP_MANUFACTURER_URL_SIZE 128
|
#define SSDP_MANUFACTURER_URL_SIZE 128
|
||||||
|
#define SSDP_INTERVAL_SECONDS 1200
|
||||||
|
#define SSDP_MULTICAST_TTL 2
|
||||||
|
#define SSDP_HTTP_PORT 80
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NONE,
|
NONE,
|
||||||
@ -101,20 +104,20 @@ class SSDPClass{
|
|||||||
void _stopTimer();
|
void _stopTimer();
|
||||||
static void _onTimerStatic(SSDPClass* self);
|
static void _onTimerStatic(SSDPClass* self);
|
||||||
|
|
||||||
UdpContext* _server;
|
UdpContext* _server = nullptr;
|
||||||
SSDPTimer* _timer;
|
SSDPTimer* _timer = nullptr;
|
||||||
uint16_t _port;
|
uint16_t _port = SSDP_HTTP_PORT;
|
||||||
uint8_t _ttl;
|
uint8_t _ttl = SSDP_MULTICAST_TTL;
|
||||||
uint32_t _interval;
|
uint32_t _interval = SSDP_INTERVAL_SECONDS;
|
||||||
|
|
||||||
IPAddress _respondToAddr;
|
IPAddress _respondToAddr;
|
||||||
uint16_t _respondToPort;
|
uint16_t _respondToPort = 0;
|
||||||
|
|
||||||
bool _pending;
|
bool _pending = false;
|
||||||
bool _st_is_uuid;
|
bool _st_is_uuid = false;
|
||||||
unsigned short _delay;
|
unsigned short _delay = 0;
|
||||||
unsigned long _process_time;
|
unsigned long _process_time = 0;
|
||||||
unsigned long _notify_time;
|
unsigned long _notify_time = 0;
|
||||||
|
|
||||||
char _schemaURL[SSDP_SCHEMA_URL_SIZE];
|
char _schemaURL[SSDP_SCHEMA_URL_SIZE];
|
||||||
char _uuid[SSDP_UUID_SIZE];
|
char _uuid[SSDP_UUID_SIZE];
|
||||||
|
@ -39,47 +39,12 @@ namespace esp8266webserver {
|
|||||||
template <typename ServerType>
|
template <typename ServerType>
|
||||||
ESP8266WebServerTemplate<ServerType>::ESP8266WebServerTemplate(IPAddress addr, int port)
|
ESP8266WebServerTemplate<ServerType>::ESP8266WebServerTemplate(IPAddress addr, int port)
|
||||||
: _server(addr, 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>
|
template <typename ServerType>
|
||||||
ESP8266WebServerTemplate<ServerType>::ESP8266WebServerTemplate(int port)
|
ESP8266WebServerTemplate<ServerType>::ESP8266WebServerTemplate(int port)
|
||||||
: _server(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;
|
ServerType _server;
|
||||||
ClientType _currentClient;
|
ClientType _currentClient;
|
||||||
HTTPMethod _currentMethod;
|
HTTPMethod _currentMethod = HTTP_ANY;
|
||||||
String _currentUri;
|
String _currentUri;
|
||||||
uint8_t _currentVersion;
|
uint8_t _currentVersion = 0;
|
||||||
HTTPClientStatus _currentStatus;
|
HTTPClientStatus _currentStatus = HC_NONE;
|
||||||
unsigned long _statusChange;
|
unsigned long _statusChange = 0;
|
||||||
bool _keepAlive;
|
|
||||||
|
|
||||||
RequestHandlerType* _currentHandler;
|
RequestHandlerType* _currentHandler = nullptr;
|
||||||
RequestHandlerType* _firstHandler;
|
RequestHandlerType* _firstHandler = nullptr;
|
||||||
RequestHandlerType* _lastHandler;
|
RequestHandlerType* _lastHandler = nullptr;
|
||||||
THandlerFunction _notFoundHandler;
|
THandlerFunction _notFoundHandler;
|
||||||
THandlerFunction _fileUploadHandler;
|
THandlerFunction _fileUploadHandler;
|
||||||
|
|
||||||
int _currentArgCount;
|
int _currentArgCount = 0;
|
||||||
RequestArgument* _currentArgs;
|
RequestArgument* _currentArgs = nullptr;
|
||||||
int _currentArgsHavePlain;
|
int _currentArgsHavePlain = 0;
|
||||||
std::unique_ptr<HTTPUpload> _currentUpload;
|
std::unique_ptr<HTTPUpload> _currentUpload;
|
||||||
int _postArgsLen;
|
int _postArgsLen = 0;
|
||||||
RequestArgument* _postArgs;
|
RequestArgument* _postArgs = nullptr;
|
||||||
|
|
||||||
int _headerKeysCount;
|
int _headerKeysCount = 0;
|
||||||
RequestArgument* _currentHeaders;
|
RequestArgument* _currentHeaders = nullptr;
|
||||||
|
|
||||||
size_t _contentLength;
|
size_t _contentLength = 0;
|
||||||
String _responseHeaders;
|
String _responseHeaders;
|
||||||
|
|
||||||
String _hostHeader;
|
String _hostHeader;
|
||||||
bool _chunked;
|
bool _chunked = false;
|
||||||
bool _corsEnabled;
|
bool _corsEnabled = false;
|
||||||
|
bool _keepAlive = false;
|
||||||
|
|
||||||
String _snonce; // Store noance and opaque for future comparison
|
String _snonce; // Store noance and opaque for future comparison
|
||||||
String _sopaque;
|
String _sopaque;
|
||||||
|
@ -44,18 +44,12 @@ extern "C" {
|
|||||||
WiFiServer::WiFiServer(const IPAddress& addr, uint16_t port)
|
WiFiServer::WiFiServer(const IPAddress& addr, uint16_t port)
|
||||||
: _port(port)
|
: _port(port)
|
||||||
, _addr(addr)
|
, _addr(addr)
|
||||||
, _listen_pcb(nullptr)
|
|
||||||
, _unclaimed(nullptr)
|
|
||||||
, _discarded(nullptr)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
WiFiServer::WiFiServer(uint16_t port)
|
WiFiServer::WiFiServer(uint16_t port)
|
||||||
: _port(port)
|
: _port(port)
|
||||||
, _addr(IP_ANY_TYPE)
|
, _addr(IP_ANY_TYPE)
|
||||||
, _listen_pcb(nullptr)
|
|
||||||
, _unclaimed(nullptr)
|
|
||||||
, _discarded(nullptr)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,10 +70,10 @@ class WiFiServer : public Server {
|
|||||||
protected:
|
protected:
|
||||||
uint16_t _port;
|
uint16_t _port;
|
||||||
IPAddress _addr;
|
IPAddress _addr;
|
||||||
tcp_pcb* _listen_pcb;
|
tcp_pcb* _listen_pcb = nullptr;
|
||||||
|
|
||||||
ClientContext* _unclaimed;
|
ClientContext* _unclaimed = nullptr;
|
||||||
ClientContext* _discarded;
|
ClientContext* _discarded = nullptr;
|
||||||
enum { _ndDefault, _ndFalse, _ndTrue } _noDelay = _ndDefault;
|
enum { _ndDefault, _ndFalse, _ndTrue } _noDelay = _ndDefault;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user