~aleteoryx/muditaos

ref: 0823d82e5141f44812c54debf07245d0ca746124 muditaos/module-cellular/at/src/URC_QIND.cpp -rw-r--r-- 954 bytes
0823d82e — Radoslaw Wicik [EGD-3743] Update copyrights in fies - add empty line after license 5 years ago
                                                                                
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
#include <URC_QIND.hpp>
#include <log/debug.hpp>

using namespace at::urc;

QIND::QIND(const std::string &val) : Any(val)
{}

auto QIND::what() -> std::string
{
    return urc_name;
}

auto QIND::is_csq() -> bool
{
    if (tokens.size() > CSQ) {
        return tokens[CSQ].find(type_csq) != std::string::npos;
    }
    return false;
}

auto QIND::validate(enum CSQ check) -> bool
{
    try {
        if (is_csq() && tokens.size() > BER) {
            int rssi = std::stoi(tokens[RSSI]);
            int ber  = std::stoi(tokens[BER]);
            LOG_DEBUG("> %d %d", rssi, ber);
            switch (check) {
            case RSSI:
                return (rssi % 100 % invalid_rssi_modulo) != 0;
            case BER:
                return ber != invalid_ber;
            default:
                return false;
            }
        }
    }
    catch (const std::exception &ex) {
        LOG_FATAL("exception: %s", ex.what());
    }
    return false;
}