@@ -3514,15 +3514,14 @@ carries this characteristic.
35143514Note: This value can change while the device is connected, for example because
35153515an [=Exchange MTU=] procedure completes after service discovery. On some
35163516platforms an updated value can arrive late, after services are resolved.
3517- Reading
3518- {{BluetoothRemoteGATTCharacteristic/maxWriteWithoutResponseSize}} always
3519- returns the current value, so applications SHOULD read it each time it is
3520- needed rather than caching it in a variable. As a convenience, the UA also
3521- [=fires an event=] named {{maxwritewithoutresponsesizechanged}} when it
3522- observes a change, so applications that batch large transfers can react to an
3523- increase instead of polling. Not every platform surfaces ATT_MTU changes, so
3524- the event is not guaranteed to fire; the attribute remains the authoritative
3525- source and a fresh read returns the current value regardless.
3517+ Whenever the UA observes that the ATT_MTU has changed it updates this value and
3518+ [=fires an event=] named {{maxwritewithoutresponsesizechanged}} , so the two stay
3519+ in sync: the value never changes without the event firing. Some platforms do
3520+ not surface ATT_MTU changes to the UA at all; on those platforms the value
3521+ stays constant after it is first established and the event never fires.
3522+ Applications that batch large transfers can listen for
3523+ {{maxwritewithoutresponsesizechanged}} to react to an increase instead of
3524+ re-reading the attribute on every write.
35263525</div>
35273526
35283527Instances of {{BluetoothRemoteGATTCharacteristic}} are created with the
@@ -3542,6 +3541,20 @@ Instances of {{BluetoothRemoteGATTCharacteristic}} are created with the
35423541 Characteristic has been removed or otherwise invalidated.
35433542 </td>
35443543 </tr>
3544+ <tr>
3545+ <td> <dfn>\[[maxWriteWithoutResponseSize]]</dfn> </td>
3546+ <td><code> 20</code></td>
3547+ <td>
3548+ The value, in octets, exposed by
3549+ {{BluetoothRemoteGATTCharacteristic/maxWriteWithoutResponseSize}} . It is
3550+ established when the {{[[representedCharacteristic]]}} is discovered and
3551+ updated only when the UA learns of an ATT_MTU change for the
3552+ [=ATT Bearer=] that carries it, at which point the
3553+ {{maxwritewithoutresponsesizechanged}} event is fired. The initial value
3554+ of <code> 20</code> corresponds to the default ATT_MTU of 23 octets minus
3555+ the 3-octet ATT Write Command header.
3556+ </td>
3557+ </tr>
35453558 <tr>
35463559 <td> <dfn>\[[automatedCharacteristicReadResponse]]</dfn> </td>
35473560 <td><code> "not-expected"</code></td>
@@ -3648,20 +3661,15 @@ getDescriptors(<var>descriptor</var>)</dfn></code> method retrieves a list of
36483661The {{BluetoothRemoteGATTCharacteristic/maxWriteWithoutResponseSize}} getter
36493662steps are:
36503663
3651- 1. Let |mtu| be the ATT_MTU currently negotiated for the [=ATT Bearer=] that
3652- carries [=this=] .{{[[representedCharacteristic]]}} , as established by the
3653- [=Exchange MTU=] procedure. This is the smaller of the local Host's
3654- transmit ATT_MTU and the peer's receive ATT_MTU. When no MTU exchange has
3655- occurred, |mtu| is the default ATT_MTU of 23 octets.
3656- 1. Return |mtu| − 3.
3664+ 1. Return [=this=] .{{[[maxWriteWithoutResponseSize]]}} .
36573665
36583666<div class="note">
3659- Note: The getter reflects the ATT_MTU at the time it is read, so a fresh read
3660- always returns the current value even on platforms that do not surface
3661- ATT_MTU changes via the {{maxwritewithoutresponsesizechanged}} event.
3662- 3 octets are subtracted to account for the ATT Write Command header (1 octet
3663- opcode and 2 octet attribute handle), leaving the space available for the
3664- attribute value in a single PDU .
3667+ Note: The stored value is the ATT_MTU negotiated for the [=ATT Bearer=] that
3668+ carries the characteristic, minus 3 octets. The 3 octets account for the ATT
3669+ Write Command header (1 octet opcode and 2 octet attribute handle), leaving the
3670+ space available for the attribute value in a single PDU. The value is
3671+ established when the characteristic is discovered and only changes when the UA
3672+ observes an ATT_MTU change; see [[#mtu-change-events]] .
36653673</div>
36663674</div>
36673675
@@ -4413,9 +4421,9 @@ interface <a>participate in a tree</a>.
44134421 {{BluetoothRemoteGATTCharacteristic/maxWriteWithoutResponseSize}}
44144422 <a href="#mtu-change-events">changes</a> , for example after an
44154423 [=Exchange MTU=] procedure renegotiates the ATT_MTU for the connection.
4416- The UA fires this event when it observes such a change. Platforms that do
4417- not surface ATT_MTU changes do not fire this event, but reading the
4418- attribute still returns the current value .
4424+ The UA fires this event whenever it updates the value, so platforms that
4425+ never surface ATT_MTU changes (and therefore never change the value) also
4426+ never fire this event .
44194427 </dd>
44204428
44214429 <dt>
@@ -4547,13 +4555,17 @@ the UA receives the result of an [=Exchange MTU=] procedure, the UA must
45474555perform the following steps for each <a>Characteristic</a>
45484556<var> characteristic</var> carried by that [=ATT Bearer=] :
45494557
4550- Note: This event is a convenience notification. The
4551- {{BluetoothRemoteGATTCharacteristic/maxWriteWithoutResponseSize}} getter always
4552- reflects the current ATT_MTU when read, so reading it after a change returns the
4553- new value whether or not this event fires. Platforms that do not surface
4554- ATT_MTU changes to the UA never run these steps and so never fire the event,
4555- but a fresh read of the attribute still returns the current value.
4556-
4558+ Note: The UA only runs these steps when it observes an ATT_MTU change. Updating
4559+ the stored value and firing the {{maxwritewithoutresponsesizechanged}} event
4560+ happen together, so the value never changes without the event firing. Platforms
4561+ that do not surface ATT_MTU changes to the UA never run these steps, so on those
4562+ platforms the value stays constant after it is first established and the event
4563+ never fires.
4564+
4565+ 1. Let <var> newSize</var> be the ATT_MTU now negotiated for that
4566+ [=ATT Bearer=] − 3. This is the smaller of the local Host's transmit
4567+ ATT_MTU and the peer's receive ATT_MTU, less the 3-octet ATT Write Command
4568+ header.
455745691. For each |bluetoothGlobal| whose [=Bluetooth tree=] contains a
45584570 {{BluetoothRemoteGATTCharacteristic}} representing <var> characteristic</var> ,
45594571 [=queue a global task=] on the [=Bluetooth task source=] given
@@ -4566,6 +4578,10 @@ but a fresh read of the attribute still returns the current value.
45664578 1. If <code><var> characteristicObject</var>
45674579 .service.device.gatt.{{BluetoothRemoteGATTServer/connected}} </code>
45684580 is `false`, abort these sub-steps.
4581+ 1. If <var> characteristicObject</var> .{{[[maxWriteWithoutResponseSize]]}}
4582+ equals <var> newSize</var> , abort these sub-steps.
4583+ 1. Set <var> characteristicObject</var> .{{[[maxWriteWithoutResponseSize]]}}
4584+ to <var> newSize</var> .
45694585 1. <a>Fire an event</a> named {{maxwritewithoutresponsesizechanged}} with
45704586 its <code> bubbles</code> attribute initialized to <code> true</code> at
45714587 <var> characteristicObject</var> .
0 commit comments