libctru  v1.6.0
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  EXCLUSIVE_STATE_NONE = 0,
10  EXCLUSIVE_STATE_INFRASTRUCTURE = 1,
11  EXCLUSIVE_STATE_LOCAL_COMMUNICATIONS = 2,
12  EXCLUSIVE_STATE_STREETPASS = 3,
13  EXCLUSIVE_STATE_STREETPASS_DATA = 4,
15 
16 /// Current states.
17 typedef enum {
18  STATE_INITIAL = 0,
19  STATE_SUSPENDED = 1,
20  STATE_INFRASTRUCTURE_CONNECTING = 2,
21  STATE_INFRASTRUCTURE_CONNECTED = 3,
22  STATE_INFRASTRUCTURE_WORKING = 4,
23  STATE_INFRASTRUCTURE_SUSPENDING = 5,
24  STATE_INFRASTRUCTURE_FORCE_SUSPENDING = 6,
25  STATE_INFRASTRUCTURE_DISCONNECTING = 7,
26  STATE_INFRASTRUCTURE_FORCE_DISCONNECTING = 8,
27  STATE_CEC_WORKING = 9,
28  STATE_CEC_FORCE_SUSPENDING = 10,
29  STATE_CEC_SUSPENDING = 11,
30 } ndmState;
31 
32 // Daemons.
33 typedef enum {
34  DAEMON_CEC = 0,
35  DAEMON_BOSS = 1,
36  DAEMON_NIM = 2,
37  DAEMON_FRIENDS = 3,
38 } ndmDaemon;
39 
40 /// Used to specify multiple daemons.
41 typedef enum {
42  DAEMON_MASK_CEC = BIT(DAEMON_CEC),
43  DAEMON_MASK_BOSS = BIT(DAEMON_BOSS),
44  DAEMON_MASK_NIM = BIT(DAEMON_NIM),
45  DAEMON_MASK_FRIENDS = BIT(DAEMON_FRIENDS),
46  DAEMON_MASK_BACKGROUOND = DAEMON_MASK_CEC | DAEMON_MASK_BOSS | DAEMON_MASK_NIM,
47  DAEMON_MASK_ALL = DAEMON_MASK_CEC | DAEMON_MASK_BOSS | DAEMON_MASK_NIM | DAEMON_MASK_FRIENDS,
48  DAEMON_MASK_DEFAULT = DAEMON_MASK_CEC | DAEMON_MASK_FRIENDS,
50 
51 // Daemon status.
52 typedef enum {
53  DAEMON_STATUS_BUSY = 0,
54  DAEMON_STATUS_IDLE = 1,
55  DAEMON_STATUS_SUSPENDING = 2,
56  DAEMON_STATUS_SUSPENDED = 3,
57 } ndmDaemonStatus;
58 
59 /// Initializes ndmu.
60 Result ndmuInit(void);
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 the daemon state.
115  * @param state Pointer to write the daemons state to.
116  */
117 Result NDMU_QueryStatus(ndmDaemonStatus *status);
118 
119 /**
120  * @brief Sets the scan interval.
121  * @param interval Value to set the scan interval to.
122  */
124 
125 /**
126  * @brief Returns the scan interval.
127  * @param interval Pointer to write the interval value to.
128  */
129 Result NDMU_GetScanInterval(u32 *interval);
130 
131 /**
132  * @brief Returns the retry interval.
133  * @param interval Pointer to write the interval value to.
134  */
135 Result NDMU_GetRetryInterval(u32 *interval);
136 
137 /// Reverts network daemon to defaults.
139 
140 /**
141  * @brief Gets the current default daemon bit mask.
142  * @param interval Pointer to write the default daemon mask value to. The default value is (DAEMONMASK_CEC | DAEMONMASK_FRIENDS)
143  */
145 
146 /// Clears half awake mac filter.
148 
Result NDMU_GetDefaultDaemons(ndmDaemonMask *mask)
Gets the current default daemon bit mask.
Result NDMU_GetScanInterval(u32 *interval)
Returns the scan interval.
s32 Result
Function result.
Definition: types.h:42
void ndmuExit(void)
Exits ndmu.
Result NDMU_ResetDaemons(void)
Reverts network daemon to defaults.
Result NDMU_LockState(void)
Locks the exclusive state.
Result NDMU_QueryStatus(ndmDaemonStatus *status)
Returns the daemon state.
Result NDMU_SuspendScheduler(u32 flag)
Suspends scheduling for all network daemons.
Result NDMU_ClearMacFilter(void)
Clears half awake mac filter.
Result NDMU_GetCurrentState(ndmState *state)
Returns the current state for the network daemon.
Result NDMU_SetScanInterval(u32 interval)
Sets the scan interval.
uint32_t u32
32-bit unsigned integer
Definition: types.h:23
Result NDMU_SuspendDaemons(ndmDaemonMask mask)
Suspends network daemon.
Result NDMU_UnlockState(void)
Unlocks the exclusive state.
ndmExclusiveState
Exclusive states.
Definition: ndm.h:8
Result NDMU_ResumeScheduler(void)
Resumes daemon scheduling.
Result NDMU_LeaveExclusiveState(void)
Cancels an exclusive state for the network daemon.
ndmDaemonMask
Used to specify multiple daemons.
Definition: ndm.h:41
Result ndmuInit(void)
Initializes ndmu.
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:47
Result NDMU_ResumeDaemons(ndmDaemonMask mask)
Resumes network daemon.
Result NDMU_GetRetryInterval(u32 *interval)
Returns the retry interval.
Result NDMU_GetExclusiveState(ndmExclusiveState *state)
Returns the exclusive state for the network daemon.
Result NDMU_EnterExclusiveState(ndmExclusiveState state)
Sets the network daemon to an exclusive state.
ndmState
Current states.
Definition: ndm.h:17