diff --git a/features/FEATURE_BLE/ble/gap/Types.h b/features/FEATURE_BLE/ble/gap/Types.h index b3ec2d10e83..29117e0df83 100644 --- a/features/FEATURE_BLE/ble/gap/Types.h +++ b/features/FEATURE_BLE/ble/gap/Types.h @@ -31,18 +31,99 @@ namespace ble { */ /* BLE units, using microseconds as the common denominator */ -typedef Duration > adv_interval_t; -typedef Duration, Value > adv_duration_t; -typedef Duration, Value > scan_duration_t; -typedef Duration > scan_period_t; -typedef Duration > scan_interval_t; -typedef Duration > scan_window_t; -typedef Duration > conn_interval_t; + +/** + * Time interval between two advertisement. + * + * The duration is in unit of 625µs and ranges from 0x20 to 0xFFFFFF . + * + * @note before Bluetooth 5 range was 0x20 to 0xFFFF. + */ +typedef Duration > adv_interval_t; + +/** + * Advertising process duration. + * + * The duration is in unit of 10ms and ranges from 0x0001 to 0xFFFF. The special + * value 0x0000 means the advertising process never ends; it is accessible with + * adv_duration_t::forever(). + */ +typedef Duration, /* forever */ Value > adv_duration_t; + +/** + * Scan process duration. + * + * The duration is in unit of 10ms and ranges from 0x0001 to 0xFFFF. The special + * value 0x0000 means the scan process never ends; it is accessible with + * scan_duration_t::forever(). + */ +typedef Duration, /* forever */ Value > scan_duration_t; + +/** + * Time interval between two scan processes. + * + * The duration is in unit of 1.28s and ranges from 0x0001 to 0xFFFF. The special + * value 0x0000 is used to indicate that scan_period_t is not used. + */ +typedef Duration > scan_period_t; + +/** + * Time interval between two scan. + * + * The duration is in unit of 625µs and ranges from 0x04 to 0xFFFF . + */ +typedef Duration > scan_interval_t; + +/** + * Duration of a scan. + * + * The duration is in unit of 625µs and ranges from 0x04 to 0xFFFF . + */ +typedef Duration > scan_window_t; + +/** + * Time interval between two connection events. + * + * The interval is in unit of 1.250 milliseconds and ranges from 0x06 to 0xC80. + */ +typedef Duration > conn_interval_t; + +/** + * Time after which a connection is loss of devices have not exchanged data. + * + * The duration is in unit of 10 milliseconds and ranges from 0x0A to 0xC80. + * + * @note this time should be no larger than (1 + ConnLatency) * ConnIntervalMax * 2 + */ typedef Duration > supervision_timeout_t; + +/** + * Duration of a connection event. + * + * The duration is in unit of 625µs and ranges from 0x0 to 0xFFFF . + */ typedef Duration > conn_event_length_t; + +/** + * Time after which a periodic sync link is considered loss if the receiver hasn't + * receive anything from the advertiser. + * + * The duration is in unit of 10 milliseconds and ranges from 0x0A to 0x4000. + */ typedef Duration > sync_timeout_t; + +/** + * Interval between two periodic advertsising events. + * + * The duration is in unit of 1.250ms and ranges from 0x06 to 0xFFFF. + */ typedef Duration > periodic_interval_t; +/** + * Number of connection events that can be skipped by the slave. + * + * It ranges from 0 to 0x1F3. + */ typedef Bounded slave_latency_t; /** @@ -66,6 +147,7 @@ typedef uint16_t periodic_sync_handle_t; * devices in the scanning range. */ struct advertising_type_t : SafeEnum { + /// enumeration of advertising_type_t values enum type { /** * Device is connectable, scannable and doesn't expect connection from a @@ -109,6 +191,8 @@ struct advertising_type_t : SafeEnum { /** * Construct a new advertising_type_t value. + * + * @param value The value of the advertising_type_t created. */ advertising_type_t(type value) : SafeEnum(value) { @@ -119,19 +203,24 @@ struct advertising_type_t : SafeEnum { /** Used to indicate if the packet is complete and if it's truncated. */ struct advertising_data_status_t : SafeEnum { + /// enumeration of advertising_data_status_t values enum type { - COMPLETE = 0x00, /**< Advertising payload complete. */ - INCOMPLETE_MORE_DATA = 0x01, /**< Partial advertising payload, more to come. */ - INCOMPLETE_DATA_TRUNCATED = 0x02 /**< Advertising payload incomplete and no more is comoing. */ + COMPLETE = 0x00, /// Advertising payload complete. + INCOMPLETE_MORE_DATA = 0x01, /// Partial advertising payload, more to come. + INCOMPLETE_DATA_TRUNCATED = 0x02 /// Advertising payload incomplete and no more is coming. }; /** * Construct a new advertising_data_status_t value. + * + * @param value The value of the advertising_data_status_t created. */ advertising_data_status_t(type value) : SafeEnum(value) { } +#if !defined(DOXYGEN_ONLY) + /** * Explicit constructor from a raw value. */ @@ -139,6 +228,9 @@ struct advertising_data_status_t : SafeEnum SafeEnum(static_cast(raw_value)) { } + +#endif + }; /** Properties of an advertising event. @@ -286,32 +378,37 @@ typedef int8_t advertising_power_t; * @see Bluetooth Core Specification 4.2 (Vol. 6), Part B, Section 4.3.2. */ struct advertising_filter_policy_t : SafeEnum { + /// enumeration of advertising_filter_policy_t values enum type { /** * Process connection and scan requests from all devices. The whitelist is * not used. */ - NO_FILTER = 0x00, + NO_FILTER = 0x00, /** * Process connection requests from all devices but filter out scan requests * of devices which are not in the whitelist. */ - FILTER_SCAN_REQUESTS = 0x01, + FILTER_SCAN_REQUESTS = 0x01, /** * Process scan requests from all devices but filter out connection requests * of devices which are not in the whitelist. */ - FILTER_CONNECTION_REQUEST = 0x02, + FILTER_CONNECTION_REQUEST = 0x02, /** * Filter out scan or connection requests of devices which are not in the * whitelist. */ - FILTER_SCAN_AND_CONNECTION_REQUESTS = 0x03 + FILTER_SCAN_AND_CONNECTION_REQUESTS = 0x03 }; + /** + * Construct a advertising_filter_policy_t. + * @param value The value of the advertising_filter_policy_t created. + */ advertising_filter_policy_t(type value) : SafeEnum(value) { } @@ -323,6 +420,7 @@ struct advertising_filter_policy_t : SafeEnum { + /// enumeration of scanning_filter_policy_t values enum type { /** * Accept all advertising packets except directed advertising packet not @@ -336,7 +434,6 @@ struct scanning_filter_policy_t : SafeEnum { */ FILTER_ADVERTISING = 0x01, - /** * Accept all advertising packets except directed advertising packets * where the initiator's identity address does not address this device. @@ -361,6 +458,8 @@ struct scanning_filter_policy_t : SafeEnum { /** * Construct a new instance of scanning_filter_policy_t. + * + * @param value The value of the scanning_filter_policy_t created. */ scanning_filter_policy_t(type value) : SafeEnum(value) { @@ -371,6 +470,7 @@ struct scanning_filter_policy_t : SafeEnum { * Filter policy which can be used during connection initiation. */ struct initiator_filter_policy_t : SafeEnum { + /// enumeration of initiator_filter_policy_t values. enum type { /** * The whitelist is not used to determine which advertiser to connect to. @@ -383,6 +483,10 @@ struct initiator_filter_policy_t : SafeEnum USE_WHITE_LIST }; + /** + * Construct a initiator_filter_policy_t. + * @param value The value of the initiator_filter_policy_t. + */ initiator_filter_policy_t(type value) : SafeEnum(value) { } @@ -394,6 +498,7 @@ struct initiator_filter_policy_t : SafeEnum * @see Bluetooth Core Specification 4.2 (Vol. 6), Part B, Section 4.3.3. */ struct duplicates_filter_t : SafeEnum { + /// enumeration of duplicates_filter_t values enum type { /** * Disable duplicate filtering. @@ -413,6 +518,7 @@ struct duplicates_filter_t : SafeEnum { /** * Construct a new duplicates_filter_t value. + * @param value The value of the duplicates_filter_t created. */ duplicates_filter_t(type value) : SafeEnum(value) { @@ -424,6 +530,7 @@ struct duplicates_filter_t : SafeEnum { * advertising, scanning and initiating */ struct own_address_type_t : SafeEnum { + /// enumeration of own_address_type_t values. enum type { /** * Use the public device address. @@ -454,13 +561,20 @@ struct own_address_type_t : SafeEnum { /** * Construct a new instance of own_address_type_t. + * @param value The value of the own_address_type_t created. */ own_address_type_t(type value) : SafeEnum(value) { } }; +/** + * Type of an address to connect to. + * + * It is used to connect to a device directly of with directed advertising. + */ struct target_peer_address_type_t : SafeEnum { + /// enumeration of target_peer_address_type_t values. enum type { PUBLIC = 0x00, /**< Public Device Address or Public Identity Address. */ PUBLIC_ADDRESS = 0x00, @@ -468,6 +582,11 @@ struct target_peer_address_type_t : SafeEnum { + /// enumeration of clock_accuracy_t values. enum type { /** * 500 PPM @@ -549,11 +669,14 @@ struct clock_accuracy_t : SafeEnum { /** * Construct a new clock_accuracy_t value. + * @param value The value of the clock_accuracy_t created. */ clock_accuracy_t(type value) : SafeEnum(value) { } +#if !defined(DOXYGEN_ONLY) + /** * Construct a new clock_accuracy_t value from a raw value. * @param raw_value The value of the clock accuracy. @@ -561,6 +684,8 @@ struct clock_accuracy_t : SafeEnum { explicit clock_accuracy_t(uint8_t raw_value) : SafeEnum(raw_value) { } + +#endif }; /** @@ -606,11 +731,14 @@ struct connection_role_t : SafeEnum { /** * Construct a new instance of role_t. + * + * @param value The value of the role_t created. */ connection_role_t(type value) : SafeEnum(value) { } +#if !defined(DOXYGEN_ONLY) /** * Explicit constructor from a raw value. @@ -619,12 +747,15 @@ struct connection_role_t : SafeEnum { explicit connection_role_t(uint8_t raw_value) : SafeEnum(raw_value) { } + +#endif }; /** * Enumeration of disconnection reasons that should be transmited to the peer. */ struct local_disconnection_reason_t : SafeEnum { + /// enumeration of local_disconnection_reason_t values. enum type { /** * GAP or GATT failed to authenticate the peer. @@ -669,6 +800,8 @@ struct local_disconnection_reason_t : SafeEnum { + /// enumeration of disconnection_reason_t values. enum type { /** * GAP or GATT failed to authenticate the peer. @@ -720,6 +854,8 @@ struct disconnection_reason_t : SafeEnum { /** * Construct a new instance of disconnection_reason_t. + * + * @param value The value of the disconnection_reason_t created. */ disconnection_reason_t(type value) : SafeEnum(value) {