goep_server: add disconnect, increase l2cap ertm buffer

This commit is contained in:
Matthias Ringwald 2024-09-25 16:10:52 +02:00
parent 650271be49
commit 03ebb5214d
2 changed files with 40 additions and 6 deletions

View File

@ -63,12 +63,12 @@ static l2cap_ertm_config_t ertm_config = {
2000,
12000,
(GOEP_SERVER_ERTM_BUFFER / 2), // l2cap ertm mtu
2,
2,
4,
4,
1, // 16-bit FCS
};
static uint8_t goep_server_l2cap_packet_buffer[1000];
static uint8_t goep_server_l2cap_packet_buffer[GOEP_SERVER_ERTM_BUFFER];
#endif
@ -430,7 +430,11 @@ uint8_t goep_server_register_service(btstack_packet_handler_t callback, uint8_t
if (service != NULL) {
return L2CAP_SERVICE_ALREADY_REGISTERED;
}
}
}
#else
UNUSED(l2cap_mtu);
UNUSED(l2cap_psm);
UNUSED(security_level);
#endif
// alloc structure
@ -680,13 +684,36 @@ uint8_t goep_server_execute(uint16_t goep_cid, uint8_t response_code){
#endif
case GOEP_CONNECTION_RFCOMM:
return rfcomm_send_prepared(connection->bearer_cid, pos);
break;
default:
btstack_unreachable();
return ERROR_CODE_SUCCESS;
}
}
uint8_t goep_server_disconnect(uint16_t goep_cid){
goep_server_connection_t * connection = goep_server_get_connection_for_goep_cid(goep_cid);
if (connection == NULL) {
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
}
if (connection->state < GOEP_SERVER_CONNECTED){
return ERROR_CODE_COMMAND_DISALLOWED;
}
switch (connection->type) {
#ifdef ENABLE_GOEP_L2CAP
case GOEP_CONNECTION_L2CAP:
return l2cap_disconnect(connection->bearer_cid);
#endif
case GOEP_CONNECTION_RFCOMM:
return rfcomm_disconnect(connection->bearer_cid);
default:
btstack_unreachable();
break;
}
return ERROR_CODE_SUCCESS;
}
void goep_server_deinit(void){
goep_server_cid_counter = 0;
goep_server_services = NULL;

View File

@ -47,7 +47,7 @@ extern "C" {
#ifdef ENABLE_GOEP_L2CAP
#ifndef GOEP_SERVER_ERTM_BUFFER
#define GOEP_SERVER_ERTM_BUFFER 1000
#define GOEP_SERVER_ERTM_BUFFER 2000
#endif
#endif
@ -208,6 +208,13 @@ uint8_t goep_server_header_add_application_parameters(uint16_t goep_cid, const u
*/
uint8_t goep_server_execute(uint16_t goep_cid, uint8_t response_code);
/**
* @brief Disconnect client
* @param goep_cid
* @return status
*/
uint8_t goep_server_disconnect(uint16_t goep_cid);
/**
* De-Init
*/