2019-07-15 10:47 PM
Dear Members,
I tried to send SMS with SIM7600SAH, the code was working but now it's giving me intermittent result...
The code
//Clear buffer
HAL_UART_Transmit_IT(&huart1,(uint8_t*)&aTxBuffer4, sizeof(aTxBuffer4));
HAL_Delay(5);
HAL_UART_Transmit_IT(&huart1,(uint8_t*)&aTxBuffer, sizeof(aTxBuffer));
HAL_UART_Receive_IT(&huart1, (uint8_t *)&SIM900.rxBuffer,1);
//HAL_UART_Receive_IT(&huart1, (uint8_t *)&SIM900.rxBuffer,sizeof(SIM900.rxBuffer));
SIM900_Process();
HAL_Delay(5000);
//Clear buffer
HAL_UART_Transmit_IT(&huart1,(uint8_t*)&aTxBuffer4, sizeof(aTxBuffer4));
HAL_Delay(5);
HAL_UART_Transmit_IT(&huart1,(uint8_t*)&aTxBuffer2,sizeof(aTxBuffer2)); //AT command
HAL_UART_Receive_IT(&huart1, (uint8_t *)&SIM900.rxBuffer,1);
// HAL_UART_Receive_IT(&huart1, (uint8_t *)&SIM900.rxBuffer,sizeof(SIM900.rxBuffer));
SIM900_Process();
HAL_Delay(5000);
callback
void HAL_UART_RxCpltCallback(UART_HandleTypeDef* huart)
{
if(huart->Instance==USART2)
{
}
if(huart->Instance==USART1)
{
SIM900_CallBack();
}
}
void SIM900_CallBack(void)
{
SIM900.LastTime=HAL_GetTick();
if(SIM900.rxIndex < sizeof(SIM900.rxBuffer)-2)
{
SIM900.rxBuffer[SIM900.rxIndex] = SIM900.rxTmp;
SIM900.rxIndex++;
memcpy((void *)line_buffer_SIM900, SIM900.rxBuffer, SIM900.rxIndex);
}
HAL_UART_Receive_IT(&_SIM900_USART,&SIM900.rxTmp,1);
}
void SIM900_Process(void)
{
printf("%s",SIM900.rxBuffer);
}
Do I miss something here ?
Do I need TXcomplete callback ??
void HAL_UART_TxCpltCallback(UART_HandleTypeDef* huart)
{
if(huart->Instance==USART1)
{
HAL_UART_Receive_IT(&huart1, (uint8_t *)&SIM900.rxBuffer,1);
}
}
then printf what it has received on process ?
Thanks