From d9743f73289ac8cbbef0c787deb7a594c86c183d Mon Sep 17 00:00:00 2001 From: Pascal Brunot Date: Thu, 16 Nov 2023 19:34:04 +0100 Subject: [PATCH] renamed .h to .hpp --- include/{AuthProvider.h => AuthProvider.hpp} | 2 +- include/BoardInfo.hpp | 19 +++++++ include/{BoardLogic.h => BoardLogic.hpp} | 6 +- include/{FabServer.h => FabServer.hpp} | 8 +-- include/{FabUser.h => FabUser.hpp} | 4 +- include/{LCDWrapper.h => LCDWrapper.hpp} | 18 +----- include/{MQTTtypes.h => MQTTtypes.hpp} | 6 +- include/{Machine.h => Machine.hpp} | 2 +- .../{MockMQTTBroker.h => MockMQTTBroker.hpp} | 2 +- ...{MockRFIDWrapper.h => MockRFIDWrapper.hpp} | 4 +- include/{RFIDWrapper.h => RFIDWrapper.hpp} | 4 +- include/{card.h => card.hpp} | 2 +- include/{conf.h => conf.hpp} | 0 include/{globals.h => globals.hpp} | 22 ++++---- include/{pins.h => pins.hpp} | 0 include/secrets.h.example | 6 +- include/secrets.hpp | 56 +++++++++++++++++++ src/AuthProvider.cpp | 7 ++- src/BoardLogic.cpp | 20 +++---- src/FabServer.cpp | 4 +- src/LCDWrapper.tpp | 3 - src/MQTTtypes.cpp | 8 +-- src/Machine.cpp | 6 +- src/MockMQTTBroker.cpp | 4 +- src/MockRFIDWrapper.cpp | 10 ++-- src/RFIDWrapper.cpp | 8 +-- src/main.cpp | 6 +- 27 files changed, 149 insertions(+), 88 deletions(-) rename include/{AuthProvider.h => AuthProvider.hpp} (97%) create mode 100644 include/BoardInfo.hpp rename include/{BoardLogic.h => BoardLogic.hpp} (95%) rename include/{FabServer.h => FabServer.hpp} (96%) rename include/{FabUser.h => FabUser.hpp} (96%) rename include/{LCDWrapper.h => LCDWrapper.hpp} (85%) rename include/{MQTTtypes.h => MQTTtypes.hpp} (98%) rename include/{Machine.h => Machine.hpp} (99%) rename include/{MockMQTTBroker.h => MockMQTTBroker.hpp} (94%) rename include/{MockRFIDWrapper.h => MockRFIDWrapper.hpp} (95%) rename include/{RFIDWrapper.h => RFIDWrapper.hpp} (95%) rename include/{card.h => card.hpp} (98%) rename include/{conf.h => conf.hpp} (100%) rename include/{globals.h => globals.hpp} (75%) rename include/{pins.h => pins.hpp} (100%) create mode 100644 include/secrets.hpp diff --git a/include/AuthProvider.h b/include/AuthProvider.hpp similarity index 97% rename from include/AuthProvider.h rename to include/AuthProvider.hpp index 8b490e88..ecbe02ca 100644 --- a/include/AuthProvider.h +++ b/include/AuthProvider.hpp @@ -1,7 +1,7 @@ #ifndef AUTHPROVIDER_H_ #define AUTHPROVIDER_H_ -#include "FabUser.h" +#include "FabUser.hpp" #include #include #include diff --git a/include/BoardInfo.hpp b/include/BoardInfo.hpp new file mode 100644 index 00000000..b3f7cca2 --- /dev/null +++ b/include/BoardInfo.hpp @@ -0,0 +1,19 @@ +#ifndef BOARDINFO_HPP +#define BOARDINFO_HPP + +#include "Machine.hpp" + +struct BoardInfo +{ + bool server_connected; + Machine::PowerState power_state; + bool power_warning; + bool operator==(const BoardInfo &t) const + { + return server_connected == t.server_connected && + power_state == t.power_state && + power_warning == t.power_warning; + } +}; + +#endif // BOARDINFO_HPP \ No newline at end of file diff --git a/include/BoardLogic.h b/include/BoardLogic.hpp similarity index 95% rename from include/BoardLogic.h rename to include/BoardLogic.hpp index f4454a1a..94d21afd 100644 --- a/include/BoardLogic.h +++ b/include/BoardLogic.hpp @@ -1,10 +1,10 @@ #ifndef BOARDLOGIC_H #define BOARDLOGIC_H -#include "FabUser.h" -#include "card.h" +#include "FabUser.hpp" +#include "card.hpp" #include -#include "pins.h" +#include "pins.hpp" class BoardLogic { diff --git a/include/FabServer.h b/include/FabServer.hpp similarity index 96% rename from include/FabServer.h rename to include/FabServer.hpp index 25298fef..ff467d3c 100644 --- a/include/FabServer.h +++ b/include/FabServer.hpp @@ -1,15 +1,15 @@ #ifndef FABSERVER_H_ #define FABSERVER_H_ -#include "FabUser.h" -#include "WiFi.h" +#include "FabUser.hpp" +#include "Wifi.h" #include -#include "conf.h" +#include "conf.hpp" #include #include #include #include -#include "MQTTtypes.h" +#include "MQTTtypes.hpp" #include using namespace ServerMQTT; diff --git a/include/FabUser.h b/include/FabUser.hpp similarity index 96% rename from include/FabUser.h rename to include/FabUser.hpp index 3fff2dd8..365ff345 100644 --- a/include/FabUser.h +++ b/include/FabUser.hpp @@ -5,8 +5,8 @@ #include #include #include "Arduino.h" -#include "conf.h" -#include "card.h" +#include "conf.hpp" +#include "card.hpp" #include struct FabUser diff --git a/include/LCDWrapper.h b/include/LCDWrapper.hpp similarity index 85% rename from include/LCDWrapper.h rename to include/LCDWrapper.hpp index a7a26169..e0e975a5 100644 --- a/include/LCDWrapper.h +++ b/include/LCDWrapper.hpp @@ -2,26 +2,14 @@ #define LCDWRAPPER_H_ #include +#include "BoardInfo.hpp" #include "LiquidCrystal.h" -#include "Machine.h" -#include "pins.h" +#include "Machine.hpp" +#include "pins.hpp" #include using namespace std::chrono; -struct BoardInfo -{ - bool server_connected; - Machine::PowerState power_state; - bool power_warning; - bool operator==(const BoardInfo &t) const - { - return server_connected == t.server_connected && - power_state == t.power_state && - power_warning == t.power_warning; - } -}; - template class LCDWrapper { diff --git a/include/MQTTtypes.h b/include/MQTTtypes.hpp similarity index 98% rename from include/MQTTtypes.h rename to include/MQTTtypes.hpp index 707762eb..fe9e3707 100644 --- a/include/MQTTtypes.h +++ b/include/MQTTtypes.hpp @@ -1,11 +1,11 @@ #ifndef MQTTTYPES_H_ #define MQTTTYPES_H_ -#include "card.h" +#include "card.hpp" #include "string" #include -#include "FabUser.h" -#include "Machine.h" +#include "FabUser.hpp" +#include "Machine.hpp" #include #include "ArduinoJson.h" diff --git a/include/Machine.h b/include/Machine.hpp similarity index 99% rename from include/Machine.h rename to include/Machine.hpp index 99e1f9ec..a5d631de 100644 --- a/include/Machine.h +++ b/include/Machine.hpp @@ -4,7 +4,7 @@ #include #include #include -#include "FabUser.h" +#include "FabUser.hpp" class FabServer; diff --git a/include/MockMQTTBroker.h b/include/MockMQTTBroker.hpp similarity index 94% rename from include/MockMQTTBroker.h rename to include/MockMQTTBroker.hpp index d4113685..aafb21e6 100644 --- a/include/MockMQTTBroker.h +++ b/include/MockMQTTBroker.hpp @@ -2,7 +2,7 @@ #ifndef MOCKMQTTBROKER_H_ #define MOCKMQTTBROKER_H_ -#include "sMQTTBroker.h" +#include "sMQTTBroker.hpp" class MockMQTTBroker : public sMQTTBroker { diff --git a/include/MockRFIDWrapper.h b/include/MockRFIDWrapper.hpp similarity index 95% rename from include/MockRFIDWrapper.h rename to include/MockRFIDWrapper.hpp index f74c5beb..4b7bd30e 100644 --- a/include/MockRFIDWrapper.h +++ b/include/MockRFIDWrapper.hpp @@ -4,8 +4,8 @@ #include #include -#include "conf.h" -#include "card.h" +#include "conf.hpp" +#include "card.hpp" class MockRFIDWrapper { diff --git a/include/RFIDWrapper.h b/include/RFIDWrapper.hpp similarity index 95% rename from include/RFIDWrapper.h rename to include/RFIDWrapper.hpp index 4773c37c..cd8955bb 100644 --- a/include/RFIDWrapper.h +++ b/include/RFIDWrapper.hpp @@ -4,8 +4,8 @@ #include #include -#include "conf.h" -#include "card.h" +#include "conf.hpp" +#include "card.hpp" #include "MFRC522v2.h" #include "MFRC522DriverSPI.h" #include "MFRC522DriverPinSimple.h" diff --git a/include/card.h b/include/card.hpp similarity index 98% rename from include/card.h rename to include/card.hpp index 00e9e09a..7de5a3cf 100644 --- a/include/card.h +++ b/include/card.hpp @@ -2,7 +2,7 @@ #define CARD_H_ #include "Arduino.h" -#include "conf.h" +#include "conf.hpp" namespace card { diff --git a/include/conf.h b/include/conf.hpp similarity index 100% rename from include/conf.h rename to include/conf.hpp diff --git a/include/globals.h b/include/globals.hpp similarity index 75% rename from include/globals.h rename to include/globals.hpp index 3b84ef8a..79db8cd0 100644 --- a/include/globals.h +++ b/include/globals.hpp @@ -1,18 +1,18 @@ #ifndef GLOBALS_H_ #define GLOBALS_H_ -#include "FabServer.h" -#include "Machine.h" -#include "LCDWrapper.h" -#include "conf.h" -#include "MockRFIDWrapper.h" -#include "RFIDWrapper.h" -#include "pins.h" -#include "secrets.h" -#include "AuthProvider.h" -#include "BoardLogic.h" +#include "FabServer.hpp" +#include "Machine.hpp" +#include "LCDWrapper.hpp" +#include "conf.hpp" +#include "MockRFIDWrapper.hpp" +#include "RFIDWrapper.hpp" +#include "pins.hpp" +#include "secrets.hpp" +#include "AuthProvider.hpp" +#include "BoardLogic.hpp" #include -#include "MockMQTTBroker.h" +#include "MockMQTTBroker.hpp" // Global variables namespace Board diff --git a/include/pins.h b/include/pins.hpp similarity index 100% rename from include/pins.h rename to include/pins.hpp diff --git a/include/secrets.h.example b/include/secrets.h.example index db7666e5..30757cad 100644 --- a/include/secrets.h.example +++ b/include/secrets.h.example @@ -4,9 +4,9 @@ #include #include #include -#include "Machine.h" -#include "conf.h" -#include "FabUser.h" +#include "Machine.hpp" +#include "conf.hpp" +#include "FabUser.hpp" namespace secrets::cards { diff --git a/include/secrets.hpp b/include/secrets.hpp new file mode 100644 index 00000000..37615f90 --- /dev/null +++ b/include/secrets.hpp @@ -0,0 +1,56 @@ +#ifndef SECRETS_H_ +#define SECRETS_H_ + +#include +#include +#include +#include "Machine.hpp" +#include "conf.hpp" +#include "FabUser.hpp" + +namespace secrets::cards +{ + using WhiteListEntry = std::tuple; + using WhiteList = std::array; + + static constexpr WhiteList whitelist /* List of RFID tags whitelisted, regardless of connection */ + { + std::make_tuple(0xAABBCCD1, FabUser::UserLevel::FABLAB_ADMIN, "ABCDEFG"), + std::make_tuple(0xAABBCCD2, FabUser::UserLevel::FABLAB_ADMIN, "PIPPO"), + std::make_tuple(0xAABBCCD3, FabUser::UserLevel::FABLAB_USER, "USER1"), + std::make_tuple(0xAABBCCD4, FabUser::UserLevel::FABLAB_USER, "USER2"), + std::make_tuple(0xAABBCCD5, FabUser::UserLevel::FABLAB_USER, "USER3"), + std::make_tuple(0xAABBCCD6, FabUser::UserLevel::FABLAB_USER, "USER1"), + std::make_tuple(0xAABBCCD7, FabUser::UserLevel::FABLAB_USER, "USER1"), + std::make_tuple(0xAABBCCD8, FabUser::UserLevel::FABLAB_USER, "USER1"), + std::make_tuple(0xAABBCCD9, FabUser::UserLevel::FABLAB_USER, "USER1"), + std::make_tuple(0xAABBCCDA, FabUser::UserLevel::FABLAB_USER, "USER1")}; +} // namespace secrets::cards + +namespace secrets::machine +{ + // Machine connected to the ESP32 + static constexpr std::string_view machine_name = "LASER1"; + static constexpr Machine::MachineType machine_type = Machine::MachineType::LASER; + static constexpr std::string_view machine_topic = "shellyplus1-007/command/switch:0"; + static constexpr Machine::MachineID machine_id{1}; /* ID of the machine. Will be used to compose MQTT topic*/ + +} // namespace secrets::machine + +namespace secrets::wifi +{ + static constexpr std::string_view ssid = "MORIA"; /* Change with WIFI SSID name */ + static constexpr std::string_view password = "Youshallnotpass!"; /* Change with WIFI SSID password */ +} // namespace secrets::wifi + +namespace secrets::mqtt +{ + static constexpr std::string_view client = "BOARD-1"; /* Name of with MQTT client */ + static constexpr std::string_view user = "user!"; /* Change with MQTT user */ + static constexpr std::string_view password = "password"; /* Change with MQTT password */ + static constexpr std::string_view server = "192.168.1.123"; /* IP of MQTT broker*/ + static constexpr std::string_view topic = "/machine"; /* Initial part of the topic, machine ID will be added */ + static constexpr std::string_view response_topic = "/reply"; /* Server reply (sub-topic of the full machine topic) */ +} // namespace secrets::mqtt + +#endif // SECRETS_H_ \ No newline at end of file diff --git a/src/AuthProvider.cpp b/src/AuthProvider.cpp index ef52ce66..ed2d2f83 100644 --- a/src/AuthProvider.cpp +++ b/src/AuthProvider.cpp @@ -1,8 +1,9 @@ -#include "AuthProvider.h" +#include "AuthProvider.hpp" -#include #include -#include "FabServer.h" +#include + +#include "FabServer.hpp" namespace Board { diff --git a/src/BoardLogic.cpp b/src/BoardLogic.cpp index 82681c91..d897a0e3 100644 --- a/src/BoardLogic.cpp +++ b/src/BoardLogic.cpp @@ -1,16 +1,16 @@ -#include "BoardLogic.h" +#include "BoardLogic.hpp" #include "Arduino.h" -#include "secrets.h" -#include "conf.h" -#include "Machine.h" -#include "FabServer.h" -#include "RFIDWrapper.h" -#include "MockRFIDWrapper.h" -#include "AuthProvider.h" +#include "secrets.hpp" +#include "conf.hpp" +#include "Machine.hpp" +#include "FabServer.hpp" +#include "RFIDWrapper.hpp" +#include "MockRFIDWrapper.hpp" +#include "AuthProvider.hpp" #include -#include "LCDWrapper.h" +#include "LCDWrapper.hpp" #include -#include "pins.h" +#include "pins.hpp" #include namespace Board diff --git a/src/FabServer.cpp b/src/FabServer.cpp index 08baf1f1..0de52fba 100644 --- a/src/FabServer.cpp +++ b/src/FabServer.cpp @@ -1,5 +1,5 @@ -#include "FabServer.h" -#include "secrets.h" +#include "FabServer.hpp" +#include "secrets.hpp" #include #include diff --git a/src/LCDWrapper.tpp b/src/LCDWrapper.tpp index 178a3fb0..ad6396b7 100644 --- a/src/LCDWrapper.tpp +++ b/src/LCDWrapper.tpp @@ -1,10 +1,7 @@ -#include "LCDWrapper.h" - #include #include #include #include -#include "Machine.h" template LCDWrapper<_COLS, _ROWS>::LCDWrapper(const pins_config::lcd_config &conf) : config(conf), diff --git a/src/MQTTtypes.cpp b/src/MQTTtypes.cpp index b7d1de63..bb603b1b 100644 --- a/src/MQTTtypes.cpp +++ b/src/MQTTtypes.cpp @@ -1,11 +1,11 @@ -#include "MQTTtypes.h" -#include "card.h" +#include "MQTTtypes.hpp" +#include "card.hpp" #include "string" #include -#include "FabUser.h" +#include "FabUser.hpp" #include #include -#include "ArduinoJson.h" +#include "ArduinoJson.hpp" namespace ServerMQTT { diff --git a/src/Machine.cpp b/src/Machine.cpp index 07a2e97f..1efbeb31 100644 --- a/src/Machine.cpp +++ b/src/Machine.cpp @@ -1,11 +1,11 @@ -#include "Machine.h" +#include "Machine.hpp" #include "Arduino.h" #include #include #include #include -#include "secrets.h" -#include "FabServer.h" +#include "secrets.hpp" +#include "FabServer.hpp" using namespace std::chrono_literals; using namespace std::chrono; diff --git a/src/MockMQTTBroker.cpp b/src/MockMQTTBroker.cpp index 20ee9daa..62ff27fb 100644 --- a/src/MockMQTTBroker.cpp +++ b/src/MockMQTTBroker.cpp @@ -1,6 +1,6 @@ #ifdef WOKWI_SIMULATION -#include "MockMQTTBroker.h" -#include "conf.h" +#include "MockMQTTBroker.hpp" +#include "conf.hpp" MockMQTTBroker::MockMQTTBroker() { diff --git a/src/MockRFIDWrapper.cpp b/src/MockRFIDWrapper.cpp index 49c24987..0f1afd07 100644 --- a/src/MockRFIDWrapper.cpp +++ b/src/MockRFIDWrapper.cpp @@ -1,9 +1,9 @@ -#include "MockRFIDWrapper.h" -#include "pins.h" -#include "conf.h" -#include "card.h" +#include "MockRFIDWrapper.hpp" +#include "pins.hpp" +#include "conf.hpp" +#include "card.hpp" #include -#include "secrets.h" +#include "secrets.hpp" MockRFIDWrapper::MockRFIDWrapper() { diff --git a/src/RFIDWrapper.cpp b/src/RFIDWrapper.cpp index 975629f1..9276d0ef 100644 --- a/src/RFIDWrapper.cpp +++ b/src/RFIDWrapper.cpp @@ -1,11 +1,11 @@ -#include "RFIDWrapper.h" -#include "pins.h" +#include "RFIDWrapper.hpp" +#include "pins.hpp" #include "MFRC522v2.h" #include "MFRC522DriverSPI.h" #include "MFRC522DriverPinSimple.h" #include "MFRC522Debug.h" -#include "conf.h" -#include "card.h" +#include "conf.hpp" +#include "card.hpp" #include RFIDWrapper::RFIDWrapper() diff --git a/src/main.cpp b/src/main.cpp index e0154c0a..a3659beb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,9 +3,9 @@ #include #include -#include "globals.h" -#include "pins.h" -#include "BoardLogic.h" +#include "globals.hpp" +#include "pins.hpp" +#include "BoardLogic.hpp" #include "pthread.h" #define _TASK_SLEEP_ON_IDLE_RUN