mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-14 01:27:41 +00:00
allow specify MTU for outgoing l2cap connections (was 150 before)
This commit is contained in:
parent
fa2b26270d
commit
15470d2718
@ -238,6 +238,7 @@ extern const hci_cmd_t hci_write_simple_pairing_mode;
|
||||
|
||||
extern const hci_cmd_t l2cap_accept_connection;
|
||||
extern const hci_cmd_t l2cap_create_channel;
|
||||
extern const hci_cmd_t l2cap_create_channel_mtu;
|
||||
extern const hci_cmd_t l2cap_decline_connection;
|
||||
extern const hci_cmd_t l2cap_disconnect;
|
||||
extern const hci_cmd_t l2cap_register_service;
|
||||
|
@ -132,10 +132,16 @@ static int btstack_command_handler(connection_t *connection, uint8_t *packet, ui
|
||||
hci_emit_system_bluetooth_enabled(0);
|
||||
break;
|
||||
#endif
|
||||
case L2CAP_CREATE_CHANNEL_MTU:
|
||||
bt_flip_addr(addr, &packet[3]);
|
||||
psm = READ_BT_16(packet, 9);
|
||||
mtu = READ_BT_16(packet, 11);
|
||||
l2cap_create_channel_internal( connection, NULL, addr, psm, mtu);
|
||||
break;
|
||||
case L2CAP_CREATE_CHANNEL:
|
||||
bt_flip_addr(addr, &packet[3]);
|
||||
psm = READ_BT_16(packet, 9);
|
||||
l2cap_create_channel_internal( connection, NULL, addr, psm );
|
||||
l2cap_create_channel_internal( connection, NULL, addr, psm, 150); // until r865
|
||||
break;
|
||||
case L2CAP_DISCONNECT:
|
||||
cid = READ_BT_16(packet, 3);
|
||||
|
@ -102,6 +102,9 @@
|
||||
// decline l2cap disconnect,@param bd_addr(48), dest cid (16), reason(8)
|
||||
#define L2CAP_DECLINE_CONNECTION 0x25
|
||||
|
||||
// create l2cap channel: @param bd_addr(48), psm (16), mtu (16)
|
||||
#define L2CAP_CREATE_CHANNEL_MTU 0x26
|
||||
|
||||
// register SDP Service Record: service record (size)
|
||||
#define SDP_REGISTER_SERVICE_RECORD 0x30
|
||||
|
||||
|
@ -346,7 +346,10 @@ const hci_cmd_t l2cap_create_channel = {
|
||||
OPCODE(OGF_BTSTACK, L2CAP_CREATE_CHANNEL), "B2"
|
||||
// @param bd_addr(48), psm (16)
|
||||
};
|
||||
|
||||
const hci_cmd_t l2cap_create_channel_mtu = {
|
||||
OPCODE(OGF_BTSTACK, L2CAP_CREATE_CHANNEL), "B22"
|
||||
// @param bd_addr(48), psm (16), mtu (16)
|
||||
};
|
||||
const hci_cmd_t l2cap_disconnect = {
|
||||
OPCODE(OGF_BTSTACK, L2CAP_DISCONNECT), "21"
|
||||
// @param channel(16), reason(8)
|
||||
|
@ -229,7 +229,8 @@ int l2cap_send_internal(uint16_t local_cid, uint8_t *data, uint16_t len){
|
||||
}
|
||||
|
||||
// open outgoing L2CAP channel
|
||||
void l2cap_create_channel_internal(void * connection, btstack_packet_handler_t packet_handler, bd_addr_t address, uint16_t psm){
|
||||
void l2cap_create_channel_internal(void * connection, btstack_packet_handler_t packet_handler,
|
||||
bd_addr_t address, uint16_t psm, uint16_t mtu){
|
||||
|
||||
// alloc structure
|
||||
l2cap_channel_t * chan = malloc(sizeof(l2cap_channel_t));
|
||||
@ -243,7 +244,7 @@ void l2cap_create_channel_internal(void * connection, btstack_packet_handler_t p
|
||||
chan->connection = connection;
|
||||
chan->packet_handler = packet_handler;
|
||||
chan->remote_mtu = L2CAP_MINIMAL_MTU;
|
||||
chan->local_mtu = 150; // TODO allow to specify this
|
||||
chan->local_mtu = mtu;
|
||||
|
||||
// flow control
|
||||
chan->packets_granted = 0;
|
||||
|
@ -112,7 +112,7 @@ typedef struct {
|
||||
|
||||
void l2cap_init();
|
||||
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);
|
||||
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_disconnect_internal(uint16_t local_cid, uint8_t reason);
|
||||
int l2cap_send_internal(uint16_t local_cid, uint8_t *data, uint16_t len);
|
||||
uint16_t l2cap_get_remote_mtu_for_local_cid(uint16_t local_cid);
|
||||
|
Loading…
x
Reference in New Issue
Block a user