I need to set the connection interval to 7.5 ms. The main.c has the corresponding macro: MIN_CONN_INTERVAL but it seems to me that it supports only integer values...
Please let me know how to handle that.
Thanks.
I need to set the connection interval to 7.5 ms. The main.c has the corresponding macro: MIN_CONN_INTERVAL but it seems to me that it supports only integer values...
Please let me know how to handle that.
Thanks.
Hi Baruch,
Fortunately MIN_CONN_INTERVAL is specified in 1.25ms units, at least for SDK15, and the integer 6 will yield the desired 7.5ms. See ble_gap.h
Best Regards, Howard
main.c
#define MIN_CONN_INTERVAL MSEC_TO_UNITS(20, UNIT_1_25_MS) /**< Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
app_util.h
/**@brief Macro for converting milliseconds to ticks.
*
* @param[in] TIME Number of milliseconds to convert.
* @param[in] RESOLUTION Unit to be converted to in [us/ticks].
*/
#define MSEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000) / (RESOLUTION))
enum
{
UNIT_0_625_MS = 625, /**< Number of microseconds in 0.625 milliseconds. */
UNIT_1_25_MS = 1250, /**< Number of microseconds in 1.25 milliseconds. */
UNIT_10_MS = 10000 /**< Number of microseconds in 10 milliseconds. */
};
So, even though that value 6 does work substituting breaks the integrity of the code. That is the major reason for my question.
The units could change in the next release. I agree with you.
EDIT Units unlikely to change though, per Kenneth below
The format here follow the BT core spec:
Thank you, but this is well-known information. The actual subject is how to represent the required interval using the macros given by Nordic in their examples to keep the integrity and compatibility of the code. It isn't the question of a value but about proper representation.
Interesting. I suppose it's unlikely the units will change then, absent a core spec update. Good catch.
Howard, why do you think it is a good catch? I'm not following.
Howard, why do you think it is a good catch? I'm not following.
I think it's a good catch because the 1.25mS unit defined in the spec is not likely to change. OTOH there is the issue of the units being obscured by the preproc macro. Would you prefer to pass a floating (or fixed point) interval to a wrapper?
I'd prefer to have a macro which indeed takes everything. I do agree that 1.25 isn't going to change then using units of ms in the given macro doesn't make much sense and that is the whole reason for my complaint.