示例#1
0
        public override Task <GenericMessage> Scan(Wifistuff.WlanInterface request, ServerCallContext context)
        {
            GenericMessage      result     = new GenericMessage();
            WlanNotifSubscriber subscriber = new WlanNotifSubscriber()
            {
                InterfaceGuid = Guid.Parse(request.InterfaceGuid)
            };
            // subscriber._interfaceGuid = Guid.Parse(request.InterfaceGuid);
            //Get the interface matching the one described by the request (Guid should match)
            WlanInterface wlanInterface = GetWlanInterfaceById(request.InterfaceGuid);

            wlanInterface.WlanNotification += subscriber.WlanNotificationChanged;
            try
            {
                wlanInterface.Scan();
                while (subscriber.ScanSuccessful == null)
                {
                }

                result.Result  = (bool)subscriber.ScanSuccessful;
                result.Message = subscriber.LastFailReason;
            }
            catch (Exception e)
            {
                subscriber.ScanSuccessful = false;
                subscriber.LastFailReason = e.Message;
            }

            wlanInterface.WlanNotification -= subscriber.WlanNotificationChanged;
            return(Task.FromResult(result));
        }
示例#2
0
 public static Wifistuff.WlanInterface Translate(WlanInterface wlanInterface)
 {
     Wifistuff.WlanInterface result = new Wifistuff.WlanInterface
     {
         State = (Wifistuff.WlanInterface.Types.WlanInterfaceState)Enum.Parse(typeof(WlanInterfaceState),
                                                                              wlanInterface.InterfaceState.ToString())
     };
     return(result);
 }
示例#3
0
        public override Task <JAccessPointSeq> GetAccessPoints(Wifistuff.WlanInterface request,
                                                               ServerCallContext context)
        {
            IEnumerable <JAccessPoint> accessPoints = GetWlanInterfaceById(request.InterfaceGuid).GetAccessPoints(_wifi)
                                                      .OrderByDescending(ap => ap.SignalStrength)
                                                      .Select(WiFiApiImpl.Translate);
            JAccessPointSeq seq = new JAccessPointSeq();

            seq.AccessPoints.AddRange(accessPoints);
            return(Task.FromResult(seq));
        }
示例#4
0
        public override Task <WlanInterfaceSeq> GetWlanInterfaces(Empty request, ServerCallContext context)
        {
            var interfaces            = _wifi.Interfaces();
            WlanInterfaceSeq sequence = new WlanInterfaceSeq();

            Wifistuff.WlanInterface[] wlanInterfaces = new Wifistuff.WlanInterface[interfaces.Count()];
            for (int i = 0; i < wlanInterfaces.Length; i++)
            {
                wlanInterfaces[i] = WiFiApiImpl.Translate(interfaces.ElementAt(i));
            }
            sequence.Interfaces.AddRange(wlanInterfaces);
            return(Task.FromResult(sequence));
        }