2025-11-04 12:05 AM
Hi all,
I am transmitting and receiving the image data using AT commands via UART in stmf767vi board.
My transmission is sending successfully like sending chunk by chunk. I am able to see the count also. But the problem is while receiving side, I am able to receive the chunk for 2 min only. not all the image. If tx image size is 80k, I am able to see upto 35k only. after that my mqtt is stopping receiving the image data. I don't know where it is causing whether it is keep-alive timeout or something else. Even when I am receiving the small size data, it is receiving 6 times the full image like upto 2 min. after that it is stopping. what is the issue ? someone please help...
while(1)
{
receive_data_test((char *)&response[0], RX_BUFFER_SIZE, 60000);
}
eState_t receive_data_test(unsigned char *out_buf, uint16_t buf_size, uint32_t timeout_ms)
{
uint32_t last_ping_time = HAL_GetTick();
uint8_t rx_byte;
rcvdCount = 0;
notRcvdCount = 0;
while (1)
{
if (HAL_UART_Receive(&huart3, &rx_byte, 1, 10) == HAL_OK)
{
rcvdCount++;
notRcvdCount = 0;
}
else
{
notRcvdCount++;
if(notRcvdCount > 1000)
{
notRcvdCount = 0;
}
}
// one minute checking for keep-alive timeout
if((HAL_GetTick() - last_ping_time) > 60000)
{
// publish the command.
snprintf(cmd, sizeof(cmd), "AT+QMTPUBEX=0,0,0,0,\"keepalive/topic\",4\r\n");
send_at_command(cmd);
// Step 2: Waiting for '>' prompt
if (!receive_response_wait_for(">", response, RX_BUFFER_SIZE, 5000))
{
print("No '>' prompt received for QMTPUB\r\n");
errorStepNumber = 14;
return;
}
HAL_Delay(100);
send_at_command("ping\r\n"); // sending the payload
// Step 4: Wait for broker ack
if (!receive_response_wait_for("+QMTPUB: 0,0,0", response, RX_BUFFER_SIZE, 5000))
{
print("Keepalive publish failed\r\n");
errorStepNumber = 15;
return;
}
print("Keepalive sent successfully\r\n");
HAL_Delay(100);
last_ping_time = HAL_GetTick();
}
}
return state;
}
just checking the data reception is happening or not.
before the receive_test_data functions, I am sending the AT commands successfully.
send_at_command("AT\r\n");
send_at_command("AT+CSQ\r\n");
send_at_command("AT+CPIN?\r\n");
send_at_command("AT+CREG?\r\n");
send_at_command("AT+CGATT?\r\n");
send_at_command("AT+QIDEACT=1\r\n");
snprintf(cmd, sizeof(cmd), "AT+QICSGP=1,1,\"%s\",\"\",\"\",1\r\n", apn);
send_at_command("AT+QIACT=1\r\n");
send_at_command("AT+QIACT?\r\n");
snprintf(cmd, sizeof(cmd), "AT+QMTOPEN=0,\"test.mosquitto.org\",1883\r\n");
snprintf(cmd, sizeof(cmd), "AT+QMTCONN=0,\"clientid835\",\"\",\"\",0\r\n");
send_at_command("AT+QMTCONN?\r\n");
snprintf(cmd, sizeof(cmd), "AT+QMTSUB=0,1,\"image/data\",2\r\n");