libctru  v2.4.1
ndm.h
Go to the documentation of this file.
1 /**
2  * @file ndm.h
3  * @brief NDMU service. https://3dbrew.org/wiki/NDM_Services
4  */
5 #pragma once
6 
7 /// Exclusive states.
8 typedef enum {
9  NDM_EXCLUSIVE_STATE_NONE = 0,
10  NDM_EXCLUSIVE_STATE_INFRASTRUCTURE = 1,
11  NDM_EXCLUSIVE_STATE_LOCAL_COMMUNICATIONS = 2,
12  NDM_EXCLUSIVE_STATE_STREETPASS = 3,
13  NDM_EXCLUSIVE_STATE_STREETPASS_DATA = 4,
15 
16 /// Current states.
17 typedef enum {
18  NDM_STATE_INITIAL = 0,
19  NDM_STATE_SUSPENDED = 1,
20  NDM_STATE_INFRASTRUCTURE_CONNECTING = 2,
21  NDM_STATE_INFRASTRUCTURE_CONNECTED = 3,
22  NDM_STATE_INFRASTRUCTURE_WORKING = 4,
23  NDM_STATE_INFRASTRUCTURE_SUSPENDING = 5,
24  NDM_STATE_INFRASTRUCTURE_FORCE_SUSPENDING = 6,
25  NDM_STATE_INFRASTRUCTURE_DISCONNECTING = 7,
26  NDM_STATE_INFRASTRUCTURE_FORCE_DISCONNECTING = 8,
27  NDM_STATE_CEC_WORKING = 9,
28  NDM_STATE_CEC_FORCE_SUSPENDING = 10,
29  NDM_STATE_CEC_SUSPENDING = 11,
30 } ndmState;
31 
32 // Daemons.
33 typedef enum {
34  NDM_DAEMON_CEC = 0,
35  NDM_DAEMON_BOSS = 1,
36  NDM_DAEMON_NIM = 2,
37  NDM_DAEMON_FRIENDS = 3,
38 } ndmDaemon;
39 
40 /// Used to specify multiple daemons.
41 typedef enum {
42  NDM_DAEMON_MASK_CEC = BIT(NDM_DAEMON_CEC),
43  NDM_DAEMON_MASK_BOSS = BIT(NDM_DAEMON_BOSS),
44  NDM_DAEMON_MASK_NIM = BIT(NDM_DAEMON_NIM),
45  NDM_DAEMON_MASK_FRIENDS = BIT(NDM_DAEMON_FRIENDS),
46  NDM_DAEMON_MASK_BACKGROUOND = NDM_DAEMON_MASK_CEC | NDM_DAEMON_MASK_BOSS | NDM_DAEMON_MASK_NIM,
47  NDM_DAEMON_MASK_ALL = NDM_DAEMON_MASK_CEC | NDM_DAEMON_MASK_BOSS | NDM_DAEMON_MASK_NIM | NDM_DAEMON_MASK_FRIENDS,
48  NDM_DAEMON_MASK_DEFAULT = NDM_DAEMON_MASK_CEC | NDM_DAEMON_MASK_FRIENDS,
50 
51 // Daemon status.
52 typedef enum {
53  NDM_DAEMON_STATUS_BUSY = 0,
54  NDM_DAEMON_STATUS_IDLE = 1,
55  NDM_DAEMON_STATUS_SUSPENDING = 2,
56  NDM_DAEMON_STATUS_SUSPENDED = 3,
57 } ndmDaemonStatus;
58 
59 /// Initializes ndmu.
61 
62 /// Exits ndmu.
63 void ndmuExit(void);
64 
65 /**
66  * @brief Sets the network daemon to an exclusive state.
67  * @param state State specified in the ndmExclusiveState enumerator.
68  */
70 
71 /// Cancels an exclusive state for the network daemon.
73 
74 /**
75  * @brief Returns the exclusive state for the network daemon.
76  * @param state Pointer to write the exclsuive state to.
77  */
79 
80 /// Locks the exclusive state.
82 
83 /// Unlocks the exclusive state.
85 
86 /**
87  * @brief Suspends network daemon.
88  * @param mask The specified daemon.
89  */
91 
92 /**
93  * @brief Resumes network daemon.
94  * @param mask The specified daemon.
95  */
97 
98 /**
99  * @brief Suspends scheduling for all network daemons.
100  * @param flag 0 = Wait for completion, 1 = Perform in background.
101  */
103 
104 /// Resumes daemon scheduling.
106 
107 /**
108  * @brief Returns the current state for the network daemon.
109  * @param state Pointer to write the current state to.
110  */
112 
113 /**
114  * @brief Returns a daemon state.
115  * @param daemon The specified daemon.
116  * @param state Pointer to write the daemon state to.
117  */
118 Result NDMU_QueryStatus(ndmDaemon daemon, ndmDaemonStatus *status);
119 
120 /**
121  * @brief Sets the scan interval.
122  * @param interval Value to set the scan interval to.
123  */
125 
126 /**
127  * @brief Returns the scan interval.
128  * @param interval Pointer to write the interval value to.
129  */
131 
132 /**
133  * @brief Returns the retry interval.
134  * @param interval Pointer to write the interval value to.
135  */
137 
138 /// Reverts network daemon to defaults.
140 
141 /**
142  * @brief Gets the current default daemon bit mask.
143  * @param interval Pointer to write the default daemon mask value to. The default value is (DAEMONMASK_CEC | DAEMONMASK_FRIENDS)
144  */
146 
147 /// Clears half awake mac filter.
149 
Result NDMU_GetRetryInterval(u32 *interval)
Returns the retry interval.
ndmDaemonMask
Used to specify multiple daemons.
Definition: ndm.h:41
Result NDMU_LeaveExclusiveState(void)
Cancels an exclusive state for the network daemon.
Result NDMU_GetExclusiveState(ndmExclusiveState *state)
Returns the exclusive state for the network daemon.
Result NDMU_SuspendDaemons(ndmDaemonMask mask)
Suspends network daemon.
ndmState
Current states.
Definition: ndm.h:17
Result NDMU_GetDefaultDaemons(ndmDaemonMask *mask)
Gets the current default daemon bit mask.
Result NDMU_QueryStatus(ndmDaemon daemon, ndmDaemonStatus *status)
Returns a daemon state.
Result NDMU_LockState(void)
Locks the exclusive state.
Result NDMU_EnterExclusiveState(ndmExclusiveState state)
Sets the network daemon to an exclusive state.
Result NDMU_GetScanInterval(u32 *interval)
Returns the scan interval.
Result NDMU_UnlockState(void)
Unlocks the exclusive state.
Result NDMU_ResumeScheduler(void)
Resumes daemon scheduling.
Result NDMU_SuspendScheduler(u32 flag)
Suspends scheduling for all network daemons.
Result NDMU_GetCurrentState(ndmState *state)
Returns the current state for the network daemon.
Result NDMU_ResetDaemons(void)
Reverts network daemon to defaults.
Result NDMU_SetScanInterval(u32 interval)
Sets the scan interval.
void ndmuExit(void)
Exits ndmu.
Result ndmuInit(void)
Initializes ndmu.
ndmExclusiveState
Exclusive states.
Definition: ndm.h:8
Result NDMU_ClearMacFilter(void)
Clears half awake mac filter.
Result NDMU_ResumeDaemons(ndmDaemonMask mask)
Resumes network daemon.
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:47
s32 Result
Function result.
Definition: types.h:42
uint32_t u32
32-bit unsigned integer
Definition: types.h:23