~aleteoryx/muditaos

ref: 249e584a843e061f3ecbf2290f2562ab9c735c18 muditaos/module-services/service-cellular/src/ImeiGetHandler.cpp -rw-r--r-- 961 bytes
249e584a — Lefucjusz [MOS-1040] Add HNI codes for Egypt 2 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
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "ImeiGetHandler.hpp"
#include <ATFactory.hpp>
#include <modem/BaseChannel.hpp>

namespace
{
    constexpr auto IMEIResonseSize = 2;
}

namespace cellular::service
{
    void ImeiGetHandler::setChannel(at::BaseChannel *channel)
    {
        this->channel = channel;
    }

    auto ImeiGetHandler::getImei(std::string &destination) -> bool
    {

        if (channel == nullptr) {
            LOG_ERROR("No channel provided. Request ignored");
            return false;
        }
        auto result = channel->cmd(at::factory(at::AT::GET_IMEI));

        if (result.code == at::Result::Code::OK && result.response.size() == IMEIResonseSize) {
            destination = result.response[0];
            return true;
        }
        else {
            return false;
        }
    }

} // namespace cellular::service