コード例 #1
0
        private void CallToInitApp(
            IBluetoothLowEnergyAdapter adapter,
            IUserDialogs dialogs,
            string appVersion)
        {
            // Catch unhandled exceptions
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
            TaskScheduler.UnobservedTaskException      += TaskSchedulerOnUnobservedTaskException;

            Utils.Print("FormsApp: Interactive [ " + Data.Get.IsFromScripting + " ]");

            appVersion_str = appVersion;

            deviceId = CrossDeviceInfo.Current.Id;

            // Profiles manager
            credentialsService = new CredentialsService();

            // Initializes Bluetooth
            ble_interface = new BleSerial(adapter);

            AppResources.Culture = CrossMultilingual.Current.DeviceCultureInfo;

            // Config path
            ConfigPaths();

            if (Device.RuntimePlatform == Device.iOS)
            {
                var MamServ = DependencyService.Get <IMAMService>();
                MamServ.UtilMAMService();
            }

            this.LoadConfigurationAndOpenScene(dialogs);
        }
コード例 #2
0
        private void CallToInitApp(IBluetoothLowEnergyAdapter adapter, List <string> listaDatos, IUserDialogs dialogs, string appVersion)
        {
            appVersion_str = appVersion;

            deviceId = CrossDeviceInfo.Current.Id;

            // Profiles manager
            credentialsService = new CredentialsService();

            // Initializes Bluetooth
            ble_interface = new BleSerial(adapter);

            string data = string.Empty;

            if (listaDatos.Count != 0 ||
                listaDatos != null)
            {
                for (int i = 0; i < listaDatos.Count; i++)
                {
                    data = data + listaDatos[i] + "\r\n";
                }
            }

            string base64CertificateString = "";

            try
            {
                base64CertificateString = listaDatos[2].Replace("cert_file: ", "");
                byte[]           bytes           = Convert.FromBase64String(base64CertificateString);
                X509Certificate2 x509certificate = new X509Certificate2(bytes);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            AppResources.Culture = CrossMultilingual.Current.DeviceCultureInfo;

            // Force to not download server XML files
            if (DEBUG_MODE_ON)
            {
                this.LoadXmlsAndCreateContainer(dialogs, data);
            }
            else
            {
                // Downloads, if necesary, and loads configuration from XML files
                if (this.HasDeviceAllXmls())
                {
                    this.LoadXmlsAndCreateContainer(dialogs, data);
                }
                else
                {
                    this.DownloadXmlsIfNecessary(dialogs, data);
                }
            }
        }
コード例 #3
0
        public static void Load(IBluetoothLowEnergyAdapter adapter)
        {
            // Initializes Bluetooth
            BleSerial ble = new BleSerial(adapter);

            // Initializes Lexi
            Lexi.Lexi lexi = new Lexi.Lexi(ble, 10000);

            // Set singleton references
            Singleton.Set = ble;
            Singleton.Set = lexi;
        }
コード例 #4
0
        private void RefreshDeviceList()
        {
            //invoke the listAvailableDevicesAsync method of the correct Serial class. Since it is Async, we will wrap it in a Task and add a llambda to execute when finished
            Task <DeviceInformationCollection> task = null;

            if (ConnectionMethodComboBox.SelectedItem == null)
            {
                ConnectMessage.Text = "Select a connection method to continue.";
                return;
            }

            switch (ConnectionMethodComboBox.SelectedItem as String)
            {
            default:
            case "Bluetooth":
                ConnectionList.Visibility        = Visibility.Visible;
                DevicesText.Visibility           = Visibility.Visible;
                NetworkHostNameTextBox.IsEnabled = false;
                NetworkPortTextBox.IsEnabled     = false;
                BaudRateComboBox.IsEnabled       = true;
                NetworkHostNameTextBox.Text      = "";
                NetworkPortTextBox.Text          = "";
                BLESchemaComboBox.IsEnabled      = false;

                //create a cancellation token which can be used to cancel a task
                cancelTokenSource = new CancellationTokenSource();
                cancelTokenSource.Token.Register(() => OnConnectionCancelled());

                task = BluetoothSerial.listAvailableDevicesAsync().AsTask <DeviceInformationCollection>(cancelTokenSource.Token);
                break;

            case "BLE":
                ConnectionList.Visibility        = Visibility.Visible;
                DevicesText.Visibility           = Visibility.Visible;
                NetworkHostNameTextBox.IsEnabled = false;
                NetworkPortTextBox.IsEnabled     = false;
                BaudRateComboBox.IsEnabled       = false;
                NetworkHostNameTextBox.Text      = "";
                NetworkPortTextBox.Text          = "";
                BLESchemaComboBox.IsEnabled      = true;

                //create a cancellation token which can be used to cancel a task
                cancelTokenSource = new CancellationTokenSource();
                cancelTokenSource.Token.Register(() => OnConnectionCancelled());

                task = BleSerial.listAvailableDevicesAsync().AsTask <DeviceInformationCollection>(cancelTokenSource.Token);
                break;

            case "USB":
                ConnectionList.Visibility        = Visibility.Visible;
                DevicesText.Visibility           = Visibility.Visible;
                NetworkHostNameTextBox.IsEnabled = false;
                NetworkPortTextBox.IsEnabled     = false;
                BaudRateComboBox.IsEnabled       = true;
                NetworkHostNameTextBox.Text      = "";
                NetworkPortTextBox.Text          = "";
                BLESchemaComboBox.IsEnabled      = false;

                //create a cancellation token which can be used to cancel a task
                cancelTokenSource = new CancellationTokenSource();
                cancelTokenSource.Token.Register(() => OnConnectionCancelled());

                task = UsbSerial.listAvailableDevicesAsync().AsTask <DeviceInformationCollection>(cancelTokenSource.Token);
                break;

            case "Network":
                ConnectionList.Visibility        = Visibility.Collapsed;
                DevicesText.Visibility           = Visibility.Collapsed;
                NetworkHostNameTextBox.IsEnabled = true;
                NetworkPortTextBox.IsEnabled     = true;
                BaudRateComboBox.IsEnabled       = false;
                BLESchemaComboBox.IsEnabled      = false;
                ConnectMessage.Text = "Enter a host and port to connect.";
                task = null;
                break;
            }

            if (task != null)
            {
                //store the returned DeviceInformation items when the task completes
                task.ContinueWith(listTask =>
                {
                    //store the result and populate the device list on the UI thread
                    var action = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new Windows.UI.Core.DispatchedHandler(() =>
                    {
                        Connections connections = new Connections();

                        var result = listTask.Result;
                        if (result == null || result.Count == 0)
                        {
                            ConnectMessage.Text       = "No items found.";
                            ConnectionList.Visibility = Visibility.Collapsed;
                        }
                        else
                        {
                            foreach (DeviceInformation device in result)
                            {
                                connections.Add(new Connection(device.Name, device));
                            }
                            ConnectMessage.Text = "Select an item and press \"Connect\" to connect.";
                        }

                        ConnectionList.ItemsSource = connections;
                    }));
                });
            }
        }
コード例 #5
0
        private void CallToInitApp(
            IBluetoothLowEnergyAdapter adapter,
            IUserDialogs dialogs,
            string appVersion)
        {
            // Catch unhandled exceptions
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
            TaskScheduler.UnobservedTaskException      += TaskSchedulerOnUnobservedTaskException;

            Utils.Print("FormsApp: Interactive [ " + Data.Get.IsFromScripting + " ]");

            appVersion_str = appVersion;

            deviceId = CrossDeviceInfo.Current.Id;

            // Profiles manager
            credentialsService = new CredentialsService();

            // Initializes Bluetooth
            ble_interface = new BleSerial(adapter);

            AppResources.Culture = CrossMultilingual.Current.DeviceCultureInfo;

            // Config path
            ConfigPaths();

            string Mode = GenericUtilsClass.ChekInstallMode();

            if (Data.Get.IsAndroid && Mode.Equals("None"))
            {
                var MamServ = DependencyService.Get <IMAMService>();
                MamServ.UtilMAMService();
                if (Mobile.configData.HasIntune)
                {
                    GenericUtilsClass.SetInstallMode("Intune");
                    this.LoadConfigurationAndOpenScene(dialogs);
                    return;
                }
            }

            // var MamServ = DependencyService.Get<IMAMService>();
            // MamServ.UtilMAMService();

            if (VersionTracking.IsFirstLaunchEver || Mode.Equals("None"))
            {
                SecureStorage.RemoveAll();
                Device.BeginInvokeOnMainThread(() =>
                {
                    MainPage = new NavigationPage(new AclaraInstallPage());
                });
            }
            else
            {
                if (Mode.Equals("Intune"))
                {
                    var MamServ = DependencyService.Get <IMAMService>();
                    MamServ.UtilMAMService();
                }
                else if (Mode.Equals("FTP"))
                {
                    // Check if FTP settings is in securestorage
                    GenericUtilsClass.CheckFTPDownload();
                }

                this.LoadConfigurationAndOpenScene(dialogs);
            }
        }