mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 13:20:39 +00:00
gatt_client: add gatt_client_request_can_write_without_response_event()
This commit is contained in:
parent
71af96a130
commit
47181045ae
@ -998,10 +998,22 @@ static int gatt_client_run_for_peripheral( gatt_client_t * peripheral){
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// requested can send snow?
|
||||
if (peripheral->write_without_response_callback){
|
||||
btstack_packet_handler_t packet_handler = peripheral->write_without_response_callback;
|
||||
peripheral->write_without_response_callback = NULL;
|
||||
uint8_t event[4];
|
||||
event[0] = GATT_EVENT_CAN_WRITE_WITHOUT_RESPONSE;
|
||||
event[1] = sizeof(event) - 2;
|
||||
little_endian_store_16(event, 2, peripheral->con_handle);
|
||||
packet_handler(HCI_EVENT_PACKET, peripheral->con_handle, event, sizeof(event));
|
||||
return 1; // to trigger requeueing (even if higher layer didn't sent)
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1915,3 +1927,12 @@ void gatt_client_send_mtu_negotiation(btstack_packet_handler_t callback, hci_con
|
||||
gatt_client_run();
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t gatt_client_request_can_write_without_response_event(btstack_packet_handler_t callback, hci_con_handle_t con_handle){
|
||||
gatt_client_t * context = provide_context_for_conn_handle(con_handle);
|
||||
if (!context) return BTSTACK_MEMORY_ALLOC_FAILED;
|
||||
if (context->write_without_response_callback) return GATT_CLIENT_IN_WRONG_STATE;
|
||||
context->write_without_response_callback = callback;
|
||||
att_dispatch_client_request_can_send_now_event(context->con_handle);
|
||||
return 0;
|
||||
}
|
||||
|
@ -138,6 +138,9 @@ typedef struct gatt_client{
|
||||
// user callback
|
||||
btstack_packet_handler_t callback;
|
||||
|
||||
// can write without response callback
|
||||
btstack_packet_handler_t write_without_response_callback;
|
||||
|
||||
hci_con_handle_t con_handle;
|
||||
|
||||
uint8_t address_type;
|
||||
@ -358,6 +361,14 @@ void gatt_client_listen_for_characteristic_value_updates(gatt_client_notificatio
|
||||
*/
|
||||
void gatt_client_stop_listening_for_characteristic_value_updates(gatt_client_notification_t * notification);
|
||||
|
||||
/**
|
||||
* @brief Requests GATT_EVENT_CAN_WRITE_WITHOUT_RESPONSE that guarantees a single successful gatt_client_write_value_of_characteristic_without_response
|
||||
* @param packet_handler
|
||||
* @param con_handle
|
||||
* @returns status
|
||||
*/
|
||||
uint8_t gatt_client_request_can_write_without_response_event(btstack_packet_handler_t callback, hci_con_handle_t con_handle);
|
||||
|
||||
/**
|
||||
* @brief -> gatt complete event
|
||||
*/
|
||||
@ -381,9 +392,6 @@ void gatt_client_deserialize_service(const uint8_t *packet, int offset, gatt_cli
|
||||
void gatt_client_deserialize_characteristic(const uint8_t * packet, int offset, gatt_client_characteristic_t * characteristic);
|
||||
void gatt_client_deserialize_characteristic_descriptor(const uint8_t * packet, int offset, gatt_client_characteristic_descriptor_t * descriptor);
|
||||
|
||||
// only used for testing
|
||||
void gatt_client_pts_suppress_mtu_exchange(void);
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user