mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-07 16:20:19 +00:00
use correct size for max l2cap packet used in rfcomm
This commit is contained in:
parent
ea54feb7f2
commit
5af02935dd
@ -48,8 +48,6 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define L2CAP_HEADER_SIZE 4
|
|
||||||
|
|
||||||
// size of HCI ACL + L2CAP Header for regular data packets (8)
|
// size of HCI ACL + L2CAP Header for regular data packets (8)
|
||||||
#define COMPLETE_L2CAP_HEADER (HCI_ACL_DATA_PKT_HDR + L2CAP_HEADER_SIZE)
|
#define COMPLETE_L2CAP_HEADER (HCI_ACL_DATA_PKT_HDR + L2CAP_HEADER_SIZE)
|
||||||
|
|
||||||
|
@ -50,6 +50,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define L2CAP_SIG_ID_INVALID 0
|
#define L2CAP_SIG_ID_INVALID 0
|
||||||
|
|
||||||
|
#define L2CAP_HEADER_SIZE 4
|
||||||
|
|
||||||
void l2cap_init(void);
|
void l2cap_init(void);
|
||||||
void l2cap_register_packet_handler(void (*handler)(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size));
|
void l2cap_register_packet_handler(void (*handler)(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size));
|
||||||
void l2cap_create_channel_internal(void * connection, btstack_packet_handler_t packet_handler, bd_addr_t address, uint16_t psm, uint16_t mtu);
|
void l2cap_create_channel_internal(void * connection, btstack_packet_handler_t packet_handler, bd_addr_t address, uint16_t psm, uint16_t mtu);
|
||||||
|
10
src/rfcomm.c
10
src/rfcomm.c
@ -75,7 +75,7 @@
|
|||||||
#define BT_RFCOMM_TEST_CMD 0x23
|
#define BT_RFCOMM_TEST_CMD 0x23
|
||||||
#define BT_RFCOMM_TEST_RSP 0x21
|
#define BT_RFCOMM_TEST_RSP 0x21
|
||||||
|
|
||||||
#define RFCOMM_MAX_PAYLOAD (HCI_ACL_BUFFER_SIZE-HCI_ACL_DATA_PKT_HDR)
|
#define MAX_L2CAP_PAYLOAD (HCI_ACL_BUFFER_SIZE-L2CAP_HEADER_SIZE)
|
||||||
#define RFCOMM_MULIPLEXER_TIMEOUT_MS 60000
|
#define RFCOMM_MULIPLEXER_TIMEOUT_MS 60000
|
||||||
|
|
||||||
// FCS calc
|
// FCS calc
|
||||||
@ -95,7 +95,7 @@ static linked_list_t rfcomm_channels = NULL;
|
|||||||
static linked_list_t rfcomm_services = NULL;
|
static linked_list_t rfcomm_services = NULL;
|
||||||
|
|
||||||
// used to assemble rfcomm packets
|
// used to assemble rfcomm packets
|
||||||
uint8_t rfcomm_out_buffer[RFCOMM_MAX_PAYLOAD];
|
uint8_t rfcomm_out_buffer[MAX_L2CAP_PAYLOAD];
|
||||||
|
|
||||||
static void (*app_packet_handler)(void * connection, uint8_t packet_type,
|
static void (*app_packet_handler)(void * connection, uint8_t packet_type,
|
||||||
uint16_t channel, uint8_t *packet, uint16_t size);
|
uint16_t channel, uint8_t *packet, uint16_t size);
|
||||||
@ -195,7 +195,7 @@ static void rfcomm_multiplexer_initialize(rfcomm_multiplexer_t *multiplexer){
|
|||||||
|
|
||||||
// - Max RFCOMM header has 6 bytes (P/F bit is set, payload length >= 128)
|
// - Max RFCOMM header has 6 bytes (P/F bit is set, payload length >= 128)
|
||||||
// - therefore, we set RFCOMM max frame size <= Local L2CAP MTU - 6
|
// - therefore, we set RFCOMM max frame size <= Local L2CAP MTU - 6
|
||||||
multiplexer->max_frame_size = RFCOMM_MAX_PAYLOAD - 6; // max
|
multiplexer->max_frame_size = MAX_L2CAP_PAYLOAD - 6; // max
|
||||||
}
|
}
|
||||||
|
|
||||||
static rfcomm_multiplexer_t * rfcomm_multiplexer_create_for_addr(bd_addr_t *addr){
|
static rfcomm_multiplexer_t * rfcomm_multiplexer_create_for_addr(bd_addr_t *addr){
|
||||||
@ -1638,7 +1638,7 @@ void rfcomm_create_channel_internal(void * connection, bd_addr_t *addr, uint8_t
|
|||||||
|
|
||||||
channel->state = RFCOMM_CHANNEL_W4_MULTIPLEXER;
|
channel->state = RFCOMM_CHANNEL_W4_MULTIPLEXER;
|
||||||
|
|
||||||
l2cap_create_channel_internal(connection, rfcomm_packet_handler, *addr, PSM_RFCOMM, RFCOMM_MAX_PAYLOAD);
|
l2cap_create_channel_internal(connection, rfcomm_packet_handler, *addr, PSM_RFCOMM, MAX_L2CAP_PAYLOAD);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1674,7 +1674,7 @@ void rfcomm_register_service_internal(void * connection, uint8_t channel, uint16
|
|||||||
|
|
||||||
// register with l2cap if not registered before
|
// register with l2cap if not registered before
|
||||||
if (linked_list_empty(&rfcomm_services)){
|
if (linked_list_empty(&rfcomm_services)){
|
||||||
l2cap_register_service_internal(NULL, rfcomm_packet_handler, PSM_RFCOMM, RFCOMM_MAX_PAYLOAD);
|
l2cap_register_service_internal(NULL, rfcomm_packet_handler, PSM_RFCOMM, MAX_L2CAP_PAYLOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill in
|
// fill in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user