From c5abeaec92af0135c624eb6b804d096c4162ac30 Mon Sep 17 00:00:00 2001 From: Harsh Sharma Date: Wed, 3 Jun 2020 12:31:49 -0500 Subject: Bug fix: GP-682 --- src/AccessoryCards/AcessoryCard.cpp | 1 - src/Device/Device.cpp | 12 +++++++----- 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); } -- cgit v1.2.3