From c165bd98b715d11be9ddabd3e8f235a7f6a6bb8c Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Thu, 15 Nov 2018 21:19:40 +0000 Subject: [PATCH] BLE: Add explicit constructor for Duration that accepts millisecond in input. --- features/FEATURE_BLE/ble/common/Duration.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/features/FEATURE_BLE/ble/common/Duration.h b/features/FEATURE_BLE/ble/common/Duration.h index ce4588ec1d..f37a03025e 100644 --- a/features/FEATURE_BLE/ble/common/Duration.h +++ b/features/FEATURE_BLE/ble/common/Duration.h @@ -18,6 +18,7 @@ #define BLE_COMMON_DURATION_H_ #include +#include #include "platform/mbed_assert.h" namespace ble { @@ -62,6 +63,11 @@ struct Duration { MBED_STATIC_ASSERT(OtherTB >= TB && (OtherTB % TB) == 0, "Incompatible units"); } + template + explicit Duration(Duration other_ms, void* = NULL) : + duration(clamp(((other_ms.value() * 1000) + TB - 1) / TB)) + { } + Rep value() { return duration; }