Esempio n. 1
0
 internal ServiceStateChangedEventArgs(WiFiDirectError error, WiFiDirectServiceDiscoveryState state, WiFiDirectServiceType type, string response, WiFiDirectPeer peer)
 {
     _error    = error;
     _state    = state;
     _type     = type;
     _response = response;
     _peer     = peer;
 }
Esempio n. 2
0
        internal uint RegisterService(WiFiDirectServiceType type, string info, string serviceInfo)
        {
            uint serviceId;
            int  ret = Interop.WiFiDirect.RegisterService(type, info, serviceInfo, out serviceId);

            if (ret != (int)WiFiDirectError.None)
            {
                Log.Error(Globals.LogTag, "Failed to register for service, Error - " + (WiFiDirectError)ret);
                WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
            }

            return(serviceId);
        }
Esempio n. 3
0
        /// <summary>
        /// Stops the Wi-Fi Direct service discovery.
        /// </summary>
        /// <remarks>
        /// Wi-Fi Direct must be activated.
        /// </remarks>
        /// <exception cref="NotSupportedException">
        /// Thrown during one of the following cases:
        /// 1. When the Wi-Fi Direct is not supported.
        /// 2. When the Wi-Fi Direct service discovery is not supported.
        /// </exception>
        /// <param name="type">The type of the service.</param>
        /// <since_tizen> 3 </since_tizen>
        public void CancelServiceDiscovery(WiFiDirectServiceType type)
        {
            if (Globals.IsActivated)
            {
                int ret = Interop.WiFiDirect.StopServiceDiscovery(_peerMacAddress, type);
                if (ret != (int)WiFiDirectError.None)
                {
                    Log.Error(Globals.LogTag, "Failed to stop Wi-Fi Direct service discovery, Error - " + (WiFiDirectError)ret);
                    WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
                }
            }

            else
            {
                Log.Error(Globals.LogTag, "Wifi-direct is not activated");
                WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
            }
        }
Esempio n. 4
0
        private void RegisterServiceStateChangedEvent()
        {
            _serviceStateChangedCallback = (int result, WiFiDirectServiceDiscoveryState stateInfo, WiFiDirectServiceType typeInfo, IntPtr responseData, string address, IntPtr userData) =>
            {
                if (_serviceStateChanged != null)
                {
                    WiFiDirectError error = (WiFiDirectError)result;
                    WiFiDirectServiceDiscoveryState state = stateInfo;
                    WiFiDirectServiceType           type  = typeInfo;
                    string response = Marshal.PtrToStringAnsi(responseData);
                    IntPtr peer;
                    Interop.WiFiDirect.GetDiscoveredPeerInfo(address, out peer);
                    DiscoveredPeerStruct peerStruct = (DiscoveredPeerStruct)Marshal.PtrToStructure(peer, typeof(DiscoveredPeerStruct));

                    _serviceStateChanged(null, new ServiceStateChangedEventArgs(error, state, type, response, WiFiDirectUtils.ConvertStructToDiscoveredPeer(peerStruct)));
                }
            };
            int ret = Interop.WiFiDirect.SetServiceStateChangedCallback(_serviceStateChangedCallback, IntPtr.Zero);

            if (ret != (int)WiFiDirectError.None)
            {
                Log.Error(Globals.LogTag, "Failed to set service state changed callback, Error - " + (WiFiDirectError)ret);
            }
        }
Esempio n. 5
0
 internal static extern int RegisterService(WiFiDirectServiceType type, string info1, string info2, out uint serviceId);
Esempio n. 6
0
 internal static extern int StopServiceDiscovery(string address, WiFiDirectServiceType type);