/* * Stairs * Copyright 2017 (c) Mark van Renswoude * * https://git.x2software.net/pub/Stairs */ #ifndef __settingsconnection #define __settingsconnection #include #include #include #include "../charproperties.h" enum ConnectionSettingsFlags { AccessPoint = 1, StationMode = 2, DHCP = 4 }; class ConnectionSettings : CharProperties { private: char* mHostname = nullptr; uint8_t mFlags = AccessPoint | DHCP; char* mSSID = nullptr; char* mPassword = nullptr; IPAddress mIP = (uint32_t)0; IPAddress mSubnetMask = (uint32_t)0; IPAddress mGateway = (uint32_t)0; public: void read(); void write(); void toJson(Print &print); bool fromJson(char* data); bool fromJson(char* data, bool* changed); char* hostname() { return mHostname; } void hostname(const char* value) { assignChar(&mHostname, value); } bool flag(ConnectionSettingsFlags flag) { return (mFlags & flag) != 0; } void flag(ConnectionSettingsFlags flag, bool enabled) { if (enabled) mFlags |= flag; else mFlags &= ~flag; } char* ssid() { return mSSID; } void ssid(const char* value) { assignChar(&mSSID, value); } char* password() { return mPassword; } void password(const char* value) { assignChar(&mPassword, value); } IPAddress ip() { return mIP; } void ip(IPAddress value) { mIP = value; } IPAddress subnetMask() { return mSubnetMask; } void subnetMask(IPAddress value) { mSubnetMask = value; } IPAddress gateway() { return mGateway; } void gateway(IPAddress value) { mGateway = value; } }; #endif