ndm.h
Go to the documentation of this file.
/**
* @file ndm.h
* @brief NDMU service. https://3dbrew.org/wiki/NDM_Services
*/
#pragma once
/// Exclusive states.
typedef enum {
NDM_EXCLUSIVE_STATE_NONE = 0,
NDM_EXCLUSIVE_STATE_INFRASTRUCTURE = 1,
NDM_EXCLUSIVE_STATE_LOCAL_COMMUNICATIONS = 2,
NDM_EXCLUSIVE_STATE_STREETPASS = 3,
NDM_EXCLUSIVE_STATE_STREETPASS_DATA = 4,
} ndmExclusiveState;
/// Current states.
typedef enum {
NDM_STATE_INITIAL = 0,
NDM_STATE_SUSPENDED = 1,
NDM_STATE_INFRASTRUCTURE_CONNECTING = 2,
NDM_STATE_INFRASTRUCTURE_CONNECTED = 3,
NDM_STATE_INFRASTRUCTURE_WORKING = 4,
NDM_STATE_INFRASTRUCTURE_SUSPENDING = 5,
NDM_STATE_INFRASTRUCTURE_FORCE_SUSPENDING = 6,
NDM_STATE_INFRASTRUCTURE_DISCONNECTING = 7,
NDM_STATE_INFRASTRUCTURE_FORCE_DISCONNECTING = 8,
NDM_STATE_CEC_WORKING = 9,
NDM_STATE_CEC_FORCE_SUSPENDING = 10,
NDM_STATE_CEC_SUSPENDING = 11,
} ndmState;
// Daemons.
typedef enum {
NDM_DAEMON_CEC = 0,
NDM_DAEMON_BOSS = 1,
NDM_DAEMON_NIM = 2,
NDM_DAEMON_FRIENDS = 3,
} ndmDaemon;
/// Used to specify multiple daemons.
typedef enum {
NDM_DAEMON_MASK_CEC = BIT(NDM_DAEMON_CEC),
NDM_DAEMON_MASK_BOSS = BIT(NDM_DAEMON_BOSS),
NDM_DAEMON_MASK_NIM = BIT(NDM_DAEMON_NIM),
NDM_DAEMON_MASK_FRIENDS = BIT(NDM_DAEMON_FRIENDS),
NDM_DAEMON_MASK_BACKGROUOND = NDM_DAEMON_MASK_CEC | NDM_DAEMON_MASK_BOSS | NDM_DAEMON_MASK_NIM,
NDM_DAEMON_MASK_ALL = NDM_DAEMON_MASK_CEC | NDM_DAEMON_MASK_BOSS | NDM_DAEMON_MASK_NIM | NDM_DAEMON_MASK_FRIENDS,
NDM_DAEMON_MASK_DEFAULT = NDM_DAEMON_MASK_CEC | NDM_DAEMON_MASK_FRIENDS,
} ndmDaemonMask;
// Daemon status.
typedef enum {
NDM_DAEMON_STATUS_BUSY = 0,
NDM_DAEMON_STATUS_IDLE = 1,
NDM_DAEMON_STATUS_SUSPENDING = 2,
NDM_DAEMON_STATUS_SUSPENDED = 3,
} ndmDaemonStatus;
/// Initializes ndmu.
Result ndmuInit(void);
/// Exits ndmu.
void ndmuExit(void);
/**
* @brief Sets the network daemon to an exclusive state.
* @param state State specified in the ndmExclusiveState enumerator.
*/
Result NDMU_EnterExclusiveState(ndmExclusiveState state);
/// Cancels an exclusive state for the network daemon.
Result NDMU_LeaveExclusiveState(void);
/**
* @brief Returns the exclusive state for the network daemon.
* @param state Pointer to write the exclsuive state to.
*/
Result NDMU_GetExclusiveState(ndmExclusiveState *state);
/// Locks the exclusive state.
Result NDMU_LockState(void);
/// Unlocks the exclusive state.
Result NDMU_UnlockState(void);
/**
* @brief Suspends network daemon.
* @param mask The specified daemon.
*/
Result NDMU_SuspendDaemons(ndmDaemonMask mask);
/**
* @brief Resumes network daemon.
* @param mask The specified daemon.
*/
Result NDMU_ResumeDaemons(ndmDaemonMask mask);
/**
* @brief Suspends scheduling for all network daemons.
* @param flag 0 = Wait for completion, 1 = Perform in background.
*/
Result NDMU_SuspendScheduler(u32 flag);
/// Resumes daemon scheduling.
Result NDMU_ResumeScheduler(void);
/**
* @brief Returns the current state for the network daemon.
* @param state Pointer to write the current state to.
*/
Result NDMU_GetCurrentState(ndmState *state);
/**
* @brief Returns a daemon state.
* @param daemon The specified daemon.
* @param state Pointer to write the daemon state to.
*/
Result NDMU_QueryStatus(ndmDaemon daemon, ndmDaemonStatus *status);
/**
* @brief Sets the scan interval.
* @param interval Value to set the scan interval to.
*/
Result NDMU_SetScanInterval(u32 interval);
/**
* @brief Returns the scan interval.
* @param interval Pointer to write the interval value to.
*/
Result NDMU_GetScanInterval(u32 *interval);
/**
* @brief Returns the retry interval.
* @param interval Pointer to write the interval value to.
*/
Result NDMU_GetRetryInterval(u32 *interval);
/// Reverts network daemon to defaults.
Result NDMU_ResetDaemons(void);
/**
* @brief Gets the current default daemon bit mask.
* @param interval Pointer to write the default daemon mask value to. The default value is (DAEMONMASK_CEC | DAEMONMASK_FRIENDS)
*/
Result NDMU_GetDefaultDaemons(ndmDaemonMask *mask);
/// Clears half awake mac filter.
Result NDMU_ClearMacFilter(void);
NDMU_GetRetryInterval
Result NDMU_GetRetryInterval(u32 *interval)
Returns the retry interval.
ndmDaemonMask
ndmDaemonMask
Used to specify multiple daemons.
Definition: ndm.h:41
NDMU_LeaveExclusiveState
Result NDMU_LeaveExclusiveState(void)
Cancels an exclusive state for the network daemon.
NDMU_GetExclusiveState
Result NDMU_GetExclusiveState(ndmExclusiveState *state)
Returns the exclusive state for the network daemon.
NDMU_SuspendDaemons
Result NDMU_SuspendDaemons(ndmDaemonMask mask)
Suspends network daemon.
ndmState
ndmState
Current states.
Definition: ndm.h:17
NDMU_GetDefaultDaemons
Result NDMU_GetDefaultDaemons(ndmDaemonMask *mask)
Gets the current default daemon bit mask.
NDMU_QueryStatus
Result NDMU_QueryStatus(ndmDaemon daemon, ndmDaemonStatus *status)
Returns a daemon state.
NDMU_LockState
Result NDMU_LockState(void)
Locks the exclusive state.
NDMU_EnterExclusiveState
Result NDMU_EnterExclusiveState(ndmExclusiveState state)
Sets the network daemon to an exclusive state.
NDMU_GetScanInterval
Result NDMU_GetScanInterval(u32 *interval)
Returns the scan interval.
NDMU_UnlockState
Result NDMU_UnlockState(void)
Unlocks the exclusive state.
NDMU_ResumeScheduler
Result NDMU_ResumeScheduler(void)
Resumes daemon scheduling.
NDMU_SuspendScheduler
Result NDMU_SuspendScheduler(u32 flag)
Suspends scheduling for all network daemons.
NDMU_GetCurrentState
Result NDMU_GetCurrentState(ndmState *state)
Returns the current state for the network daemon.
NDMU_ResetDaemons
Result NDMU_ResetDaemons(void)
Reverts network daemon to defaults.
NDMU_SetScanInterval
Result NDMU_SetScanInterval(u32 interval)
Sets the scan interval.
ndmuExit
void ndmuExit(void)
Exits ndmu.
ndmuInit
Result ndmuInit(void)
Initializes ndmu.
ndmExclusiveState
ndmExclusiveState
Exclusive states.
Definition: ndm.h:8
NDMU_ClearMacFilter
Result NDMU_ClearMacFilter(void)
Clears half awake mac filter.
NDMU_ResumeDaemons
Result NDMU_ResumeDaemons(ndmDaemonMask mask)
Resumes network daemon.
BIT
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:47
Result
s32 Result
Function result.
Definition: types.h:42
u32
uint32_t u32
32-bit unsigned integer
Definition: types.h:23