add gatt_client_write_long_characteristic_descriptor_using_descriptor_handle_with_offset and gatt_client_write_long_value_of_characteristic_with_offset

This commit is contained in:
Matthias Ringwald 2015-10-05 22:30:46 +02:00
parent 08e94b2a6e
commit d622771835
2 changed files with 18 additions and 7 deletions

View File

@ -1290,6 +1290,7 @@ static void att_signed_write_handle_cmac_result(uint8_t hash[8]){
if (peripheral->gatt_client_state == P_W4_CMAC_RESULT){
// store result
memcpy(peripheral->cmac, hash, 8);
// swap64(hash, peripheral->cmac);
peripheral->gatt_client_state = P_W2_SEND_SIGNED_WRITE;
gatt_client_run();
return;
@ -1562,7 +1563,7 @@ le_command_status_t gatt_client_write_value_of_characteristic_without_response(u
return BLE_PERIPHERAL_OK;
}
le_command_status_t gatt_client_write_value_of_characteristic(uint16_t gatt_client_id, uint16_t con_handle, uint16_t value_handle, uint16_t value_length, uint8_t * value){
le_command_status_t gatt_client_write_value_of_characteristic(uint16_t gatt_client_id, uint16_t con_handle, uint16_t value_handle, uint16_t value_length, uint8_t * data){
gatt_client_t * peripheral = provide_context_for_conn_handle_and_start_timer(con_handle);
if (!peripheral) return (le_command_status_t) BTSTACK_MEMORY_ALLOC_FAILED;
@ -1571,13 +1572,13 @@ le_command_status_t gatt_client_write_value_of_characteristic(uint16_t gatt_clie
peripheral->subclient_id = gatt_client_id;
peripheral->attribute_handle = value_handle;
peripheral->attribute_length = value_length;
peripheral->attribute_value = value;
peripheral->attribute_value = data;
peripheral->gatt_client_state = P_W2_SEND_WRITE_CHARACTERISTIC_VALUE;
gatt_client_run();
return BLE_PERIPHERAL_OK;
}
le_command_status_t gatt_client_write_long_value_of_characteristic(uint16_t gatt_client_id, uint16_t con_handle, uint16_t value_handle, uint16_t value_length, uint8_t * value){
le_command_status_t gatt_client_write_long_value_of_characteristic_with_offset(uint16_t gatt_client_id, uint16_t con_handle, uint16_t value_handle, uint16_t offset, uint16_t value_length, uint8_t * data){
gatt_client_t * peripheral = provide_context_for_conn_handle_and_start_timer(con_handle);
if (!peripheral) return (le_command_status_t) BTSTACK_MEMORY_ALLOC_FAILED;
@ -1586,13 +1587,17 @@ le_command_status_t gatt_client_write_long_value_of_characteristic(uint16_t gatt
peripheral->subclient_id = gatt_client_id;
peripheral->attribute_handle = value_handle;
peripheral->attribute_length = value_length;
peripheral->attribute_offset = 0;
peripheral->attribute_value = value;
peripheral->attribute_offset = offset;
peripheral->attribute_value = data;
peripheral->gatt_client_state = P_W2_PREPARE_WRITE;
gatt_client_run();
return BLE_PERIPHERAL_OK;
}
le_command_status_t gatt_client_write_long_value_of_characteristic(uint16_t gatt_client_id, uint16_t con_handle, uint16_t value_handle, uint16_t value_length, uint8_t * value){
return gatt_client_write_long_value_of_characteristic_with_offset(gatt_client_id, con_handle, value_handle, 0, value_length, value);
}
le_command_status_t gatt_client_reliable_write_long_value_of_characteristic(uint16_t gatt_client_id, uint16_t con_handle, uint16_t value_handle, uint16_t value_length, uint8_t * value){
gatt_client_t * peripheral = provide_context_for_conn_handle_and_start_timer(con_handle);
@ -1695,7 +1700,7 @@ le_command_status_t gatt_client_write_characteristic_descriptor(uint16_t gatt_cl
return gatt_client_write_characteristic_descriptor_using_descriptor_handle(gatt_client_id, con_handle, descriptor->handle, length, value);
}
le_command_status_t gatt_client_write_long_characteristic_descriptor_using_descriptor_handle(uint16_t gatt_client_id, uint16_t con_handle, uint16_t descriptor_handle, uint16_t length, uint8_t * data){
le_command_status_t gatt_client_write_long_characteristic_descriptor_using_descriptor_handle_with_offset(uint16_t gatt_client_id, uint16_t con_handle, uint16_t descriptor_handle, uint16_t offset, uint16_t length, uint8_t * data){
gatt_client_t * peripheral = provide_context_for_conn_handle_and_start_timer(con_handle);
if (!peripheral) return (le_command_status_t) BTSTACK_MEMORY_ALLOC_FAILED;
@ -1704,13 +1709,17 @@ le_command_status_t gatt_client_write_long_characteristic_descriptor_using_descr
peripheral->subclient_id = gatt_client_id;
peripheral->attribute_handle = descriptor_handle;
peripheral->attribute_length = length;
peripheral->attribute_offset = 0;
peripheral->attribute_offset = offset;
peripheral->attribute_value = data;
peripheral->gatt_client_state = P_W2_PREPARE_WRITE_CHARACTERISTIC_DESCRIPTOR;
gatt_client_run();
return BLE_PERIPHERAL_OK;
}
le_command_status_t gatt_client_write_long_characteristic_descriptor_using_descriptor_handle(uint16_t gatt_client_id, uint16_t con_handle, uint16_t descriptor_handle, uint16_t length, uint8_t * data){
return gatt_client_write_long_characteristic_descriptor_using_descriptor_handle_with_offset(gatt_client_id, con_handle, descriptor_handle, 0, length, data );
}
le_command_status_t gatt_client_write_long_characteristic_descriptor(uint16_t gatt_client_id, uint16_t con_handle, le_characteristic_descriptor_t * descriptor, uint16_t length, uint8_t * value){
return gatt_client_write_long_characteristic_descriptor_using_descriptor_handle(gatt_client_id, con_handle, descriptor->handle, length, value);
}

View File

@ -344,6 +344,7 @@ le_command_status_t gatt_client_signed_write_without_response(uint16_t gatt_clie
*/
le_command_status_t gatt_client_write_value_of_characteristic(uint16_t gatt_client_id, uint16_t con_handle, uint16_t characteristic_value_handle, uint16_t length, uint8_t * data);
le_command_status_t gatt_client_write_long_value_of_characteristic(uint16_t gatt_client_id, uint16_t con_handle, uint16_t characteristic_value_handle, uint16_t length, uint8_t * data);
le_command_status_t gatt_client_write_long_value_of_characteristic_with_offset(uint16_t gatt_client_id, uint16_t con_handle, uint16_t characteristic_value_handle, uint16_t offset, uint16_t length, uint8_t * data);
/**
* @brief Writes of the long characteristic value using the characteristic's value handle. It uses server response to validate that the write was correctly received. The gatt_complete_event_t with type set to GATT_QUERY_COMPLETE marks the end of write. The write is successfully performed, if the event's status field is set to 0.
@ -370,6 +371,7 @@ le_command_status_t gatt_client_write_characteristic_descriptor(uint16_t gatt_cl
le_command_status_t gatt_client_write_characteristic_descriptor_using_descriptor_handle(uint16_t gatt_client_id, uint16_t con_handle, uint16_t descriptor_handle, uint16_t length, uint8_t * data);
le_command_status_t gatt_client_write_long_characteristic_descriptor(uint16_t gatt_client_id, uint16_t con_handle, le_characteristic_descriptor_t * descriptor, uint16_t length, uint8_t * data);
le_command_status_t gatt_client_write_long_characteristic_descriptor_using_descriptor_handle(uint16_t gatt_client_id, uint16_t con_handle, uint16_t descriptor_handle, uint16_t length, uint8_t * data);
le_command_status_t gatt_client_write_long_characteristic_descriptor_using_descriptor_handle_with_offset(uint16_t gatt_client_id, uint16_t con_handle, uint16_t descriptor_handle, uint16_t offset, uint16_t length, uint8_t * data);
/**
* @brief Writes the client characteristic configuration of the specified characteristic. It is used to subscribe for notifications or indications of the characteristic value. For notifications or indications specify: GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION resp. GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION as configuration value.