diff options
author | Harsh Sharma <harsh.sharma@multitech.com> | 2020-01-07 15:50:56 -0600 |
---|---|---|
committer | Harsh Sharma <harsh.sharma@multitech.com> | 2020-01-07 15:50:56 -0600 |
commit | c4811dd1b73b37b0916803097237acd31f1df98b (patch) | |
tree | b0d73a975fc7e7de8444775440e0b729fa61d0fa /include/Device/Device.h | |
parent | 68c0c5ed8ad7c733743de1afc5deb9de862d60f3 (diff) | |
download | mts-io-sysfs-c4811dd1b73b37b0916803097237acd31f1df98b.tar.gz mts-io-sysfs-c4811dd1b73b37b0916803097237acd31f1df98b.tar.bz2 mts-io-sysfs-c4811dd1b73b37b0916803097237acd31f1df98b.zip |
Refactored accessory cards classes with inheritence, fixed Makefile clean, moved some helper functions to header utility
Diffstat (limited to 'include/Device/Device.h')
-rw-r--r-- | include/Device/Device.h | 69 |
1 files changed, 53 insertions, 16 deletions
diff --git a/include/Device/Device.h b/include/Device/Device.h index 946221b..aa1d32b 100644 --- a/include/Device/Device.h +++ b/include/Device/Device.h @@ -2,6 +2,7 @@ #define DEVICE_H_ #include "General.h" +#include "Utility.h" #include "Version.h" #include "AccessoryCardLora15.h" @@ -11,17 +12,12 @@ class Device { bool isRoot; rapidjson::Document capabilities; rapidjson::Document deviceInfo; + static const std::vector<std::string> apIdentifiers; 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}}; + static std::map<std::string, bool> capabilityList; 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", ""}}; @@ -36,11 +32,58 @@ class Device { static const std::regex storeFilters; static const std::regex showFilters; + + class AccessoryCard { + protected: + Device& device; + public: + AccessoryCard(Device& d); + }; + + class LoraCard : public AccessoryCard { + protected: + std::string spiPath; + public: + LoraCard(Device& d, const std::string productId, const std::string port); + }; + + class Lora15Card : public LoraCard { + private: + void *spi_target_ptr = NULL; + uint8_t fpgaVersion = 255; + public: + Lora15Card(Device& d, const std::string productId, const std::string port); + int spiOpen(const char *spidev); + int spiRead(uint8_t address, uint8_t *data); + int spiClose(); + }; + + class Lora21Card : public LoraCard { + private: + std::string fpgaVersion; + public: + Lora21Card(Device& d, const std::string productId, const std::string port); + }; + + class Lora21ExtCard : public Lora21Card { + private: + std::string fpgaVersion2; + public: + Lora21ExtCard(Device& d, const std::string productId, const std::string port); + }; + + class Gpiob : public AccessoryCard { + public: + Gpiob(Device& d); + }; + + class Mfser : public AccessoryCard { + public: + Mfser(Device& d, const std::string port); + }; + 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(); @@ -53,16 +96,10 @@ class Device { void printJson(); void printVersion (std::string name); void printUsage(std::string program); - void setupLora15(std::string fileData, const char * dir_name); - void setupLoraG16(std::string fileData, const char * dir_name); - void setupLoraG64(std::string fileData, const char * dir_name); - void setupGpiob(std::string fileData, const char * dir_name); - void setupMfser(std::string fileData, const char * dir_name); 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(); |