summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/AccessoryCards/AcessoryCard.cpp1
-rw-r--r--src/Device/Device.cpp12
2 files changed, 7 insertions, 6 deletions
diff --git a/src/AccessoryCards/AcessoryCard.cpp b/src/AccessoryCards/AcessoryCard.cpp
index c4804d1..6a7a0d8 100644
--- a/src/AccessoryCards/AcessoryCard.cpp
+++ b/src/AccessoryCards/AcessoryCard.cpp
@@ -18,5 +18,4 @@
#include "Device.h"
Device::AccessoryCard::AccessoryCard(Device& d, const std::string ProductId, const std::string Port) : device(d), productId(ProductId), port(Port) {
- device.accessoryCard.AddMember("port", rapidjson::Value().SetString(port.c_str(), device.accessoryCardsAlloc), device.accessoryCardsAlloc);
}
diff --git a/src/Device/Device.cpp b/src/Device/Device.cpp
index d3eb4ab..6c589a5 100644
--- a/src/Device/Device.cpp
+++ b/src/Device/Device.cpp
@@ -84,11 +84,13 @@ void Device::getSystemTreeJson(const char * dir_name) {
if (isAccessoryCard(d_name, dir_name)) {
if (accessoryCard.IsNull()) {
accessoryCard.SetObject();
- } else if (accessoryCard.HasMember(d_name)) {
+ accessoryCard.AddMember("port", rapidjson::Value().SetString(dir_name, accessoryCardsAlloc), accessoryCardsAlloc);
+ } else if (accessoryCard["port"] != dir_name) {
accessoryCards.PushBack(accessoryCard, accessoryCardsAlloc);
accessoryCard.SetObject();
+ accessoryCard.AddMember("port", rapidjson::Value().SetString(dir_name, accessoryCardsAlloc), accessoryCardsAlloc);
}
- if (strcmp(d_name, "product-id") == 0) {
+ if (strcmp(d_name, "product-id") == 0) { // Map additional details based on product id not found in mts-io dir
if (regex_match(fileData, loraG16Filters)) {
Lora21Card lora21(*this, fileData, dir_name);
} else if (regex_match(fileData, loraG64Filters)) {
@@ -117,11 +119,11 @@ void Device::getSystemTreeJson(const char * dir_name) {
}
}
}
- if (isValidDirectory(entry, fullPath, d_name)) { /* Check that the directory is not "d" or d's parent. */
- getSystemTreeJson(d_name); /* Recursively call with the new path */
+ if (isValidDirectory(entry, fullPath, d_name)) { // Check that the directory is not "d" or d's parent.
+ getSystemTreeJson(d_name); // Recursively call with the new path
}
}
- if (closedir (d)) { /* After going through all the entries, close the directory. */
+ if (closedir (d)) { // After going through all the entries, close the directory.
logError("Could not close " + std::string(fullPath));
exitHandler(errno);
}