Xamarin Plugin.BLE // I can't pull data

Viewed 131

There is a device that measures tire tread depth and air pressure. I made a connection but I can't pull data. Can you direct me on how to do it? I pulled data using Android DLLs but failed with plugin.ble. Note: The state in the device object disconnect after a certain time. I do not know the reason.

Source code I wrote

Part-1

bluetoothBLE = CrossBluetoothLE.Current;
adapter = CrossBluetoothLE.Current.Adapter;
list = new ObservableCollection();
DevicesList.ItemsSource = list;

Part-2

adapter.ScanTimeout = 10000;
adapter.ScanMode = ScanMode.Balanced;
adapter.DeviceDiscovered += (obj, a) =>
{
if (!list.Contains(a.Device))
list.Add(a.Device);
};
await adapter.StartScanningForDevicesAsync();

Part-3

device = DevicesList.SelectedItem as IDevice;
await adapter.StopScanningForDevicesAsync();
var connectParams = new ConnectParameters(true, true);
await adapter.ConnectToDeviceAsync(device, connectParams);

Part-4

var xservices = await device.GetServicesAsync();
var xservice = await device.GetServiceAsync(xservices[0].Id);
var Characteristic = await xservice.GetCharacteristicsAsync();
var xxxcharacteristicread = await xservice.GetCharacteristicAsync(xitem.Id);
var c = await xxxcharacteristicread.ReadAsync();

Version of the Plugin: 2.1.1

Platform: iOS 10.1 / Android 7.0

Device: samsung note 5 /i Phone 7

0 Answers
Related