New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | |
| | | namespace HDL_ON.Stan |
| | | { |
| | | /// <summary> |
| | | /// WiFi的逻辑 |
| | | /// </summary> |
| | | public class HdlWifiLogic |
| | | { |
| | | #region ■ 变量声明___________________________ |
| | | |
| | | /// <summary> |
| | | /// WiFi的逻辑 |
| | | /// </summary> |
| | | private static HdlWifiLogic m_Current = null; |
| | | /// <summary> |
| | | /// WiFi的逻辑 |
| | | /// </summary> |
| | | public static HdlWifiLogic Current |
| | | { |
| | | get |
| | | { |
| | | if (m_Current == null) |
| | | { |
| | | m_Current = new HdlWifiLogic(); |
| | | } |
| | | return m_Current; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 当前wifi的SSID,也叫Wifi的名字(取不到时,会返回null) |
| | | /// </summary> |
| | | public string SSID |
| | | { |
| | | get |
| | | { |
| | | #if __IOS__ |
| | | string ssiD = Shared.WiimuUPnP.SSID; |
| | | if (string.IsNullOrEmpty(ssiD) == false && ssiD.StartsWith("\"") && ssiD.EndsWith("\"")) |
| | | { |
| | | ssiD = ssiD.Substring(1, ssiD.Length - 2); |
| | | } |
| | | return ssiD; |
| | | #endif |
| | | #if __Android__ |
| | | string ssiD = null; |
| | | HdlThreadLogic.Current.RunThread(() => |
| | | { |
| | | Shared.Net.NetWiFi.GetWIFISSID((strId) => |
| | | { |
| | | ssiD = strId; |
| | | }); |
| | | }, ShowErrorMode.NO); |
| | | int count = 0; |
| | | while (ssiD == null) |
| | | { |
| | | System.Threading.Thread.Sleep(50); |
| | | count++; |
| | | if (count == 20) |
| | | { |
| | | //1秒超时 |
| | | return null; |
| | | } |
| | | } |
| | | if (string.IsNullOrEmpty(ssiD) == false && ssiD.StartsWith("\"") && ssiD.EndsWith("\"")) |
| | | { |
| | | ssiD = ssiD.Substring(1, ssiD.Length - 2); |
| | | } |
| | | return ssiD; |
| | | #endif |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 一般方法___________________________ |
| | | |
| | | /// <summary> |
| | | /// 打开手机wifi设置界面 |
| | | /// </summary> |
| | | public void OpenAppWifiSettion() |
| | | { |
| | | if (Shared.Application.DeviceType == Shared.Device.Android) |
| | | { |
| | | ///打开WI-IF界面 |
| | | Shared.CommonClass.OpenAction("android.settings.WIFI_SETTINGS"); |
| | | } |
| | | else |
| | | { |
| | | Shared.CommonClass.OpenAction("App-Prefs:root=WIFI"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |