Skip to content

HCI data length configuration option #37

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

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added set_data_length
  • Loading branch information
KMeldgaard committed Nov 24, 2021
commit 0490ea33ff86d926f83d07ee28fb100b51ad922c
2 changes: 2 additions & 0 deletions src/utility/ATT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ void ATTClass::addConnection(uint16_t handle, uint8_t role, uint8_t peerBdaddrTy
if (_eventHandlers[BLEConnected]) {
_eventHandlers[BLEConnected](BLEDevice(peerBdaddrType, peerBdaddr));
}
// TODO (krm) increase speed!
HCI.hciSetDataLength(handle, 251, 2120);
}

void ATTClass::handleData(uint16_t connectionHandle, uint8_t dlen, uint8_t data[])
Expand Down
14 changes: 14 additions & 0 deletions src/utility/HCI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,20 @@ void HCIClass::setTransport(HCITransportInterface *HCITransport)
_HCITransport = HCITransport;
}

int HCIClass::hciSetDataLength(uint16_t connectionHandle, uint16_t txOctects, uint16_t txTime){
const uint8_t payload_len = 6;
const uint16_t opcode = 0x2022;
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
hci_le_set_data_length_cp0 *cp0 = (hci_le_set_data_length_cp0*)(cmd_buffer);

// create payload
cp0->Connection_Handle = connectionHandle;
cp0->TxOctets = txOctects;
cp0->TxTime = txTime;

return sendCommand(opcode, payload_len, cmd_buffer);
}

#if !defined(FAKE_HCI)
HCIClass HCIObj;
HCIClass& HCI = HCIObj;
Expand Down
23 changes: 23 additions & 0 deletions src/utility/HCI.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
#include <Arduino.h>
#include "HCITransport.h"

#define BLE_CMD_MAX_PARAM_LEN 255

struct hci_le_set_data_length_cp0{
uint16_t Connection_Handle;
uint16_t TxOctets;
uint16_t TxTime;
};

class HCIClass {
public:
HCIClass();
Expand Down Expand Up @@ -74,6 +82,21 @@ class HCIClass {

void setTransport(HCITransportInterface *HCITransport);

//-----------------------------
// @brief
// @param connectionHandle Connection_Handle Connection handle for which the command applies.
// Values: 0x0000 ... 0x0EFF
// @param txOctects TxOctets Preferred maximum number of payload octets that the local
// Controller should include in a single Link Layer packet on this
// connection.
// Values: 0x001B ... 0x00FB
// @param txTime TxTime Preferred maximum number of microseconds that the local
// Controller should use to transmit a single Link Layer packet on this
// connection.
// Values: 0x0148 ... 0x4290
// @return Value indicating success or error code.
int hciSetDataLength(uint16_t connectionHandle, uint16_t txOctects, uint16_t txTime);

private:
virtual int sendCommand(uint16_t opcode, uint8_t plen = 0, void* parameters = NULL);

Expand Down