Esempio n. 1
0
        public void Down(Device device)
        {
            Logger.LogInformation($"Desactivation de la connection {device.Connection.Name} {device.Connection.Uuid}");

            WifiService.Down(device.Connection);

            Telemetry.TrackEvent("Deactivate Wifi");
        }
Esempio n. 2
0
        public void Disconnect(Device device)
        {
            Logger.LogInformation($"Suppression de la connection {device.Connection.Name} {device.Connection.Uuid}");

            WifiService.Disconnect(device.Connection);

            Telemetry.TrackEvent("Deconnect Wifi");
        }
Esempio n. 3
0
        public void Connect(Device device)
        {
            Logger.LogInformation($"Creation de la connection {device.Ssid}");

            Telemetry.TrackEvent("Connect Wifi");

            WifiService.Connect(device);
        }
Esempio n. 4
0
        protected override void OnInitialized()
        {
            Telemetry.TrackPageView(new PageViewTelemetry("Wifi Page")
            {
                Url = new Uri("/Wifi/Manage", UriKind.Relative)
            });

            base.OnInitialized();

            WifiService.LoadDevices();
        }
        public void GetAccessPoints()
        {
            var accessPoints = WifiService.GetAccessPointsOrderedBySignalStrength();

            foreach (var accessPoint in accessPoints)
            {
                AccessPoints.Add(new WifiAccessPoint
                {
                    Name           = accessPoint.Name,
                    SignalStrength = accessPoint.SignalStrength,
                    IsConnected    = accessPoint.IsConnected,
                    IsSecure       = accessPoint.IsSecure
                });
            }
        }
 public static List <string> GetWifiConnectedSsids()
 {
     try
     {
         return(WifiService.ReturnWifiSsids());
     }
     catch (Exception ex)
     {
         //if there is no wifi exception is thrown
         return(new List <string>()
         {
             ex.Message
         });
     }
 }
Esempio n. 7
0
        public void ParseConnectionConsoleOutputTest()
        {
            // assert
            var output = "NAME                 UUID                                  TYPE      DEVICE\r\n" +
                         "Maison 2             33de31e2-fffc-4e55-82cc-5c9db0104f8e  wifi      wlan0\r\n" +
                         "BOX                  3b6269bd-ef19-43ff-b753-25d5ac06337e  wifi      --\r\n" +
                         "Connexion filaire 1  23dca64d-1f09-378e-a284-257a8321afd7  ethernet  --\r\n" +
                         "Honor 9              986cb8c6-fe8e-4951-903f-105aef31a3ab  wifi      --\r\n";

            var logger    = Substitute.For <ILogger <WifiService> >();
            var telemetry = new TelemetryClient();

            // act
            var service     = new WifiService(logger, telemetry);
            var connections = service.ParseConnectionConsoleOutput(output);

            // assert
            Assert.AreEqual(connections.Count, 4);
        }
Esempio n. 8
0
        public void ParseDeviceConsoleOutputTest()
        {
            // assert
            var output = "IN-USE  SSID                         MODE   CHAN  RATE        SIGNAL  BARS  SECURITY\r\n" +
                         "*       Maison                       Infra  1     130 Mbit/s  57      ***   WPA2\r\n" +
                         "        Maison_Guest                 Infra  1     130 Mbit/s  57      ***   WPA2\r\n" +
                         "        DIRECT-14-HP Officejet 5740  Infra  11    65 Mbit/s   30      *     WPA2\r\n" +
                         "        Sunrise_2.4GHz_8F92E0        Infra  11    195 Mbit/s  14      *     WPA1 WPA2\r\n";

            var logger    = Substitute.For <ILogger <WifiService> >();
            var telemetry = new TelemetryClient();

            // act
            var service = new WifiService(logger, telemetry);
            var devices = service.ParseDeviceConsoleOutput(output);

            // assert
            Assert.AreEqual(devices.Count, 4);
        }
Esempio n. 9
0
        public async Task Run()
        {
            DebugHelper.LogInformation("Onboarding starting");
            DebugHelper.LogInformation($"Device Provisioning State: {(SimulatedDevice.IsProvisioned ? "Provisioned" : "Not provisioned")}");

            //Init Portal Api and turn on access point
            if (!InitializePortalAPI())
            {
                return;
            }

            //Start Services
            _WifiService         = new WifiService();
            _ProvisioningService = new ProvisioningService();
            _PortalService       = new PortalService();

            //Start AP App
            AccessPointHelper.StartAccessPoint();

            //Start Stream Socker Service
            _DeviceApiServer = new WebDeviceApiServer();
            _DeviceApiServer.CommandReceived += CommandReceived;
            _DeviceApiServer.Start();

            DebugHelper.LogInformation("Onboarding started");

            //Wait for AP Timeout
            _LastAccess = DateTime.UtcNow;
            while (true)
            {
                if (_APTimeoutEnabled && SimulatedDevice.IsProvisioned &&
                    DateTime.UtcNow.AddMinutes(-(APTimeoutMinutes)) > _LastAccess)
                {
                    AccessPointHelper.StopAccessPoint();
                }
                await Task.Delay(500);
            }
        }
Esempio n. 10
0
 public void Refresh()
 {
     WifiService.LoadDevices();
 }
Esempio n. 11
0
 public WifiController(WifiService wifiService)
 {
     _wifiService = wifiService;
 }