Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions System.Device.Wifi/WifiAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ private WifiAvailableNetwork[] ParseNativeReports(byte[] nativeReport)

byte[] rawSsid = new byte[33];
Array.Copy(nativeReport, bytePos, rawSsid, 0, 33);

int ssidLength = Array.IndexOf(rawSsid, (byte)0);
if (ssidLength < 0)
if (ssidLength < 0)
{
ssidLength = 33;
}

WifiNetworks[index].Ssid = Encoding.UTF8.GetString(rawSsid, 0, ssidLength);
bytePos += 33;

Expand Down Expand Up @@ -191,6 +191,26 @@ public static WifiAdapter[] FindAllAdapters()
return adapters;
}

/// <summary>
/// Sets the device name advertised by this Wi-Fi adapter when connecting to a network.
/// </summary>
/// <param name="deviceName">The device Name to assign to the adapter.</param>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// <param name="deviceName">The device Name to assign to the adapter.</param>
/// <param name="deviceName">The device name to assign to this adapter.</param>

/// <exception cref="ArgumentException">If <paramref name="deviceName"/> is null or empty or the length more than 32 characters</exception>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// <exception cref="ArgumentException">If <paramref name="deviceName"/> is null or empty or the length more than 32 characters</exception>
/// <exception cref="ArgumentException">If <paramref name="deviceName"/> is <see langword="null"/>, empty or the length over 32 characters.</exception>

/// <remarks>
/// The deviceName is sent to the access point during connection and may appear in the router’s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The deviceName is sent to the access point during connection and may appear in the router’s
/// The device name is sent to the access point during connection and may appear in the router’s

/// client list or DHCP lease table.
/// This method must be called before initiating a connection to take effect.
/// </remarks>
public void SetDeviceName(string deviceName)
{
if (string.IsNullOrEmpty(deviceName) || deviceName.Length > 32)
{
throw new ArgumentException();
}

NativeSetDeviceName(deviceName);
}

/// <summary>
/// Directs this adapter to initiate an asynchronous network scan.
/// </summary>
Expand Down Expand Up @@ -276,6 +296,9 @@ public void Dispose()
[MethodImpl(MethodImplOptions.InternalCall)]
private extern byte[] GetNativeScanReport();

[MethodImpl(MethodImplOptions.InternalCall)]
private extern void NativeSetDeviceName(string deviceName);

#endregion

}
Expand Down