ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if ((mtu < ESP_GATT_DEF_BLE_MTU_SIZE) || (mtu > ESP_GATT_MAX_MTU_SIZE)) {
- return ESP_GATT_ILLEGAL_PARAMETER;
+ return ESP_ERR_INVALID_SIZE;
}
msg.sig = BTC_SIG_API_CALL;
// This is kind of a weird case, since we're dispatching a partially sent packet
// up to a higher layer.
// TODO(zachoverflow): rework upper layer so this isn't necessary.
- buffer_allocator->free(packet);
- //dispatch_reassembled(packet);
+ //buffer_allocator->free(packet);
+
+ /* dispatch_reassembled(packet) will send the packet back to the higher layer
+ when controller buffer is not enough. hci will send the remain packet back
+ to the l2cap layer and saved in the Link Queue (p_lcb->link_xmit_data_q).
+ The l2cap layer will resend the packet to lower layer when controller buffer
+ can be used.
+ */
+
+ dispatch_reassembled(packet);
//data_dispatcher_dispatch(interface.event_dispatcher, packet->event & MSG_EVT_MASK, packet);
}
}
packet->layer_specific--;
if (packet->layer_specific == 0) {
packet->event = MSG_HC_TO_STACK_L2C_SEG_XMIT;
+
+ /* The remain packet will send back to the l2cap layer when controller buffer is not enough
+ current_fragment_packet must be NULL, otherwise hci_host_thread_handler() will
+ connitue handle the remain packet. then the remain packet will be freed.
+ */
+
+ current_fragment_packet = NULL;
callbacks->transmit_finished(packet, false);
return;
}