~aleteoryx/muditaos

ref: 21a7855d8c229f7893bc60a9b2fab1ae0615cbf6 muditaos/module-apps/application-settings/windows/CellularPassthroughWindow.hpp -rw-r--r-- 2.4 KiB
21a7855d — Kuba [EGD-6973] Fix Auto date is on by default 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
79
80
81
82
83
84
// 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 "AppWindow.hpp"
#include "Application.hpp"
#include <module-bsp/bsp/cellular/bsp_cellular.hpp>
#include <module-gui/gui/widgets/Text.hpp>

namespace gui
{

    namespace window
    {
        namespace cellular_passthrough
        {
            inline constexpr auto window_name = "CellularPassthroughWindow";

            inline constexpr auto passNormalDescription = "Regular passthrough";
            inline constexpr auto passNormalLabel       = "ON";

            inline constexpr auto passDFUDescription = "Firmware Upgrade";
            inline constexpr auto passDFULabel       = "ON (upgrade)";
            inline constexpr auto passDFUNote        = "Reset modem with 2*PWR_KEY";

            inline constexpr auto noPassDescription = "Disable passthrough";
            inline constexpr auto noPassLabel       = "OFF";
            inline constexpr auto noPassNote        = "Reset modem hard. (battery out)";
        } // namespace cellular_passthrough
    }     // namespace window

    class CellularPassthroughWindow : public AppWindow
    {
      private:
        VBox *layout = nullptr;

        Label *passNormal = nullptr;
        Label *passDFU    = nullptr;
        Label *noPass     = nullptr;

        HBox *statusHbox            = nullptr;
        Label *currentStateConst    = nullptr;
        Label *currentStateVariable = nullptr;

        Label *note = nullptr;

      protected:
        enum class State
        {
            PASS_NORMAL,
            PASS_DFU,
            NO_PASS,
            FAIL,
            UNKNOWN,
        };

        State previousState = State::UNKNOWN;

        const time_t wait_for_pin_change_state = 10; // [ms]

      public:
        CellularPassthroughWindow(app::Application *app);

        virtual ~CellularPassthroughWindow() override = default;

        void rebuild() override;

        void buildInterface() override;

        void destroyInterface() override;

        void addSeparator(VBox *layout);

        CellularPassthroughWindow::State getInitialState();

        bool set(bsp::cellular::USB::PassthroughState pass_to_set, bsp::cellular::USB::BootPinState dfu_to_set);

        void setWindowState(State state);

      private:
        void invalidate() noexcept;
    };
} // namespace gui