summaryrefslogtreecommitdiff
path: root/include/Device/Device.h
blob: 1c6f77e76b73636ce85eeabfc06e4088636bb3ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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_ */