I am attempting to enable a second custom service with a vendor specific UUID with three characteristics (in addition to an existing custom service and the battery service which are already working just fine) in SDK 13.0.0-alpha with the 5.0.0-1.alpha S132 softdevice, on an nrf52832.
Just like many other instances I have seen on the forum, calling sd_ble_uuid_vs_add()
on the second custom service was resulting in NRF_ERROR_NO_MEM
As per the many other threads, to remedy this, in ble_stack_init() I am calling:
ble_enable_params_t ble_enable_params;
err_code = softdevice_enable_get_default_config(CENTRAL_LINK_COUNT,
PERIPHERAL_LINK_COUNT,
&ble_enable_params);
APP_ERROR_CHECK(err_code);
ble_enable_params.common_enable_params.vs_uuid_count = 2;
ble_enable_params.gatts_enable_params.attr_tab_size = 0x900;
ble_enable_params.gatts_enable_params.service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT;
before calling softdevice_enable(&ble_enable_params);
Of course, I have no idea what size to set attr_tab_size
to. The best advice I have seen is to try setting it too big then do some trial and error.
The default target memory sizes for my project (which work fine with my softdevice when this service is commented out) are:
IROM1 Start: 0x20000
IROM1 Size: 0x53000
IRAM1 Start: 0x20002168
IRAM1 Size: 0xDE98
As I understand it, I also need to adjust the IRAM Start and Size to accommodate my attr_tab_size
.
I have seen it suggest that these should be set to:
IRAM1 Start: 0x20002168 + BLE_GATTS_ATTR_TAB_SIZE
IRAM1 Size: 0xDE98 - BLE_GATTS_ATTR_TAB_SIZE
So in my case, if using an attr_tab_size
of 0x900
, I believe they should be:
IRAM1 Start: 0x20002A68
IRAM1 Size: 0xD598
No dice : (
I have also tried larger and smaller values for attr_tab_size
, each time adjusting my IRAM settings accordingly with no luck.
Within my custom service, I have also tried setting attr_md.vloc = BLE_GATTS_VLOC_USER;
insted of BLE_GATTS_VLOC_STACK
to no avail.
(cccd_md.vloc
always remains set to BLE_GATTS_VLOC_STACK
)
Any advice regarding what I might be doing wrong would be much appreciated.