~aleteoryx/muditaos

ref: 9098f69e7b9f22e2333d83e2f2503797a1d6b8df muditaos/module-apps/application-antenna/ApplicationAntenna.hpp -rw-r--r-- 2.4 KiB
9098f69e — Wojtek Rzepecki [EGD-5814] Fix battery revert 4 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
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
75
76
77
78
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <Application.hpp>
#include <service-cellular/CellularServiceAPI.hpp>
#include <windows/AppWindow.hpp>

namespace app
{

    inline constexpr auto name_antenna = "ApplicationAntenna";
    namespace antenna
    {
        class StoreParams
        {
          public:
            std::string csq;
            std::string creg;
            std::string bandFreq;
        };
        constexpr uint32_t paramsMaxSize = 9;
    } // namespace antenna

    class ApplicationAntenna : public app::Application
    {
      protected:
        std::unique_ptr<sys::Timer> appTimer;
        void timerHandler(void);
        bool cellularRequestInProgress = false;
        bsp::cellular::antenna antenna;

        bool csqUpdated   = false;
        uint32_t lastCsq  = 0;
        uint32_t lastCreg = 0;
        uint32_t lastFreq = 0;

      public:
        ApplicationAntenna(std::string name                    = name_antenna,
                           std::string parent                  = {},
                           StartInBackground startInBackground = {false});
        virtual ~ApplicationAntenna();

        sys::MessagePointer DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) override;
        sys::ReturnCodes InitHandler() override;
        sys::ReturnCodes DeinitHandler() override;

        sys::ReturnCodes SwitchPowerModeHandler(const sys::ServicePowerMode mode) override final
        {
            return sys::ReturnCodes::Success;
        }

        void createUserInterface() override;
        void destroyUserInterface() override;
        void setScanInProgress(bool value)
        {
            cellularRequestInProgress = value;
        };
        void handleNetworkParams(std::vector<std::string> &data);
        bsp::cellular::antenna getAntenna(void)
        {
            CellularServiceAPI::GetAntenna(this, antenna);
            return antenna;
        }

        std::vector<app::antenna::StoreParams> lowBandParams;
        std::vector<app::antenna::StoreParams> highBandParams;
    };

    template <> struct ManifestTraits<ApplicationAntenna>
    {
        static auto GetManifest() -> manager::ApplicationManifest
        {
            return {{manager::actions::Launch}};
        }
    };
} /* namespace app */