]> Chaos Git - corbenik/ctrulib.git/commitdiff
Added a new param to udsScanBeacons() for using ScanOnConnection internally.
authoryellows8 <yellows8@users.noreply.github.com>
Wed, 6 Apr 2016 23:38:56 +0000 (19:38 -0400)
committeryellows8 <yellows8@users.noreply.github.com>
Wed, 6 Apr 2016 23:38:56 +0000 (19:38 -0400)
libctru/include/3ds/services/uds.h
libctru/source/services/uds.c

index 371de37a99911839edbf3547eda4cde20648b1f4..e894310268c37d3a4d2cff951904bfb821203a5d 100644 (file)
@@ -176,8 +176,9 @@ void udsGenerateDefaultNetworkStruct(udsNetworkStruct *network, u32 wlancommID,
  * @param wlancommID Unique local-WLAN communications ID for each application.
  * @param id8 Additional ID that can be used by the application for different types of networks.
  * @param host_macaddress When set, this code will only return network info from the specified host MAC address.
+ * @connected When not connected to a network this *must* be false. When connected to a network this *must* be true.
  */
-Result udsScanBeacons(u8 *outbuf, u32 maxsize, udsNetworkScanInfo **networks, u32 *total_networks, u32 wlancommID, u8 id8, u8 *host_macaddress);
+Result udsScanBeacons(u8 *outbuf, u32 maxsize, udsNetworkScanInfo **networks, u32 *total_networks, u32 wlancommID, u8 id8, u8 *host_macaddress, bool connected);
 
 /**
  * @brief This can be used by the host to set the appdata contained in the broadcasted beacons.
index 3d760cad1161bba7de6627b396b6c7c97487b67d..1434f765fae99e9476a38138e2a773d6c0a52690 100644 (file)
@@ -35,6 +35,7 @@ static Result udsipc_ConnectToNetwork(udsNetworkStruct *network, void* passphras
 static Result udsipc_SetProbeResponseParam(u32 oui, s8 data);
 
 static Result udsipc_RecvBeaconBroadcastData(u8 *outbuf, u32 maxsize, nwmScanInputStruct *scaninput, u32 wlancommID, u8 id8, Handle event);
+static Result udsipc_ScanOnConnection(u8 *outbuf, u32 maxsize, nwmScanInputStruct *scaninput, u32 wlancommID, u8 id8);
 
 static Result udsipc_Bind(udsBindContext *bindcontext, u32 input0, u8 input1, u16 NetworkNodeID);
 static Result udsipc_Unbind(udsBindContext *bindcontext);
@@ -440,7 +441,7 @@ Result udsGetNodeInformation(u16 NetworkNodeID, udsNodeInfo *output)
        return ret;
 }
 
-Result udsScanBeacons(u8 *outbuf, u32 maxsize, udsNetworkScanInfo **networks, u32 *total_networks, u32 wlancommID, u8 id8, u8 *host_macaddress)
+Result udsScanBeacons(u8 *outbuf, u32 maxsize, udsNetworkScanInfo **networks, u32 *total_networks, u32 wlancommID, u8 id8, u8 *host_macaddress, bool connected)
 {
        Result ret=0;
        Handle event=0;
@@ -468,7 +469,8 @@ Result udsScanBeacons(u8 *outbuf, u32 maxsize, udsNetworkScanInfo **networks, u3
        ret = svcCreateEvent(&event, 0);
        if(R_FAILED(ret))return ret;
 
-       ret = udsipc_RecvBeaconBroadcastData(outbuf, maxsize, &scaninput, wlancommID, id8, event);
+       if(!connected)ret = udsipc_RecvBeaconBroadcastData(outbuf, maxsize, &scaninput, wlancommID, id8, event);
+       if(connected)ret = udsipc_ScanOnConnection(outbuf, maxsize, &scaninput, wlancommID, id8);
        svcCloseHandle(event);
        if(R_FAILED(ret))return ret;
 
@@ -990,3 +992,21 @@ static Result udsipc_SetProbeResponseParam(u32 oui, s8 data)
        return cmdbuf[1];
 }
 
+static Result udsipc_ScanOnConnection(u8 *outbuf, u32 maxsize, nwmScanInputStruct *scaninput, u32 wlancommID, u8 id8)
+{
+       u32* cmdbuf=getThreadCommandBuffer();
+
+       cmdbuf[0]=IPC_MakeHeader(0x22,16,2); // 0x220402
+       cmdbuf[1]=maxsize;
+       memcpy(&cmdbuf[2], scaninput, sizeof(nwmScanInputStruct));
+       cmdbuf[15]=wlancommID;
+       cmdbuf[16]=id8;
+       cmdbuf[17]=IPC_Desc_Buffer(maxsize, IPC_BUFFER_W);
+       cmdbuf[18]=(u32)outbuf;
+
+       Result ret=0;
+       if(R_FAILED(ret=svcSendSyncRequest(__uds_servhandle)))return ret;
+
+       return cmdbuf[1];
+}
+