~aleteoryx/muditaos

ref: 99e21185b60b0b2c14f57c171455a4521fa88367 muditaos/module-sys/Service/Common.hpp -rw-r--r-- 3.1 KiB
99e21185 — Marcin Smoczyński Merge branch 'stable' - release v0.61.1 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "FreeRTOSConfig.h"
#include "SystemReturnCodes.hpp"

namespace sys
{

    enum class BusChannel
    {
        System,
        SystemManagerRequests,
        PowerManagerRequests,
        ServiceCellularNotifications,
        Test2CustomBusChannel,
        ServiceDBNotifications,
        ServiceAudioNotifications,
        AppManagerNotifications,
        ServiceFotaNotifications,
        AntennaNotifications,
        ServiceEvtmgrNotifications,
        CalendarNotifications,
        PhoneModeChanges,
    };

    enum class ServicePriority
    {
        Idle     = 0, ///< priority: idle (lowest)
        Low      = 1, ///< priority: low
        Normal   = 2, ///< priority: normal
        High     = 3, ///< priority: high
        Realtime = 4, ///< priority: realtime (highest)
    };

    enum class ServicePowerMode
    {
        Active,
        SuspendToRAM,
        SuspendToNVM
    };

    enum class CloseReason
    {
        RegularPowerDown,
        Reboot,
        SystemBrownout,
        LowBattery
    };

} // namespace sys

inline const char *c_str(sys::ReturnCodes code)
{
    switch (code) {
    case sys::ReturnCodes::Success:
        return "Success";
    case sys::ReturnCodes::Failure:
        return "Failure";
    case sys::ReturnCodes::Timeout:
        return "Timeout";
    case sys::ReturnCodes::ServiceDoesntExist:
        return "ServiceDoesntExist";
    case sys::ReturnCodes::Unresolved:
        return "Unresolved";
    }
    return "Undefined";
}

inline const char *c_str(sys::ServicePowerMode code)
{
    switch (code) {
    case sys::ServicePowerMode::Active:
        return "Active";
    case sys::ServicePowerMode::SuspendToRAM:
        return "SuspendToRAM";
    case sys::ServicePowerMode::SuspendToNVM:
        return "SuspendToNVM";
    }
    return "";
}

inline const char *c_str(sys::BusChannel channel)
{
    switch (channel) {
    case sys::BusChannel::System:
        return "System";
    case sys::BusChannel::SystemManagerRequests:
        return "SystemManagerRequests";
    case sys::BusChannel::PowerManagerRequests:
        return "PowerManagerRequests";
    case sys::BusChannel::ServiceCellularNotifications:
        return "ServiceCellularNotifications,";
    case sys::BusChannel::Test2CustomBusChannel:
        return "Test2CustomBusChannel,";
    case sys::BusChannel::ServiceDBNotifications:
        return "ServiceDBNotifications,";
    case sys::BusChannel::ServiceAudioNotifications:
        return "ServiceAudioNotifications";
    case sys::BusChannel::AppManagerNotifications:
        return "AppManagerNotifications,";
    case sys::BusChannel::ServiceFotaNotifications:
        return "ServiceFotaNotifications";
    case sys::BusChannel::AntennaNotifications:
        return "AntennaNotifications";
    case sys::BusChannel::ServiceEvtmgrNotifications:
        return "ServiceEvtmgrNotifications";
    case sys::BusChannel::CalendarNotifications:
        return "CalendarNotifications";
    case sys::BusChannel::PhoneModeChanges:
        return "PhoneModeChanges";
    }
    return "";
}