From 17e3209a015e2f23b655b860917a1d2dffcd6040 Mon Sep 17 00:00:00 2001 From: Harsh Sharma Date: Thu, 10 Mar 2022 15:36:48 -0600 Subject: Added mtcap default case for 2.4g card in case it is added in the future --- src/AccessoryCards/LoraCard2G4.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/AccessoryCards/LoraCard2G4.cpp b/src/AccessoryCards/LoraCard2G4.cpp index 7653dbf..2ca8c28 100644 --- a/src/AccessoryCards/LoraCard2G4.cpp +++ b/src/AccessoryCards/LoraCard2G4.cpp @@ -23,8 +23,29 @@ Device::Lora2G4Card::Lora2G4Card(Device &d) void Device::Lora2G4Card::AddToDeviceInfo(const std::string Port, const std::string ProductID) { + std::string ttyPath; + + if (ProductID.rfind("MTCAP", 0) == 0) { + /* + Set to default value in case it is supported in + the future + */ + ttyPath = "/dev/ttyACM0"; + } else { + /* + Set path based on mtcdt rules. + Path is linked to a AP hardware path + so that additional installed usb devices do + not cause any bugs dependant on usb load order + */ + std::string ttyPathBase = "/dev/ttyLora"; + std::string ttyPathExtension = Port; + for (auto & c: ttyPathExtension) c = toupper(c); + ttyPath = ttyPathBase + ttyPathExtension; + } + LoraCard::AddToDeviceInfo(Port, ProductID); - std::string ttyPath = "/dev/ttyLoraAP" + Port; + device.accessoryCard.AddMember( "ttyPath", rapidjson::Value().SetString(ttyPath.c_str(), device.acAlloc), -- cgit v1.2.3