From 8c7856e74ba7bc149180aa3ab9f820043260cdc8 Mon Sep 17 00:00:00 2001 From: Harsh Sharma Date: Thu, 9 Jan 2020 12:10:01 -0600 Subject: Added spidev as to accessory card object, moved setting capabilities for lora accessory cards to a common base class function --- src/AccessoryCards/LoraCard.cpp | 5 +++++ src/AccessoryCards/LoraCard15.cpp | 6 +++--- src/AccessoryCards/LoraCard21.cpp | 5 +++-- src/AccessoryCards/LoraCard21Ext.cpp | 5 ++--- src/Version.cpp | 2 +- 5 files changed, 14 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/AccessoryCards/LoraCard.cpp b/src/AccessoryCards/LoraCard.cpp index ba50aa7..66047f3 100644 --- a/src/AccessoryCards/LoraCard.cpp +++ b/src/AccessoryCards/LoraCard.cpp @@ -19,5 +19,10 @@ Device::LoraCard::LoraCard(Device& d, const std::string productId, const std::string port) : AccessoryCard(d) { spiPath = "/dev/spidev0.0"; +} + +void Device::LoraCard::setCapabilities() { device.capabilityList["lora"] = true; + device.accessoryCard.AddMember("spiPath", rapidjson::Value().SetString(spiPath.c_str(), device.accessoryCardsAlloc), device.accessoryCardsAlloc); + device.accessoryCard.AddMember("fpgaVersion", fpgaVersion, device.accessoryCardsAlloc); } \ No newline at end of file diff --git a/src/AccessoryCards/LoraCard15.cpp b/src/AccessoryCards/LoraCard15.cpp index df5c969..7d2140b 100644 --- a/src/AccessoryCards/LoraCard15.cpp +++ b/src/AccessoryCards/LoraCard15.cpp @@ -19,8 +19,8 @@ Device::Lora15Card::Lora15Card(Device& d, const std::string productId, const std::string port) : LoraCard(d, productId, port) { int ret; - fpgaVersion = 255; - if ((productId.find("MTCDT3-") == 0) && (port.back() == '2')) { + printf("PORT %s\n", port.c_str()); + if ((productId.rfind("MTCDT3-", 0) == 0 || productId.rfind("MTLGA-", 0) == 0) && (port.back() == '2')) { spiPath = "/dev/spidev1.0"; } else if (productId.find("MTAC-LORA-") == 0) { if (port.back() == '2') { @@ -42,7 +42,7 @@ Device::Lora15Card::Lora15Card(Device& d, const std::string productId, const std spiClose(); spi_target_ptr = NULL; - device.accessoryCard.AddMember("fpgaVersion", fpgaVersion, device.accessoryCardsAlloc); + setCapabilities(); } int Device::Lora15Card::spiOpen(const char *spidev) { diff --git a/src/AccessoryCards/LoraCard21.cpp b/src/AccessoryCards/LoraCard21.cpp index 70bec11..99f76d6 100644 --- a/src/AccessoryCards/LoraCard21.cpp +++ b/src/AccessoryCards/LoraCard21.cpp @@ -19,6 +19,7 @@ Device::Lora21Card::Lora21Card(Device& d, const std::string productId, const std::string port): LoraCard(d, productId, port) { spiPath = "/dev/spidev32766.2"; - MTS::System::cmd(LORA_2_1_FPGA_VERSION, fpgaVersion); - device.accessoryCard.AddMember("fpgaVersion", std::stoi(fpgaVersion), device.accessoryCardsAlloc); + MTS::System::cmd(LORA_2_1_FPGA_VERSION, cmdFpgaVersion); + fpgaVersion = std::stoi(cmdFpgaVersion); + setCapabilities(); } \ No newline at end of file diff --git a/src/AccessoryCards/LoraCard21Ext.cpp b/src/AccessoryCards/LoraCard21Ext.cpp index b7531c7..51b43f7 100644 --- a/src/AccessoryCards/LoraCard21Ext.cpp +++ b/src/AccessoryCards/LoraCard21Ext.cpp @@ -18,7 +18,6 @@ #include "Device.h" Device::Lora21ExtCard::Lora21ExtCard(Device& d, const std::string productId, const std::string port): Lora21Card(d, productId, port) { - MTS::System::cmd(LORA_2_1_EXT_FPGA_VERSION, fpgaVersion2); - device.accessoryCard.AddMember("fpgaVersion2", std::stoi(fpgaVersion2), device.accessoryCardsAlloc); - + MTS::System::cmd(LORA_2_1_EXT_FPGA_VERSION, cmdFpgaVersion2); + device.accessoryCard.AddMember("fpgaVersion2", std::stoi(cmdFpgaVersion2), device.accessoryCardsAlloc); } \ No newline at end of file diff --git a/src/Version.cpp b/src/Version.cpp index 5513345..365abbb 100644 --- a/src/Version.cpp +++ b/src/Version.cpp @@ -1,4 +1,4 @@ //Pre-Build Auto-Generated Source #include "Version.h" -const std::string Version::version("v1.0.0-6-gc4811dd"); +const std::string Version::version("v1.0.0-8-gd32e7c8"); -- cgit v1.2.3