nimaltd / gsm_v5

gsm module library for STM32 LL
GNU General Public License v3.0
232 stars 86 forks source link

Always false returning on Sim80x_SendAtCommand function #14

Closed omidk94 closed 4 years ago

omidk94 commented 4 years ago

Dear nimaLtd,

thank you so much for your best lib for sim800 modules, I have some problem with Sim80x_SendAtCommand function, this function just returns false in all-time although the simcom module returns true answer and the MCU will go to UART interrupt routine and then called Sim80x_RxCallBack(),

but the SIM80x_SendAtCommand returned false value ,

can you help me, please? or send some better examples, please?

thank you so much Best Regards Omid.K

nimaltd commented 4 years ago

Hello. Please check your rx buffer. I think your mcu can not get correct character

omidk94 commented 4 years ago

but in debug mode, I can check all of the chars that MCU received from simcom module, and it's ok, do you have any idea?

nimaltd commented 4 years ago

Incrase your rtos heap and try again. After init , 2 task must be crated.

omidk94 commented 4 years ago

Dear Nima, in fact, the task can create cause the MCU can send at-command to simcom module, but it can't understand the simcom response, my simcom module is sim808 and it's on sim80x series. if the RTOS heap is low the MCU should go to hard fault error, is it true? but I don't have this problem. may I upload my code and you see it, please?

Best regards, Omid

omidk94 commented 4 years ago

`void Sim80x_Init(osPriority Priority) {

if (_SIM80X_USE_POWER_KEY==1)

HAL_GPIO_WritePin(_SIM80X_POWER_KEY_GPIO,_SIM80X_POWER_KEY_PIN,GPIO_PIN_SET);

else

osDelay(1000);

endif

memset(&Sim80x,0,sizeof(Sim80x));
memset(Sim80x.UsartRxBuffer,0,_SIM80X_BUFFER_SIZE);
HAL_UART_Receive_IT(&_SIM80X_USART,&Sim80x.UsartRxTemp,1);

osThreadDef(Sim80xTask, StartSim80xTask, Priority, 0, 256); Sim80xTaskHandle = osThreadCreate(osThread(Sim80xTask), NULL); osThreadDef(Sim80xBuffTask, StartSim80xBuffTask, Priority, 0, 256); Sim80xBuffTaskHandle = osThreadCreate(osThread(Sim80xBuffTask), NULL); for(uint8_t i=0 ;i<10 ;i++)
{ printf("%s\n", Sim80x.UsartRxBuffer); if(Sim80x_SendAtCommand("AT\r\n",200,1,"AT\r\r\nOK\r\n") == 1) break; osDelay(200); }
Sim80x_SetPower(true); }`

I just add printf in Sim80x_Init function for finding the answer, and it returns this :

ATT ATTATT ATTATTATT ATTATTATTATT ATTATTATTATTATT ATTATTATTATTATTATT ATTATTATTATTATTATTATT ATTATTATTATTATTATTATTATT

nimaltd commented 4 years ago

You do a test after increasing the memory

omidk94 commented 4 years ago

I increase the heap size to 4096 bytes but the issue is same, can you please check my code? https://drive.google.com/file/d/1b17LG8e0bS6cb-xn33oa8vSUPPtm0nQB/view?usp=sharing thank you,

omidk94 commented 4 years ago

Dear Nima,

thanks for your help, my code issue is on another function, I didn't call:

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { Sim80x_RxCallBack(); } on my code and increase the heap to 16K and then everything works well,

thank you for your help, Best Regards, Omid