mirror of https://github.com/ARMmbed/mbed-os.git
BLE: Move common type from pal to ble namespace.
parent
74c2def5ef
commit
194e2cb4f8
|
|
@ -337,6 +337,25 @@ private:
|
||||||
uint8_t value;
|
uint8_t value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identify an advertising SID. Range: [0x00, 0x0F]
|
||||||
|
*/
|
||||||
|
typedef uint8_t advertising_sid_t;
|
||||||
|
|
||||||
|
// Range -127 <= N <= +20
|
||||||
|
// Special value: 127
|
||||||
|
// - RSSI not available.
|
||||||
|
typedef int8_t rssi_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describe the advertising power.
|
||||||
|
*
|
||||||
|
* Value comprised between -127 and +126 are considered power values in dBm while
|
||||||
|
* the special value 127 can be used as a wildcard to indicates that the host
|
||||||
|
* has no preference or if the power information is not available.
|
||||||
|
*/
|
||||||
|
typedef int8_t advertising_power_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Advertising policy filter modes.
|
* Advertising policy filter modes.
|
||||||
*
|
*
|
||||||
|
|
@ -888,6 +907,13 @@ struct target_peer_address_type_t : ble::SafeEnum<target_peer_address_type_t, ui
|
||||||
struct phy_t : SafeEnum<phy_t, uint8_t> {
|
struct phy_t : SafeEnum<phy_t, uint8_t> {
|
||||||
/** struct scoped enum wrapped by the class */
|
/** struct scoped enum wrapped by the class */
|
||||||
enum type {
|
enum type {
|
||||||
|
/**
|
||||||
|
* No phy selected.
|
||||||
|
*
|
||||||
|
* @note This value can be used to indicate the absence of phy
|
||||||
|
*/
|
||||||
|
NONE = 0,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1Mbit/s LE.
|
* 1Mbit/s LE.
|
||||||
*
|
*
|
||||||
|
|
@ -1064,6 +1090,98 @@ struct coded_symbol_per_bit_t :SafeEnum<coded_symbol_per_bit_t, uint8_t> {
|
||||||
SafeEnum<coded_symbol_per_bit_t, uint8_t>(value) { }
|
SafeEnum<coded_symbol_per_bit_t, uint8_t>(value) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accuracy of the master clock.
|
||||||
|
*/
|
||||||
|
struct clock_accuracy_t : SafeEnum<clock_accuracy_t, uint8_t >{
|
||||||
|
enum type {
|
||||||
|
/**
|
||||||
|
* 500 PPM
|
||||||
|
*/
|
||||||
|
PPM_500 = 0x00,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 250 PPM
|
||||||
|
*/
|
||||||
|
PPM_250 = 0x01,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 150 PPM
|
||||||
|
*/
|
||||||
|
PPM_150 = 0x02,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 100 PPM
|
||||||
|
*/
|
||||||
|
PPM_100 = 0x03,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 75 PPM
|
||||||
|
*/
|
||||||
|
PPM_75 = 0x04,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 50 PPM
|
||||||
|
*/
|
||||||
|
PPM_50 = 0x05,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 30 PPM
|
||||||
|
*/
|
||||||
|
PPM_30 = 0x06,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 20 PPM
|
||||||
|
*/
|
||||||
|
PPM_20 = 0x07
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Get clock accuracy.
|
||||||
|
*
|
||||||
|
* @return Parts per million as a number.
|
||||||
|
*/
|
||||||
|
uint16_t get_ppm() {
|
||||||
|
uint16_t ppm = 0;
|
||||||
|
|
||||||
|
switch(value()) {
|
||||||
|
case PPM_500:
|
||||||
|
ppm = 500;
|
||||||
|
break;
|
||||||
|
case PPM_250:
|
||||||
|
ppm = 250;
|
||||||
|
break;
|
||||||
|
case PPM_150:
|
||||||
|
ppm = 150;
|
||||||
|
break;
|
||||||
|
case PPM_100:
|
||||||
|
ppm = 100;
|
||||||
|
break;
|
||||||
|
case PPM_75:
|
||||||
|
ppm = 75;
|
||||||
|
break;
|
||||||
|
case PPM_50:
|
||||||
|
ppm = 50;
|
||||||
|
break;
|
||||||
|
case PPM_30:
|
||||||
|
ppm = 30;
|
||||||
|
break;
|
||||||
|
case PPM_20:
|
||||||
|
ppm = 20;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ppm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new clock_accuracy_t value.
|
||||||
|
*/
|
||||||
|
clock_accuracy_t(type value) : SafeEnum<clock_accuracy_t, uint8_t>(value) { }
|
||||||
|
|
||||||
|
explicit clock_accuracy_t(uint8_t raw_value) :
|
||||||
|
SafeEnum<clock_accuracy_t, uint8_t>(static_cast<type>(raw_value)) { }
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace ble
|
} // namespace ble
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -555,7 +555,7 @@ private:
|
||||||
const ble::address_t &address,
|
const ble::address_t &address,
|
||||||
phy_t primary_phy,
|
phy_t primary_phy,
|
||||||
const phy_t *secondary_phy,
|
const phy_t *secondary_phy,
|
||||||
pal::advertising_sid_t advertising_sid,
|
advertising_sid_t advertising_sid,
|
||||||
pal::advertising_power_t tx_power,
|
pal::advertising_power_t tx_power,
|
||||||
pal::rssi_t rssi,
|
pal::rssi_t rssi,
|
||||||
uint16_t periodic_advertising_interval,
|
uint16_t periodic_advertising_interval,
|
||||||
|
|
@ -568,7 +568,7 @@ private:
|
||||||
virtual void on_periodic_advertising_sync_established(
|
virtual void on_periodic_advertising_sync_established(
|
||||||
pal::hci_error_code_t error,
|
pal::hci_error_code_t error,
|
||||||
pal::sync_handle_t sync_handle,
|
pal::sync_handle_t sync_handle,
|
||||||
pal::advertising_sid_t advertising_sid,
|
advertising_sid_t advertising_sid,
|
||||||
pal::connection_peer_address_type_t advertiser_address_type,
|
pal::connection_peer_address_type_t advertiser_address_type,
|
||||||
const ble::address_t &advertiser_address,
|
const ble::address_t &advertiser_address,
|
||||||
uint16_t periodic_advertising_interval,
|
uint16_t periodic_advertising_interval,
|
||||||
|
|
|
||||||
|
|
@ -754,7 +754,7 @@ typedef uint16_t periodic_advertising_interval_t;
|
||||||
// Range -127 <= N <= +20
|
// Range -127 <= N <= +20
|
||||||
// Special value: 127
|
// Special value: 127
|
||||||
// - RSSI not available.
|
// - RSSI not available.
|
||||||
typedef int8_t rssi_t;
|
typedef ble::rssi_t rssi_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of an advertising fragment.
|
* Description of an advertising fragment.
|
||||||
|
|
@ -831,35 +831,9 @@ struct duplicates_filter_t : SafeEnum<duplicates_filter_t, uint8_t >{
|
||||||
/**
|
/**
|
||||||
* Identify a periodic advertising sync.
|
* Identify a periodic advertising sync.
|
||||||
*/
|
*/
|
||||||
typedef uint16_t sync_handle_t;
|
typedef ble::periodic_sync_handle_t sync_handle_t;
|
||||||
|
|
||||||
/**
|
typedef ble::advertising_data_status_t advertising_data_status_t;
|
||||||
* Identify an advertising SID. Range: [0x00, 0x0F]
|
|
||||||
*/
|
|
||||||
typedef uint8_t advertising_sid_t;
|
|
||||||
|
|
||||||
struct advertising_data_status_t : SafeEnum<advertising_data_status_t, uint8_t >{
|
|
||||||
enum type {
|
|
||||||
COMPLETE = 0x00,
|
|
||||||
INCOMPLETE_MORE_DATA = 0x01,
|
|
||||||
INCOMPLETE_DATA_TRUNCATED = 0x02
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a new advertising_data_status_t value.
|
|
||||||
*/
|
|
||||||
advertising_data_status_t(type value) :
|
|
||||||
SafeEnum<advertising_data_status_t, uint8_t>(value) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Explicit constructor from a raw value.
|
|
||||||
*/
|
|
||||||
explicit advertising_data_status_t(uint8_t value) :
|
|
||||||
SafeEnum<advertising_data_status_t, uint8_t>(
|
|
||||||
static_cast<advertising_data_status_t>(value)
|
|
||||||
)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct extended_advertising_report_event_type_t {
|
struct extended_advertising_report_event_type_t {
|
||||||
extended_advertising_report_event_type_t(uint8_t value) : value(value) { }
|
extended_advertising_report_event_type_t(uint8_t value) : value(value) { }
|
||||||
|
|
@ -943,97 +917,7 @@ struct direct_address_type_t : SafeEnum<direct_address_type_t, uint8_t> {
|
||||||
explicit direct_address_type_t(uint8_t raw_value) : SafeEnum(raw_value) { }
|
explicit direct_address_type_t(uint8_t raw_value) : SafeEnum(raw_value) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
typedef ble::clock_accuracy_t clock_accuracy_t;
|
||||||
* Accuracy of the master clock.
|
|
||||||
*/
|
|
||||||
struct clock_accuracy_t : SafeEnum<clock_accuracy_t, uint8_t >{
|
|
||||||
enum type {
|
|
||||||
/**
|
|
||||||
* 500 PPM
|
|
||||||
*/
|
|
||||||
PPM_500 = 0x00,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 250 PPM
|
|
||||||
*/
|
|
||||||
PPM_250 = 0x01,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 150 PPM
|
|
||||||
*/
|
|
||||||
PPM_150 = 0x02,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 100 PPM
|
|
||||||
*/
|
|
||||||
PPM_100 = 0x03,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 75 PPM
|
|
||||||
*/
|
|
||||||
PPM_75 = 0x04,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 50 PPM
|
|
||||||
*/
|
|
||||||
PPM_50 = 0x05,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 30 PPM
|
|
||||||
*/
|
|
||||||
PPM_30 = 0x06,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 20 PPM
|
|
||||||
*/
|
|
||||||
PPM_20 = 0x07
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a new clock_accuracy_t value.
|
|
||||||
*/
|
|
||||||
clock_accuracy_t(type value) : SafeEnum<clock_accuracy_t, uint8_t>(value) { }
|
|
||||||
|
|
||||||
/** Get clock accuracy.
|
|
||||||
*
|
|
||||||
* @return Parts per million as a number.
|
|
||||||
*/
|
|
||||||
uint16_t get_ppm() {
|
|
||||||
uint16_t ppm = 0;
|
|
||||||
|
|
||||||
switch(value()) {
|
|
||||||
case PPM_500:
|
|
||||||
ppm = 500;
|
|
||||||
break;
|
|
||||||
case PPM_250:
|
|
||||||
ppm = 250;
|
|
||||||
break;
|
|
||||||
case PPM_150:
|
|
||||||
ppm = 150;
|
|
||||||
break;
|
|
||||||
case PPM_100:
|
|
||||||
ppm = 100;
|
|
||||||
break;
|
|
||||||
case PPM_75:
|
|
||||||
ppm = 75;
|
|
||||||
break;
|
|
||||||
case PPM_50:
|
|
||||||
ppm = 50;
|
|
||||||
break;
|
|
||||||
case PPM_30:
|
|
||||||
ppm = 30;
|
|
||||||
break;
|
|
||||||
case PPM_20:
|
|
||||||
ppm = 20;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ppm;
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit clock_accuracy_t(uint8_t raw_value) :
|
|
||||||
SafeEnum<clock_accuracy_t, uint8_t>(static_cast<type>(raw_value)) { }
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace pal
|
} // namespace pal
|
||||||
} // namespace ble
|
} // namespace ble
|
||||||
|
|
|
||||||
|
|
@ -185,13 +185,13 @@ struct Gap {
|
||||||
* report event.
|
* report event.
|
||||||
*/
|
*/
|
||||||
virtual void on_periodic_advertising_sync_established(
|
virtual void on_periodic_advertising_sync_established(
|
||||||
hci_error_code_t error,
|
pal::hci_error_code_t error,
|
||||||
sync_handle_t sync_handle,
|
pal::sync_handle_t sync_handle,
|
||||||
advertising_sid_t advertising_sid,
|
advertising_sid_t advertising_sid,
|
||||||
connection_peer_address_type_t advertiser_address_type,
|
connection_peer_address_type_t advertiser_address_type,
|
||||||
const address_t &advertiser_address,
|
const ble::address_t &advertiser_address,
|
||||||
uint16_t periodic_advertising_interval,
|
uint16_t periodic_advertising_interval,
|
||||||
clock_accuracy_t clock_accuracy
|
pal::clock_accuracy_t clock_accuracy
|
||||||
) = 0;
|
) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2206,7 +2206,7 @@ void GenericGap::on_extended_advertising_report(
|
||||||
const ble::address_t &address,
|
const ble::address_t &address,
|
||||||
phy_t primary_phy,
|
phy_t primary_phy,
|
||||||
const phy_t *secondary_phy,
|
const phy_t *secondary_phy,
|
||||||
pal::advertising_sid_t advertising_sid,
|
advertising_sid_t advertising_sid,
|
||||||
pal::advertising_power_t tx_power,
|
pal::advertising_power_t tx_power,
|
||||||
pal::rssi_t rssi,
|
pal::rssi_t rssi,
|
||||||
uint16_t periodic_advertising_interval,
|
uint16_t periodic_advertising_interval,
|
||||||
|
|
@ -2239,7 +2239,7 @@ void GenericGap::on_extended_advertising_report(
|
||||||
void GenericGap::on_periodic_advertising_sync_established(
|
void GenericGap::on_periodic_advertising_sync_established(
|
||||||
pal::hci_error_code_t error,
|
pal::hci_error_code_t error,
|
||||||
pal::sync_handle_t sync_handle,
|
pal::sync_handle_t sync_handle,
|
||||||
pal::advertising_sid_t advertising_sid,
|
advertising_sid_t advertising_sid,
|
||||||
connection_peer_address_type_t advertiser_address_type,
|
connection_peer_address_type_t advertiser_address_type,
|
||||||
const ble::address_t &advertiser_address,
|
const ble::address_t &advertiser_address,
|
||||||
uint16_t periodic_advertising_interval,
|
uint16_t periodic_advertising_interval,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue