On Sat, Jul 23, 2016 at 09:11:43AM +0000, Marco Ferreira wrote:
> Hi all,
>
> While my Central is trying to connect to the second peripheral, it fails with
> reason BLE_HS_ENOMEM (6).
Is this error code returned by ble_gap_connect()? If so, one of the
following settings is too low:
* cfg.max_connections
* cfg.max_l2cap_chans
* cfg.max_client_configs
Just a wild guess, but I would bet the problem is too few l2cap
channels. I think pretty much everyone agrees that getting the host
configuration right is too difficult, so this is something that will
need to be improved (more about this below). In the meantime, the
following code should ensure sufficient resources:
cfg = ble_hs_cfg_dflt;
cfg.max_l2cap_chans = cfg.max_connections * 3;
cfg.max_connections gets properly assigned NIMBLE_OPT_MAX_CONNECTIONS by
by the first line (cfg = ble_hs_cfg_dflt).
cfg.max_l2cap_chans must always be greater than or equal to three times
the number of connections.
cfg.max_client_configs gets populated automatically when the various
GATT services are initialized (e.g., ble_svc_gap_init()), so you
probably don't need to do anything different there.
Regarding future improvements to the host- I can think of a few easy
ones, listed below. If anyone has any other ideas, please feel free to post
them to
the list.
1. ble_hs_cfg_dflt should contain the correct value for max_l2cap_chans.
Currently it is initialized with the arbitrary value of 16.
2. When something fails due to resource shortage, a specific diagnostic
should get printed to the debug log.
Thanks,
Chris