mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-28 19:20:54 +00:00
pbap: send disconnect request before closing connection
This commit is contained in:
parent
645e6347ac
commit
0729a915d3
@ -429,6 +429,12 @@ void goep_client_create_connect_request(uint16_t goep_cid, uint8_t obex_version_
|
||||
goep_client_packet_append(&fields[0], sizeof(fields));
|
||||
}
|
||||
|
||||
void goep_client_create_disconnect_request(uint16_t goep_cid){
|
||||
UNUSED(goep_cid);
|
||||
goep_client_packet_init(goep_cid, OBEX_OPCODE_DISCONNECT);
|
||||
goep_client_packet_add_connection_id(goep_cid);
|
||||
}
|
||||
|
||||
void goep_client_create_get_request(uint16_t goep_cid){
|
||||
UNUSED(goep_cid);
|
||||
goep_client_packet_init(goep_cid, OBEX_OPCODE_GET | OBEX_OPCODE_FINAL_BIT_MASK);
|
||||
|
@ -108,6 +108,12 @@ void goep_client_set_connection_id(uint16_t goep_cid, uint32_t connection_id)
|
||||
*/
|
||||
void goep_client_create_connect_request(uint16_t goep_cid, uint8_t obex_version_number, uint8_t flags, uint16_t maximum_obex_packet_length);
|
||||
|
||||
/**
|
||||
* @brief Start Disconnect request
|
||||
* @param gope_cid
|
||||
*/
|
||||
void goep_client_create_disconnect_request(uint16_t goep_cid);
|
||||
|
||||
/**
|
||||
* @brief Start Get request
|
||||
* @param gope_cid
|
||||
|
@ -93,6 +93,9 @@ typedef enum {
|
||||
PBAP_CONNECT_RESPONSE_RECEIVED,
|
||||
PBAP_CONNECTED,
|
||||
//
|
||||
PBAP_W2_SEND_DISCONNECT_REQUEST,
|
||||
PBAP_W4_DISCONNECT_RESPONSE,
|
||||
//
|
||||
PBAP_W2_PULL_PHONEBOOK,
|
||||
PBAP_W4_PHONEBOOK,
|
||||
PBAP_W2_SET_PATH_ROOT,
|
||||
@ -190,9 +193,12 @@ static void pbap_handle_can_send_now(void){
|
||||
case PBAP_W2_SEND_CONNECT_REQUEST:
|
||||
goep_client_create_connect_request(pbap_client->goep_cid, OBEX_VERSION, 0, OBEX_MAX_PACKETLEN_DEFAULT);
|
||||
goep_client_add_header_target(pbap_client->goep_cid, 16, pbap_uuid);
|
||||
// state
|
||||
pbap_client->state = PBAP_W4_CONNECT_RESPONSE;
|
||||
// send packet
|
||||
goep_client_execute(pbap_client->goep_cid);
|
||||
return;
|
||||
case PBAP_W2_SEND_DISCONNECT_REQUEST:
|
||||
goep_client_create_disconnect_request(pbap_client->goep_cid);
|
||||
pbap_client->state = PBAP_W4_DISCONNECT_RESPONSE;
|
||||
goep_client_execute(pbap_client->goep_cid);
|
||||
return;
|
||||
case PBAP_W2_PULL_PHONEBOOK:
|
||||
@ -317,6 +323,9 @@ static void pbap_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *
|
||||
pbap_client_emit_connected_event(pbap_client, OBEX_CONNECT_FAILED);
|
||||
}
|
||||
break;
|
||||
case PBAP_W4_DISCONNECT_RESPONSE:
|
||||
goep_client_disconnect(pbap_client->goep_cid);
|
||||
break;
|
||||
case PBAP_W4_SET_PATH_ROOT_COMPLETE:
|
||||
case PBAP_W4_SET_PATH_ELEMENT_COMPLETE:
|
||||
if (packet[0] == OBEX_RESP_SUCCESS){
|
||||
@ -412,7 +421,8 @@ uint8_t pbap_connect(btstack_packet_handler_t handler, bd_addr_t addr, uint16_t
|
||||
uint8_t pbap_disconnect(uint16_t pbap_cid){
|
||||
UNUSED(pbap_cid);
|
||||
if (pbap_client->state != PBAP_CONNECTED) return BTSTACK_BUSY;
|
||||
goep_client_disconnect(pbap_client->goep_cid);
|
||||
pbap_client->state = PBAP_W2_SEND_DISCONNECT_REQUEST;
|
||||
goep_client_request_can_send_now(pbap_client->goep_cid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user