mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	not string anymore
This commit is contained in:
		| @@ -514,7 +514,8 @@ esp_err_t BluetoothConnection::read_characteristic(uint16_t handle) { | |||||||
|   return this->check_and_log_error_("esp_ble_gattc_read_char", err); |   return this->check_and_log_error_("esp_ble_gattc_read_char", err); | ||||||
| } | } | ||||||
|  |  | ||||||
| esp_err_t BluetoothConnection::write_characteristic(uint16_t handle, const std::string &data, bool response) { | esp_err_t BluetoothConnection::write_characteristic(uint16_t handle, const uint8_t *data, size_t length, | ||||||
|  |                                                     bool response) { | ||||||
|   if (!this->connected()) { |   if (!this->connected()) { | ||||||
|     this->log_gatt_not_connected_("write", "characteristic"); |     this->log_gatt_not_connected_("write", "characteristic"); | ||||||
|     return ESP_GATT_NOT_CONNECTED; |     return ESP_GATT_NOT_CONNECTED; | ||||||
| @@ -523,7 +524,7 @@ esp_err_t BluetoothConnection::write_characteristic(uint16_t handle, const std:: | |||||||
|            handle); |            handle); | ||||||
|  |  | ||||||
|   esp_err_t err = |   esp_err_t err = | ||||||
|       esp_ble_gattc_write_char(this->gattc_if_, this->conn_id_, handle, data.size(), (uint8_t *) data.data(), |       esp_ble_gattc_write_char(this->gattc_if_, this->conn_id_, handle, length, const_cast<uint8_t *>(data), | ||||||
|                                response ? ESP_GATT_WRITE_TYPE_RSP : ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE); |                                response ? ESP_GATT_WRITE_TYPE_RSP : ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE); | ||||||
|   return this->check_and_log_error_("esp_ble_gattc_write_char", err); |   return this->check_and_log_error_("esp_ble_gattc_write_char", err); | ||||||
| } | } | ||||||
| @@ -540,7 +541,7 @@ esp_err_t BluetoothConnection::read_descriptor(uint16_t handle) { | |||||||
|   return this->check_and_log_error_("esp_ble_gattc_read_char_descr", err); |   return this->check_and_log_error_("esp_ble_gattc_read_char_descr", err); | ||||||
| } | } | ||||||
|  |  | ||||||
| esp_err_t BluetoothConnection::write_descriptor(uint16_t handle, const std::string &data, bool response) { | esp_err_t BluetoothConnection::write_descriptor(uint16_t handle, const uint8_t *data, size_t length, bool response) { | ||||||
|   if (!this->connected()) { |   if (!this->connected()) { | ||||||
|     this->log_gatt_not_connected_("write", "descriptor"); |     this->log_gatt_not_connected_("write", "descriptor"); | ||||||
|     return ESP_GATT_NOT_CONNECTED; |     return ESP_GATT_NOT_CONNECTED; | ||||||
| @@ -549,7 +550,7 @@ esp_err_t BluetoothConnection::write_descriptor(uint16_t handle, const std::stri | |||||||
|            handle); |            handle); | ||||||
|  |  | ||||||
|   esp_err_t err = esp_ble_gattc_write_char_descr( |   esp_err_t err = esp_ble_gattc_write_char_descr( | ||||||
|       this->gattc_if_, this->conn_id_, handle, data.size(), (uint8_t *) data.data(), |       this->gattc_if_, this->conn_id_, handle, length, const_cast<uint8_t *>(data), | ||||||
|       response ? ESP_GATT_WRITE_TYPE_RSP : ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE); |       response ? ESP_GATT_WRITE_TYPE_RSP : ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE); | ||||||
|   return this->check_and_log_error_("esp_ble_gattc_write_char_descr", err); |   return this->check_and_log_error_("esp_ble_gattc_write_char_descr", err); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -18,9 +18,9 @@ class BluetoothConnection final : public esp32_ble_client::BLEClientBase { | |||||||
|   esp32_ble_tracker::AdvertisementParserType get_advertisement_parser_type() override; |   esp32_ble_tracker::AdvertisementParserType get_advertisement_parser_type() override; | ||||||
|  |  | ||||||
|   esp_err_t read_characteristic(uint16_t handle); |   esp_err_t read_characteristic(uint16_t handle); | ||||||
|   esp_err_t write_characteristic(uint16_t handle, const std::string &data, bool response); |   esp_err_t write_characteristic(uint16_t handle, const uint8_t *data, size_t length, bool response); | ||||||
|   esp_err_t read_descriptor(uint16_t handle); |   esp_err_t read_descriptor(uint16_t handle); | ||||||
|   esp_err_t write_descriptor(uint16_t handle, const std::string &data, bool response); |   esp_err_t write_descriptor(uint16_t handle, const uint8_t *data, size_t length, bool response); | ||||||
|  |  | ||||||
|   esp_err_t notify_characteristic(uint16_t handle, bool enable); |   esp_err_t notify_characteristic(uint16_t handle, bool enable); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -305,7 +305,7 @@ void BluetoothProxy::bluetooth_gatt_write(const api::BluetoothGATTWriteRequest & | |||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   auto err = connection->write_characteristic(msg.handle, msg.data, msg.response); |   auto err = connection->write_characteristic(msg.handle, msg.data, msg.data_len, msg.response); | ||||||
|   if (err != ESP_OK) { |   if (err != ESP_OK) { | ||||||
|     this->send_gatt_error(msg.address, msg.handle, err); |     this->send_gatt_error(msg.address, msg.handle, err); | ||||||
|   } |   } | ||||||
| @@ -331,7 +331,7 @@ void BluetoothProxy::bluetooth_gatt_write_descriptor(const api::BluetoothGATTWri | |||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   auto err = connection->write_descriptor(msg.handle, msg.data, true); |   auto err = connection->write_descriptor(msg.handle, msg.data, msg.data_len, true); | ||||||
|   if (err != ESP_OK) { |   if (err != ESP_OK) { | ||||||
|     this->send_gatt_error(msg.address, msg.handle, err); |     this->send_gatt_error(msg.address, msg.handle, err); | ||||||
|   } |   } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user