Пример #1
0
    public void Start()
    {
        if (FAp == IntPtr.Zero)
        {
            FConnectedCb    = new DEVICE_EVENT(DeviceConnected);
            FDisconnectedCb = new DEVICE_EVENT(DeviceDisconnected);
            FStartedCb      = new AP_EVENT(ApStarted);
            FStoppedCb      = new AP_EVENT(ApStopped);

            FAp = CreateSoftAp(FStartedCb, FStoppedCb, FConnectedCb, FDisconnectedCb);
            if (FAp == IntPtr.Zero)
            {
                Cleanup();
                Debug.Log("Unable create WiFi Direct Soft AP");
            }
            else
            {
                Int32 Res = StartSoftAp(FAp, "btframework", "12345678");
                if (Res != 0)
                {
                    DestroySoftAp(FAp);
                    Cleanup();
                    Debug.Log("Failed to start WiFi Direct Soft AP: 0x" + Res.ToString("X8"));
                }
            }
        }
        else
        {
            Debug.Log("Already started");
        }
    }
Пример #2
0
 private void Cleanup()
 {
     FAp             = IntPtr.Zero;
     FConnectedCb    = null;
     FDisconnectedCb = null;
     FStartedCb      = null;
     FStoppedCb      = null;
 }
Пример #3
0
 private static extern IntPtr CreateSoftAp(
     [param: MarshalAs(UnmanagedType.FunctionPtr), In] AP_EVENT OnStarted,
     [param: MarshalAs(UnmanagedType.FunctionPtr), In] AP_EVENT OnStopped,
     [param: MarshalAs(UnmanagedType.FunctionPtr), In] DEVICE_EVENT OnConnected,
     [param: MarshalAs(UnmanagedType.FunctionPtr), In] DEVICE_EVENT OnDisconnected);