Added a new param to udsScanBeacons() for using ScanOnConnection internally.

This commit is contained in:
yellows8 2016-04-06 19:38:56 -04:00
parent bdb2835b62
commit 6f6926921e
2 changed files with 24 additions and 3 deletions

View File

@ -176,8 +176,9 @@ void udsGenerateDefaultNetworkStruct(udsNetworkStruct *network, u32 wlancommID,
* @param wlancommID Unique local-WLAN communications ID for each application. * @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 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. * @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. * @brief This can be used by the host to set the appdata contained in the broadcasted beacons.

View File

@ -35,6 +35,7 @@ static Result udsipc_ConnectToNetwork(udsNetworkStruct *network, void* passphras
static Result udsipc_SetProbeResponseParam(u32 oui, s8 data); 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_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_Bind(udsBindContext *bindcontext, u32 input0, u8 input1, u16 NetworkNodeID);
static Result udsipc_Unbind(udsBindContext *bindcontext); static Result udsipc_Unbind(udsBindContext *bindcontext);
@ -440,7 +441,7 @@ Result udsGetNodeInformation(u16 NetworkNodeID, udsNodeInfo *output)
return ret; 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; Result ret=0;
Handle event=0; Handle event=0;
@ -468,7 +469,8 @@ Result udsScanBeacons(u8 *outbuf, u32 maxsize, udsNetworkScanInfo **networks, u3
ret = svcCreateEvent(&event, 0); ret = svcCreateEvent(&event, 0);
if(R_FAILED(ret))return ret; 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); svcCloseHandle(event);
if(R_FAILED(ret))return ret; if(R_FAILED(ret))return ret;
@ -990,3 +992,21 @@ static Result udsipc_SetProbeResponseParam(u32 oui, s8 data)
return cmdbuf[1]; 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];
}