Browse Source

add example

master
rjwats@gmail.com 6 years ago
parent
commit
ff43e69bc0
  1. 36
      README.md
  2. 2
      src/WiFiStatus.h

36
README.md

@ -95,7 +95,41 @@ The default settings configure the device to bring up an access point on start u
## Software Overview
TODO...
### Back End
The back end is a set of REST endpoints hosted by a ([ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer)) instance. The source is split up by feature, for example ([WiFiScanner.h](src/WiFiScanner.h)) implements the end points for scanning for available networks.
There is an abstract class ([SettingsService.h](src/SettingsService.h)) that provides an easy means of adding configurable services/features to the device. It takes care of writing the settings as JSON to the SPIFFS filesystem. All you need to do is extend the class with your required configuration and implement the functions which serialize the settings to/from JSON. JSON serialization utilizes the excellent [ArduinoJson](https://github.com/bblanchon/ArduinoJson) library. Here is a example is a service with username and password settings:
```cpp
#include <SettingsService.h>
class ExampleSettingsService : public SettingsService {
public:
ExampleSettingsService(AsyncWebServer* server, FS* fs) : SettingsService(server, fs, "/apSettings", "/config/apSettings.json") {}
~ExampleSettingsService(){}
protected:
void readFromJsonObject(JsonObject& root) {
_username = root["username"] | "";
_password = root["password"] | "";
}
void writeToJsonObject(JsonObject& root) {
root["username"] = _username;
root["password"] = _password;
}
private:
String _username;
String _password;
};
```
## Future Extensions

2
src/WiFiStatus.h

@ -23,7 +23,7 @@ class WiFiStatus {
WiFiEventHandler _onStationModeDisconnectedHandler;
WiFiEventHandler _onStationModeGotIPHandler;
// static functions for logging wifi events to the UART
// static functions for logging WiFi events to the UART
static void onStationModeConnected(const WiFiEventStationModeConnected& event);
static void onStationModeDisconnected(const WiFiEventStationModeDisconnected& event);
static void onStationModeGotIP(const WiFiEventStationModeGotIP& event);

Loading…
Cancel
Save