summaryrefslogtreecommitdiff
path: root/src/AccessoryCards/LoraCard15.cpp
blob: f71bff34e40f5bb7f24a09f2b4f314cf394ee627 (plain)
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
/**********************************************************************
 * COPYRIGHT 2020 MULTI-TECH SYSTEMS, INC.
 *
 * ALL RIGHTS RESERVED BY AND FOR THE EXCLUSIVE BENEFIT OF
 * MULTI-TECH SYSTEMS, INC.
 *
 * MULTI-TECH SYSTEMS, INC. - CONFIDENTIAL AND PROPRIETARY
 * INFORMATION AND/OR TRADE SECRET.
 *
 * NOTICE: ALL CODE, PROGRAM, INFORMATION, SCRIPT, INSTRUCTION,
 * DATA, AND COMMENT HEREIN IS AND SHALL REMAIN THE CONFIDENTIAL
 * INFORMATION AND PROPERTY OF MULTI-TECH SYSTEMS, INC.
 * USE AND DISCLOSURE THEREOF, EXCEPT AS STRICTLY AUTHORIZED IN A
 * WRITTEN AGREEMENT SIGNED BY MULTI-TECH SYSTEMS, INC. IS PROHIBITED.
 *
 ***********************************************************************/

#include "Device.h"

Device::Lora15Card::Lora15Card(Device &d)
    : LoraCard(d, std::regex("(MTAC-LORA-H)(.*)|(MTAC-LORA-F)(.*)|(MTCAP-LORA-)"
                             "(.*)|(MTLGA-)(.*)|(MTCDT3-)(.*)")) {}

void Device::Lora15Card::AddToDeviceInfo(const std::string Port,
                                         const std::string ProductID) {

    LoraCard::AddToDeviceInfo(Port, ProductID);

    if (ProductID.rfind("MTCAP", 0) == 0) {
        spiPath = LORA_1_5_MTCAP_SPI;
    } else if (Port.back() == '2') {
        spiPath = LORA_1_5_MTCDT_SPI_AP_2;
    } else {
        spiPath = LORA_1_5_MTCDT_SPI_AP_1;
    }

    Mtac15Fpga mtac15Fpga(spiPath);
    mtac15Fpga.getFpgaVersion();
    fpgaVersion = mtac15Fpga.FpgaVersion();
    device.accessoryCard.AddMember(
        "spiPath",
        rapidjson::Value().SetString(spiPath.c_str(), device.acAlloc),
        device.acAlloc);
    device.accessoryCard.AddMember("fpgaVersion", fpgaVersion, device.acAlloc);
}