protected override Task <ThingState> OnInitAsync()
        {
            var url      = _gatewaySetupInfo.Address;
            var userName = _gatewaySetupInfo.ReadSetting <string>("UserName");
            var password = _gatewaySetupInfo.ReadSetting <string>("Password");

            _fritzBox = new FritzBox(url, userName, password);

            return(Task.FromResult(ThingState.Online));
        }
Exemplo n.º 2
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            AnimateLoadStart();

            var progress = new MyProgressHandler(SynchronizationContext.Current);

            progress.ProgressReported += tuple => {
                LabelLoad.Text          = String.Format("{0} / {1} ({2:.00}%)", tuple.Item1, tuple.Item2, tuple.Item1 * 100.0 / tuple.Item2);
                ProgressBarLoad.Maximum = tuple.Item2;
                ProgressBarLoad.Value   = tuple.Item1;
            };

            ProgressBarLoad.Value = 0;

            if (_cancellationTokenSource == null)
            {
                _cancellationTokenSource = new CancellationTokenSource();
            }

            Session session;

            try {
                session = await FritzBox.ConnectAsync(TextBoxHost.Text, TextBoxPassword.Password, CancellationToken.None);
            } catch (OperationCanceledException) {
                return;
            } catch (Exception ex) {
                AnimateLoadStop();
                MessageBox.Show(this, ex.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            LabelLoad.Text = session.Id;

            var data = new ExampleQuery();

            try {
                await session.QueryAsync(data, _cancellationTokenSource.Token, progress);
            } catch (OperationCanceledException) {
                return;
            } catch (Exception ex) {
                MessageBox.Show(this, ex.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            } finally {
                AnimateLoadStop();
            }

            // Use data ...
            //MessageBox.Show(this, data.DslamVendor);

            var newWindow = new DetailWindow();

            newWindow.DetailCollection.Clear();
            FillDetailCollection(newWindow.DetailCollection, data);
            newWindow.Show();
        }
        public FritzBoxWlanDeviceThingHandler(IThingSetupInfo thingSetupInfo, FritzBox fritzBox)
        {
            _thingSetupInfo = thingSetupInfo;
            _fritzBox       = fritzBox;

            _isActiveChannelHandler       = new SimpleThingChannelHandler <bool>(_thingSetupInfo.Id, "IsActive");
            _lastConnectChannelHandler    = new SimpleThingChannelHandler <DateTime>(_thingSetupInfo.Id, "LastConnect");
            _lastDisconnectChannelHandler = new SimpleThingChannelHandler <DateTime>(_thingSetupInfo.Id, "LastDisconnect");

            _hostAddress = _thingSetupInfo.Address;
            _interval    = _thingSetupInfo.ReadSetting("Interval", 10000);
        }
Exemplo n.º 4
0
        public static void Run()
        {
            var args = Environment.GetCommandLineArgs();

            var user     = args[1];
            var password = args[2];

            var fritzBox = new FritzBox("https://fritz.box", user, password);

            var device = fritzBox.Wlan.GetWlanDeviceInfo("8C:B8:4A:CA:8F:29");

            Console.WriteLine($"Ip: {device.IpAddress}");
        }
Exemplo n.º 5
0
        /// <summary>
        /// Entry method of the application.
        /// </summary>
        /// <param name="args">The program arguments.</param>
        public static void Main(string[] args)
        {
            FritzBox fritzBox = new FritzBox();

            fritzBox.Connect();
            fileHeader = File.ReadAllText("FileHeader.txt");
            string targetDirectory = Path.GetFullPath(Path.Combine(Assembly.GetEntryAssembly().Location, "./../../../../../FritzControl/Soap"));

            new Program().GenerateServiceWrapper(targetDirectory, "FritzControl.Soap", fritzBox.Description.Device);

            // Just for testing: Serialize current description to XML
            // new System.Xml.Serialization.XmlSerializer(fritzBox.Description.GetType()).Serialize(new StreamWriter("Description.xml"), fritzBox.Description);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Entry method of the application.
        /// </summary>
        /// <param name="args">The program arguments.</param>
        public static void Main(string[] args)
        {
#if DEBUG
            InternalLogger.LogToConsole = true;
#endif

            // Example
            // FritzBox fritzBox = new FritzBox { Username = "******", Password = "******", Hostname = "fritz.box" };
            FritzBox fritzBox = new FritzBox();
            fritzBox.Connect();
            X_AVM_DE_Dect dect = new X_AVM_DE_Dect {
                FritzBox = fritzBox
            };
            ushort numberOfDectEntries = dect.GetNumberOfDectEntries();
            for (ushort i = 0; i < numberOfDectEntries; i++)
            {
                var result = dect.GetGenericDectEntry(i);
                Log.Info($"DECT device index {i}");
                Log.Info($"Model: {result.NewModel}");
                Log.Info($"Model: {result.NewName}");
            }

            LogManager.Shutdown();
        }