From 61a18cc5eaa6b03e0d073610c4ce526ffeb62a37 Mon Sep 17 00:00:00 2001 From: Ken Sanislo Date: Fri, 29 Jan 2016 14:16:50 -0800 Subject: [PATCH 01/15] Identified meaning of HTTPC_CreateContext's cmdbuf[2] --- libctru/source/services/httpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libctru/source/services/httpc.c b/libctru/source/services/httpc.c index b0daef8..ba5862c 100644 --- a/libctru/source/services/httpc.c +++ b/libctru/source/services/httpc.c @@ -170,7 +170,7 @@ Result HTTPC_CreateContext(Handle handle, char* url, Handle* contextHandle) cmdbuf[0]=IPC_MakeHeader(0x2,2,2); // 0x20082 cmdbuf[1]=l; - cmdbuf[2]=0x01; //unk + cmdbuf[2]=0x01; //0x01 == GET, 0x02 == POST, more to be determined. cmdbuf[3]=IPC_Desc_Buffer(l,IPC_BUFFER_R); cmdbuf[4]=(u32)url; From 448fb0453e239357bb7da57586718188450941f4 Mon Sep 17 00:00:00 2001 From: Ken Sanislo Date: Sat, 30 Jan 2016 17:29:25 -0800 Subject: [PATCH 02/15] comment the use of the request type --- libctru/source/services/httpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libctru/source/services/httpc.c b/libctru/source/services/httpc.c index ba5862c..7f5fb79 100644 --- a/libctru/source/services/httpc.c +++ b/libctru/source/services/httpc.c @@ -170,8 +170,8 @@ Result HTTPC_CreateContext(Handle handle, char* url, Handle* contextHandle) cmdbuf[0]=IPC_MakeHeader(0x2,2,2); // 0x20082 cmdbuf[1]=l; - cmdbuf[2]=0x01; //0x01 == GET, 0x02 == POST, more to be determined. - cmdbuf[3]=IPC_Desc_Buffer(l,IPC_BUFFER_R); + cmdbuf[2]=0x01; // 0x01 == GET, 0x02 == POST, 0x03 == HEAD, 0x04 == PUT, 0x05 == DELETE + cmdbuf[3]=IPC_Desc_Buffer(l,IPC_BUFFER_R); cmdbuf[4]=(u32)url; Result ret=0; From 4c89c108583b86ae54448b868f2e15e45bf00c1a Mon Sep 17 00:00:00 2001 From: Ken Sanislo Date: Sat, 30 Jan 2016 19:39:43 -0800 Subject: [PATCH 03/15] httpcOpenContext now takes an HTTPC_RequestMethod parameter --- libctru/include/3ds/services/httpc.h | 13 +++++++++++-- libctru/source/services/httpc.c | 8 ++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/libctru/include/3ds/services/httpc.h b/libctru/include/3ds/services/httpc.h index 1ac41a7..8bc0765 100644 --- a/libctru/include/3ds/services/httpc.h +++ b/libctru/include/3ds/services/httpc.h @@ -10,6 +10,15 @@ typedef struct { u32 httphandle; ///< HTTP handle. } httpcContext; +/// HTTP request method. +typedef enum { + HTTPC_METHOD_GET = 0x1, + HTTPC_METHOD_POST = 0x2, + HTTPC_METHOD_HEAD = 0x3, + HTTPC_METHOD_PUT = 0x4, + HTTPC_METHOD_DELETE = 0x5 +} HTTPC_RequestMethod; + /// HTTP request status. typedef enum { HTTPC_STATUS_REQUEST_IN_PROGRESS = 0x5, ///< Request in progress. @@ -31,7 +40,7 @@ void httpcExit(void); * @param url URL to connect to. * @param use_defaultproxy Whether the default proxy should be used (0 for default) */ -Result httpcOpenContext(httpcContext *context, char* url, u32 use_defaultproxy); +Result httpcOpenContext(httpcContext *context, HTTPC_RequestMethod method, char* url, u32 use_defaultproxy); /** * @brief Closes a HTTP context. @@ -124,7 +133,7 @@ Result HTTPC_InitializeConnectionSession(Handle handle, Handle contextHandle); * @param url URL to connect to. * @param contextHandle Pointer to output the created HTTP context handle to. */ -Result HTTPC_CreateContext(Handle handle, char* url, Handle* contextHandle); +Result HTTPC_CreateContext(Handle handle, HTTPC_RequestMethod method, char* url, Handle* contextHandle); /** * @brief Closes a HTTP context. diff --git a/libctru/source/services/httpc.c b/libctru/source/services/httpc.c index 7f5fb79..2ff0661 100644 --- a/libctru/source/services/httpc.c +++ b/libctru/source/services/httpc.c @@ -33,11 +33,11 @@ void httpcExit(void) svcCloseHandle(__httpc_servhandle); } -Result httpcOpenContext(httpcContext *context, char* url, u32 use_defaultproxy) +Result httpcOpenContext(httpcContext *context, HTTPC_RequestMethod method, char* url, u32 use_defaultproxy) { Result ret=0; - ret = HTTPC_CreateContext(__httpc_servhandle, url, &context->httphandle); + ret = HTTPC_CreateContext(__httpc_servhandle, method, url, &context->httphandle); if(R_FAILED(ret))return ret; ret = srvGetServiceHandle(&context->servhandle, "http:C"); @@ -163,14 +163,14 @@ Result HTTPC_Initialize(Handle handle) return cmdbuf[1]; } -Result HTTPC_CreateContext(Handle handle, char* url, Handle* contextHandle) +Result HTTPC_CreateContext(Handle handle, HTTPC_RequestMethod method, char* url, Handle* contextHandle) { u32* cmdbuf=getThreadCommandBuffer(); u32 l=strlen(url)+1; cmdbuf[0]=IPC_MakeHeader(0x2,2,2); // 0x20082 cmdbuf[1]=l; - cmdbuf[2]=0x01; // 0x01 == GET, 0x02 == POST, 0x03 == HEAD, 0x04 == PUT, 0x05 == DELETE + cmdbuf[2]=method; cmdbuf[3]=IPC_Desc_Buffer(l,IPC_BUFFER_R); cmdbuf[4]=(u32)url; From 3df558e6ec5db96e5fbc971a12e147a3b62a8d0a Mon Sep 17 00:00:00 2001 From: Ken Sanislo Date: Tue, 2 Feb 2016 21:45:44 -0800 Subject: [PATCH 04/15] httpcDownloadData() re-implemented to allow chunked encoding --- libctru/source/services/httpc.c | 37 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/libctru/source/services/httpc.c b/libctru/source/services/httpc.c index 2ff0661..f4e9325 100644 --- a/libctru/source/services/httpc.c +++ b/libctru/source/services/httpc.c @@ -113,12 +113,13 @@ Result httpcGetResponseStatusCode(httpcContext *context, u32* out, u64 delay) Result httpcDownloadData(httpcContext *context, u8* buffer, u32 size, u32 *downloadedsize) { Result ret=0; - u32 contentsize=0; u32 pos=0, sz=0; + u32 dlstartpos=0; + u32 dlpos=0; if(downloadedsize)*downloadedsize = 0; - ret=httpcGetDownloadSizeState(context, NULL, &contentsize); + ret=httpcGetDownloadSizeState(context, &dlstartpos, NULL); if(R_FAILED(ret))return ret; while(pos < size) @@ -126,25 +127,23 @@ Result httpcDownloadData(httpcContext *context, u8* buffer, u32 size, u32 *downl sz = size - pos; ret=httpcReceiveData(context, &buffer[pos], sz); + if(ret!=HTTPC_RESULTCODE_DOWNLOADPENDING)break; - if(ret==HTTPC_RESULTCODE_DOWNLOADPENDING) - { - ret=httpcGetDownloadSizeState(context, &pos, NULL); - if(R_FAILED(ret))return ret; - } - else if(R_FAILED(ret)) - { - return ret; - } - else - { - pos+= sz; - } + ret=httpcGetDownloadSizeState(context, &dlpos, NULL); + if(R_FAILED(ret))return ret; - if(downloadedsize)*downloadedsize = pos; + pos = dlpos - dlstartpos; } - return 0; + // This duplication is awful, but if I reorder the loop to avoid it + // then I get failure returns from httpcReceiveData()... wtf? + ret=httpcGetDownloadSizeState(context, &dlpos, NULL); + if(R_FAILED(ret))return ret; + pos = dlpos - dlstartpos; + + if(downloadedsize)*downloadedsize = pos; + + return ret; } Result HTTPC_Initialize(Handle handle) @@ -152,10 +151,10 @@ Result HTTPC_Initialize(Handle handle) u32* cmdbuf=getThreadCommandBuffer(); cmdbuf[0]=IPC_MakeHeader(0x1,1,4); // 0x10044 - cmdbuf[1]=0x1000; //unk + cmdbuf[1]=0x1000; // POST buffer size (page aligned) cmdbuf[2]=IPC_Desc_CurProcessHandle(); cmdbuf[4]=IPC_Desc_SharedHandles(1); - cmdbuf[5]=0;//Some sort of handle. + cmdbuf[5]=0;// POST buffer memory block handle Result ret=0; if(R_FAILED(ret=svcSendSyncRequest(handle)))return ret; From 09611e0284a559eebcbe2e3236afe2f6dbf82ed1 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Wed, 3 Feb 2016 00:25:54 -0800 Subject: [PATCH 05/15] Fix crash when getting or setting struct params in CAM:U --- libctru/source/services/cam.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libctru/source/services/cam.c b/libctru/source/services/cam.c index 6425cda..996d544 100644 --- a/libctru/source/services/cam.c +++ b/libctru/source/services/cam.c @@ -6,6 +6,7 @@ #include <3ds/types.h> #include <3ds/result.h> #include <3ds/ipc.h> +#include Handle camHandle; static int camRefCount; @@ -534,7 +535,7 @@ Result CAMU_GetStereoCameraCalibrationData(CAMU_StereoCameraCalibrationData* dat cmdbuf[0] = IPC_MakeHeader(0x2B,0,0); // 0x2B0000 if (R_FAILED(ret = svcSendSyncRequest(camHandle))) return ret; - *data = *(CAMU_StereoCameraCalibrationData*) cmdbuf[2]; + memcpy(data, &cmdbuf[2], sizeof(*data)); return cmdbuf[1]; } @@ -542,7 +543,7 @@ Result CAMU_SetStereoCameraCalibrationData(CAMU_StereoCameraCalibrationData data Result ret = 0; u32* cmdbuf = getThreadCommandBuffer(); cmdbuf[0] = IPC_MakeHeader(0x2C,16,0); // 0x2C0400 - *(CAMU_StereoCameraCalibrationData*) cmdbuf[1] = data; + memcpy(&cmdbuf[1], &data, sizeof(data)); if (R_FAILED(ret = svcSendSyncRequest(camHandle))) return ret; return cmdbuf[1]; @@ -600,7 +601,7 @@ Result CAMU_SetImageQualityCalibrationData(CAMU_ImageQualityCalibrationData data Result ret = 0; u32* cmdbuf = getThreadCommandBuffer(); cmdbuf[0] = IPC_MakeHeader(0x31,6,0); // 0x310180 - *(CAMU_ImageQualityCalibrationData*) cmdbuf[1] = data; + memcpy(&cmdbuf[1], &data, sizeof(data)); if (R_FAILED(ret = svcSendSyncRequest(camHandle))) return ret; return cmdbuf[1]; @@ -612,7 +613,7 @@ Result CAMU_GetImageQualityCalibrationData(CAMU_ImageQualityCalibrationData* dat cmdbuf[0] = IPC_MakeHeader(0x32,0,0); // 0x320000 if (R_FAILED(ret = svcSendSyncRequest(camHandle))) return ret; - *data = *(CAMU_ImageQualityCalibrationData*) cmdbuf[2]; + memcpy(data, &cmdbuf[2], sizeof(*data)); return cmdbuf[1]; } @@ -620,7 +621,7 @@ Result CAMU_SetPackageParameterWithoutContext(CAMU_PackageParameterCameraSelect Result ret = 0; u32* cmdbuf = getThreadCommandBuffer(); cmdbuf[0] = IPC_MakeHeader(0x33,11,0); // 0x3302C0 - *(CAMU_PackageParameterCameraSelect*) cmdbuf[1] = param; + memcpy(&cmdbuf[1], ¶m, sizeof(param)); if (R_FAILED(ret = svcSendSyncRequest(camHandle))) return ret; return cmdbuf[1]; @@ -630,7 +631,7 @@ Result CAMU_SetPackageParameterWithContext(CAMU_PackageParameterContext param) { Result ret = 0; u32* cmdbuf = getThreadCommandBuffer(); cmdbuf[0] = IPC_MakeHeader(0x34,5,0); // 0x340140 - *(CAMU_PackageParameterContext*) cmdbuf[1] = param; + memcpy(&cmdbuf[1], ¶m, sizeof(param)); if (R_FAILED(ret = svcSendSyncRequest(camHandle))) return ret; return cmdbuf[1]; @@ -640,7 +641,7 @@ Result CAMU_SetPackageParameterWithContextDetail(CAMU_PackageParameterContextDet Result ret = 0; u32* cmdbuf = getThreadCommandBuffer(); cmdbuf[0] = IPC_MakeHeader(0x35,7,0); // 0x3501C0 - *(CAMU_PackageParameterContextDetail*) cmdbuf[1] = param; + memcpy(&cmdbuf[1], ¶m, sizeof(param)); if (R_FAILED(ret = svcSendSyncRequest(camHandle))) return ret; return cmdbuf[1]; From 5aac462be08dda22bdcf48e8458fcc61a4befa6b Mon Sep 17 00:00:00 2001 From: Ken Sanislo Date: Wed, 3 Feb 2016 18:40:13 -0800 Subject: [PATCH 06/15] pass httpcReceiveData's return back through httpcDownloadData --- libctru/source/services/httpc.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/libctru/source/services/httpc.c b/libctru/source/services/httpc.c index f4e9325..1750fd0 100644 --- a/libctru/source/services/httpc.c +++ b/libctru/source/services/httpc.c @@ -1,3 +1,8 @@ +//#include +//#include +//#include +//#include <3ds.h> + #include #include <3ds/types.h> #include <3ds/result.h> @@ -113,6 +118,7 @@ Result httpcGetResponseStatusCode(httpcContext *context, u32* out, u64 delay) Result httpcDownloadData(httpcContext *context, u8* buffer, u32 size, u32 *downloadedsize) { Result ret=0; + Result dlret=HTTPC_RESULTCODE_DOWNLOADPENDING; u32 pos=0, sz=0; u32 dlstartpos=0; u32 dlpos=0; @@ -122,12 +128,11 @@ Result httpcDownloadData(httpcContext *context, u8* buffer, u32 size, u32 *downl ret=httpcGetDownloadSizeState(context, &dlstartpos, NULL); if(R_FAILED(ret))return ret; - while(pos < size) + while(pos < size && dlret==HTTPC_RESULTCODE_DOWNLOADPENDING) { sz = size - pos; - ret=httpcReceiveData(context, &buffer[pos], sz); - if(ret!=HTTPC_RESULTCODE_DOWNLOADPENDING)break; + dlret=httpcReceiveData(context, &buffer[pos], sz); ret=httpcGetDownloadSizeState(context, &dlpos, NULL); if(R_FAILED(ret))return ret; @@ -135,15 +140,9 @@ Result httpcDownloadData(httpcContext *context, u8* buffer, u32 size, u32 *downl pos = dlpos - dlstartpos; } - // This duplication is awful, but if I reorder the loop to avoid it - // then I get failure returns from httpcReceiveData()... wtf? - ret=httpcGetDownloadSizeState(context, &dlpos, NULL); - if(R_FAILED(ret))return ret; - pos = dlpos - dlstartpos; - if(downloadedsize)*downloadedsize = pos; - return ret; + return dlret; } Result HTTPC_Initialize(Handle handle) From 0c1152900082848276fbda7aaa8181f338d607b0 Mon Sep 17 00:00:00 2001 From: Javi Date: Thu, 4 Feb 2016 12:51:06 +0100 Subject: [PATCH 07/15] Add basic NFC service support --- libctru/include/3ds/services/nfc.h | 79 ++++++++++++++ libctru/source/services/nfc.c | 169 +++++++++++++++++++++++++++++ 2 files changed, 248 insertions(+) create mode 100644 libctru/include/3ds/services/nfc.h create mode 100644 libctru/source/services/nfc.c diff --git a/libctru/include/3ds/services/nfc.h b/libctru/include/3ds/services/nfc.h new file mode 100644 index 0000000..7c848e1 --- /dev/null +++ b/libctru/include/3ds/services/nfc.h @@ -0,0 +1,79 @@ +/** + * @file nfc.h + * @brief NFC service. + */ +#pragma once + +/** + * @brief Initializes NFC. + */ +Result nfcInit(void); + +/** + * @brief Shuts down NFC. + */ +void nfcExit(void); + +/** + * @brief Gets the NFC service handle. + * @return The NFC service handle. + */ +Handle nfcGetSessionHandle(void); + +/** + * @brief Initialize NFC module. + * @param type Unknown, can be either value 0x1 or 0x2. + */ +Result nfc_Initialize(u8 type); + +/** + * @brief Shutdown NFC module. + * @param type Unknown. + */ +Result nfc_Shutdown(u8 type); + +/** + * @brief O3DS starts communication with the O3DS NFC hardware. N3DS just checks state for this command. + */ +Result nfc_StartCommunication(); + +/** + * @brief O3DS stops communication with the O3DS NFC hardware. N3DS just uses code used internally by NFC:StopTagScanning for this. + */ +Result nfc_StopCommunication(); + +/** + * @brief Starts scanning for NFC tags. + * @param unknown Unknown. + */ +Result nfc_StartTagScanning(u16 unknown); + +/** + * @brief Stops scanning for NFC tags. + */ +Result nfc_StopTagScanning(); + +/** + * @brief Read Amiibo NFC data and load in memory. + */ +Result nfc_LoadAmiiboData(); + +/** + * @brief If the tagstate is valid, it then sets the current tagstate to 3. + */ +Result nfc_ResetTagScanState(); + +/** + * @brief Returns the current NFC tag state. + * @param state Pointer to write NFC tag state. + * + * Tag state values: + * - 0: NFC:Initialize was not used yet. + * - 1: Not currently scanning for NFC tags. Set by NFC:StopTagScanning and NFC:Initialize, when successful. + * - 2: Currently scanning for NFC tags. Set by NFC:StartTagScanning when successful. + * - 3: NFC tag is in range. The state automatically changes to this when the state was previous value 3, without using any NFC service commands. + * - 4: NFC tag is now out of range, where the NFC tag was previously in range. This occurs automatically without using any NFC service commands. Once this state is entered, it won't automatically change to anything else when the tag is moved in range again. Hence, if you want to keep doing tag scanning after this, you must stop+start scanning. + * - 5: NFC tag data was successfully loaded. This is set by NFC:LoadAmiiboData when successful. + */ +Result nfc_GetTagState(u8 *state); + diff --git a/libctru/source/services/nfc.c b/libctru/source/services/nfc.c new file mode 100644 index 0000000..317ef5b --- /dev/null +++ b/libctru/source/services/nfc.c @@ -0,0 +1,169 @@ +#include <3ds/types.h> +#include <3ds/result.h> +#include <3ds/svc.h> +#include <3ds/srv.h> +#include <3ds/synchronization.h> +#include <3ds/services/nfc.h> +#include <3ds/ipc.h> + +static Handle nfcHandle; +static int nfcRefCount; + +Result nfcInit(void) +{ + Result ret=0; + + if (AtomicPostIncrement(&nfcRefCount)) return 0; + + ret = srvGetServiceHandle(&nfcHandle, "nfc:u"); + if (R_SUCCEEDED(ret)) + { + ret = nfc_Initialize(0x02); + if (R_FAILED(ret)) svcCloseHandle(nfcHandle); + } + if (R_FAILED(ret)) AtomicDecrement(&nfcRefCount); + + return ret; +} + +void nfcExit(void) +{ + if (AtomicDecrement(&nfcRefCount)) return; + svcCloseHandle(nfcHandle); +} + +Handle nfcGetSessionHandle(void) +{ + return nfcHandle; +} + +Result nfc_Initialize(u8 type) +{ + Result ret=0; + u32* cmdbuf=getThreadCommandBuffer(); + + cmdbuf[0]=IPC_MakeHeader(0x1,1,0); // 0x10040 + cmdbuf[1]=type; + + if(R_FAILED(ret = svcSendSyncRequest(nfcHandle)))return ret; + + ret = (Result)cmdbuf[1]; + + return ret; +} + +Result nfc_Shutdown(u8 type) +{ + Result ret=0; + u32* cmdbuf=getThreadCommandBuffer(); + + cmdbuf[0]=IPC_MakeHeader(0x2,1,0); // 0x20040 + cmdbuf[1]=type; + + if(R_FAILED(ret = svcSendSyncRequest(nfcHandle)))return ret; + + ret = (Result)cmdbuf[1]; + + return ret; +} + +Result nfc_StartCommunication() +{ + Result ret=0; + u32* cmdbuf=getThreadCommandBuffer(); + + cmdbuf[0]=IPC_MakeHeader(0x3,0,0); // 0x30000 + + if(R_FAILED(ret = svcSendSyncRequest(nfcHandle)))return ret; + + ret = (Result)cmdbuf[1]; + + return ret; +} + +Result nfc_StopCommunication() +{ + Result ret=0; + u32* cmdbuf=getThreadCommandBuffer(); + + cmdbuf[0]=IPC_MakeHeader(0x4,0,0); // 0x40000 + + if(R_FAILED(ret = svcSendSyncRequest(nfcHandle)))return ret; + + ret = (Result)cmdbuf[1]; + + return ret; +} + +Result nfc_StartTagScanning(u16 unknown) +{ + Result ret=0; + u32* cmdbuf=getThreadCommandBuffer(); + + cmdbuf[0]=IPC_MakeHeader(0x5,1,0); // 0x50040 + cmdbuf[1]=unknown; + + if(R_FAILED(ret = svcSendSyncRequest(nfcHandle)))return ret; + + ret = (Result)cmdbuf[1]; + + return ret; +} + +Result nfc_StopTagScanning() +{ + Result ret=0; + u32* cmdbuf=getThreadCommandBuffer(); + + cmdbuf[0]=IPC_MakeHeader(0x6,0,0); // 0x60000 + + if(R_FAILED(ret = svcSendSyncRequest(nfcHandle)))return ret; + + ret = (Result)cmdbuf[1]; + + return ret; +} + +Result nfc_LoadAmiiboData() +{ + Result ret=0; + u32* cmdbuf=getThreadCommandBuffer(); + + cmdbuf[0]=IPC_MakeHeader(0x7,0,0); // 0x70000 + + if(R_FAILED(ret = svcSendSyncRequest(nfcHandle)))return ret; + + ret = (Result)cmdbuf[1]; + + return ret; +} + +Result nfc_ResetTagScanState() +{ + Result ret=0; + u32* cmdbuf=getThreadCommandBuffer(); + + cmdbuf[0]=IPC_MakeHeader(0x8,0,0); // 0x80000 + + if(R_FAILED(ret = svcSendSyncRequest(nfcHandle)))return ret; + + ret = (Result)cmdbuf[1]; + + return ret; +} + +Result nfc_GetTagState(u8 *state) +{ + Result ret=0; + u32* cmdbuf=getThreadCommandBuffer(); + + cmdbuf[0]=IPC_MakeHeader(0xD,0,0); // 0xD0000 + + if(R_FAILED(ret = svcSendSyncRequest(nfcHandle)))return ret; + + ret = (Result)cmdbuf[1]; + *state = cmdbuf[2]; + + return ret; +} + From 14005eee528d232dc7c1cd2d5d09feae75996e14 Mon Sep 17 00:00:00 2001 From: Javi Date: Thu, 4 Feb 2016 17:18:26 +0100 Subject: [PATCH 08/15] Fixed prefix and parameters declaration --- libctru/include/3ds/services/nfc.h | 18 +++++++++--------- libctru/source/services/nfc.c | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/libctru/include/3ds/services/nfc.h b/libctru/include/3ds/services/nfc.h index 7c848e1..8f78d62 100644 --- a/libctru/include/3ds/services/nfc.h +++ b/libctru/include/3ds/services/nfc.h @@ -24,44 +24,44 @@ Handle nfcGetSessionHandle(void); * @brief Initialize NFC module. * @param type Unknown, can be either value 0x1 or 0x2. */ -Result nfc_Initialize(u8 type); +Result NFC_Initialize(u8 type); /** * @brief Shutdown NFC module. * @param type Unknown. */ -Result nfc_Shutdown(u8 type); +Result NFC_Shutdown(u8 type); /** * @brief O3DS starts communication with the O3DS NFC hardware. N3DS just checks state for this command. */ -Result nfc_StartCommunication(); +Result NFC_StartCommunication(void); /** * @brief O3DS stops communication with the O3DS NFC hardware. N3DS just uses code used internally by NFC:StopTagScanning for this. */ -Result nfc_StopCommunication(); +Result NFC_StopCommunication(void); /** * @brief Starts scanning for NFC tags. * @param unknown Unknown. */ -Result nfc_StartTagScanning(u16 unknown); +Result NFC_StartTagScanning(u16 unknown); /** * @brief Stops scanning for NFC tags. */ -Result nfc_StopTagScanning(); +Result NFC_StopTagScanning(void); /** * @brief Read Amiibo NFC data and load in memory. */ -Result nfc_LoadAmiiboData(); +Result NFC_LoadAmiiboData(void); /** * @brief If the tagstate is valid, it then sets the current tagstate to 3. */ -Result nfc_ResetTagScanState(); +Result NFC_ResetTagScanState(void); /** * @brief Returns the current NFC tag state. @@ -75,5 +75,5 @@ Result nfc_ResetTagScanState(); * - 4: NFC tag is now out of range, where the NFC tag was previously in range. This occurs automatically without using any NFC service commands. Once this state is entered, it won't automatically change to anything else when the tag is moved in range again. Hence, if you want to keep doing tag scanning after this, you must stop+start scanning. * - 5: NFC tag data was successfully loaded. This is set by NFC:LoadAmiiboData when successful. */ -Result nfc_GetTagState(u8 *state); +Result NFC_GetTagState(u8 *state); diff --git a/libctru/source/services/nfc.c b/libctru/source/services/nfc.c index 317ef5b..cd3fa1d 100644 --- a/libctru/source/services/nfc.c +++ b/libctru/source/services/nfc.c @@ -37,7 +37,7 @@ Handle nfcGetSessionHandle(void) return nfcHandle; } -Result nfc_Initialize(u8 type) +Result NFC_Initialize(u8 type) { Result ret=0; u32* cmdbuf=getThreadCommandBuffer(); @@ -52,7 +52,7 @@ Result nfc_Initialize(u8 type) return ret; } -Result nfc_Shutdown(u8 type) +Result NFC_Shutdown(u8 type) { Result ret=0; u32* cmdbuf=getThreadCommandBuffer(); @@ -67,7 +67,7 @@ Result nfc_Shutdown(u8 type) return ret; } -Result nfc_StartCommunication() +Result NFC_StartCommunication(void) { Result ret=0; u32* cmdbuf=getThreadCommandBuffer(); @@ -81,7 +81,7 @@ Result nfc_StartCommunication() return ret; } -Result nfc_StopCommunication() +Result NFC_StopCommunication(void) { Result ret=0; u32* cmdbuf=getThreadCommandBuffer(); @@ -95,7 +95,7 @@ Result nfc_StopCommunication() return ret; } -Result nfc_StartTagScanning(u16 unknown) +Result NFC_StartTagScanning(u16 unknown) { Result ret=0; u32* cmdbuf=getThreadCommandBuffer(); @@ -110,7 +110,7 @@ Result nfc_StartTagScanning(u16 unknown) return ret; } -Result nfc_StopTagScanning() +Result NFC_StopTagScanning(void) { Result ret=0; u32* cmdbuf=getThreadCommandBuffer(); @@ -124,7 +124,7 @@ Result nfc_StopTagScanning() return ret; } -Result nfc_LoadAmiiboData() +Result NFC_LoadAmiiboData(void) { Result ret=0; u32* cmdbuf=getThreadCommandBuffer(); @@ -138,7 +138,7 @@ Result nfc_LoadAmiiboData() return ret; } -Result nfc_ResetTagScanState() +Result NFC_ResetTagScanState(void) { Result ret=0; u32* cmdbuf=getThreadCommandBuffer(); @@ -152,7 +152,7 @@ Result nfc_ResetTagScanState() return ret; } -Result nfc_GetTagState(u8 *state) +Result NFC_GetTagState(u8 *state) { Result ret=0; u32* cmdbuf=getThreadCommandBuffer(); From c3b22e3922848bd795503f8983ff868bfd7baba2 Mon Sep 17 00:00:00 2001 From: Javi Date: Thu, 4 Feb 2016 17:20:40 +0100 Subject: [PATCH 09/15] Fix nfcInit error --- libctru/source/services/nfc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libctru/source/services/nfc.c b/libctru/source/services/nfc.c index cd3fa1d..ef6300c 100644 --- a/libctru/source/services/nfc.c +++ b/libctru/source/services/nfc.c @@ -18,7 +18,7 @@ Result nfcInit(void) ret = srvGetServiceHandle(&nfcHandle, "nfc:u"); if (R_SUCCEEDED(ret)) { - ret = nfc_Initialize(0x02); + ret = NFC_Initialize(0x02); if (R_FAILED(ret)) svcCloseHandle(nfcHandle); } if (R_FAILED(ret)) AtomicDecrement(&nfcRefCount); From e7a222ee901408b5787e9b24fba27e53d6ab0aa4 Mon Sep 17 00:00:00 2001 From: Ken Sanislo Date: Thu, 4 Feb 2016 10:15:01 -0800 Subject: [PATCH 10/15] new result code, HTTPC_RESULTCODE_NOTFOUND=0xd840a028 --- libctru/include/3ds/services/httpc.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libctru/include/3ds/services/httpc.h b/libctru/include/3ds/services/httpc.h index 8bc0765..c49069b 100644 --- a/libctru/include/3ds/services/httpc.h +++ b/libctru/include/3ds/services/httpc.h @@ -28,6 +28,9 @@ typedef enum { /// Result code returned when a download is pending. #define HTTPC_RESULTCODE_DOWNLOADPENDING 0xd840a02b +// Result code returned when asked about a non-existing header +#define HTTPC_RESULTCODE_NOTFOUND 0xd840a028 + /// Initializes HTTPC. Result httpcInit(void); From 4f1c3e53e225fff50fcd85e58642f0cedb56568d Mon Sep 17 00:00:00 2001 From: Ken Sanislo Date: Thu, 4 Feb 2016 10:28:40 -0800 Subject: [PATCH 11/15] Clean up --- libctru/source/services/httpc.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/libctru/source/services/httpc.c b/libctru/source/services/httpc.c index 1750fd0..ec979fa 100644 --- a/libctru/source/services/httpc.c +++ b/libctru/source/services/httpc.c @@ -1,8 +1,3 @@ -//#include -//#include -//#include -//#include <3ds.h> - #include #include <3ds/types.h> #include <3ds/result.h> @@ -169,7 +164,7 @@ Result HTTPC_CreateContext(Handle handle, HTTPC_RequestMethod method, char* url, cmdbuf[0]=IPC_MakeHeader(0x2,2,2); // 0x20082 cmdbuf[1]=l; cmdbuf[2]=method; - cmdbuf[3]=IPC_Desc_Buffer(l,IPC_BUFFER_R); + cmdbuf[3]=IPC_Desc_Buffer(l,IPC_BUFFER_R); cmdbuf[4]=(u32)url; Result ret=0; From 83dbd0dae9d97e02b74d2c0e1c8a8f62be200b16 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Wed, 3 Feb 2016 00:25:54 -0800 Subject: [PATCH 12/15] Fix crash when getting or setting struct params in CAM:U --- libctru/source/services/cam.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libctru/source/services/cam.c b/libctru/source/services/cam.c index 6425cda..996d544 100644 --- a/libctru/source/services/cam.c +++ b/libctru/source/services/cam.c @@ -6,6 +6,7 @@ #include <3ds/types.h> #include <3ds/result.h> #include <3ds/ipc.h> +#include Handle camHandle; static int camRefCount; @@ -534,7 +535,7 @@ Result CAMU_GetStereoCameraCalibrationData(CAMU_StereoCameraCalibrationData* dat cmdbuf[0] = IPC_MakeHeader(0x2B,0,0); // 0x2B0000 if (R_FAILED(ret = svcSendSyncRequest(camHandle))) return ret; - *data = *(CAMU_StereoCameraCalibrationData*) cmdbuf[2]; + memcpy(data, &cmdbuf[2], sizeof(*data)); return cmdbuf[1]; } @@ -542,7 +543,7 @@ Result CAMU_SetStereoCameraCalibrationData(CAMU_StereoCameraCalibrationData data Result ret = 0; u32* cmdbuf = getThreadCommandBuffer(); cmdbuf[0] = IPC_MakeHeader(0x2C,16,0); // 0x2C0400 - *(CAMU_StereoCameraCalibrationData*) cmdbuf[1] = data; + memcpy(&cmdbuf[1], &data, sizeof(data)); if (R_FAILED(ret = svcSendSyncRequest(camHandle))) return ret; return cmdbuf[1]; @@ -600,7 +601,7 @@ Result CAMU_SetImageQualityCalibrationData(CAMU_ImageQualityCalibrationData data Result ret = 0; u32* cmdbuf = getThreadCommandBuffer(); cmdbuf[0] = IPC_MakeHeader(0x31,6,0); // 0x310180 - *(CAMU_ImageQualityCalibrationData*) cmdbuf[1] = data; + memcpy(&cmdbuf[1], &data, sizeof(data)); if (R_FAILED(ret = svcSendSyncRequest(camHandle))) return ret; return cmdbuf[1]; @@ -612,7 +613,7 @@ Result CAMU_GetImageQualityCalibrationData(CAMU_ImageQualityCalibrationData* dat cmdbuf[0] = IPC_MakeHeader(0x32,0,0); // 0x320000 if (R_FAILED(ret = svcSendSyncRequest(camHandle))) return ret; - *data = *(CAMU_ImageQualityCalibrationData*) cmdbuf[2]; + memcpy(data, &cmdbuf[2], sizeof(*data)); return cmdbuf[1]; } @@ -620,7 +621,7 @@ Result CAMU_SetPackageParameterWithoutContext(CAMU_PackageParameterCameraSelect Result ret = 0; u32* cmdbuf = getThreadCommandBuffer(); cmdbuf[0] = IPC_MakeHeader(0x33,11,0); // 0x3302C0 - *(CAMU_PackageParameterCameraSelect*) cmdbuf[1] = param; + memcpy(&cmdbuf[1], ¶m, sizeof(param)); if (R_FAILED(ret = svcSendSyncRequest(camHandle))) return ret; return cmdbuf[1]; @@ -630,7 +631,7 @@ Result CAMU_SetPackageParameterWithContext(CAMU_PackageParameterContext param) { Result ret = 0; u32* cmdbuf = getThreadCommandBuffer(); cmdbuf[0] = IPC_MakeHeader(0x34,5,0); // 0x340140 - *(CAMU_PackageParameterContext*) cmdbuf[1] = param; + memcpy(&cmdbuf[1], ¶m, sizeof(param)); if (R_FAILED(ret = svcSendSyncRequest(camHandle))) return ret; return cmdbuf[1]; @@ -640,7 +641,7 @@ Result CAMU_SetPackageParameterWithContextDetail(CAMU_PackageParameterContextDet Result ret = 0; u32* cmdbuf = getThreadCommandBuffer(); cmdbuf[0] = IPC_MakeHeader(0x35,7,0); // 0x3501C0 - *(CAMU_PackageParameterContextDetail*) cmdbuf[1] = param; + memcpy(&cmdbuf[1], ¶m, sizeof(param)); if (R_FAILED(ret = svcSendSyncRequest(camHandle))) return ret; return cmdbuf[1]; From 0201c696f9838b3f8957cbe828a24476702fc615 Mon Sep 17 00:00:00 2001 From: Javi Date: Thu, 4 Feb 2016 12:51:06 +0100 Subject: [PATCH 13/15] Add basic NFC service support --- libctru/include/3ds/services/nfc.h | 79 ++++++++++++++ libctru/source/services/nfc.c | 169 +++++++++++++++++++++++++++++ 2 files changed, 248 insertions(+) create mode 100644 libctru/include/3ds/services/nfc.h create mode 100644 libctru/source/services/nfc.c diff --git a/libctru/include/3ds/services/nfc.h b/libctru/include/3ds/services/nfc.h new file mode 100644 index 0000000..7c848e1 --- /dev/null +++ b/libctru/include/3ds/services/nfc.h @@ -0,0 +1,79 @@ +/** + * @file nfc.h + * @brief NFC service. + */ +#pragma once + +/** + * @brief Initializes NFC. + */ +Result nfcInit(void); + +/** + * @brief Shuts down NFC. + */ +void nfcExit(void); + +/** + * @brief Gets the NFC service handle. + * @return The NFC service handle. + */ +Handle nfcGetSessionHandle(void); + +/** + * @brief Initialize NFC module. + * @param type Unknown, can be either value 0x1 or 0x2. + */ +Result nfc_Initialize(u8 type); + +/** + * @brief Shutdown NFC module. + * @param type Unknown. + */ +Result nfc_Shutdown(u8 type); + +/** + * @brief O3DS starts communication with the O3DS NFC hardware. N3DS just checks state for this command. + */ +Result nfc_StartCommunication(); + +/** + * @brief O3DS stops communication with the O3DS NFC hardware. N3DS just uses code used internally by NFC:StopTagScanning for this. + */ +Result nfc_StopCommunication(); + +/** + * @brief Starts scanning for NFC tags. + * @param unknown Unknown. + */ +Result nfc_StartTagScanning(u16 unknown); + +/** + * @brief Stops scanning for NFC tags. + */ +Result nfc_StopTagScanning(); + +/** + * @brief Read Amiibo NFC data and load in memory. + */ +Result nfc_LoadAmiiboData(); + +/** + * @brief If the tagstate is valid, it then sets the current tagstate to 3. + */ +Result nfc_ResetTagScanState(); + +/** + * @brief Returns the current NFC tag state. + * @param state Pointer to write NFC tag state. + * + * Tag state values: + * - 0: NFC:Initialize was not used yet. + * - 1: Not currently scanning for NFC tags. Set by NFC:StopTagScanning and NFC:Initialize, when successful. + * - 2: Currently scanning for NFC tags. Set by NFC:StartTagScanning when successful. + * - 3: NFC tag is in range. The state automatically changes to this when the state was previous value 3, without using any NFC service commands. + * - 4: NFC tag is now out of range, where the NFC tag was previously in range. This occurs automatically without using any NFC service commands. Once this state is entered, it won't automatically change to anything else when the tag is moved in range again. Hence, if you want to keep doing tag scanning after this, you must stop+start scanning. + * - 5: NFC tag data was successfully loaded. This is set by NFC:LoadAmiiboData when successful. + */ +Result nfc_GetTagState(u8 *state); + diff --git a/libctru/source/services/nfc.c b/libctru/source/services/nfc.c new file mode 100644 index 0000000..317ef5b --- /dev/null +++ b/libctru/source/services/nfc.c @@ -0,0 +1,169 @@ +#include <3ds/types.h> +#include <3ds/result.h> +#include <3ds/svc.h> +#include <3ds/srv.h> +#include <3ds/synchronization.h> +#include <3ds/services/nfc.h> +#include <3ds/ipc.h> + +static Handle nfcHandle; +static int nfcRefCount; + +Result nfcInit(void) +{ + Result ret=0; + + if (AtomicPostIncrement(&nfcRefCount)) return 0; + + ret = srvGetServiceHandle(&nfcHandle, "nfc:u"); + if (R_SUCCEEDED(ret)) + { + ret = nfc_Initialize(0x02); + if (R_FAILED(ret)) svcCloseHandle(nfcHandle); + } + if (R_FAILED(ret)) AtomicDecrement(&nfcRefCount); + + return ret; +} + +void nfcExit(void) +{ + if (AtomicDecrement(&nfcRefCount)) return; + svcCloseHandle(nfcHandle); +} + +Handle nfcGetSessionHandle(void) +{ + return nfcHandle; +} + +Result nfc_Initialize(u8 type) +{ + Result ret=0; + u32* cmdbuf=getThreadCommandBuffer(); + + cmdbuf[0]=IPC_MakeHeader(0x1,1,0); // 0x10040 + cmdbuf[1]=type; + + if(R_FAILED(ret = svcSendSyncRequest(nfcHandle)))return ret; + + ret = (Result)cmdbuf[1]; + + return ret; +} + +Result nfc_Shutdown(u8 type) +{ + Result ret=0; + u32* cmdbuf=getThreadCommandBuffer(); + + cmdbuf[0]=IPC_MakeHeader(0x2,1,0); // 0x20040 + cmdbuf[1]=type; + + if(R_FAILED(ret = svcSendSyncRequest(nfcHandle)))return ret; + + ret = (Result)cmdbuf[1]; + + return ret; +} + +Result nfc_StartCommunication() +{ + Result ret=0; + u32* cmdbuf=getThreadCommandBuffer(); + + cmdbuf[0]=IPC_MakeHeader(0x3,0,0); // 0x30000 + + if(R_FAILED(ret = svcSendSyncRequest(nfcHandle)))return ret; + + ret = (Result)cmdbuf[1]; + + return ret; +} + +Result nfc_StopCommunication() +{ + Result ret=0; + u32* cmdbuf=getThreadCommandBuffer(); + + cmdbuf[0]=IPC_MakeHeader(0x4,0,0); // 0x40000 + + if(R_FAILED(ret = svcSendSyncRequest(nfcHandle)))return ret; + + ret = (Result)cmdbuf[1]; + + return ret; +} + +Result nfc_StartTagScanning(u16 unknown) +{ + Result ret=0; + u32* cmdbuf=getThreadCommandBuffer(); + + cmdbuf[0]=IPC_MakeHeader(0x5,1,0); // 0x50040 + cmdbuf[1]=unknown; + + if(R_FAILED(ret = svcSendSyncRequest(nfcHandle)))return ret; + + ret = (Result)cmdbuf[1]; + + return ret; +} + +Result nfc_StopTagScanning() +{ + Result ret=0; + u32* cmdbuf=getThreadCommandBuffer(); + + cmdbuf[0]=IPC_MakeHeader(0x6,0,0); // 0x60000 + + if(R_FAILED(ret = svcSendSyncRequest(nfcHandle)))return ret; + + ret = (Result)cmdbuf[1]; + + return ret; +} + +Result nfc_LoadAmiiboData() +{ + Result ret=0; + u32* cmdbuf=getThreadCommandBuffer(); + + cmdbuf[0]=IPC_MakeHeader(0x7,0,0); // 0x70000 + + if(R_FAILED(ret = svcSendSyncRequest(nfcHandle)))return ret; + + ret = (Result)cmdbuf[1]; + + return ret; +} + +Result nfc_ResetTagScanState() +{ + Result ret=0; + u32* cmdbuf=getThreadCommandBuffer(); + + cmdbuf[0]=IPC_MakeHeader(0x8,0,0); // 0x80000 + + if(R_FAILED(ret = svcSendSyncRequest(nfcHandle)))return ret; + + ret = (Result)cmdbuf[1]; + + return ret; +} + +Result nfc_GetTagState(u8 *state) +{ + Result ret=0; + u32* cmdbuf=getThreadCommandBuffer(); + + cmdbuf[0]=IPC_MakeHeader(0xD,0,0); // 0xD0000 + + if(R_FAILED(ret = svcSendSyncRequest(nfcHandle)))return ret; + + ret = (Result)cmdbuf[1]; + *state = cmdbuf[2]; + + return ret; +} + From 4ebf6c378136d3c2ba2032c3f9272e5512ed0f49 Mon Sep 17 00:00:00 2001 From: Javi Date: Thu, 4 Feb 2016 17:18:26 +0100 Subject: [PATCH 14/15] Fixed prefix and parameters declaration --- libctru/include/3ds/services/nfc.h | 18 +++++++++--------- libctru/source/services/nfc.c | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/libctru/include/3ds/services/nfc.h b/libctru/include/3ds/services/nfc.h index 7c848e1..8f78d62 100644 --- a/libctru/include/3ds/services/nfc.h +++ b/libctru/include/3ds/services/nfc.h @@ -24,44 +24,44 @@ Handle nfcGetSessionHandle(void); * @brief Initialize NFC module. * @param type Unknown, can be either value 0x1 or 0x2. */ -Result nfc_Initialize(u8 type); +Result NFC_Initialize(u8 type); /** * @brief Shutdown NFC module. * @param type Unknown. */ -Result nfc_Shutdown(u8 type); +Result NFC_Shutdown(u8 type); /** * @brief O3DS starts communication with the O3DS NFC hardware. N3DS just checks state for this command. */ -Result nfc_StartCommunication(); +Result NFC_StartCommunication(void); /** * @brief O3DS stops communication with the O3DS NFC hardware. N3DS just uses code used internally by NFC:StopTagScanning for this. */ -Result nfc_StopCommunication(); +Result NFC_StopCommunication(void); /** * @brief Starts scanning for NFC tags. * @param unknown Unknown. */ -Result nfc_StartTagScanning(u16 unknown); +Result NFC_StartTagScanning(u16 unknown); /** * @brief Stops scanning for NFC tags. */ -Result nfc_StopTagScanning(); +Result NFC_StopTagScanning(void); /** * @brief Read Amiibo NFC data and load in memory. */ -Result nfc_LoadAmiiboData(); +Result NFC_LoadAmiiboData(void); /** * @brief If the tagstate is valid, it then sets the current tagstate to 3. */ -Result nfc_ResetTagScanState(); +Result NFC_ResetTagScanState(void); /** * @brief Returns the current NFC tag state. @@ -75,5 +75,5 @@ Result nfc_ResetTagScanState(); * - 4: NFC tag is now out of range, where the NFC tag was previously in range. This occurs automatically without using any NFC service commands. Once this state is entered, it won't automatically change to anything else when the tag is moved in range again. Hence, if you want to keep doing tag scanning after this, you must stop+start scanning. * - 5: NFC tag data was successfully loaded. This is set by NFC:LoadAmiiboData when successful. */ -Result nfc_GetTagState(u8 *state); +Result NFC_GetTagState(u8 *state); diff --git a/libctru/source/services/nfc.c b/libctru/source/services/nfc.c index 317ef5b..cd3fa1d 100644 --- a/libctru/source/services/nfc.c +++ b/libctru/source/services/nfc.c @@ -37,7 +37,7 @@ Handle nfcGetSessionHandle(void) return nfcHandle; } -Result nfc_Initialize(u8 type) +Result NFC_Initialize(u8 type) { Result ret=0; u32* cmdbuf=getThreadCommandBuffer(); @@ -52,7 +52,7 @@ Result nfc_Initialize(u8 type) return ret; } -Result nfc_Shutdown(u8 type) +Result NFC_Shutdown(u8 type) { Result ret=0; u32* cmdbuf=getThreadCommandBuffer(); @@ -67,7 +67,7 @@ Result nfc_Shutdown(u8 type) return ret; } -Result nfc_StartCommunication() +Result NFC_StartCommunication(void) { Result ret=0; u32* cmdbuf=getThreadCommandBuffer(); @@ -81,7 +81,7 @@ Result nfc_StartCommunication() return ret; } -Result nfc_StopCommunication() +Result NFC_StopCommunication(void) { Result ret=0; u32* cmdbuf=getThreadCommandBuffer(); @@ -95,7 +95,7 @@ Result nfc_StopCommunication() return ret; } -Result nfc_StartTagScanning(u16 unknown) +Result NFC_StartTagScanning(u16 unknown) { Result ret=0; u32* cmdbuf=getThreadCommandBuffer(); @@ -110,7 +110,7 @@ Result nfc_StartTagScanning(u16 unknown) return ret; } -Result nfc_StopTagScanning() +Result NFC_StopTagScanning(void) { Result ret=0; u32* cmdbuf=getThreadCommandBuffer(); @@ -124,7 +124,7 @@ Result nfc_StopTagScanning() return ret; } -Result nfc_LoadAmiiboData() +Result NFC_LoadAmiiboData(void) { Result ret=0; u32* cmdbuf=getThreadCommandBuffer(); @@ -138,7 +138,7 @@ Result nfc_LoadAmiiboData() return ret; } -Result nfc_ResetTagScanState() +Result NFC_ResetTagScanState(void) { Result ret=0; u32* cmdbuf=getThreadCommandBuffer(); @@ -152,7 +152,7 @@ Result nfc_ResetTagScanState() return ret; } -Result nfc_GetTagState(u8 *state) +Result NFC_GetTagState(u8 *state) { Result ret=0; u32* cmdbuf=getThreadCommandBuffer(); From 850a34ab3ec55b62e0091d5b3687a8ec03fc0252 Mon Sep 17 00:00:00 2001 From: Javi Date: Thu, 4 Feb 2016 17:20:40 +0100 Subject: [PATCH 15/15] Fix nfcInit error --- libctru/source/services/nfc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libctru/source/services/nfc.c b/libctru/source/services/nfc.c index cd3fa1d..ef6300c 100644 --- a/libctru/source/services/nfc.c +++ b/libctru/source/services/nfc.c @@ -18,7 +18,7 @@ Result nfcInit(void) ret = srvGetServiceHandle(&nfcHandle, "nfc:u"); if (R_SUCCEEDED(ret)) { - ret = nfc_Initialize(0x02); + ret = NFC_Initialize(0x02); if (R_FAILED(ret)) svcCloseHandle(nfcHandle); } if (R_FAILED(ret)) AtomicDecrement(&nfcRefCount);