+bool LowEnergyClient::SetMtu(std::string address, int mtu) {
+ VLOG(2) << __func__ << "Address: " << address
+ << " MTU: " << mtu;
+
+ bt_bdaddr_t bda;
+ util::BdAddrFromString(address, &bda);
+
+ std::map<const bt_bdaddr_t, int>::iterator conn_id;
+ {
+ lock_guard<mutex> lock(connection_fields_lock_);
+ conn_id = connection_ids_.find(bda);
+ if (conn_id == connection_ids_.end()) {
+ LOG(WARNING) << "Can't set MTU, no existing connection to " << address;
+ return false;
+ }
+ }
+
+ bt_status_t status = hal::BluetoothGattInterface::Get()->
+ GetClientHALInterface()->configure_mtu(conn_id->second, mtu);
+ if (status != BT_STATUS_SUCCESS) {
+ LOG(ERROR) << "HAL call to set MTU failed";
+ return false;
+ }
+
+ return true;
+}
+