mirror of https://github.com/ARMmbed/mbed-os.git
comparison operator
parent
8e18e191fb
commit
7b4439567d
|
@ -53,10 +53,14 @@ public:
|
||||||
clamp(_value, min, max);
|
clamp(_value, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
LayoutType value() const {
|
const LayoutType& value() const {
|
||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator>(unit_t const& other) const {
|
||||||
|
return _value > other._value;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LayoutType _value;
|
LayoutType _value;
|
||||||
};
|
};
|
||||||
|
@ -66,7 +70,6 @@ typedef unit_t<uint16_t, 10000, 0x01, 0xFFFF> unit_adv_duration_t;
|
||||||
typedef unit_t<uint16_t, 625, 0x04, 0xFFFF> unit_scan_interval_t;
|
typedef unit_t<uint16_t, 625, 0x04, 0xFFFF> unit_scan_interval_t;
|
||||||
typedef unit_t<uint16_t, 625, 0x04, 0xFFFF> unit_scan_window_t;
|
typedef unit_t<uint16_t, 625, 0x04, 0xFFFF> unit_scan_window_t;
|
||||||
typedef unit_t<uint16_t, 1250, 0x06, 0x0C80> unit_conn_interval_t;
|
typedef unit_t<uint16_t, 1250, 0x06, 0x0C80> unit_conn_interval_t;
|
||||||
typedef unit_t<uint16_t, 0, 0, 0x01F3> unit_slave_latency_t;
|
|
||||||
typedef unit_t<uint16_t, 10000, 0x0A, 0x0C80> unit_supervision_timeout_t;
|
typedef unit_t<uint16_t, 10000, 0x0A, 0x0C80> unit_supervision_timeout_t;
|
||||||
typedef unit_t<uint16_t, 625, 0, 0xFFFF> unit_conn_event_length_t;
|
typedef unit_t<uint16_t, 625, 0, 0xFFFF> unit_conn_event_length_t;
|
||||||
typedef unit_t<uint16_t, 10000, 0x0A, 0x4000> unit_sync_timeout_t;
|
typedef unit_t<uint16_t, 10000, 0x0A, 0x4000> unit_sync_timeout_t;
|
||||||
|
@ -74,6 +77,8 @@ typedef unit_t<uint16_t, 1250, 0x06, 0xFFFF> unit_periodic_interval_t;
|
||||||
typedef unit_t<uint32_t, 1000, 0, 0xFFFFFFFF> unit_ms_t;
|
typedef unit_t<uint32_t, 1000, 0, 0xFFFFFFFF> unit_ms_t;
|
||||||
typedef unit_t<uint32_t, 1, 0, 0xFFFFFFFF> unit_us_t;
|
typedef unit_t<uint32_t, 1, 0, 0xFFFFFFFF> unit_us_t;
|
||||||
|
|
||||||
|
typedef unit_t<uint16_t, 0, 0, 0x01F3> unit_slave_latency_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opaque reference to a connection.
|
* Opaque reference to a connection.
|
||||||
*
|
*
|
||||||
|
|
|
@ -106,7 +106,7 @@ public:
|
||||||
|
|
||||||
ble_error_t startAdvertising(
|
ble_error_t startAdvertising(
|
||||||
AdvHandle_t handle,
|
AdvHandle_t handle,
|
||||||
uint16_t maxDuration,
|
UnitAdvDuration_t maxDuration,
|
||||||
uint8_t maxEvents
|
uint8_t maxEvents
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -116,8 +116,8 @@ public:
|
||||||
|
|
||||||
virtual ble_error_t setPeriodicAdvertisingParameters(
|
virtual ble_error_t setPeriodicAdvertisingParameters(
|
||||||
AdvHandle_t handle,
|
AdvHandle_t handle,
|
||||||
uint32_t periodicAdvertisingIntervalMinMs,
|
UnitPeriodicInterval_t periodicAdvertisingIntervalMinMs,
|
||||||
uint32_t periodicAdvertisingIntervalMaxMs,
|
UnitPeriodicInterval_t periodicAdvertisingIntervalMaxMs,
|
||||||
bool advertiseTxPower
|
bool advertiseTxPower
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1904,7 +1904,7 @@ ble_error_t GenericGap::setAdvertisingData(
|
||||||
|
|
||||||
ble_error_t GenericGap::startAdvertising(
|
ble_error_t GenericGap::startAdvertising(
|
||||||
AdvHandle_t handle,
|
AdvHandle_t handle,
|
||||||
uint16_t maxDuration,
|
UnitAdvDuration_t maxDuration,
|
||||||
uint8_t maxEvents
|
uint8_t maxEvents
|
||||||
) {
|
) {
|
||||||
ble_error_t error = BLE_ERROR_NONE;
|
ble_error_t error = BLE_ERROR_NONE;
|
||||||
|
@ -1928,10 +1928,10 @@ ble_error_t GenericGap::startAdvertising(
|
||||||
}
|
}
|
||||||
|
|
||||||
_advertising_timeout.detach();
|
_advertising_timeout.detach();
|
||||||
if (maxDuration) {
|
if (maxDuration.value()) {
|
||||||
_advertising_timeout.attach_us(
|
_advertising_timeout.attach_us(
|
||||||
mbed::callback(this, &GenericGap::on_advertising_timeout),
|
mbed::callback(this, &GenericGap::on_advertising_timeout),
|
||||||
maxDuration
|
maxDuration.value()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1954,7 +1954,7 @@ ble_error_t GenericGap::startAdvertising(
|
||||||
/* enable */ true,
|
/* enable */ true,
|
||||||
/* number of advertising sets */ 1,
|
/* number of advertising sets */ 1,
|
||||||
&handle,
|
&handle,
|
||||||
&maxDuration,
|
&maxDuration.value(),
|
||||||
&maxEvents
|
&maxEvents
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2009,23 +2009,12 @@ bool GenericGap::isAdvertisingActive(AdvHandle_t handle) {
|
||||||
|
|
||||||
ble_error_t GenericGap::setPeriodicAdvertisingParameters(
|
ble_error_t GenericGap::setPeriodicAdvertisingParameters(
|
||||||
Gap::AdvHandle_t handle,
|
Gap::AdvHandle_t handle,
|
||||||
uint32_t periodicAdvertisingIntervalMinMs,
|
UnitPeriodicInterval_t periodicAdvertisingIntervalMinMs,
|
||||||
uint32_t periodicAdvertisingIntervalMaxMs,
|
UnitPeriodicInterval_t periodicAdvertisingIntervalMaxMs,
|
||||||
bool advertiseTxPower
|
bool advertiseTxPower
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
uint32_t interval_min = (periodicAdvertisingIntervalMinMs * 100) / 125;
|
if (periodicAdvertisingIntervalMinMs > periodicAdvertisingIntervalMaxMs) {
|
||||||
uint32_t interval_max = (periodicAdvertisingIntervalMaxMs * 100) / 125;
|
|
||||||
|
|
||||||
if (interval_min < 6 || interval_min > 0xFFFF) {
|
|
||||||
return BLE_ERROR_INVALID_PARAM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (interval_max < 6 || interval_max > 0xFFFF) {
|
|
||||||
return BLE_ERROR_INVALID_PARAM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (interval_min > interval_max) {
|
|
||||||
return BLE_ERROR_INVALID_PARAM;
|
return BLE_ERROR_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2043,8 +2032,8 @@ ble_error_t GenericGap::setPeriodicAdvertisingParameters(
|
||||||
|
|
||||||
return _pal_gap.set_periodic_advertising_parameters(
|
return _pal_gap.set_periodic_advertising_parameters(
|
||||||
handle,
|
handle,
|
||||||
interval_min,
|
periodicAdvertisingIntervalMinMs.value(),
|
||||||
interval_max,
|
periodicAdvertisingIntervalMaxMs.value(),
|
||||||
advertiseTxPower
|
advertiseTxPower
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue