mirror of https://github.com/ARMmbed/mbed-os.git
commit
02e90ef469
|
@ -58,6 +58,10 @@ struct buf_pool_desc_t {
|
||||||
* - Access to the write function of the underlying HCITransport driver.
|
* - Access to the write function of the underlying HCITransport driver.
|
||||||
*/
|
*/
|
||||||
class CordioHCIDriver {
|
class CordioHCIDriver {
|
||||||
|
|
||||||
|
// hook for internal tests and passthrough driver
|
||||||
|
friend class CordioHCIHook;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Construct a new instance of an HCI driver.
|
* Construct a new instance of an HCI driver.
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
#include "CordioHCITransportDriver.h"
|
#include "CordioHCITransportDriver.h"
|
||||||
#include "CordioHCIDriver.h"
|
#include "CordioHCIDriver.h"
|
||||||
|
|
||||||
|
@ -23,9 +26,22 @@ namespace ble {
|
||||||
namespace vendor {
|
namespace vendor {
|
||||||
namespace cordio {
|
namespace cordio {
|
||||||
|
|
||||||
|
CordioHCITransportDriver::data_received_handler_t
|
||||||
|
CordioHCITransportDriver::data_received_handler = hciTrSerialRxIncoming;
|
||||||
|
|
||||||
void CordioHCITransportDriver::on_data_received(uint8_t* data, uint16_t len)
|
void CordioHCITransportDriver::on_data_received(uint8_t* data, uint16_t len)
|
||||||
{
|
{
|
||||||
hciTrSerialRxIncoming(data, len);
|
while (len) {
|
||||||
|
uint8_t chunk_length = std::min(len, (uint16_t) std::numeric_limits<uint8_t>::max());
|
||||||
|
data_received_handler(data, chunk_length);
|
||||||
|
len = len - chunk_length;
|
||||||
|
data = data + chunk_length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CordioHCITransportDriver::set_data_received_handler(data_received_handler_t handler)
|
||||||
|
{
|
||||||
|
data_received_handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace cordio
|
} // namespace cordio
|
||||||
|
|
|
@ -28,6 +28,10 @@ namespace cordio {
|
||||||
* It allow the stack to write data in the HCI channel.
|
* It allow the stack to write data in the HCI channel.
|
||||||
*/
|
*/
|
||||||
class CordioHCITransportDriver {
|
class CordioHCITransportDriver {
|
||||||
|
|
||||||
|
// hook for internal tests and passthrough driver
|
||||||
|
friend class CordioHCIHook;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Driver destructor.
|
* Driver destructor.
|
||||||
|
@ -64,6 +68,13 @@ public:
|
||||||
* @param len Number of bytes received.
|
* @param len Number of bytes received.
|
||||||
*/
|
*/
|
||||||
static void on_data_received(uint8_t* data, uint16_t len);
|
static void on_data_received(uint8_t* data, uint16_t len);
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef void (*data_received_handler_t)(uint8_t* data, uint8_t len);
|
||||||
|
|
||||||
|
static data_received_handler_t data_received_handler;
|
||||||
|
|
||||||
|
static void set_data_received_handler(data_received_handler_t handler);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace cordio
|
} // namespace cordio
|
||||||
|
|
Loading…
Reference in New Issue