mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-22 21:23:07 +03:00
* Convert ESP8266WebServer* into templatized model Supercedes #4912 Refactor the three versions of ESP8266WebServer and *WebServerSecure to a single templated class. Use "using" to enable old, non-templated names to b used (so no user changes required to compile or run). Fixes #4908 and clean up the code base a lot. Basic tests run (the ones in the example code). No code changes are required in userland except for setting the SSL certificates which now use a cleaner "getServer()" accessor and lets the app use the native BearSSL calls on the WiFiClientSecure object. @devyte should be proud, it removes virtuals and even has template specialization... * Fix HTTPUpdate templates and examples * Fix HTTPUpdateServer library build Need to remove dot-a linkage since there are no .cpp files in the directory anymore due to templates. * Provide backward-compat names for updt template Allow existing code to use the same well known names for HTTPUpdateSecure. * Remove ClientType from all templates, auto-infer Remove the ClientType template parameter from all objects. Simplifies the code and makes it more foolproof. Add a "using" in each server to define the type of connection returned by all servers, which is then used in the above templates automatically. * Can safely include FS.h now that SD/SPIFFS unified * Move the templates/objects to their own namespaces * Fix merge issues with untemplated methods * Address review comments * Fix mock test, remove warnings inside test dir Make the simple mock test CI job pass and clean up any spurious warnings in the test directory. There still are warnings in the libraries and core, but they should be addressed in a separate PR.
44 lines
1.5 KiB
C++
44 lines
1.5 KiB
C++
/*
|
|
sdfs.h - SDFS mock for host side testing
|
|
Copyright (c) 2019 Earle F. Philhower, III
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
all copies or substantial portions of the Software.
|
|
*/
|
|
|
|
#ifndef sdfs_mock_hpp
|
|
#define sdfs_mock_hpp
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <vector>
|
|
#include <FS.h>
|
|
|
|
class SDFSMock {
|
|
public:
|
|
SDFSMock(ssize_t fs_size, size_t fs_block, size_t fs_page, const String& storage = emptyString) { (void)fs_size; (void)fs_block; (void)fs_page; (void)storage; }
|
|
void reset() { }
|
|
~SDFSMock() { }
|
|
};
|
|
|
|
extern uint64_t _sdCardSizeB;
|
|
extern uint8_t *_sdCard;
|
|
|
|
#define SDFS_MOCK_DECLARE(size_kb, block_kb, page_b, storage) \
|
|
SDFS.end(); \
|
|
SDFSMock sdfs_mock(size_kb * 1024, block_kb * 1024, page_b, storage); free(_sdCard); \
|
|
_sdCardSizeB = size_kb ? 16 * 1024 * 1024 : 0; \
|
|
if (_sdCardSizeB) _sdCard = (uint8_t*)calloc(_sdCardSizeB, 1); \
|
|
else _sdCard = nullptr; \
|
|
SDFS.setConfig(SDFSConfig().setAutoFormat(true));
|
|
#define SDFS_MOCK_RESET() sdfs_mock.reset()
|
|
|
|
#endif /* spiffs_mock_hpp */
|