File tree 2 files changed +35
-1
lines changed
2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -545,6 +545,39 @@ uint16_t BLEClient::getMTU() {
545
545
return m_mtu;
546
546
}
547
547
548
+
549
+ /* *
550
+ @brief Set the local and remote MTU size.
551
+ Should be called once after client connects if MTU size needs to be changed.
552
+ @return bool indicating if MTU was successfully set locally and on remote.
553
+ */
554
+ bool BLEClient::setMTU (uint16_t mtu)
555
+ {
556
+ esp_err_t err = esp_ble_gatt_set_local_mtu (mtu); // First must set local MTU value.
557
+ if (err == ESP_OK)
558
+ {
559
+ err = esp_ble_gattc_send_mtu_req (m_gattc_if,m_conn_id); // Once local is set successfully set remote size
560
+ if (err!=ESP_OK)
561
+ {
562
+ log_e (" Error setting send MTU request MTU: %d err=%d" , mtu,err);
563
+ return false ;
564
+ }
565
+ }
566
+ else
567
+ {
568
+ log_e (" can't set local mtu value: %d" , mtu);
569
+ return false ;
570
+ }
571
+ log_v (" << setLocalMTU" );
572
+
573
+ m_mtu = mtu; // successfully changed
574
+
575
+ return true ;
576
+ }
577
+
578
+
579
+
580
+
548
581
/* *
549
582
* @brief Return a string representation of this client.
550
583
* @return A string representation of this client.
Original file line number Diff line number Diff line change @@ -57,7 +57,8 @@ class BLEClient {
57
57
uint16_t getConnId ();
58
58
esp_gatt_if_t getGattcIf ();
59
59
uint16_t getMTU ();
60
-
60
+ bool setMTU (uint16_t mtu);
61
+
61
62
uint16_t m_appId;
62
63
private:
63
64
friend class BLEDevice ;
You can’t perform that action at this time.
0 commit comments