mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-28 00:35:42 +00:00
allow to set packet handler for internal l2cap connections
This commit is contained in:
parent
81aa29cbfd
commit
6b296a2712
@ -135,7 +135,7 @@ static int btstack_command_handler(connection_t *connection, uint8_t *packet, ui
|
|||||||
case L2CAP_CREATE_CHANNEL:
|
case L2CAP_CREATE_CHANNEL:
|
||||||
bt_flip_addr(addr, &packet[3]);
|
bt_flip_addr(addr, &packet[3]);
|
||||||
psm = READ_BT_16(packet, 9);
|
psm = READ_BT_16(packet, 9);
|
||||||
l2cap_create_channel_internal( connection, addr, psm );
|
l2cap_create_channel_internal( connection, NULL, addr, psm );
|
||||||
break;
|
break;
|
||||||
case L2CAP_DISCONNECT:
|
case L2CAP_DISCONNECT:
|
||||||
cid = READ_BT_16(packet, 3);
|
cid = READ_BT_16(packet, 3);
|
||||||
|
@ -183,7 +183,7 @@ void l2cap_send_internal(uint16_t local_cid, uint8_t *data, uint16_t len){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// open outgoing L2CAP channel
|
// open outgoing L2CAP channel
|
||||||
void l2cap_create_channel_internal(void * connection, 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){
|
||||||
|
|
||||||
// alloc structure
|
// alloc structure
|
||||||
l2cap_channel_t * chan = malloc(sizeof(l2cap_channel_t));
|
l2cap_channel_t * chan = malloc(sizeof(l2cap_channel_t));
|
||||||
@ -195,7 +195,7 @@ void l2cap_create_channel_internal(void * connection, bd_addr_t address, uint16_
|
|||||||
chan->psm = psm;
|
chan->psm = psm;
|
||||||
chan->handle = 0;
|
chan->handle = 0;
|
||||||
chan->connection = connection;
|
chan->connection = connection;
|
||||||
chan->packet_handler = NULL;
|
chan->packet_handler = packet_handler;
|
||||||
chan->remote_mtu = L2CAP_MINIMAL_MTU;
|
chan->remote_mtu = L2CAP_MINIMAL_MTU;
|
||||||
|
|
||||||
// set initial state
|
// set initial state
|
||||||
|
@ -107,7 +107,7 @@ typedef struct {
|
|||||||
|
|
||||||
void l2cap_init();
|
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_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, 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);
|
||||||
void l2cap_disconnect_internal(uint16_t local_cid, uint8_t reason);
|
void l2cap_disconnect_internal(uint16_t local_cid, uint8_t reason);
|
||||||
void l2cap_send_internal(uint16_t local_cid, uint8_t *data, uint16_t len);
|
void 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);
|
uint16_t l2cap_get_remote_mtu_for_local_cid(uint16_t local_cid);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user