mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-19 06:40:54 +00:00
ble client: implemented write characteristic descriptor, not tested
This commit is contained in:
parent
c177678a3a
commit
807e6f62ee
@ -293,7 +293,7 @@ static le_command_status_t send_gatt_read_blob_request(le_peripheral_t *peripher
|
|||||||
return att_read_blob_request(ATT_READ_BLOB_REQUEST, peripheral->handle, peripheral->attribute_handle, peripheral->attribute_offset);
|
return att_read_blob_request(ATT_READ_BLOB_REQUEST, peripheral->handle, peripheral->attribute_handle, peripheral->attribute_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static le_command_status_t send_gatt_write_characteristic_value_request(le_peripheral_t * peripheral){
|
static le_command_status_t send_gatt_write_attribute_value_request(le_peripheral_t * peripheral){
|
||||||
return att_write_request(ATT_WRITE_REQUEST, peripheral->handle, peripheral->attribute_handle, peripheral->attribute_length, peripheral->attribute_value);
|
return att_write_request(ATT_WRITE_REQUEST, peripheral->handle, peripheral->attribute_handle, peripheral->attribute_length, peripheral->attribute_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,7 +526,7 @@ static void handle_peripheral_list(){
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case P_W2_SEND_WRITE_CHARACTERISTIC_VALUE:
|
case P_W2_SEND_WRITE_CHARACTERISTIC_VALUE:
|
||||||
status = send_gatt_write_characteristic_value_request(peripheral);
|
status = send_gatt_write_attribute_value_request(peripheral);
|
||||||
if (status != BLE_PERIPHERAL_OK) break;
|
if (status != BLE_PERIPHERAL_OK) break;
|
||||||
peripheral->state = P_W4_WRITE_CHARACTERISTIC_VALUE_RESULT;
|
peripheral->state = P_W4_WRITE_CHARACTERISTIC_VALUE_RESULT;
|
||||||
break;
|
break;
|
||||||
@ -573,6 +573,12 @@ static void handle_peripheral_list(){
|
|||||||
peripheral->state = P_W4_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_RESULT;
|
peripheral->state = P_W4_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_RESULT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case P_W2_SEND_WRITE_CHARACTERISTIC_DESCRIPTOR:
|
||||||
|
status = send_gatt_write_attribute_value_request(peripheral);
|
||||||
|
if (status != BLE_PERIPHERAL_OK) break;
|
||||||
|
peripheral->state = P_W4_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT;
|
||||||
|
break;
|
||||||
|
|
||||||
case P_W2_WRITE_CLIENT_CHARACTERISTIC_CONFIGURATION:
|
case P_W2_WRITE_CLIENT_CHARACTERISTIC_CONFIGURATION:
|
||||||
status = send_gatt_write_client_characteristic_configuration_request(peripheral);
|
status = send_gatt_write_client_characteristic_configuration_request(peripheral);
|
||||||
if (status != BLE_PERIPHERAL_OK) break;
|
if (status != BLE_PERIPHERAL_OK) break;
|
||||||
@ -881,6 +887,29 @@ le_command_status_t le_central_read_long_characteristic_descriptor(le_peripheral
|
|||||||
return BLE_PERIPHERAL_OK;
|
return BLE_PERIPHERAL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
le_command_status_t le_central_write_characteristic_descriptor(le_peripheral_t *peripheral, le_characteristic_descriptor_t * descriptor, uint16_t length, uint8_t * value){
|
||||||
|
|
||||||
|
peripheral->attribute_handle = descriptor->handle;
|
||||||
|
peripheral->attribute_length = length;
|
||||||
|
peripheral->attribute_offset = 0;
|
||||||
|
peripheral->attribute_value = value;
|
||||||
|
|
||||||
|
peripheral->state = P_W2_SEND_WRITE_CHARACTERISTIC_DESCRIPTOR;
|
||||||
|
gatt_client_run();
|
||||||
|
return BLE_PERIPHERAL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
le_command_status_t le_central_write_long_characteristic_descriptor(le_peripheral_t *peripheral, le_characteristic_descriptor_t * descriptor, uint16_t length, uint8_t * value){
|
||||||
|
peripheral->attribute_handle = descriptor->handle;
|
||||||
|
peripheral->attribute_length = length;
|
||||||
|
peripheral->attribute_offset = 0;
|
||||||
|
peripheral->attribute_value = value;
|
||||||
|
|
||||||
|
peripheral->state = P_W2_SEND_WRITE_CHARACTERISTIC_DESCRIPTOR;
|
||||||
|
gatt_client_run();
|
||||||
|
return BLE_PERIPHERAL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void gatt_client_run(){
|
static void gatt_client_run(){
|
||||||
if (state == W4_ON) return;
|
if (state == W4_ON) return;
|
||||||
@ -1438,6 +1467,9 @@ static void att_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *pa
|
|||||||
peripheral->state = P_CONNECTED;
|
peripheral->state = P_CONNECTED;
|
||||||
send_gatt_complete_event(peripheral, GATT_CLIENT_CHARACTERISTIC_CONFIGURATION_COMPLETE, 0);
|
send_gatt_complete_event(peripheral, GATT_CLIENT_CHARACTERISTIC_CONFIGURATION_COMPLETE, 0);
|
||||||
break;
|
break;
|
||||||
|
case P_W4_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT:
|
||||||
|
send_gatt_complete_event(peripheral, GATT_CHARACTERISTIC_DESCRIPTOR_WRITE_RESPONSE, 0);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -124,6 +124,9 @@ typedef enum {
|
|||||||
P_W2_SEND_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_QUERY,
|
P_W2_SEND_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_QUERY,
|
||||||
P_W4_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_RESULT,
|
P_W4_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_RESULT,
|
||||||
|
|
||||||
|
P_W2_SEND_WRITE_CHARACTERISTIC_DESCRIPTOR,
|
||||||
|
P_W4_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT,
|
||||||
|
|
||||||
P_W2_CANCEL_CONNECT,
|
P_W2_CANCEL_CONNECT,
|
||||||
P_W4_CONNECT_CANCELLED,
|
P_W4_CONNECT_CANCELLED,
|
||||||
P_W2_DISCONNECT,
|
P_W2_DISCONNECT,
|
||||||
|
@ -247,6 +247,9 @@ extern "C" {
|
|||||||
#define GATT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT 0xC2
|
#define GATT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT 0xC2
|
||||||
#define GATT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT 0xC3
|
#define GATT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT 0xC3
|
||||||
#define GATT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_COMPLETE 0xC4
|
#define GATT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_COMPLETE 0xC4
|
||||||
|
#define GATT_CHARACTERISTIC_DESCRIPTOR_WRITE_RESPONSE 0xC5
|
||||||
|
#define GATT_LONG_CHARACTERISTIC_DESCRIPTOR_WRITE_RESPONSE 0xC6
|
||||||
|
#define GATT_LONG_CHARACTERISTIC_DESCRIPTOR_WRITE_COMPLETE 0xC7
|
||||||
|
|
||||||
// data: event(8), len(8), status (8), hci_handle (16), attribute_handle (16)
|
// data: event(8), len(8), status (8), hci_handle (16), attribute_handle (16)
|
||||||
#define ATT_HANDLE_VALUE_INDICATION_COMPLETE 0xBF
|
#define ATT_HANDLE_VALUE_INDICATION_COMPLETE 0xBF
|
||||||
|
Loading…
x
Reference in New Issue
Block a user