diff --git a/src/server/ble_2904.rs b/src/server/ble_2904.rs deleted file mode 100644 index c13a23e..0000000 --- a/src/server/ble_2904.rs +++ /dev/null @@ -1,107 +0,0 @@ -use alloc::sync::Arc; -use zerocopy::{IntoBytes, TryFromBytes}; -use zerocopy_derive::{Immutable, IntoBytes, KnownLayout, TryFromBytes}; - -use crate::{utilities::mutex::Mutex, BLEDescriptor}; - -#[derive(TryFromBytes, KnownLayout, IntoBytes, Immutable)] -#[repr(u8)] -pub enum BLE2904Format { - BOOLEAN = 1, - UINT2 = 2, - UINT4 = 3, - UINT8 = 4, - UINT12 = 5, - UINT16 = 6, - UINT24 = 7, - UINT32 = 8, - UINT48 = 9, - UINT64 = 10, - UINT128 = 11, - SINT8 = 12, - SINT12 = 13, - SINT16 = 14, - SINT24 = 15, - SINT32 = 16, - SINT48 = 17, - SINT64 = 18, - SINT128 = 19, - FLOAT32 = 20, - FLOAT64 = 21, - SFLOAT16 = 22, - SFLOAT32 = 23, - IEEE20601 = 24, - UTF8 = 25, - UTF16 = 26, - OPAQUE = 27, -} - -#[derive(TryFromBytes, KnownLayout, IntoBytes, Immutable)] -#[repr(packed)] -struct Data { - format: BLE2904Format, - exponent: u8, - unit: u16, - namespace: u8, - description: u16, -} - -pub struct BLE2904 { - descriptor: Arc>, -} - -impl BLE2904 { - pub(super) fn new(descriptor: Arc>) -> Self { - descriptor.lock().set_value( - Data { - format: BLE2904Format::OPAQUE, - exponent: 0, - unit: 0, - namespace: 1, - description: 0, - } - .as_bytes(), - ); - - Self { descriptor } - } - - pub fn format(&mut self, value: BLE2904Format) -> &mut Self { - Data::try_mut_from_bytes(self.descriptor.lock().value_mut().as_mut_slice()) - .unwrap() - .format = value; - - self - } - - pub fn exponent(&mut self, value: u8) -> &mut Self { - Data::try_mut_from_bytes(self.descriptor.lock().value_mut().as_mut_slice()) - .unwrap() - .exponent = value; - - self - } - - pub fn unit(&mut self, value: u16) -> &mut Self { - Data::try_mut_from_bytes(self.descriptor.lock().value_mut().as_mut_slice()) - .unwrap() - .unit = value; - - self - } - - pub fn namespace(&mut self, value: u8) -> &mut Self { - Data::try_mut_from_bytes(self.descriptor.lock().value_mut().as_mut_slice()) - .unwrap() - .namespace = value; - - self - } - pub fn description(&mut self, value: u16) -> &mut Self { - Data::try_mut_from_bytes(self.descriptor.lock().value_mut().as_mut_slice()) - .unwrap() - .description = value; - - self - } -} diff --git a/src/server/ble_characteristic.rs b/src/server/ble_characteristic.rs index f7f6c82..be2feef 100644 --- a/src/server/ble_characteristic.rs +++ b/src/server/ble_characteristic.rs @@ -2,18 +2,17 @@ use alloc::{boxed::Box, sync::Arc, vec::Vec}; use bitflags::bitflags; use core::{cell::UnsafeCell, ffi::c_void}; use esp_idf_svc::sys; - -#[cfg(cpfd)] -use crate::cpfd::Cpfd; +#[cfg(not(cpfd))] +use zerocopy::IntoBytes; use crate::{ ble, + cpfd::Cpfd, utilities::{ ble_hs_mbuf_from_flat, ble_npl_hw_enter_critical, ble_npl_hw_exit_critical, mutex::Mutex, os_mbuf_append, voidp_to_ref, BleUuid, }, AttValue, BLEConnDesc, BLEDescriptor, BLEDevice, BLEError, DescriptorProperties, OnWriteArgs, - BLE2904, }; cfg_if::cfg_if! { @@ -209,15 +208,6 @@ impl BLECharacteristic { descriptor } - pub fn create_2904_descriptor(&mut self) -> BLE2904 { - let descriptor = Arc::new(Mutex::new(BLEDescriptor::new( - BleUuid::Uuid16(0x2904), - DescriptorProperties::READ, - ))); - self.descriptors.push(descriptor.clone()); - BLE2904::new(descriptor) - } - pub(crate) fn construct_svc_def_descriptors(&mut self) -> *mut sys::ble_gatt_dsc_def { if self.descriptors.is_empty() { return core::ptr::null_mut(); @@ -300,6 +290,17 @@ impl BLECharacteristic { self.cpfd[0].description = cpfd.description; } + #[cfg(not(cpfd))] + /// Set the Characteristic Presentation Format. + pub fn cpfd(&mut self, cpfd: Cpfd) { + let descriptor = Arc::new(Mutex::new(BLEDescriptor::new( + BleUuid::Uuid16(0x2904), + DescriptorProperties::READ, + ))); + descriptor.lock().set_value(cpfd.as_bytes()); + self.descriptors.push(descriptor); + } + pub(super) extern "C" fn handle_gap_event( conn_handle: u16, _attr_handle: u16, diff --git a/src/server/ble_hid_device.rs b/src/server/ble_hid_device.rs index 6cdae30..7341a53 100644 --- a/src/server/ble_hid_device.rs +++ b/src/server/ble_hid_device.rs @@ -1,9 +1,9 @@ use alloc::sync::Arc; use crate::{ + cpfd::*, utilities::{mutex::Mutex, BleUuid}, - BLE2904Format, BLECharacteristic, BLEServer, BLEService, DescriptorProperties, NimbleProperties, - BLE2904, + BLECharacteristic, BLEServer, BLEService, DescriptorProperties, NimbleProperties, }; const BLE_SVC_DIS_CHR_UUID16_MANUFACTURER_NAME: BleUuid = BleUuid::from_uuid16(0x2A29); @@ -24,7 +24,6 @@ pub struct BLEHIDDevice { battery_service: Arc>, battery_level_characteristic: Arc>, - battery_level_descriptor: BLE2904, } impl BLEHIDDevice { @@ -56,11 +55,13 @@ impl BLEHIDDevice { BLE_SVC_BAS_CHR_UUID16_BATTERY_LEVEL, NimbleProperties::READ | NimbleProperties::NOTIFY, ); - let mut battery_level_descriptor = battery_level_characteristic.lock().create_2904_descriptor(); - battery_level_descriptor - .format(BLE2904Format::UINT8) - .namespace(1) - .unit(0x27ad); + battery_level_characteristic.lock().cpfd(Cpfd { + format: ChrFormat::Uint8, + exponent: 0, + unit: ChrUnit::Percentage, + name_space: 1, + description: 0, + }); Self { device_info_service, @@ -73,7 +74,6 @@ impl BLEHIDDevice { protocol_mode_characteristic, battery_service, battery_level_characteristic, - battery_level_descriptor, } } diff --git a/src/server/cpfd.rs b/src/server/cpfd.rs index fbfae10..20cba9e 100644 --- a/src/server/cpfd.rs +++ b/src/server/cpfd.rs @@ -1,7 +1,17 @@ -use esp_idf_svc::sys as esp_idf_sys; use num_enum::IntoPrimitive; +use zerocopy_derive::{Immutable, IntoBytes, KnownLayout, TryFromBytes}; -#[derive(Copy, Clone, PartialEq, Eq, Debug, IntoPrimitive)] +cfg_if::cfg_if! { + if #[cfg(cpfd)] { + use esp_idf_svc::sys as esp_idf_sys; + } else { + use super::cpfd_constants as esp_idf_sys; + } +} + +#[derive( + Copy, Clone, PartialEq, Eq, Debug, IntoPrimitive, TryFromBytes, KnownLayout, IntoBytes, Immutable, +)] #[repr(u8)] pub enum ChrFormat { Boolean = esp_idf_sys::BLE_GATT_CHR_FORMAT_BOOLEAN as _, @@ -34,7 +44,9 @@ pub enum ChrFormat { Medasn1 = esp_idf_sys::BLE_GATT_CHR_FORMAT_MEDASN1 as _, } -#[derive(Copy, Clone, PartialEq, Eq, Debug, IntoPrimitive)] +#[derive( + Copy, Clone, PartialEq, Eq, Debug, IntoPrimitive, TryFromBytes, KnownLayout, IntoBytes, Immutable, +)] #[repr(u16)] pub enum ChrUnit { /// Unitless @@ -295,6 +307,8 @@ pub enum ChrUnit { VoltAmpere = esp_idf_sys::BLE_GATT_CHR_UNIT_VOLT_AMPERE as _, } +#[derive(TryFromBytes, KnownLayout, IntoBytes, Immutable)] +#[repr(packed)] pub struct Cpfd { /// Format of the value of this characteristic. pub format: ChrFormat, diff --git a/src/server/cpfd_constants.rs b/src/server/cpfd_constants.rs new file mode 100644 index 0000000..0ab3f05 --- /dev/null +++ b/src/server/cpfd_constants.rs @@ -0,0 +1,155 @@ +pub(crate) const BLE_GATT_CHR_FORMAT_BOOLEAN: u8 = 0x01; +pub(crate) const BLE_GATT_CHR_FORMAT_UINT2: u8 = 0x02; +pub(crate) const BLE_GATT_CHR_FORMAT_UINT4: u8 = 0x03; +pub(crate) const BLE_GATT_CHR_FORMAT_UINT8: u8 = 0x04; +pub(crate) const BLE_GATT_CHR_FORMAT_UINT12: u8 = 0x05; +pub(crate) const BLE_GATT_CHR_FORMAT_UINT16: u8 = 0x06; +pub(crate) const BLE_GATT_CHR_FORMAT_UINT24: u8 = 0x07; +pub(crate) const BLE_GATT_CHR_FORMAT_UINT32: u8 = 0x08; +pub(crate) const BLE_GATT_CHR_FORMAT_UINT48: u8 = 0x09; +pub(crate) const BLE_GATT_CHR_FORMAT_UINT64: u8 = 0x0A; +pub(crate) const BLE_GATT_CHR_FORMAT_UINT128: u8 = 0x0B; +pub(crate) const BLE_GATT_CHR_FORMAT_SINT8: u8 = 0x0C; +pub(crate) const BLE_GATT_CHR_FORMAT_SINT12: u8 = 0x0D; +pub(crate) const BLE_GATT_CHR_FORMAT_SINT16: u8 = 0x0E; +pub(crate) const BLE_GATT_CHR_FORMAT_SINT24: u8 = 0x0F; +pub(crate) const BLE_GATT_CHR_FORMAT_SINT32: u8 = 0x10; +pub(crate) const BLE_GATT_CHR_FORMAT_SINT48: u8 = 0x11; +pub(crate) const BLE_GATT_CHR_FORMAT_SINT64: u8 = 0x12; +pub(crate) const BLE_GATT_CHR_FORMAT_SINT128: u8 = 0x13; +pub(crate) const BLE_GATT_CHR_FORMAT_FLOAT32: u8 = 0x14; +pub(crate) const BLE_GATT_CHR_FORMAT_FLOAT64: u8 = 0x15; +pub(crate) const BLE_GATT_CHR_FORMAT_MEDFLOAT16: u8 = 0x16; +pub(crate) const BLE_GATT_CHR_FORMAT_MEDFLOAT32: u8 = 0x17; +pub(crate) const BLE_GATT_CHR_FORMAT_UINT16_2: u8 = 0x18; +pub(crate) const BLE_GATT_CHR_FORMAT_UTF8S: u8 = 0x19; +pub(crate) const BLE_GATT_CHR_FORMAT_UTF16S: u8 = 0x1A; +pub(crate) const BLE_GATT_CHR_FORMAT_STRUCT: u8 = 0x1B; +pub(crate) const BLE_GATT_CHR_FORMAT_MEDASN1: u8 = 0x1C; + +pub(crate) const BLE_GATT_CHR_UNIT_UNITLESS: u16 = 0x2700; /* Unitless */ +pub(crate) const BLE_GATT_CHR_UNIT_METRE: u16 = 0x2701; /* Length */ +pub(crate) const BLE_GATT_CHR_UNIT_KILOGRAM: u16 = 0x2702; /* Mass */ +pub(crate) const BLE_GATT_CHR_UNIT_SECOND: u16 = 0x2703; /* Time */ +pub(crate) const BLE_GATT_CHR_UNIT_AMPERE: u16 = 0x2704; /* Electric Current */ +pub(crate) const BLE_GATT_CHR_UNIT_KELVIN: u16 = 0x2705; /* Thermodynamic Temperature */ +pub(crate) const BLE_GATT_CHR_UNIT_MOLE: u16 = 0x2706; /* Amount Of Substance */ +pub(crate) const BLE_GATT_CHR_UNIT_CANDELA: u16 = 0x2707; /* Luminous Intensity */ +pub(crate) const BLE_GATT_CHR_UNIT_SQUARE_METRES: u16 = 0x2710; /* Area */ +pub(crate) const BLE_GATT_CHR_UNIT_CUBIC_METRES: u16 = 0x2711; /* Volume */ +pub(crate) const BLE_GATT_CHR_UNIT_METRES_PER_SECOND: u16 = 0x2712; /* Velocity */ +pub(crate) const BLE_GATT_CHR_UNIT_METRES_PER_SECOND_SQUARED: u16 = 0x2713; /* Acceleration */ +pub(crate) const BLE_GATT_CHR_UNIT_RECIPROCAL_METRE: u16 = 0x2714; /* Wavenumber */ +pub(crate) const BLE_GATT_CHR_UNIT_KILOGRAM_PER_CUBIC_METRE_DENSITY: u16 = 0x2715; /* Density */ +pub(crate) const BLE_GATT_CHR_UNIT_KILOGRAM_PER_SQUARE_METRE: u16 = 0x2716; /* Surface Density */ +pub(crate) const BLE_GATT_CHR_UNIT_CUBIC_METRE_PER_KILOGRAM: u16 = 0x2717; /* Specific Volume */ +pub(crate) const BLE_GATT_CHR_UNIT_AMPERE_PER_SQUARE_METRE: u16 = 0x2718; /* Current Density */ +pub(crate) const BLE_GATT_CHR_UNIT_AMPERE_PER_METRE: u16 = 0x2719; /* Magnetic Field Strength */ +pub(crate) const BLE_GATT_CHR_UNIT_MOLE_PER_CUBIC_METRE: u16 = 0x271A; /* Amount Concentration */ +pub(crate) const BLE_GATT_CHR_UNIT_KILOGRAM_PER_CUBIC_METRE_MASS_CONC: u16 = 0x271B; /* Mass Concentration */ +pub(crate) const BLE_GATT_CHR_UNIT_CANDELA_PER_SQUARE_METRE: u16 = 0x271C; /* Luminance */ +pub(crate) const BLE_GATT_CHR_UNIT_REFRACTIVE_INDEX: u16 = 0x271D; /* Refractive Index */ +pub(crate) const BLE_GATT_CHR_UNIT_RELATIVE_PERMEABILITY: u16 = 0x271E; /* Relative Permeability */ +pub(crate) const BLE_GATT_CHR_UNIT_RADIAN: u16 = 0x2720; /* Plane Angle */ +pub(crate) const BLE_GATT_CHR_UNIT_STERADIAN: u16 = 0x2721; /* Solid Angle */ +pub(crate) const BLE_GATT_CHR_UNIT_HERTZ: u16 = 0x2722; /* Frequency */ +pub(crate) const BLE_GATT_CHR_UNIT_NEWTON: u16 = 0x2723; /* Force */ +pub(crate) const BLE_GATT_CHR_UNIT_PASCAL: u16 = 0x2724; /* Pressure */ +pub(crate) const BLE_GATT_CHR_UNIT_JOULE: u16 = 0x2725; /* Energy */ +pub(crate) const BLE_GATT_CHR_UNIT_WATT: u16 = 0x2726; /* Power */ +pub(crate) const BLE_GATT_CHR_UNIT_COULOMB: u16 = 0x2727; /* Electric Charge */ +pub(crate) const BLE_GATT_CHR_UNIT_VOLT: u16 = 0x2728; /* Electric Potential Difference */ +pub(crate) const BLE_GATT_CHR_UNIT_FARAD: u16 = 0x2729; /* Capacitance */ +pub(crate) const BLE_GATT_CHR_UNIT_OHM: u16 = 0x272A; /* Electric Resistance */ +pub(crate) const BLE_GATT_CHR_UNIT_SIEMENS: u16 = 0x272B; /* Electric Conductance */ +pub(crate) const BLE_GATT_CHR_UNIT_WEBER: u16 = 0x272C; /* Magnetic Flux */ +pub(crate) const BLE_GATT_CHR_UNIT_TESLA: u16 = 0x272D; /* Magnetic Flux Density */ +pub(crate) const BLE_GATT_CHR_UNIT_HENRY: u16 = 0x272E; /* Inductance */ +pub(crate) const BLE_GATT_CHR_UNIT_DEGREE_CELSIUS: u16 = 0x272F; /* celsius Temperature */ +pub(crate) const BLE_GATT_CHR_UNIT_LUMEN: u16 = 0x2730; /* Luminous Flux */ +pub(crate) const BLE_GATT_CHR_UNIT_LUX: u16 = 0x2731; /* Illuminance */ +pub(crate) const BLE_GATT_CHR_UNIT_BECQUEREL: u16 = 0x2732; /* Activity Referred To A Radionuclide */ +pub(crate) const BLE_GATT_CHR_UNIT_GRAY: u16 = 0x2733; /* Absorbed Dose */ +pub(crate) const BLE_GATT_CHR_UNIT_SIEVERT: u16 = 0x2734; /* Dose Equivalent */ +pub(crate) const BLE_GATT_CHR_UNIT_KATAL: u16 = 0x2735; /* Catalytic Activity */ +pub(crate) const BLE_GATT_CHR_UNIT_PASCAL_SECOND: u16 = 0x2740; /* Dynamic Viscosity */ +pub(crate) const BLE_GATT_CHR_UNIT_NEWTON_METRE: u16 = 0x2741; /* Moment Of Force */ +pub(crate) const BLE_GATT_CHR_UNIT_NEWTON_PER_METRE: u16 = 0x2742; /* Surface Tension */ +pub(crate) const BLE_GATT_CHR_UNIT_RADIAN_PER_SECOND: u16 = 0x2743; /* Angular Velocity */ +pub(crate) const BLE_GATT_CHR_UNIT_RADIAN_PER_SECOND_SQUARED: u16 = 0x2744; /* Angular Acceleration */ +pub(crate) const BLE_GATT_CHR_UNIT_WATT_PER_SQUARE_METRE_HEAT: u16 = 0x2745; /* Heat Flux Density */ +pub(crate) const BLE_GATT_CHR_UNIT_JOULE_PER_KELVIN: u16 = 0x2746; /* Heat Capacity */ +pub(crate) const BLE_GATT_CHR_UNIT_JOULE_PER_KILOGRAM_KELVIN: u16 = 0x2747; /* Specific Heat Capacity */ +pub(crate) const BLE_GATT_CHR_UNIT_JOULE_PER_KILOGRAM: u16 = 0x2748; /* Specific Energy */ +pub(crate) const BLE_GATT_CHR_UNIT_WATT_PER_METRE_KELVIN: u16 = 0x2749; /* Thermal Conductivity */ +pub(crate) const BLE_GATT_CHR_UNIT_JOULE_PER_CUBIC_METRE: u16 = 0x274A; /* Energy Density */ +pub(crate) const BLE_GATT_CHR_UNIT_VOLT_PER_METRE: u16 = 0x274B; /* Electric Field Strength */ +pub(crate) const BLE_GATT_CHR_UNIT_COULOMB_PER_CUBIC_METRE: u16 = 0x274C; /* Electric Charge Density */ +pub(crate) const BLE_GATT_CHR_UNIT_COULOMB_PER_SQUARE_METRE_CHARGE: u16 = 0x274D; /* Surface Charge Density */ +pub(crate) const BLE_GATT_CHR_UNIT_COULOMB_PER_SQUARE_METRE_FLUX: u16 = 0x274E; /* Electric Flux Density */ +pub(crate) const BLE_GATT_CHR_UNIT_FARAD_PER_METRE: u16 = 0x274F; /* Permittivity */ +pub(crate) const BLE_GATT_CHR_UNIT_HENRY_PER_METRE: u16 = 0x2750; /* Permeability */ +pub(crate) const BLE_GATT_CHR_UNIT_JOULE_PER_MOLE: u16 = 0x2751; /* Molar Energy */ +pub(crate) const BLE_GATT_CHR_UNIT_JOULE_PER_MOLE_KELVIN: u16 = 0x2752; /* Molar Entropy */ +pub(crate) const BLE_GATT_CHR_UNIT_COULOMB_PER_KILOGRAM: u16 = 0x2753; /* Exposure */ +pub(crate) const BLE_GATT_CHR_UNIT_GRAY_PER_SECOND: u16 = 0x2754; /* Absorbed Dose Rate */ +pub(crate) const BLE_GATT_CHR_UNIT_WATT_PER_STERADIAN: u16 = 0x2755; /* Radiant Intensity */ +pub(crate) const BLE_GATT_CHR_UNIT_WATT_PER_SQUARE_METRE_STERADIAN: u16 = 0x2756; /* Radiance */ +pub(crate) const BLE_GATT_CHR_UNIT_KATAL_PER_CUBIC_METRE: u16 = 0x2757; /* Catalytic Activity Concentration */ +pub(crate) const BLE_GATT_CHR_UNIT_MINUTE: u16 = 0x2760; /* Time */ +pub(crate) const BLE_GATT_CHR_UNIT_HOUR: u16 = 0x2761; /* Time */ +pub(crate) const BLE_GATT_CHR_UNIT_DAY: u16 = 0x2762; /* Time */ +pub(crate) const BLE_GATT_CHR_UNIT_DEGREE: u16 = 0x2763; /* Plane Angle */ +pub(crate) const BLE_GATT_CHR_UNIT_MINUTE_ANGLE: u16 = 0x2764; /* Plane Angle */ +pub(crate) const BLE_GATT_CHR_UNIT_SECOND_ANGLE: u16 = 0x2765; /* Plane Angle */ +pub(crate) const BLE_GATT_CHR_UNIT_HECTARE: u16 = 0x2766; /* Area */ +pub(crate) const BLE_GATT_CHR_UNIT_LITRE: u16 = 0x2767; /* Volume */ +pub(crate) const BLE_GATT_CHR_UNIT_TONNE: u16 = 0x2768; /* Mass */ +pub(crate) const BLE_GATT_CHR_UNIT_BAR: u16 = 0x2780; /* Pressure */ +pub(crate) const BLE_GATT_CHR_UNIT_MILLIMETRE_OF_MERCURY: u16 = 0x2781; /* Pressure */ +pub(crate) const BLE_GATT_CHR_UNIT_ANGSTROM: u16 = 0x2782; /* Length */ +pub(crate) const BLE_GATT_CHR_UNIT_NAUTICAL_MILE: u16 = 0x2783; /* Length */ +pub(crate) const BLE_GATT_CHR_UNIT_BARN: u16 = 0x2784; /* Area */ +pub(crate) const BLE_GATT_CHR_UNIT_KNOT: u16 = 0x2785; /* Velocity */ +pub(crate) const BLE_GATT_CHR_UNIT_NEPER: u16 = 0x2786; /* Logarithmic Radio Quantity */ +pub(crate) const BLE_GATT_CHR_UNIT_BEL: u16 = 0x2787; /* Logarithmic Radio Quantity */ +pub(crate) const BLE_GATT_CHR_UNIT_YARD: u16 = 0x27A0; /* Length */ +pub(crate) const BLE_GATT_CHR_UNIT_PARSEC: u16 = 0x27A1; /* Length */ +pub(crate) const BLE_GATT_CHR_UNIT_INCH: u16 = 0x27A2; /* Length */ +pub(crate) const BLE_GATT_CHR_UNIT_FOOT: u16 = 0x27A3; /* Length */ +pub(crate) const BLE_GATT_CHR_UNIT_MILE: u16 = 0x27A4; /* Length */ +pub(crate) const BLE_GATT_CHR_UNIT_POUND_FORCE_PER_SQUARE_INCH: u16 = 0x27A5; /* Pressure */ +pub(crate) const BLE_GATT_CHR_UNIT_KILOMETRE_PER_HOUR: u16 = 0x27A6; /* Velocity */ +pub(crate) const BLE_GATT_CHR_UNIT_MILE_PER_HOUR: u16 = 0x27A7; /* Velocity */ +pub(crate) const BLE_GATT_CHR_UNIT_REVOLUTION_PER_MINUTE: u16 = 0x27A8; /* Angular Velocity */ +pub(crate) const BLE_GATT_CHR_UNIT_GRAM_CALORIE: u16 = 0x27A9; /* Energy */ +pub(crate) const BLE_GATT_CHR_UNIT_KILOGRAM_CALORIE: u16 = 0x27AA; /* Energy */ +pub(crate) const BLE_GATT_CHR_UNIT_KILOWATT_HOUR: u16 = 0x27AB; /* Energy */ +pub(crate) const BLE_GATT_CHR_UNIT_DEGREE_FAHRENHEIT: u16 = 0x27AC; /* Thermodynamic Temperature */ +pub(crate) const BLE_GATT_CHR_UNIT_PERCENTAGE: u16 = 0x27AD; /* Percentage */ +pub(crate) const BLE_GATT_CHR_UNIT_PER_MILLE: u16 = 0x27AE; /* Per Mille */ +pub(crate) const BLE_GATT_CHR_UNIT_BEATS_PER_MINUTE: u16 = 0x27AF; /* Period */ +pub(crate) const BLE_GATT_CHR_UNIT_AMPERE_HOURS: u16 = 0x27B0; /* Electric Charge */ +pub(crate) const BLE_GATT_CHR_UNIT_MILLIGRAM_PER_DECILITRE: u16 = 0x27B1; /* Mass Density */ +pub(crate) const BLE_GATT_CHR_UNIT_MILLIMOLE_PER_LITRE: u16 = 0x27B2; /* Mass Density */ +pub(crate) const BLE_GATT_CHR_UNIT_YEAR: u16 = 0x27B3; /* Time */ +pub(crate) const BLE_GATT_CHR_UNIT_MONTH: u16 = 0x27B4; /* Time */ +pub(crate) const BLE_GATT_CHR_UNIT_COUNT_PER_CUBIC_METRE: u16 = 0x27B5; /* Concentration */ +pub(crate) const BLE_GATT_CHR_UNIT_WATT_PER_SQUARE_METRE_IRRADIANCE: u16 = 0x27B6; /* Irradiance */ +pub(crate) const BLE_GATT_CHR_UNIT_PER_KILOGRAM_PER_MINUTE: u16 = 0x27B7; /* Milliliter */ +pub(crate) const BLE_GATT_CHR_UNIT_POUND: u16 = 0x27B8; /* Mass */ +pub(crate) const BLE_GATT_CHR_UNIT_METABOLIC_EQUIVALENT: u16 = 0x27B9; /* Metabolic Equivalent */ +pub(crate) const BLE_GATT_CHR_UNIT_PER_MINUTE_STEP: u16 = 0x27BA; /* Step */ +pub(crate) const BLE_GATT_CHR_UNIT_PER_MINUTE_STROKE: u16 = 0x27BC; /* Stroke */ +pub(crate) const BLE_GATT_CHR_UNIT_KILOMETRE_PER_MINUTE: u16 = 0x27BD; /* Pace */ +pub(crate) const BLE_GATT_CHR_UNIT_LUMEN_PER_WATT: u16 = 0x27BE; /* Luminous Efficacy */ +pub(crate) const BLE_GATT_CHR_UNIT_LUMEN_HOUR: u16 = 0x27BF; /* Luminous Energy */ +pub(crate) const BLE_GATT_CHR_UNIT_LUX_HOUR: u16 = 0x27C0; /* Luminous Exposure */ +pub(crate) const BLE_GATT_CHR_UNIT_GRAM_PER_SECOND: u16 = 0x27C1; /* Mass Flow */ +pub(crate) const BLE_GATT_CHR_UNIT_LITRE_PER_SECOND: u16 = 0x27C2; /* Volume Flow */ +pub(crate) const BLE_GATT_CHR_UNIT_DECIBEL: u16 = 0x27C3; /* Sound Pressure */ +pub(crate) const BLE_GATT_CHR_UNIT_PARTS_PER_MILLION: u16 = 0x27C4; /* Concentration */ +pub(crate) const BLE_GATT_CHR_UNIT_PARTS_PER_BILLION: u16 = 0x27C5; /* Concentration */ +pub(crate) const BLE_GATT_CHR_UNIT_MILLIGRAM_PER_DECILITRE_PER_MINUTE: u16 = 0x27C6; /* Mass Density Rate */ +pub(crate) const BLE_GATT_CHR_UNIT_KILOVOLT_AMPERE_HOUR: u16 = 0x27C7; /* Electrical Apparent Energy */ +pub(crate) const BLE_GATT_CHR_UNIT_VOLT_AMPERE: u16 = 0x27C8; /* Electrical Apparent Power */ diff --git a/src/server/mod.rs b/src/server/mod.rs index 3ceb4a5..e4df6fa 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -1,9 +1,6 @@ mod att_value; pub use self::att_value::AttValue; -mod ble_2904; -pub use self::ble_2904::*; - mod ble_advertisement_data; pub use self::ble_advertisement_data::BLEAdvertisementData; @@ -34,8 +31,9 @@ pub use self::ble_server::BLEServer; mod ble_service; pub use self::ble_service::BLEService; -#[cfg(cpfd)] pub mod cpfd; +#[cfg(not(cpfd))] +mod cpfd_constants; pub mod hid;