Пример #1
0
        private void OnNotificationReceived(object sender, WLAN_NOTIFICATION_DATA e)
        {
            Debug.WriteLine($"NotificationReceived: {(WLAN_NOTIFICATION_ACM)e.NotificationCode}");

            switch ((WLAN_NOTIFICATION_ACM)e.NotificationCode)
            {
            case WLAN_NOTIFICATION_ACM.wlan_notification_acm_scan_list_refresh:
                NetworkRefreshed?.Invoke(this, EventArgs.Empty);
                break;

            case WLAN_NOTIFICATION_ACM.wlan_notification_acm_network_available:
            case WLAN_NOTIFICATION_ACM.wlan_notification_acm_network_not_available:
            case WLAN_NOTIFICATION_ACM.wlan_notification_acm_start:
            case WLAN_NOTIFICATION_ACM.wlan_notification_acm_end:
                AvailabilityChanged?.Invoke(this, EventArgs.Empty);
                break;

            case WLAN_NOTIFICATION_ACM.wlan_notification_acm_interface_arrival:
            case WLAN_NOTIFICATION_ACM.wlan_notification_acm_interface_removal:
                InterfaceChanged?.Invoke(this, EventArgs.Empty);
                break;

            case WLAN_NOTIFICATION_ACM.wlan_notification_acm_connection_complete:
            case WLAN_NOTIFICATION_ACM.wlan_notification_acm_disconnected:
                ConnectionChanged?.Invoke(this, EventArgs.Empty);
                break;

            case WLAN_NOTIFICATION_ACM.wlan_notification_acm_profile_change:
            case WLAN_NOTIFICATION_ACM.wlan_notification_acm_profile_name_change:
                ProfileChanged?.Invoke(this, EventArgs.Empty);
                break;
            }
        }
Пример #2
0
        private void OnNotificationReceived(WLAN_NOTIFICATION_DATA e)
        {
            switch (e.NotificationCode)
            {
            case WLAN_NOTIFICATION_ACM.wlan_notification_acm_connection_complete:
            {
                var data = Marshal.PtrToStructure <WLAN_CONNECTION_NOTIFICATION_DATA>(e.pData);
                Connected?.Invoke(this, new ConnectionEventArgs(data.dot11Ssid.ToString()));
            }
            break;

            case WLAN_NOTIFICATION_ACM.wlan_notification_acm_disconnected:
            {
                var data = Marshal.PtrToStructure <WLAN_CONNECTION_NOTIFICATION_DATA>(e.pData);
                Disconnected?.Invoke(this, new ConnectionEventArgs(data.dot11Ssid.ToString()));
            }
            break;
            }
        }
Пример #3
0
        protected void OnNotification(ref WLAN_NOTIFICATION_DATA notifData, IntPtr context)
        {
            switch (notifData.notificationCode)
            {
            case (int)WLAN_HOSTED_NETWORK_NOTIFICATION_CODE.wlan_hosted_network_state_change:

                if (notifData.dataSize > 0 && notifData.dataPtr != IntPtr.Zero)
                {
                    WLAN_HOSTED_NETWORK_STATE_CHANGE pStateChange = (WLAN_HOSTED_NETWORK_STATE_CHANGE)Marshal.PtrToStructure(notifData.dataPtr, typeof(WLAN_HOSTED_NETWORK_STATE_CHANGE));

                    switch (pStateChange.NewState)
                    {
                    case WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_active:
                        onHostedNetworkStarted();
                        break;

                    case WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_idle:
                        if (pStateChange.OldState == WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_active)
                        {
                            OnHostedNetworkStopped();
                        }
                        else
                        {
                            OnHostedNetworkAvailable();
                        }
                        break;

                    case WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_unavailable:
                        if (pStateChange.OldState == WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_active)
                        {
                            OnHostedNetworkStopped();
                        }
                        OnHostedNetworkAvailable();
                        break;
                    }
                }

                break;

            case (int)WLAN_HOSTED_NETWORK_NOTIFICATION_CODE.wlan_hosted_network_peer_state_change:

                if (notifData.dataSize > 0 && notifData.dataPtr != IntPtr.Zero)
                {
                    WLAN_HOSTED_NETWORK_DATA_PEER_STATE_CHANGE pPeerStateChange = (WLAN_HOSTED_NETWORK_DATA_PEER_STATE_CHANGE)Marshal.PtrToStructure(notifData.dataPtr, typeof(WLAN_HOSTED_NETWORK_DATA_PEER_STATE_CHANGE));

                    if (pPeerStateChange.NewState.PeerAuthState == WLAN_HOSTED_NETWORK_PEER_AUTH_STATE.wlan_hosted_network_peer_state_authenticated)
                    {
                        // Station joined the hosted network
                        OnStationJoin(pPeerStateChange.NewState);
                    }
                    else if (pPeerStateChange.NewState.PeerAuthState == WLAN_HOSTED_NETWORK_PEER_AUTH_STATE.wlan_hosted_network_peer_state_invalid)
                    {
                        // Station left the hosted network
                        OnStationLeave(pPeerStateChange.NewState);
                    }
                    else
                    {
                        // Authentication state changed
                        OnStationStateChange(pPeerStateChange.NewState);
                    }
                }

                break;

            case (int)WLAN_HOSTED_NETWORK_NOTIFICATION_CODE.wlan_hosted_network_radio_state_change:
                if (notifData.dataSize > 0 && notifData.dataPtr != IntPtr.Zero)
                {
                    //WLAN_HOSTED_NETWORK_RADIO_STATE pRadioState = (WLAN_HOSTED_NETWORK_RADIO_STATE)Marshal.PtrToStructure(notifData.dataPtr, typeof(WLAN_HOSTED_NETWORK_RADIO_STATE));
                    // Do nothing for now
                }
                //else
                //{
                //    // // Shall NOT happen
                //    // _ASSERT(FAILSE);
                //}
                break;
            }
        }
Пример #4
0
        protected void OnNotification(ref WLAN_NOTIFICATION_DATA notificationData, IntPtr context)
        {
            switch ((int)notificationData.NotificationCode)
            {
            case (int)WLAN_HOSTED_NETWORK_NOTIFICATION_CODE.STATE_CHANGE:

                if (notificationData.dwDataSize > 0 && notificationData.pData != IntPtr.Zero)
                {
                    WLAN_HOSTED_NETWORK_STATE_CHANGE pStateChange =
                        (WLAN_HOSTED_NETWORK_STATE_CHANGE)Marshal.PtrToStructure(
                            notificationData.pData,
                            typeof(WLAN_HOSTED_NETWORK_STATE_CHANGE));

                    switch (pStateChange.NewState)
                    {
                    case WLAN_HOSTED_NETWORK_STATE.ACTIVE:
                        onHostedNetworkStarted();
                        break;

                    case WLAN_HOSTED_NETWORK_STATE.IDLE:
                        if (pStateChange.OldState == WLAN_HOSTED_NETWORK_STATE.ACTIVE)
                        {
                            onHostedNetworkStopped();
                        }
                        else
                        {
                            onHostedNetworkAvailable();
                        }
                        break;

                    case WLAN_HOSTED_NETWORK_STATE.UNAVAILABLE:
                        if (pStateChange.OldState == WLAN_HOSTED_NETWORK_STATE.ACTIVE)
                        {
                            onHostedNetworkStopped();
                        }
                        onHostedNetworkAvailable();
                        break;
                    }
                }

                break;

            case (int)WLAN_HOSTED_NETWORK_NOTIFICATION_CODE.PEER_STATE_CHANGE:

                if (notificationData.dwDataSize > 0 && notificationData.pData != IntPtr.Zero)
                {
                    WLAN_HOSTED_NETWORK_DATA_PEER_STATE_CHANGE pPeerStateChange = (WLAN_HOSTED_NETWORK_DATA_PEER_STATE_CHANGE)Marshal.PtrToStructure(notificationData.pData, typeof(WLAN_HOSTED_NETWORK_DATA_PEER_STATE_CHANGE));

                    if (pPeerStateChange.NewState.PeerAuthState == WLAN_HOSTED_NETWORK_PEER_AUTH_STATE.AUTHENTICATED)
                    {
                        // Station joined the hosted network
                        onStationJoin(pPeerStateChange.NewState);
                    }
                    else if (pPeerStateChange.NewState.PeerAuthState == WLAN_HOSTED_NETWORK_PEER_AUTH_STATE.INVALID)
                    {
                        // Station left the hosted network
                        onStationLeave(pPeerStateChange.NewState);
                    }
                    else
                    {
                        // Authentication state changed
                        onStationStateChange(pPeerStateChange.NewState);
                    }
                }

                break;

            case (int)WLAN_HOSTED_NETWORK_NOTIFICATION_CODE.RADIO_STATE_CHANGE:
                if (notificationData.dwDataSize > 0 && notificationData.pData != IntPtr.Zero)
                {
                    //WLAN_HOSTED_NETWORK_RADIO_STATE pRadioState = (WLAN_HOSTED_NETWORK_RADIO_STATE)Marshal.PtrToStructure(notifData.dataPtr, typeof(WLAN_HOSTED_NETWORK_RADIO_STATE));
                    // Do nothing for now
                }
                //else
                //{
                //    // // Shall NOT happen
                //    // _ASSERT(FAILSE);
                //}
                break;
            }
        }