cancel
Showing results for 
Search instead for 
Did you mean: 

Setting the MTU, the ACI_ATT_READ_BY_GROUP_TYPE_RESP_VSEVT_CODE event never fires.

kumaichi
Associate III

Hello,

I'm trying to figure out why setting the MTU stops the ACI_ATT_READ_BY_GROUP_TYPE_RESP_VSEVT_CODE event from ever firing.  This essentially breaks everything.

case HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE:
	/* USER CODE BEGIN EVT_LE_CONN_COMPLETE */

	hci_le_set_data_length(tpms_handleNotification.ConnectionHandle, /*tx_octets*/251, /*tx_time*/2120);

	tBleStatus result = aci_gatt_exchange_config(tpms_handleNotification.ConnectionHandle);
	if(result != BLE_STATUS_SUCCESS)
	{
		APP_DBG_MSG("\r\n\r** MTU failed to set.\n\r");
	}

	/* USER CODE END EVT_LE_CONN_COMPLETE */
	/**
	 * The connection is done,
	 */
	connection_complete_event = (hci_le_connection_complete_event_rp0 *) meta_evt->data;
	BleApplicationContext.BleApplicationContext_legacy.connectionHandle = connection_complete_event->Connection_Handle;
	BleApplicationContext.Device_Connection_Status = APP_BLE_CONNECTED_CLIENT;

	/* CONNECTION WITH CLIENT */
	APP_DBG_MSG("\r\n\r**  CONNECTION COMPLETE EVENT WITH SERVER \n\r");
	handleNotification.P2P_Evt_Opcode = PEER_CONN_HANDLE_EVT;
	handleNotification.ConnectionHandle = BleApplicationContext.BleApplicationContext_legacy.connectionHandle;
	P2PC_APP_Notification(&handleNotification);

	result = aci_gatt_disc_all_primary_services(BleApplicationContext.BleApplicationContext_legacy.connectionHandle);
	if (result == BLE_STATUS_SUCCESS)
	{
	  APP_DBG_MSG("\r\n\r** GATT SERVICES & CHARACTERISTICS DISCOVERY  \n\r");
	  APP_DBG_MSG("* GATT :  Start Searching Primary Services \r\n\r");
	}
	else
	{
	  APP_DBG_MSG("BLE_CTRL_App_Notification(), All services discovery Failed \r\n\r");
	}
	
break; /* HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE */

Both the server and client have their, CFG_BLE_MAX_ATT_MTU set to 156.  I receive the event and checking the returned value is 156.  All of that seems to be working fine.

case ACI_ATT_EXCHANGE_MTU_RESP_VSEVT_CODE:
{
	aci_att_exchange_mtu_resp_event_rp0 *exchange_mtu_resp = (aci_att_exchange_mtu_resp_event_rp0 *)blecore_evt->data;
	APP_DBG_MSG("**MTU_size = %d \n",exchange_mtu_resp->Server_RX_MTU );
	APP_DBG_MSG("\r\n\r");
	uint16_t Att_Mtu_Exchanged;
	if (exchange_mtu_resp->Server_RX_MTU < CFG_BLE_MAX_ATT_MTU)
	{
		Att_Mtu_Exchanged = exchange_mtu_resp->Server_RX_MTU - 3;
	}
	else
	{
		Att_Mtu_Exchanged = CFG_BLE_MAX_ATT_MTU;
	}
}

break;

If I comment out these lines, I can receive 20 bytes all day long.

hci_le_set_data_length(tpms_handleNotification.ConnectionHandle, /*tx_octets*/251, /*tx_time*/2120);

tBleStatus result = aci_gatt_exchange_config(tpms_handleNotification.ConnectionHandle);
if(result != BLE_STATUS_SUCCESS)
{
	APP_DBG_MSG("\r\n\r** MTU failed to set.\n\r");
}

With those lines in place, the ACI_ATT_READ_BY_GROUP_TYPE_RESP_VSEVT_CODE event is never fired.  This seems to be relevant because when that event isn't fired, the connection handle is never set.

aP2PClientContext[index].connHandle= handle;

I'm leaning towards some kind of timing issue because if I set breakpoints and debug, everything magically works, and I can receive more than 20 bytes.

Is there an event I need to catch, should the MTU code be placed somewhere else or am I just thing about/doing this completely wrong?

Any insight would be greatly appreciated.

Kindest regards.

PS. I've reviewed the, BLE_DataThroughput application, now that's an entirely different beast, as well as PM0271.  There was also another document I looked at from another post where the OP was having difficulties with setting the MTU as well.  None of the searches for setting the MTU really had any resolutions.

0 REPLIES 0