Skip to main content
LVolp.2
Associate II
Jul 11, 2023 3:03 PM UTC
Question

Router having trouble handling frames

Hello, 

I have an OpenThread network with two devices : one end device (STM32WB5MMG) and one router (NUCLEO WB55) 

I acquire data with the end device and I try to send 180 000 samples (uint16) to the router 

When I try to send, it seems that the router does not handle the data received 

Here is the pseudo code sending data for the end device : 

 

 

 

 

 

 

typedef struct __attribute__((packed))
{
	FrameHeader header;

	uint16_t cdf_id;
	uint8_t measure_type;
	uint16_t sdf_id;
	uint16_t total_frame_id;
	int8_t data[MAXSDFDATA];
} FrameSDF;

void Acquire(uint8_t ffreq_select, uint32_t samples_to_send) {

	//Init
	...

	//declaration
	uint32_t samples_sent = 0;
	uint16_t sample_counter = 0;
	uint16_t frame_amount = 0;

	sampleRes_select = 60000;
	samples_to_send = sampleRes_select * 2 * 3;
	frame_amount = ceil((float32_t) samples_to_send / (float32_t) MAXSDFDATA);

	uint16_t adddressDBG = 0, trial_address = 0;
	int16_t acceleration[3];

	do {
		adddressDBG = Get_I2C_Address(&hi2c1);
		trial_address++;
	} while (adddressDBG != KX_I2C_ADDRESS && trial_address < 3);

	FrameADF adf;

	if (adddressDBG == KX_I2C_ADDRESS) {
		FrameSDF sdf;
		BuildFrame(SDF_SEN, (uint8_t*) &sdf);
		sdf.total_frame_id = frame_amount;
		HAL_Delay(500);
		sdf.sdf_id = 0x0000;
		for (int i = 0; i < frame_amount; i++) {
			APP_DBG("Frame %d #%d/%d",sdf.sdf_id, i,frame_amount);
			APP_DBG("***************************");

			int16_t *dataPtr = sdf.data;

			if (i == frame_amount - 1) {
				sample_counter = samples_to_send - (i * MAXSDFDATA);
			} else {
				sample_counter = MAXSDFDATA;
			}

			for (int j = 0; j < sample_counter / 3; j++) { //sample_counter / 3 because 3 values acquired at once
				//APP_DBG("Samples #%d", j);

				//Acquisitions 
 ...

			}
			SHCI_C2_RADIO_AllowLowPower(THREAD_IP, FALSE);
			APP_THREAD_SDFSend(&sdf, sizeof(FrameSDF));
			UTIL_SEQ_WaitEvt(EVENT_ACK_SDF);
			HW_TS_Start(timeOutTimerID, (uint32_t) 100);
			UTIL_SEQ_WaitEvt(EVENT_TIMER);
			sdf.sdf_id++;
			samples_sent += sample_counter;
		}
		sdf.sdf_id = 0x0000; // Reset SDFID because everything was sent.
		BuildFrame(ADF_SEN, (uint8_t*) &adf);
		adf.error_code = appError;
		APP_DBG("****** AppError Value %u ******", adf.error_code);
		APP_THREAD_ADFSend(&adf);
		UTIL_SEQ_WaitEvt(EVENT_ACK_ADF);
		SHCI_C2_RADIO_AllowLowPower(THREAD_IP, TRUE);
		UTIL_SEQ_SetEvt(EVENT_SNDCMPLT);

		HAL_GPIO_WritePin(VCC_KX_GPIO_Port, VCC_KX_Pin, GPIO_PIN_RESET);
		otLinkSetPollPeriod(NULL, 500);
		UTIL_LPM_SetStopMode(1 << CFG_LPM_APP, UTIL_LPM_ENABLE);
		FeedWDT();
		UpdateState(AppState, APP_STATE_SLEEP);

	} else {
		APP_DBG("Wrong address ERROR");
		appError = 0xFF;
		BuildFrame(ADF_SEN, (uint8_t*) &adf);
		adf.error_code = appError;
		APP_THREAD_ADFSend(&adf);
		UTIL_SEQ_WaitEvt(EVENT_ACK_ADF);
		UpdateState(AppState, APP_STATE_SLEEP);

	}
}

 

 

 

 

 

 

 

Here is the code of the function handling SDF for the router : 

 

 

 

 

 

 

static void APP_THREAD_SDFRespHandler(void *pContext, otMessage *pMessage,
		const otMessageInfo *pMessageInfo)

{
	//TODO Manage SDF response.
	APP_DBG("********* SDF Req Handler *********");

	uint16_t payloadOffset = otMessageGetOffset(pMessage);
	uint16_t payloadLength = otMessageGetLength(pMessage) - payloadOffset;

	otMessageRead(pMessage, payloadOffset, PayloadRead, payloadLength);

	FrameSDF *sdf=(FrameSDF*)&PayloadRead[0];
	APP_DBG("sdf_id %d",sdf->sdf_id);
	APP_DBG("sdf_meas %d",sdf->measure_type);
	free(sdf);

	/* If Message is Confirmable, send response */
	if (otCoapMessageGetType(pMessage) == OT_COAP_TYPE_CONFIRMABLE) {
		//TODO Send Response
		APP_THREAD_CoapSendDataResponse(pMessage, pMessageInfo);
	}

}

 

 

 

 

 

 

Here are the logs of both devices (end device on the left / router on the right) : 

LVolp2_0-1689086927093.png

As you can see, the router is blocked and the end device continues to send data  
The error occurring for the end device (err code = 2) is a message drop 
I progressively remarked latency for the end device while sending

Do you what could prevent the router to receive data ? 
Do you know why the router stays blocked ? 

PS : acquisition part and frame allocation was checked and does not seem to be problematic 
These two devices are the only devices of the network

This topic has been closed for replies.