2017-01-03 6 views
2

windows IOT 코어 장치 용 유니버설 플랫폼에서 wi-fi을 직접 구현하고 있지만 프로젝트에 따라 장치에 연결할 모니터가 없다는 문제점이 있습니다.Wifi in dwdp

그래서 서버 쪽에서 하드 코딩 된 핀을 만들거나 페어링을 위해 핀을 사용하지 않는 장치를 페어링 할 수 있습니까? 한마디로

https://developer.microsoft.com/en-us/windows/iot/samples/wificonnector

(튜토리얼에서 촬영 및 편집) :

답변

2

예이 가능하다는 Windows.Devices.WiFi.WiFiAdapter API는이 튜토리얼을 살펴 사용 당신이 무선 랜에 연결하기 위해 다음과 같은 코드를 사용할 수 있습니다 그 후

<DeviceCapability Name="wifiControl" /> 

: 당신이 당신의 appx 매니페스트에 올바른 장치 기능을 추가해야합니다 ;

enum WifiConnectResult 
{ 
    WifiAccessDenied, 
    NoWifiDevice, 
    Success, 
    CouldNotConnect, 
    SsidNotFound, 
} 

private async Task<WifiConnectResult> ConnectWifi(string ssid, string password) 
{ 
    if (password == null) 
     password = ""; 

    var access = await WiFiAdapter.RequestAccessAsync(); 
    if (access != WiFiAccessStatus.Allowed) 
    { 
     return WifiConnectResult.WifiAccessDenied; 
    } 
    else 
    { 
     var allAdapters = await WiFiAdapter.FindAllAdaptersAsync(); 
     if (allAdapters.Count >= 1) 
     { 
      var firstAdapter = allAdapters[0]; 
      await firstAdapter.ScanAsync(); 

      var network = firstAdapter.NetworkReport.AvailableNetworks.SingleOrDefault(n => n.Ssid == ssid); 
      if (network != null) 
      { 
       WiFiConnectionResult wifiConnectionResult; 
       if (network.SecuritySettings.NetworkAuthenticationType == Windows.Networking.Connectivity.NetworkAuthenticationType.Open80211) 
       { 
        wifiConnectionResult = await firstAdapter.ConnectAsync(network, WiFiReconnectionKind.Automatic); 
       } 
       else 
       { 
        // Only the password potion of the credential need to be supplied 
        var credential = new Windows.Security.Credentials.PasswordCredential(); 
        credential.Password = password; 

        wifiConnectionResult = await firstAdapter.ConnectAsync(network, WiFiReconnectionKind.Automatic, credential); 
       } 

       if (wifiConnectionResult.ConnectionStatus == WiFiConnectionStatus.Success) 
       { 
        return WifiConnectResult.Success; 
       } 
       else 
       { 
        return WifiConnectResult.CouldNotConnect; 
       } 
      } 
      else 
      { 
       return WifiConnectResult.SsidNotFound; 
      } 
     } 
     else 
     { 
      return WifiConnectResult.NoWifiDevice; 
     } 
    } 
} 
0

가 다른 라이브러리 PeerFinder이 와이파이 다이렉트 UWP 애플리케이션에 사용할 수 있습니다. 그것은 매우 편리하고 신뢰할 수 있습니다. 그것은 광고 및 발견을 위해 wifi-direct를 사용합니다. 기본적으로 앱 ID로 피어를 검색하고 동일한 앱을 실행하는 다른 피어와 연결됩니다.

+0

'PeerFinder'는 절대로 작동하지 않았으며 몇 년 동안 고장났습니다 ([here] (https://social.msdn.microsoft.com/Forums/vstudio/en-US/767cdb62-a991-4b6a 참조) -8d23-1ba4fa4067e5/uwp-winrt-peerfinderconnectsync-method-doesnt-work-cant-create-a-socket-connection? 포럼 = wpdevelop) 및 [여기] (https://stackoverflow.com/questions/14525065/wi- fi-direct-doesnt-connect-devices-WinRT)), 문제가 해결되었는지 압니까? 두 장치간에 WiFi-Direct 기능을 올바르게 사용 했습니까? – Sergio0694