Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLE: Cordio host upgrade #9864

Merged
merged 11 commits into from Mar 2, 2019
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions features/FEATURE_BLE/targets/TARGET_CORDIO/mbed_lib.json
Expand Up @@ -53,6 +53,11 @@
"max-prepared-writes": {
"help": "Number of queued prepare writes supported by server.",
"value": 4
},
"cmac-calculation": {
"help": "Where the CBC MAC calculatio is performed. Valid values are 0 (host) and 1 (controller through HCI).",
"value": 1,
"macro_name": "SEC_CCM_CFG"
}
}
}
16 changes: 12 additions & 4 deletions features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioBLE.cpp
Expand Up @@ -41,6 +41,10 @@
/*! WSF handler ID */
wsfHandlerId_t stack_handler_id;

/* WSF heap allocation */
uint8_t *SystemHeapStart;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these be made static? (and stack_handler_id above as well)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, they need to be provided for wsf

uint32_t SystemHeapSize;

/**
* Weak definition of ble_cordio_get_hci_driver.
* A runtime error is generated if the user does not define any
Expand Down Expand Up @@ -369,15 +373,19 @@ void BLE::stack_setup()

buf_pool_desc_t buf_pool_desc = _hci_driver->get_buffer_pool_description();

// use the buffer for the WSF heap
SystemHeapStart = buf_pool_desc.buffer_memory;
SystemHeapSize = buf_pool_desc.buffer_size;

// Initialize buffers with the ones provided by the HCI driver
uint16_t bytes_used = WsfBufInit(
buf_pool_desc.buffer_size, buf_pool_desc.buffer_memory,
buf_pool_desc.pool_count, buf_pool_desc.pool_description
);
uint16_t bytes_used = WsfBufInit(buf_pool_desc.pool_count, (wsfBufPoolDesc_t*)buf_pool_desc.pool_description);

// Raise assert if not enough memory was allocated
MBED_ASSERT(bytes_used != 0);

SystemHeapStart += bytes_used;
SystemHeapSize -= bytes_used;

// This warning will be raised if we've allocated too much memory
if(bytes_used < buf_pool_desc.buffer_size)
{
Expand Down