l2cap: return error for l2cap_unregister_service

This commit is contained in:
Matthias Ringwald 2016-07-17 22:43:06 +02:00
parent e981dfc496
commit 7e8856ebfd
3 changed files with 8 additions and 5 deletions

View File

@ -118,6 +118,7 @@ typedef uint8_t sm_key_t[16];
#define L2CAP_SERVICE_ALREADY_REGISTERED 0x69
#define L2CAP_DATA_LEN_EXCEEDS_REMOTE_MTU 0x6A
#define L2CAP_SERVICE_DOES_NOT_EXIST 0x6B
#define RFCOMM_MULTIPLEXER_STOPPED 0x70
#define RFCOMM_CHANNEL_ALREADY_REGISTERED 0x71

View File

@ -1560,18 +1560,20 @@ uint8_t l2cap_register_service(btstack_packet_handler_t service_packet_handler,
return 0;
}
void l2cap_unregister_service(uint16_t psm){
uint8_t l2cap_unregister_service(uint16_t psm){
log_info("L2CAP_UNREGISTER_SERVICE psm 0x%x", psm);
l2cap_service_t *service = l2cap_get_service(psm);
if (!service) return;
if (!service) return L2CAP_SERVICE_DOES_NOT_EXIST;
btstack_linked_list_remove(&l2cap_services, (btstack_linked_item_t *) service);
btstack_memory_l2cap_service_free(service);
// disable page scan when no services registered
if (!btstack_linked_list_empty(&l2cap_services)) return;
gap_connectable_control(0);
if (btstack_linked_list_empty(&l2cap_services)) {
gap_connectable_control(0);
}
return 0;
}
// Bluetooth 4.0 - allows to register handler for Attribute Protocol and Security Manager Protocol

View File

@ -234,7 +234,7 @@ uint8_t l2cap_register_service(btstack_packet_handler_t packet_handler, uint16_t
/**
* @brief Unregisters L2CAP service with given PSM. On embedded systems, use NULL for connection parameter.
*/
void l2cap_unregister_service(uint16_t psm);
uint8_t l2cap_unregister_service(uint16_t psm);
/**
* @brief Accepts incoming L2CAP connection.