mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 20:42:44 +02:00
wlaninf: Updated for new-ipc.
This commit is contained in:
parent
1c334bafb9
commit
be2cb63722
@ -1,13 +1,13 @@
|
|||||||
/**
|
/**
|
||||||
* @file wlaninf.h
|
* @file wlaninf.h
|
||||||
* @brief WLAN InfraManager service IPC wrapper.
|
* @brief WLAN InfraManager service IPC wrapper.
|
||||||
* @author natinusala
|
* @author natinusala, yellows8
|
||||||
* @copyright libnx Authors
|
* @copyright libnx Authors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../kernel/ipc.h"
|
#include "../kernel/ipc.h"
|
||||||
#include "../services/sm.h"
|
#include "../sf/service.h"
|
||||||
|
|
||||||
/// WLAN State.
|
/// WLAN State.
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -20,6 +20,7 @@ Result wlaninfInitialize(void);
|
|||||||
void wlaninfExit(void);
|
void wlaninfExit(void);
|
||||||
Service* wlaninfGetServiceSession(void);
|
Service* wlaninfGetServiceSession(void);
|
||||||
|
|
||||||
|
/// Gets \ref WlanInfState.
|
||||||
Result wlaninfGetState(WlanInfState* out);
|
Result wlaninfGetState(WlanInfState* out);
|
||||||
|
|
||||||
/// Value goes from -30 (really good signal) to -90 (barely enough to stay connected)
|
/// Value goes from -30 (really good signal) to -90 (barely enough to stay connected)
|
||||||
|
@ -1,111 +1,34 @@
|
|||||||
/**
|
#define NX_SERVICE_ASSUME_NON_DOMAIN
|
||||||
* @file wlaninf.c
|
#include "service_guard.h"
|
||||||
* @brief WLAN InfraManager service IPC wrapper.
|
|
||||||
* @author natinusala
|
|
||||||
* @copyright libnx Authors
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "types.h"
|
|
||||||
#include "result.h"
|
|
||||||
#include "services/sm.h"
|
|
||||||
#include "services/wlaninf.h"
|
#include "services/wlaninf.h"
|
||||||
#include "arm/atomics.h"
|
|
||||||
|
|
||||||
static Service g_wlaninfSrv;
|
static Service g_wlaninfSrv;
|
||||||
static u64 g_refCnt;
|
|
||||||
|
|
||||||
Result wlaninfInitialize(void) {
|
NX_GENERATE_SERVICE_GUARD(wlaninf);
|
||||||
Result rc;
|
|
||||||
|
|
||||||
atomicIncrement64(&g_refCnt);
|
Result _wlaninfInitialize(void) {
|
||||||
|
return smGetService(&g_wlaninfSrv, "wlan:inf");
|
||||||
if (serviceIsActive(&g_wlaninfSrv))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
rc = smGetService(&g_wlaninfSrv, "wlan:inf");
|
|
||||||
|
|
||||||
if (R_FAILED(rc))
|
|
||||||
wlaninfExit();
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlaninfExit(void) {
|
void _wlaninfCleanup(void) {
|
||||||
if (atomicDecrement64(&g_refCnt) == 0) {
|
|
||||||
serviceClose(&g_wlaninfSrv);
|
serviceClose(&g_wlaninfSrv);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Service* wlaninfGetServiceSession(void) {
|
Service* wlaninfGetServiceSession(void) {
|
||||||
return &g_wlaninfSrv;
|
return &g_wlaninfSrv;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result wlaninfGetState(WlanInfState* out) {
|
static Result _wlaninfCmdNoInOutU32(Service* srv, u32 *out, u32 cmd_id) {
|
||||||
IpcCommand c;
|
return serviceDispatchOut(srv, cmd_id, *out);
|
||||||
ipcInitialize(&c);
|
|
||||||
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 cmd_id;
|
|
||||||
} *raw;
|
|
||||||
|
|
||||||
raw = serviceIpcPrepareHeader(&g_wlaninfSrv, &c, sizeof(*raw));
|
|
||||||
|
|
||||||
raw->magic = SFCI_MAGIC;
|
|
||||||
raw->cmd_id = 10;
|
|
||||||
|
|
||||||
Result rc = serviceIpcDispatch(&g_wlaninfSrv);
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
|
||||||
IpcParsedCommand r;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 result;
|
|
||||||
u32 out;
|
|
||||||
} *resp;
|
|
||||||
|
|
||||||
serviceIpcParse(&g_wlaninfSrv, &r, sizeof(*resp));
|
|
||||||
resp = r.Raw;
|
|
||||||
|
|
||||||
rc = resp->result;
|
|
||||||
*out = resp->out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result wlaninfGetState(WlanInfState* out) {
|
||||||
|
u32 tmp=0;
|
||||||
|
Result rc = _wlaninfCmdNoInOutU32(&g_wlaninfSrv, &tmp, 10);
|
||||||
|
if (R_SUCCEEDED(rc) && out) *out = tmp;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result wlaninfGetRSSI(s32* out) {
|
Result wlaninfGetRSSI(s32* out) {
|
||||||
IpcCommand c;
|
return _wlaninfCmdNoInOutU32(&g_wlaninfSrv, (u32*)out, 12);
|
||||||
ipcInitialize(&c);
|
|
||||||
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 cmd_id;
|
|
||||||
} *raw;
|
|
||||||
|
|
||||||
raw = serviceIpcPrepareHeader(&g_wlaninfSrv, &c, sizeof(*raw));
|
|
||||||
|
|
||||||
raw->magic = SFCI_MAGIC;
|
|
||||||
raw->cmd_id = 12;
|
|
||||||
|
|
||||||
Result rc = serviceIpcDispatch(&g_wlaninfSrv);
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
|
||||||
IpcParsedCommand r;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 result;
|
|
||||||
s32 out;
|
|
||||||
} *resp;
|
|
||||||
|
|
||||||
serviceIpcParse(&g_wlaninfSrv, &r, sizeof(*resp));
|
|
||||||
resp = r.Raw;
|
|
||||||
|
|
||||||
rc = resp->result;
|
|
||||||
*out = resp->out;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user