Skip to content

Commit 7a94940

Browse files
committed
Replace magic number and add comment.
1 parent d4492aa commit 7a94940

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

ports/nrf/common-hal/_bleio/PacketBuffer.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ STATIC void write_to_ringbuf(bleio_packet_buffer_obj_t *self, uint8_t *data, uin
6565
}
6666

6767
STATIC uint32_t queue_next_write(bleio_packet_buffer_obj_t *self) {
68+
// Queue up the next outgoing buffer. We use two, one that has been passed to the SD for
69+
// transmission (when packet_queued is true) and the other is `pending` and can still be
70+
// modified. By primarily appending to the `pending` buffer we can reduce the protocol overhead
71+
// of the lower level link and ATT layers.
6872
self->packet_queued = false;
6973
if (self->pending_size > 0) {
7074
uint16_t conn_handle = self->conn_handle;
@@ -311,7 +315,7 @@ uint16_t common_hal_bleio_packet_buffer_get_packet_size(bleio_packet_buffer_obj_
311315
}
312316
}
313317
if (connection->mtu == 0) {
314-
mtu = 23;
318+
mtu = BLE_GATT_ATT_MTU_DEFAULT;
315319
}
316320
if (self->characteristic->max_length > mtu) {
317321
mtu = self->characteristic->max_length;

ports/nrf/common-hal/_bleio/PacketBuffer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ typedef struct {
3737
bleio_characteristic_obj_t *characteristic;
3838
// Ring buffer storing consecutive incoming values.
3939
ringbuf_t ringbuf;
40+
// Two outgoing buffers to alternate between. One will be queued for transmission by the SD and
41+
// the other is waiting to be queued and can be extended.
4042
uint8_t* outgoing[2];
4143
uint16_t pending_size;
4244
uint16_t conn_handle;

0 commit comments

Comments
 (0)