Skip to content

Commit 0490ea3

Browse files
committed
added set_data_length
1 parent 49ac7b4 commit 0490ea3

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

src/utility/ATT.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ void ATTClass::addConnection(uint16_t handle, uint8_t role, uint8_t peerBdaddrTy
256256
if (_eventHandlers[BLEConnected]) {
257257
_eventHandlers[BLEConnected](BLEDevice(peerBdaddrType, peerBdaddr));
258258
}
259+
// TODO (krm) increase speed!
260+
HCI.hciSetDataLength(handle, 251, 2120);
259261
}
260262

261263
void ATTClass::handleData(uint16_t connectionHandle, uint8_t dlen, uint8_t data[])

src/utility/HCI.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,20 @@ void HCIClass::setTransport(HCITransportInterface *HCITransport)
672672
_HCITransport = HCITransport;
673673
}
674674

675+
int HCIClass::hciSetDataLength(uint16_t connectionHandle, uint16_t txOctects, uint16_t txTime){
676+
const uint8_t payload_len = 6;
677+
const uint16_t opcode = 0x2022;
678+
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
679+
hci_le_set_data_length_cp0 *cp0 = (hci_le_set_data_length_cp0*)(cmd_buffer);
680+
681+
// create payload
682+
cp0->Connection_Handle = connectionHandle;
683+
cp0->TxOctets = txOctects;
684+
cp0->TxTime = txTime;
685+
686+
return sendCommand(opcode, payload_len, cmd_buffer);
687+
}
688+
675689
#if !defined(FAKE_HCI)
676690
HCIClass HCIObj;
677691
HCIClass& HCI = HCIObj;

src/utility/HCI.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
#include <Arduino.h>
2424
#include "HCITransport.h"
2525

26+
#define BLE_CMD_MAX_PARAM_LEN 255
27+
28+
struct hci_le_set_data_length_cp0{
29+
uint16_t Connection_Handle;
30+
uint16_t TxOctets;
31+
uint16_t TxTime;
32+
};
33+
2634
class HCIClass {
2735
public:
2836
HCIClass();
@@ -74,6 +82,21 @@ class HCIClass {
7482

7583
void setTransport(HCITransportInterface *HCITransport);
7684

85+
//-----------------------------
86+
// @brief
87+
// @param connectionHandle Connection_Handle Connection handle for which the command applies.
88+
// Values: 0x0000 ... 0x0EFF
89+
// @param txOctects TxOctets Preferred maximum number of payload octets that the local
90+
// Controller should include in a single Link Layer packet on this
91+
// connection.
92+
// Values: 0x001B ... 0x00FB
93+
// @param txTime TxTime Preferred maximum number of microseconds that the local
94+
// Controller should use to transmit a single Link Layer packet on this
95+
// connection.
96+
// Values: 0x0148 ... 0x4290
97+
// @return Value indicating success or error code.
98+
int hciSetDataLength(uint16_t connectionHandle, uint16_t txOctects, uint16_t txTime);
99+
77100
private:
78101
virtual int sendCommand(uint16_t opcode, uint8_t plen = 0, void* parameters = NULL);
79102

0 commit comments

Comments
 (0)