nfc: Added more cmds, etc.

This commit is contained in:
yellows8 2021-12-09 01:01:24 -05:00
parent 74c639ec3a
commit 4a33b32f43
No known key found for this signature in database
GPG Key ID: 0AF90DA3F1E60E43
2 changed files with 45 additions and 1 deletions

View File

@ -155,3 +155,7 @@ Result nfpAttachAvailabilityChangeEvent(Event *out_event);
/// This uses nfc:*. /// This uses nfc:*.
Result nfcIsNfcEnabled(bool *out); Result nfcIsNfcEnabled(bool *out);
Result nfcSendCommandByPassThrough(const NfcDeviceHandle *handle, u64 timeout, const void* cmd_buf, size_t cmd_buf_size, void* reply_buf, size_t reply_buf_size, u64 *out_size);
Result nfcKeepPassThroughSession(const NfcDeviceHandle *handle);
Result nfcReleasePassThroughSession(const NfcDeviceHandle *handle);

View File

@ -69,7 +69,7 @@ void _nfpCleanup(void) {
NX_GENERATE_SERVICE_GUARD_PARAMS(nfc, (NfcServiceType service_type), (service_type)); NX_GENERATE_SERVICE_GUARD_PARAMS(nfc, (NfcServiceType service_type), (service_type));
Result _nfcInitialize(NfcServiceType service_type) { Result _nfcInitialize(NfcServiceType service_type) {
Result rc=0; Result rc = MAKERESULT(Module_Libnx, LibnxError_BadInput);
g_nfcServiceType = service_type; g_nfcServiceType = service_type;
switch (g_nfcServiceType) { switch (g_nfcServiceType) {
@ -347,3 +347,43 @@ Result nfpAttachAvailabilityChangeEvent(Event *out_event) {
Result nfcIsNfcEnabled(bool *out) { Result nfcIsNfcEnabled(bool *out) {
return _nfcCmdNoInOutBool(&g_nfcInterface, out, hosversionBefore(4,0,0) ? 3 : 403); return _nfcCmdNoInOutBool(&g_nfcInterface, out, hosversionBefore(4,0,0) ? 3 : 403);
} }
Result nfcSendCommandByPassThrough(const NfcDeviceHandle *handle, u64 timeout, const void* cmd_buf, size_t cmd_buf_size, void* reply_buf, size_t reply_buf_size, u64 *out_size) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
const struct {
NfcDeviceHandle handle;
u64 timeout;
} in = { *handle, timeout };
serviceAssumeDomain(&g_nfcInterface);
u32 tmp_out=0;
Result rc = serviceDispatchInOut(&g_nfcInterface, 1300, in, tmp_out,
.buffer_attrs = {
SfBufferAttr_HipcMapAlias | SfBufferAttr_Out,
SfBufferAttr_HipcMapAlias | SfBufferAttr_In,
},
.buffers = {
{ reply_buf, reply_buf_size },
{ cmd_buf, cmd_buf_size },
},
);
if (R_SUCCEEDED(rc) && out_size) *out_size = tmp_out;
return rc;
}
Result nfcKeepPassThroughSession(const NfcDeviceHandle *handle) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _nfcCmdInDevhandleNoOut(&g_nfcInterface, handle, 1301);
}
Result nfcReleasePassThroughSession(const NfcDeviceHandle *handle) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _nfcCmdInDevhandleNoOut(&g_nfcInterface, handle, 1302);
}