public bool Transmit(BluetoothGattCharacteristicModel characteristicModel, byte[] buffer) { /*BluetoothGattCharacteristic characteristic = * new BluetoothGattCharacteristic(UUID.FromString(characteristicModel.Uuid.ToString()), * (Android.Bluetooth.GattProperty)characteristicModel.Properties, * (Android.Bluetooth.GattPermission)characteristicModel.Permissions);*/ var characteristic = _gatt.GetService(UUID.FromString(characteristicModel.ServiceUuid.ToString())) .GetCharacteristic(UUID.FromString(characteristicModel.Uuid.ToString())); characteristic.SetValue(buffer); bool result = _gatt.WriteCharacteristic(characteristic); return(result); }
public bool Transmit(BluetoothGattCharacteristicModel characteristicModel, byte[] buffer) { bool result = default; if (_gatt.Connect()) { var characteristic = _gatt.GetService(Java.Util.UUID.FromString(characteristicModel.ServiceUuid.ToString())) .GetCharacteristic(Java.Util.UUID.FromString(characteristicModel.Uuid.ToString())); characteristic.SetValue(buffer); result = _gatt.WriteCharacteristic(characteristic); } return(result); }
public bool Notify(BluetoothGattCharacteristicModel bluetoothGattCharacteristicModel) { const bool Enable = true; var characteristic = _gatt.GetService(Java.Util.UUID.FromString(bluetoothGattCharacteristicModel.ServiceUuid.ToString())) .GetCharacteristic(Java.Util.UUID.FromString(bluetoothGattCharacteristicModel.Uuid.ToString())); bool result = _gatt.SetCharacteristicNotification(characteristic, Enable); foreach (var descriptor in characteristic.Descriptors) { descriptor.SetValue(BluetoothGattDescriptor.EnableNotificationValue.ToArray()); _gatt.WriteDescriptor(descriptor); } return(result); }
public byte[] Recive(BluetoothGattCharacteristicModel bluetoothGattCharacteristicModel) { byte[] result; var characteristic = _gatt.GetService(Java.Util.UUID.FromString(bluetoothGattCharacteristicModel.ServiceUuid.ToString())) .GetCharacteristic(Java.Util.UUID.FromString(bluetoothGattCharacteristicModel.Uuid.ToString())); if (_gatt.ReadCharacteristic(characteristic)) { result = characteristic.GetValue(); } else { result = default; } return(result); }
public bool Transmit(BluetoothGattCharacteristicModel characteristicModel, Memory <byte> buffer) { return(Transmit(characteristicModel, buffer.ToArray())); }