summaryrefslogtreecommitdiff
path: root/include/Device
diff options
context:
space:
mode:
Diffstat (limited to 'include/Device')
-rw-r--r--include/Device/Device.h66
1 files changed, 66 insertions, 0 deletions
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<std::string> apIdentifiers;
+
+ std::map<std::string, bool> 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<std::string, std::string> 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<std::string> &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_ */