Hi, thanks for the help! Here is my experience trying to get this to work:
Using these definitions:
static struct ble_gap_upd_params bleprph_gap_upd_params = {
.itvl_min = MIN_CONNECTION_INTERVAL,
.itvl_max = MAX_CONNECTION_INTERVAL,
.latency = SLAVE_LATENCY,
.supervision_timeout = CONNECTION_SUPERVISION_TIMEOUT_MULTIPLIER,
.min_ce_len = 1, // Information parameter about the minimum length of
connection event needed for this LE connection.
.max_ce_len = 10, // Units: 0.625 ms; min: 0; max 0xFFFF (40.9s)
// I really have no idea what to put in min/max_ce_len. I thought a
connection event was sending a few packets, so should take a couple of
milliseconds.
// Why would you ever have a 40s one?
};
static struct ble_l2cap_sig_update_params bleprph_l2cap_sig_update_params =
{
.itvl_min = MIN_CONNECTION_INTERVAL,
.itvl_max = MAX_CONNECTION_INTERVAL,
.slave_latency = SLAVE_LATENCY,
.timeout_multiplier = CONNECTION_SUPERVISION_TIMEOUT_MULTIPLIER,
};
And this modification to bleprph:
case BLE_GAP_EVENT_CONN:
// ...
if (status == 0) {
// 1. Either this:
ble_gap_update_params(ctxt->desc->conn_handle, &bleprph_gap_upd_params);
// 2. Or this:
ble_l2cap_sig_update(ctxt->desc->conn_handle,
&bleprph_l2cap_sig_update_params,
NULL, NULL);
// 3. Or this:
g_conn_handle = ctxt->desc->conn_handle; // Not the best way to do this
no doubt, but I couldn't find a way to attach data to a callout since the
void* arg is fixed.
os_callout_reset(&g_conn_param_update_timer.cf_c, OS_TICKS_PER_SEC * 5);
} else {
// ...
void conn_param_update_cb(void* arg)
{
ble_gap_update_params(g_conn_handle, &bleprph_gap_upd_params);
}
// (Plus all the gubbins to set up the os_callout.)
The results are:
1. Using ble_gap_update_params, the connection interval isn't changed. I
have confirmed that my device (Xperica Z3C) does support the Connection
Parameter Update Procedure.
2. Using ble_l2cap_sig_update, it does change the connection interval! Most
of the time anyway. However it then gets stuck discovering services. Maybe
because the connection is slowed to a crawl? Also the connection drops
after a while (maybe the central gives up discovering services and
disconnects).
3. Using a 5 second timeout, then ble_gap_update_params it works as
expected! I couldn't find in the spec where it mentions the 5 seconds, but
I guess it is needed in some way.
Cheers,
Tim
On 24 August 2016 at 23:31, Christopher Collins <[email protected]> wrote:
> On Wed, Aug 24, 2016 at 03:24:16PM -0700, Christopher Collins wrote:
> [...]
>
> > As the slave, you can update the connection by calling
> > ble_gap_update_params()
> > (http://mynewt.apache.org/develop/network/ble/ble_hs/
> ble_gap/functions/ble_gap_update_params/)
> > after the connection is established. Note: the NimBLE host API has
> > changed quite a bit lately, so if you are using 0.9.0 (instead of the
> > master branch), the API reference may be inaccurate.
>
> There is something I forgot to mention. There's an outstanding bug
> which might bite you in this case. If the central device does not
> support the connection parameter update link-layer procedure, then the
> call to ble_gap_update_params() will fail. The host should then fall
> back to using the old L2CAP connection update procedure, but it does
> not.
>
> (this bug is filed: https://issues.apache.org/jira/browse/MYNEWT-347.)
>
> If you run into this issue, you can use the L2CAP update procedure by
> calling the following function:
>
> int
> ble_l2cap_sig_update(uint16_t conn_handle,
> struct ble_l2cap_sig_update_params *params,
> ble_l2cap_sig_update_fn *cb, void *cb_arg)
>
> Sorry for the annoyance!
>
> Chris
>