mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-21 03:40:47 +00:00
l2cap_signaling: add l2cap credit-based connection pdus
This commit is contained in:
parent
14b592b74d
commit
f74aded932
@ -64,7 +64,6 @@ static uint16_t l2cap_create_signaling_internal(uint8_t * acl_buffer, hci_con_ha
|
||||
"D", // 0x09 echo response: data
|
||||
"2", // 0x0a information request: info type {1=Connectionless MTU, 2=Extended features supported}
|
||||
"22D", // 0x0b information response: info type, Result, Data
|
||||
#ifdef ENABLE_BLE
|
||||
NULL, // 0x0c non-supported AMP command
|
||||
NULL, // 0x0d non-supported AMP command
|
||||
NULL, // 0x0e non-supported AMP command
|
||||
@ -73,11 +72,13 @@ static uint16_t l2cap_create_signaling_internal(uint8_t * acl_buffer, hci_con_ha
|
||||
NULL, // 0x11 non-supported AMP command
|
||||
"2222", // 0x12 connection parameter update request: interval min, interval max, slave latency, timeout multiplier
|
||||
"2", // 0x13 connection parameter update response: result
|
||||
"22222", // 0X14 le credit-based connection request: le psm, source cid, mtu, mps, initial credits
|
||||
"22222", // 0X14 le credit-based connection request: simplified psm, source cid, mtu, mps, initial credits
|
||||
"22222", // 0x15 le credit-based connection response: dest cid, mtu, mps, initial credits, result
|
||||
"22", // 0x16 le flow control credit indication: source cid, credits
|
||||
#endif
|
||||
|
||||
"2222C", // 0x17 l2cap credit-based connection request: simplified psm, mtu, mps, initial credits, source cid[0]
|
||||
"2222C", // 0x18 l2cap credit-based connection request: mtu, mps, initial credits, result, destinations cid[0]
|
||||
"22C", // 0x19 l2cap credit-based reconfigure request: mu, mps, destination cid[0]
|
||||
"2", // 0x1a l2cap credit-based reconfigure response: result
|
||||
#ifdef UNIT_TEST
|
||||
"M", // invalid format for unit testing
|
||||
#endif
|
||||
@ -114,7 +115,8 @@ static uint16_t l2cap_create_signaling_internal(uint8_t * acl_buffer, hci_con_ha
|
||||
// 12 - L2CAP signaling parameters
|
||||
uint16_t pos = 12;
|
||||
uint16_t word;
|
||||
uint8_t * ptr;
|
||||
uint8_t * ptr_u8;
|
||||
uint16_t * ptr_u16;
|
||||
while (*format) {
|
||||
switch(*format) {
|
||||
case '2': // 16 bit value
|
||||
@ -123,10 +125,18 @@ static uint16_t l2cap_create_signaling_internal(uint8_t * acl_buffer, hci_con_ha
|
||||
acl_buffer[pos++] = word & 0xffu;
|
||||
acl_buffer[pos++] = word >> 8;
|
||||
break;
|
||||
case 'C': // list of cids != zero, last one is zero
|
||||
ptr_u16 = va_arg(argptr, uint16_t *); // LCOV_EXCL_BR_LINE
|
||||
while (*ptr_u16 != 0){
|
||||
little_endian_store_16(acl_buffer, pos, *ptr_u16);
|
||||
ptr_u16++;
|
||||
pos += 2;
|
||||
}
|
||||
break;
|
||||
case 'D': // variable data. passed: len, ptr
|
||||
word = va_arg(argptr, int); // LCOV_EXCL_BR_LINE
|
||||
ptr = va_arg(argptr, uint8_t *); // LCOV_EXCL_BR_LINE
|
||||
(void)memcpy(&acl_buffer[pos], ptr, word);
|
||||
ptr_u8 = va_arg(argptr, uint8_t *); // LCOV_EXCL_BR_LINE
|
||||
(void)memcpy(&acl_buffer[pos], ptr_u8, word);
|
||||
pos += word;
|
||||
break;
|
||||
default:
|
||||
|
@ -70,6 +70,10 @@ typedef enum {
|
||||
LE_CREDIT_BASED_CONNECTION_REQUEST,
|
||||
LE_CREDIT_BASED_CONNECTION_RESPONSE,
|
||||
LE_FLOW_CONTROL_CREDIT,
|
||||
L2CAP_CREDIT_BASED_CONNECTION_REQUEST,
|
||||
L2CAP_CREDIT_BASED_CONNECTION_RESPONSE,
|
||||
L2CAP_CREDIT_BASED_RECONFIGURE_REQUEST,
|
||||
L2CAP_CREDIT_BASED_RECONFIGURE_RESPONSE,
|
||||
#ifdef UNIT_TEST
|
||||
COMMAND_WITH_INVALID_FORMAT,
|
||||
#endif
|
||||
|
@ -44,6 +44,12 @@ TEST(L2CAP_LE_Signaling, l2cap_create_signaling_le_valid_cmd_2_format){
|
||||
CHECK_EQUAL(14, size);
|
||||
}
|
||||
|
||||
TEST(L2CAP_LE_Signaling, l2cap_create_signaling_le_valid_cmd_C_format){
|
||||
uint16_t cids[2] = { 0x3333, 0 };
|
||||
uint16_t size = l2cap_send_le_signaling_packet((hci_con_handle_t) 0x01, L2CAP_CREDIT_BASED_RECONFIGURE_REQUEST, 1, 0x1111, 0x2222, cids);
|
||||
CHECK_EQUAL(18, size);
|
||||
}
|
||||
|
||||
TEST(L2CAP_LE_Signaling, l2cap_create_signaling_le_valid_cmd_D_format){
|
||||
uint16_t size = l2cap_send_le_signaling_packet((hci_con_handle_t) 0x01, ECHO_REQUEST, 1, 0, NULL);
|
||||
CHECK_EQUAL(12, size);
|
||||
|
Loading…
x
Reference in New Issue
Block a user