cancel
Showing results for 
Search instead for 
Did you mean: 

BLE sending more data than expected

MichalPesko
Associate III

Hello, I am trying to achieve high throughput on a custom board. I partially replicated BLE_Throughput example for an initial testing.

I am receiving the BLE data in MATLAB. In CubeMX, I use a custom ble template. I am trying send a payload 1000x times, in MATLAB i receive > 3000x randomly. (I mean  > (3000 x 244) Bytes of course, not 3000 Bytes).

This is the main task for notification. Why I am receiving > 3000 Bytes while the transfer is limited by transfer_count?

 

volatile uint8_t transfer_flow = 0;
 uint8_t transfer_count = 0;

void SendActivityData_Task_Update(void) {

	uint8_t activity_buffer[244] = {0};

	tBleStatus status = BLE_STATUS_INVALID_PARAMS;

	memset(activity_buffer, 0x11, sizeof(activity_buffer));

	if (transfer_flow == 1 && transfer_count < 1000) {

		status = Custom_STM_App_Update_Char(CUSTOM_STM_ACTIVITYDATA_CHARINDICATE,
												(uint8_t *)activity_buffer);

		if (status == BLE_STATUS_INSUFFICIENT_RESOURCES)
		{
			transfer_flow = 0;
		}
		else
		{
			SendActivityData_ResumeNotification();
			transfer_count++;
		}

	}

	__NOP();


}


void SendActivityData_ResumeNotification(void) {

	UTIL_SEQ_SetTask(1 << CFG_TASK_SEND_ACTIVITY_DATA,
					 CFG_SCH_PRIO_0);
}

 

To control the data flow, I added this event to custom_stm.c switch case.

 

case ACI_GATT_TX_POOL_AVAILABLE_VSEVT_CODE:
{

	transfer_flow = 1;
	SendActivityData_ResumeNotification();

	__NOP();

	break;
}

 

I am sure this must be something obvious. When a notification is unsuccessfull (e.g. insufficient resources), are the data queued and transferred later? I dont know what else would explain the excess data received. 

I am also changing connection parameters in these 2 tasks, the parameters are recommended here (interval 320 = 400 ms)  https://community.st.com/t5/stm32-mcus-wireless/stm32wb-data-throughput-issues/td-p/319093 .  Return val is successfull. Still getting only < 10 kBytes speed:

 

void update_conn_parameters(void) {

   uint16_t interval_min = 320;
   uint16_t interval_max = 320;
   uint16_t peripheral_latency = L2CAP_PERIPHERAL_LATENCY;
   uint16_t timeout_multiplier = L2CAP_TIMEOUT_MULTIPLIER;

   tBleStatus result;

   result = aci_l2cap_connection_parameter_update_req(BleApplicationContext.BleApplicationContext_legacy.connectionHandle,
													  interval_min, interval_max,
													  peripheral_latency, timeout_multiplier);

   __NOP();

}



void update_le_length(void) {

   tBleStatus result;

   result = hci_le_set_data_length(BleApplicationContext.BleApplicationContext_legacy.connectionHandle,
		   	   	   	   	  	  	  	  251, 2120);

   __NOP();

}

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
MichalPesko
Associate III

transfer_count was declared as uint8_t, works correctly as uint32_t. Silly mistake.

View solution in original post

1 REPLY 1
MichalPesko
Associate III

transfer_count was declared as uint8_t, works correctly as uint32_t. Silly mistake.