From 8ce2b9763c880084fd9d38fae6033e487fde58d9 Mon Sep 17 00:00:00 2001 From: Harsh Sharma Date: Thu, 19 Dec 2019 11:53:10 -0600 Subject: Initial commit --- include/Device/Device.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 include/Device/Device.h (limited to 'include/Device') diff --git a/include/Device/Device.h b/include/Device/Device.h new file mode 100644 index 0000000..1c6f77e --- /dev/null +++ b/include/Device/Device.h @@ -0,0 +1,66 @@ +#ifndef DEVICE_H_ +#define DEVICE_H_ + +#include "General.h" +#include "Version.h" +#include "AccessoryCardLora15.h" + +class Device { + private: + bool verbose = false; + bool isRoot; + rapidjson::Document capabilities; + rapidjson::Document deviceInfo; + rapidjson::Document accessoryCards; + rapidjson::Value accessoryCard; + rapidjson::Document::AllocatorType& alloc = deviceInfo.GetAllocator(); + rapidjson::Document::AllocatorType& accessoryCardsAlloc = accessoryCards.GetAllocator(); + static const std::vector apIdentifiers; + + std::map capabilityList = {{"adc", false},{"battery", false},{"bluetooth", false}, + {"cell", false},{"cellWwan", false},{"din", false},{"dout", false},{"externalSerialPort", false}, + {"gpio", false},{"gps", false},{"lora", false},{"loraNetworkServer", false}, + {"nodeRed", false},{"rs232", false},{"rs422", false},{"rs485", false},{"serial", false}, + {"wifi", false}}; + std::map deviceInfoList = {{"deviceId", ""},{"hardwareVersion", ""}, + {"imei", ""},{"macAddress", "00:00:00:00:00:00"},{"macBluetooth", "00:00:00:00:00:00"}, + {"macWifi", "00:00:00:00:00:00"},{"productId", ""},{"uuid", ""},{"vendorId", ""}}; + + static const std::regex apFilters; + static const std::regex lora15Filters; + static const std::regex loraG16Filters; + static const std::regex loraG64Filters; + static const std::regex gpiobFilters; + static const std::regex mfserFilters; + static const std::regex serialModeFilter; + static const std::regex storeFilters; + static const std::regex showFilters; + + public: + Device(); + void exitHandler(int code); + bool fileExists(std::string file); + mode_t fileType(std::string file); + void getSystemTreeJson(const char * dir_name); + void init(); + void load(); + void logInfo(std::string info); + void logError(std::string info); + void json(); + void mapFileToCapability(); + void mapFirmware(); + void printDir(const std::string dir_name, std::vector &results); + void printJson(); + void printVersion (std::string name); + void printUsage(std::string program); + void show(std::string program); + void showTrigger(std::string name); + void store(std::string name, std::string value); + void storeTrigger(std::string name, std::string value); + std::string toCamelCase(const char * d_name); + void Verbose(bool val); + bool Verbose(); + void writeJson(); +}; + +#endif /* DEVICE_H_ */ -- cgit v1.2.3