diff options
author | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2022-02-12 01:51:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-12 01:51:46 +0100 |
commit | 96677c1f5a2da8aa5b43602eb5332bbaf6b6d403 (patch) | |
tree | d12fe3735835e541ed149180140e85bfcd7ce8ad | |
parent | ba31fc03d97facc54efb9456901abf02549a4209 (diff) | |
parent | dd568798094372284fd8334888f07c25d565be83 (diff) | |
download | nrf-softdevice-96677c1f5a2da8aa5b43602eb5332bbaf6b6d403.zip |
Merge pull request #101 from danielzfranklin/master
Add FixedGattValue for bool
-rw-r--r-- | nrf-softdevice/src/ble/gatt_traits.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/nrf-softdevice/src/ble/gatt_traits.rs b/nrf-softdevice/src/ble/gatt_traits.rs index 1916687..490e59a 100644 --- a/nrf-softdevice/src/ble/gatt_traits.rs +++ b/nrf-softdevice/src/ble/gatt_traits.rs @@ -75,6 +75,21 @@ impl<T: Primitive> FixedGattValue for T { } } +impl FixedGattValue for bool { + const SIZE: usize = 1; + + fn from_gatt(data: &[u8]) -> Self { + data != [0x00] + } + + fn to_gatt(&self) -> &[u8] { + match self { + true => &[0x01], + false => &[0x00], + } + } +} + impl<const N: usize> GattValue for Vec<u8, N> { const MIN_SIZE: usize = 0; const MAX_SIZE: usize = N; |