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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#ifndef DEVICE_H_
#define DEVICE_H_
#include "General.h"
#include "Utility.h"
#include "Version.h"
class Device {
private:
bool verbose ;
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 std::map<std::string, bool> capabilityList;
static 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;
class AccessoryCard {
protected:
Device& device;
public:
AccessoryCard(Device& d);
};
class LoraCard : public AccessoryCard {
protected:
std::string spiPath;
uint8_t fpgaVersion = 255;
public:
LoraCard(Device& d, const std::string productId, const std::string port);
void setCapabilities();
};
class Lora15Card : public LoraCard {
private:
void *spi_target_ptr = NULL;
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 cmdFpgaVersion;
public:
Lora21Card(Device& d, const std::string productId, const std::string port);
};
class Lora21ExtCard : public Lora21Card {
private:
std::string cmdFpgaVersion2;
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 getSystemTreeJson(const char * dir_name);
void init();
bool isAccessoryCard(const char * d_name, const char * dir_name);
bool isValidDirectory(const struct dirent * entry, std::string fullPath, const char * d_name);
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);
void Verbose(bool val);
bool Verbose();
void writeJson();
};
#endif /* DEVICE_H_ */
|