public App(IBluetoothManager bluetoothManager, ILocalStorageManager localStorageManager) { Instance = this; PlatformSpecificManagers.BluetoothManager = bluetoothManager; PlatformSpecificManagers.LocalStorageManager = localStorageManager; MainPage = new Biketimer.Views.Slideout.SlideoutNavigation(); }
public BluetoothHelper() { _Manager = BluetoothManager.Instance; //_Myexception = new ExceptionHandler(); //PrinterCentral = new PrinterHelper(); GloVa.DevicesDiscovered = new List <RemoteDevice>(); }
public void Initialize() { ListDevices = new ObservableCollection <BTDevice>(); IBluetoothManager btMan = DependencyService.Get <IBluetoothManager>(); var listBTDevices = btMan.GetBondedDevices(); if (listBTDevices != null && listBTDevices.Count > 0) { foreach (var device in listBTDevices) { Device = new BTDevice { Name = device.Name, UUID = device.UUID, Address = device.Address }; ListDevices.Add(Device); } } else { lbl1 = "Bluetoothデバイスがありません。"; } }
public KeyManagementPageViewModel(KeyVendorUser user, IBluetoothManager bluetooth) { _bluetooth = bluetooth; _user = user; KeyList = ""; }
public ManufacturerNameStringCharacteristicBuilder(IBluetoothManager bluetoothManager) { _Builder = bluetoothManager.NewGattCharacteristicBuilder(); _Builder.SetUuid(CHARACTERISTIC_MANUFACTURER_NAME) .SetPermissions(PERMISSIONS) .SetProperties(PROPERTIES); }
public RfcommServerPage() { BluetoothManager = DependencyService.Get <IManagerManager>().BluetoothManager; ServiceProviders = new ObservableCollection <IRfcommServiceProvider>(); InitializeComponent(); ProviderListView.ItemsSource = ServiceProviders; }
public static async Task <bool> TurnOnBluetoothAsync( this IBluetoothManager bluetooth, uint timeout, uint delay) { return(await Task.Run(async() => { if (!bluetooth.IsBluetoothOn) { bluetooth.IsBluetoothOn = true; for (int i = 0; i *delay < timeout; i++) { if (!bluetooth.IsBluetoothOn) { await Task.Delay((int)delay); } else { break; } Debug.WriteLine("turning BT on..."); } } return bluetooth.IsBluetoothOn; })); }
public static async Task <BluetoothDevice> FindBluetoothDeviceByAddressAsync( this IBluetoothManager bluetooth, string address, uint delay) { return(await Task.Run(async() => { await bluetooth.StartDeviceDiscoveryAsync(1000, delay); while (bluetooth.IsDiscovering) { foreach (var device in bluetooth.DeviceList) { if (device.Address == address) { bluetooth.StopDiscovering(); return new BluetoothDevice() { Name = device.Name, Address = device.Address }; } } Debug.WriteLine("looking fot device with address..."); await Task.Delay((int)delay); } return null; })); }
public static async Task <bool> StartDeviceDiscoveryAsync( this IBluetoothManager bluetooth, uint timeout, uint delay) { return(await Task.Run(async() => { if (!bluetooth.IsDiscovering) { bluetooth.StartDiscovering(); for (int i = 0; i *delay < timeout; i++) { if (!bluetooth.IsDiscovering) { await Task.Delay((int)delay); } else { break; } Debug.WriteLine("starting BT discovering..."); } } return bluetooth.IsDiscovering; })); }
public static async Task <bool> CreateConnectionAsync( this IBluetoothManager bluetooth, uint timeout, uint delay) { return(await Task.Run(async() => { if (!bluetooth.IsConnected) { bluetooth.OpenConnection(); for (int i = 0; i *delay < timeout; i++) { if (!bluetooth.IsConnected) { await Task.Delay((int)delay); } else { break; } Debug.WriteLine("trying to connect..."); } } return bluetooth.IsConnected; })); }
public static async Task <bool> BondWithBluetoothDeviceAsync( this IBluetoothManager bluetooth, string address, int timeout, uint delay) { return(await Task.Run(async() => { if (!bluetooth.IsBonded) { bluetooth.CreateBond(address); for (int i = 0; i *delay < timeout; i++) { if (!bluetooth.IsBonded) { await Task.Delay((int)delay); } else { break; } Debug.WriteLine("trying to bond..."); } } return bluetooth.IsBonded; })); }
public BluetoothDeviceListPage() { bluetoothManager = DependencyService.Get <IBluetoothManager>(); bluetoothDeviceList = new ObservableCollection <IBluetoothDevice>(); resetDeviceList(); ListView bluetoothDeviceListView = new ListView(); bluetoothDeviceListView.ItemSelected += onDeviceSelected; bluetoothDeviceListView.ItemsSource = bluetoothDeviceList; bluetoothDeviceListView.ItemTemplate = new DataTemplate(typeof(BluetoothDeviceCell)); qrCodeConnectButton = new Button(); qrCodeConnectButton.Text = "QRCode"; qrCodeConnectButton.Clicked += onQRCodeConnectClicked; scanDevicesButton = new Button(); scanDevicesButton.Clicked += (object sender, EventArgs e) => { resetDeviceList(); bluetoothManager.SearchForBlutoothDevices(); }; bluetoothManager.onDiscoveryStarted += onDiscoveryStarted; bluetoothManager.onDevicesFound += onDevicesFound; bluetoothManager.onDiscoveryFinished += onDiscoveryFinished; scanDevicesButton.Text = "Scan Devices"; Content = new StackLayout { Children = { qrCodeConnectButton, scanDevicesButton, bluetoothDeviceListView } }; }
public KeyVendorTerminal(IBluetoothManager bluetoothManager) { _bluetoothManager = bluetoothManager; SplittingEnabled = true; PartLenght = 20; TimeToReadPart = 200; }
public RfcommRXConnectionGroup(IBluetoothManager bluetoothManager, RXConnectionManager connectionManager) { BluetoothManager = bluetoothManager; Listener = new RfcommAdvertiseRXListener(this); //Scanner = new RfcommRXScanner(this); Scanner = new RfcommFromAttRXScanner(this); ConnectionManager = connectionManager; }
public BatteryServiceWrapper(IBluetoothManager bluetoothManager) { IGattServiceBuilder builder = bluetoothManager.NewGattServiceBuilder(); builder.SetUuid(BATTERY_SERVICE_UUID).SetServiceType(GattServiceType.Primary); BatteryLevelCharacteristicWrapper = new BatteryLevelCharacteristicWrapper(bluetoothManager); builder.AddCharacteristics(BatteryLevelCharacteristicWrapper.GattServerCharacteristic); GattServerService = builder.Build(); }
public ClientRfcommServiceWrapper(IBluetoothManager bluetoothManager) { BluetoothManager = bluetoothManager; AddressCharacteristicWrapper = new ClientRfcommAddressCharacteristicWrapper(this); GattServerService = BluetoothManager.NewGattServiceBuilder() .SetUuid(Constants.ClientRfcommServiceGuid) .AddCharacteristics(AddressCharacteristicWrapper.GattServerCharacteristic) .Build(); }
public BleDeviceSelectorWindow(IBluetoothManager bluetoothManager, ConnectionProfile connectionProfile) { BluetoothManager = bluetoothManager; ConnectionProfile = connectionProfile; ScanResultItemSource = new ObservableCollection <BleDeviceViewModel>(); InitializeComponent(); DeviceListView.ItemsSource = ScanResultItemSource; IsVisibleChanged += BleDeviceSelectorWindow_IsVisibleChanged; }
public LogPageViewModel(KeyVendorUser user, IBluetoothManager bluetooth) { _bluetooth = bluetooth; _user = user; LogList = new ObservableCollection <LogInfo>(); Indexer = 0; GetLogAsync(Indexer); }
public RXRfcommServiceProvider(IBluetoothManager bluetoothManager, RfcommServiceProvider win10Provider) { BluetoothManager = bluetoothManager; Win10RfcommServiceProvider = win10Provider; RfcommConnectionList = new List <RXRFCommConnection>(); RfcommServiceProviderSocketListener = new StreamSocketListener(); RfcommServiceProviderSocketListener.ConnectionReceived += RfcommServiceProviderSocketListener_ConnectionReceived; RfcommServiceProviderSocketListener.BindServiceNameAsync("{" + ServiceId.ToString().ToUpper() + "}", SocketProtectionLevel.BluetoothEncryptionAllowNullAuthentication).AsTask().Wait(); InitializeServiceSdpAttributes(Win10RfcommServiceProvider, "TestService"); }
public GyroscopeServiceWrapper(IBluetoothManager bluetoothManager) { BluetoothManager = bluetoothManager; AngularVelocityCharacteristicWrapper = new GyroscopeAngularVelocityCharacteristicWrapper(this); IGattServiceBuilder builder = bluetoothManager.NewGattServiceBuilder(); GattServerService = builder.SetUuid(Constant.GyroscopeServiceGuid) .AddCharacteristics(AngularVelocityCharacteristicWrapper.GattServerCharacteristic) .Build(); }
public ClientCharacteristicConfigurationDescriptorWrapper(IBluetoothManager bluetoothManager) { _ClientConfigurations = new Dictionary <IBluetoothDevice, Configuration>(); var builder = bluetoothManager.NewGattDescriptorBuilder(); builder.SetUuid(CLIENT_CHARACTERISTIC_CONFIGURATION_UUID).SetPermissions(PERMISSIONS); GattServerDescriptor = builder.Build(); GattServerDescriptor.OnRead += _OnRead; GattServerDescriptor.OnWrite += _OnWrite; }
public KeepNotifyingCharacteristicWrapper(IBluetoothManager bluetoothManager) { ClientCharacteristicConfigurationDescriptorWrapper = new ClientCharacteristicConfigurationDescriptorWrapper(bluetoothManager); IGattCharacteristicBuilder builder = bluetoothManager.NewGattCharacteristicBuilder(); builder.SetUuid(UUID).SetPermissions(PERMISSIONS).SetProperties(PROPERTIES); builder.AddDescriptors(ClientCharacteristicConfigurationDescriptorWrapper.GattServerDescriptor); GattServerCharacteristic = builder.Build(); GattServerCharacteristic.OnRead += _OnRead; }
public VendingPageViewModel(KeyVendorUser user, IBluetoothManager bluetooth) { _bluetooth = bluetooth; _user = user; IsToolbarVisible = _user.HasAdminRights; KeyList = new ObservableCollection <string>(); GetKeyListAsync(); }
public ConnectionPageViewModel(KeyVendorUser user, IBluetoothManager bluetooth) { _user = user; _bluetooth = bluetooth; ButtonText = TextConstants.ButtonStartRefreshing; DeviceList = _bluetooth.DeviceList; StartRefreshingAsync(); }
public RfcommSettingPage() { InitializeComponent(); IManagerManager managerManager = DependencyService.Get <IManagerManager>(); BluetoothManager = managerManager.BluetoothManager; var rxConnManager = managerManager.RXConnectionManager; RfcommRXConnectionGroup rfcommConnectionGroup = new RfcommRXConnectionGroup(BluetoothManager, rxConnManager); rxConnManager.AddConnectionGroup(rfcommConnectionGroup); }
public TestServiceWrapper(IBluetoothManager bluetoothManager) { IGattServiceBuilder builder = bluetoothManager.NewGattServiceBuilder(); builder.SetUuid(SERVICE_UUID).SetServiceType(GattServiceType.Primary); TestCharacteristicWrapper = new TestCharacteristicWrapper(bluetoothManager); KeepNotifyingCharacteristicWrapper = new KeepNotifyingCharacteristicWrapper(bluetoothManager); builder.AddCharacteristics(TestCharacteristicWrapper.GattServerCharacteristic); builder.AddCharacteristics(KeepNotifyingCharacteristicWrapper.GattServerCharacteristic); GattServerService = builder.Build(); }
public BleDeviceSelectorDialog(IBluetoothManager bluetoothManager, ConnectionProfile connectionProfile) { ScanResultItemSource = new ObservableCollection <BleDeviceViewModel>(); BluetoothManager = bluetoothManager; ConnectionProfile = connectionProfile; this.InitializeComponent(); ScanResultListView.ItemsSource = ScanResultItemSource; ConnectButton.Click += ConnectButton_Click; Opened += BleDeviceSelectorDialog_Opened; Closed += BleDeviceSelectorDialog_Closed; }
public TranspondCharacteristicWrapper(IBluetoothManager bluetoothManager) { ClientCharacteristicConfigurationDescriptorWrapper = new ClientCharacteristicConfigurationDescriptorWrapper(bluetoothManager); var builder = bluetoothManager.NewGattCharacteristicBuilder(); GattServerCharacteristic = builder.SetUuid(UUID) .AddDescriptors(ClientCharacteristicConfigurationDescriptorWrapper.GattServerDescriptor) .SetPermissions(PERMISSIONS) .SetProperties(PROPERTIES) .Build(); }
public KeyboardServiceWrapper(IBluetoothManager bluetoothManager) { BluetoothManager = bluetoothManager; KeyActionCharacteristicWrapper = new KeyActionCharacteristicWrapper(this); MouseActionCharacteristicWrapper = new MouseActionCharacteristicWrapper(this); GattServerService = BluetoothManager.NewGattServiceBuilder() .SetUuid(Guid) .AddCharacteristics(KeyActionCharacteristicWrapper.GattServerCharacteristic) .AddCharacteristics(MouseActionCharacteristicWrapper.GattServerCharacteristic) .Build(); }
public DeviceInfomationServiceBuilder(IBluetoothManager bluetoothManager) { BluetoothManager = bluetoothManager; var manufacturerNameStringCharacteristic = new ManufacturerNameStringCharacteristicBuilder(BluetoothManager).Build(); manufacturerNameStringCharacteristic.OnRead += OnManufacturerNameStringCharacteristicRead; manufacturerNameStringCharacteristic.OnWrite += OnManufacturerNameStringCharacteristicWrite; _ServiceBuilder = BluetoothManager.NewGattServiceBuilder().SetUuid(SERVICE_DEVICE_INFORMATION) .SetServiceType(GattServiceType.Primary) .AddCharacteristics(manufacturerNameStringCharacteristic); }
public MainPageViewModel() { lbl1 = "Bluetoothデバイス一覧"; Initialize(); IBluetoothManager btMan = DependencyService.Get <IBluetoothManager>(); btMan.DataReceived += (sender, e) => { Console.WriteLine("#debug {0}", e.Data); }; btMan.Start(); }
public SmartSwitchViewModel() { // instantiate/retrieve Bluetooth manager _btManager = DependencyService.Get<IBluetoothManager>(); _devices = new List<DeviceInfo>(); _devices.Add(SelectedDevice); // refresh command Refresh = new Command( async () => { try { // disconnect the Bluetooth mnager from any existing connections _btManager.Disconnect(); ErrorMessage = string.Empty; // get the paired devices and select the first one Devices = await _btManager.GetPairedDevices(); } catch (Exception ex) { ErrorMessage = ex.Message; } if (Devices.Count > 0) { // This was changed for Xamarin.Forms // SelectedDevice = Devices[0]; // SelectedDeviceIndex = -1; ; SelectedDeviceIndex = 0; } // Notify the listeners of the affected properties RaisePropertyChanged("CanConnect"); RaisePropertyChanged("IsConnected"); }); // Connect command Connect = new Command(async () => await ConnectToBT(), () => CanConnect); // there is no command for OnOff as WindowsPhone does not support it for toggleSwitch // instead IsOn property is used. // if you wish to use plug-in and a command to launch web browser, this may be helpful // http://stackoverflow.com/questions/16616774/mvvmcross-how-to-navigate-to-something-besides-a-viewmodel }