summaryrefslogtreecommitdiff
path: root/src/MTS_IO_ME910Radio.cpp
blob: 2e461643c3a3cfba31e702950d153e42b85058ad (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 * Copyright (C) 2017 by Multi-Tech Systems
 *
 * This file is part of libmts-io.
 *
 * libmts-io is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * libmts-io is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with libmts-io.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

/*! 
 \file MTS_IO_ME910Radio.cpp
 \brief A brief description 

 A more elaborate description
*/

#include <mts/MTS_Text.h>
#include <mts/MTS_Logger.h>
#include <mts/MTS_IO_ME910Radio.h>

using namespace MTS::IO;

ME910Radio::ME910Radio(const std::string& sME910Model, const std::string& sPort)
: CellularRadio(sME910Model, sPort)
{

}

CellularRadio::CODE ME910Radio::setRxDiversity(const Json::Value& jArgs) {
        return FAILURE;
}


CellularRadio::CODE ME910Radio::getFirmwareBuild(std::string& sFirmwareBuild) {
    std::string sCmd("AT#CFVR");

    std::string sResult = sendCommand(sCmd);

    size_t end = sResult.find(RSP_OK);
    if (end == std::string::npos) {
        printWarning("%s| Unable to get firmware build number [%s]",
                getName().c_str(),
                sCmd.c_str());
        return FAILURE;
    }

    size_t start = sResult.find("#CFVR:");
    if (start == std::string::npos) {
        printWarning("%s| Command returned unexpected response [%s]",
                getName().c_str(),
                sCmd.c_str());
        return FAILURE;
    }

    start += sizeof("#CFVR:");

    sFirmwareBuild = MTS::Text::trim(sResult.substr(start, end-start));
    if(sFirmwareBuild.size() == 0) {
        printWarning("%s| Firmware Build Version is empty", getName().c_str());
        return FAILURE;
    }
    return SUCCESS;
}