]> Chaos Git - corbenik/ctrulib.git/commitdiff
Fixed udsGetChannel() output. Implemented udsSetApplicationData() and udsGetApplicati...
authoryellows8 <yellows8@users.noreply.github.com>
Tue, 5 Apr 2016 20:57:16 +0000 (16:57 -0400)
committeryellows8 <yellows8@users.noreply.github.com>
Tue, 5 Apr 2016 20:57:16 +0000 (16:57 -0400)
libctru/include/3ds/services/uds.h
libctru/source/services/uds.c

index a34e6bc86bfe10b35c5eff36964c1332a1ee64d3..d7cb83b6b987b4320f7ffd4d7b58399dcf70becc 100644 (file)
@@ -169,6 +169,21 @@ void udsGenerateDefaultNetworkStruct(udsNetworkStruct *network, u32 wlancommID,
  */
 Result udsScanBeacons(u8 *outbuf, u32 maxsize, udsNetworkScanInfo **networks, u32 *total_networks, u32 wlancommID, u8 id8, u8 *host_macaddress);
 
+/**
+ * @brief This can be used by the host to set the appdata contained in the broadcasted beacons.
+ * @param buf Appdata buffer.
+ * @param size Size of the input appdata.
+ */
+Result udsSetApplicationData(u8 *buf, u32 size);
+
+/**
+ * @brief This can be used while on a network(host/client) to get the appdata from the current beacon.
+ * @param buf Appdata buffer.
+ * @param size Max size of the output buffer.
+ * @param actual_size If set, the actual size of the appdata written into the buffer is stored here.
+ */
+Result udsGetApplicationData(u8 *buf, u32 size, u32 *actual_size);
+
 /**
  * @brief Create a bind.
  * @param bindcontext The output bind context.
@@ -215,7 +230,7 @@ Result udsSendTo(u16 dst_NetworkNodeID, u8 input8, u8 flags, void* buf, size_t s
  * @brief Gets the wifi channel currently being used.
  * @param channel Output channel.
  */
-Result udsGetChannel(u32 *channel);
+Result udsGetChannel(u8 *channel);
 
 /**
  * @brief Starts hosting a new network.
index bce9bb4cf52f9e72d93807c277875ef133e1c2bf..253c5e8f34a942507a0cba8c4a7b338a000af04f 100644 (file)
@@ -262,7 +262,7 @@ Result udsCreateNetwork(udsNetworkStruct *network, void* passphrase, size_t pass
 Result udsConnectNetwork(udsNetworkStruct *network, void* passphrase, size_t passphrase_size, udsBindContext *context, u16 recv_NetworkNodeID, udsConnectionType connection_type)
 {
        Result ret=0;
-       printf("connecting...\n");
+       printf("connecting...\n");//Removing these prints caused connecting to fail.
        ret = udsipc_ConnectToNetwork(network, passphrase, passphrase_size, connection_type);
        if(R_FAILED(ret))return ret;
        printf("bind...\n");
@@ -614,6 +614,54 @@ static Result udsipc_RecvBeaconBroadcastData(u8 *outbuf, u32 maxsize, nwmScanInp
        return cmdbuf[1];
 }
 
+Result udsSetApplicationData(u8 *buf, u32 size)
+{
+       u32* cmdbuf=getThreadCommandBuffer();
+
+       cmdbuf[0]=IPC_MakeHeader(0x10,1,2); // 0x100042
+       cmdbuf[1]=size;
+       cmdbuf[2]=IPC_Desc_StaticBuffer(size, 4);
+       cmdbuf[3]=(u32)buf;
+
+       Result ret=0;
+       if(R_FAILED(ret=svcSendSyncRequest(__uds_servhandle)))return ret;
+
+       return cmdbuf[1];
+}
+
+Result udsGetApplicationData(u8 *buf, u32 size, u32 *actual_size)
+{
+       u32* cmdbuf=getThreadCommandBuffer();
+       u32 saved_threadstorage[2];
+
+       cmdbuf[0]=IPC_MakeHeader(0x11,1,0); // 0x110040
+       cmdbuf[1]=size;
+
+       u32 * staticbufs = getThreadStaticBuffers();
+       saved_threadstorage[0] = staticbufs[0];
+       saved_threadstorage[1] = staticbufs[1];
+
+       staticbufs[0] = IPC_Desc_StaticBuffer(size,0);
+       staticbufs[1] = (u32)buf;
+
+       Result ret=0;
+       ret=svcSendSyncRequest(__uds_servhandle);
+
+       staticbufs[0] = saved_threadstorage[0];
+       staticbufs[1] = saved_threadstorage[1];
+
+       if(R_FAILED(ret))return ret;
+
+       ret = cmdbuf[1];
+
+       if(R_SUCCEEDED(ret))
+       {
+               if(actual_size)*actual_size = cmdbuf[2];
+       }
+
+       return ret;
+}
+
 static Result udsipc_Bind(udsBindContext *bindcontext, u32 input0, u8 input1, u16 NetworkNodeID)//input0 and input1 are unknown.
 {
        u32* cmdbuf=getThreadCommandBuffer();
@@ -709,7 +757,7 @@ Result udsSendTo(u16 dst_NetworkNodeID, u8 input8, u8 flags, void* buf, size_t s
        return cmdbuf[1];
 }
 
-Result udsGetChannel(u32 *channel)
+Result udsGetChannel(u8 *channel)
 {
        u32* cmdbuf=getThreadCommandBuffer();