2014-10-01 02:11 PM
2014-10-01 05:41 PM
You seems to be mixing a number of strategies here, you probably want to be getting ALL received characters via the interrupt, but you definitely don't want to echo those back to the modem.
You need to think a little more about how you interact with the modem. It's going to respond with OK, ERROR or whatever, so delaying is not a effective strategy to deal with what comes back. You need to collect the data, and then pass it back to the main loop, and that loop is going to want to be able to synchronize and parse the returned data. Your rigid expectation for particular characters one after another is unlikely to work with the somewhat dynamic responses the modem may provide. ie you might get several different, but valid, responses and you need to handle them all. I'm also pretty sure sending hanging ''AT+CMGR='' and ''AT+CMGD=''' requests won't work. The modem almost certainly expects you to provide a message number, and the range of numbers will depend on the carrier/SIM, so you will need to enumerate a range of potential slots in-coming SMS will be directed to.2014-10-05 04:18 AM
2014-10-27 03:01 AM
Hello Mr Clive
I have managed to make it work :)Now im trying to send a notification message (msg) to my cellphone using GSM modem/AT commands with STM32F4the message i want to receive is ''A temperature of temp_c C was registered. please switch off geyser.'' but temp_c is an integer so it is giving errors ( i cant use an integer in a string.)
so i used Strcpybut i only receive ''A temeperature of''i dont think my Strcpy is working, please help.msg=''A temperature of '';
toString(temp_c,s);strcpy(s, msg);strcpy(msg, '' C was registered. Please switch off geyser'');SendNotification(msg);please help2014-10-27 03:21 AM
Consider if you should be using strcat() or sprintf() to construct your string.
2014-10-27 05:37 AM
void send_sms(volatile char *string,volatile char *number)
{ USART_puts(''AT+CMGF=1 ''); Delay(0xFFFFF); USART_puts(''AT+CMGS=''); while(!(USART1->SR & 0x00000040)); USART_SendData(USART1, 0x22); USART_puts(number); while(!(USART1->SR & 0x00000040)); USART_SendData(USART1, 0x22); USART_puts('' ''); Delay(0xFFFFF); USART_puts(string); Delay(0xFF); while(!(USART1->SR & 0x00000040)); USART_SendData(USART1, 0x1A);//CTRL+Z Delay(0xFFFFF); } This is how i do it of for GPS data that can be opened inside android browser, with little flag on spotvoid send_sms_GPS(volatile char *number,float x, float y)
{
char masyvas[160]={0};
USART_puts(''AT+CMGF=1
'');
Delay(0xFFFFF);
USART_puts(''AT+CMGS='');
while(!(USART1->SR & 0x00000040));
USART_SendData(USART1, 0x22);
USART_puts(number);
while(!(USART1->SR & 0x00000040));
USART_SendData(USART1, 0x22);
USART_puts(''
'');
Delay(0xFFFFF);
sprintf(masyvas,''https://maps.google.com//maps?z=18&q=%f,%f'',x,y);
USART_puts(masyvas);
Delay(0xFF);
while(!(USART1->SR & 0x00000040));
USART_SendData(USART1, 0x1A);//CTRL+Z
Delay(0xFFFFF);
}
2014-10-27 04:41 PM
Don't just use blind delays!
As clive1 says, the modem gives a reply to every command - you shouldpay attention to those replies!
2014-10-28 12:50 AM
And I guess that code example doesn't help the OP much, as he seems to have serious trouble understanding the inner workings of C strings and the
strcpy()
function.2014-10-28 10:20 AM
As clive1 says, the modem gives a reply to every command - you should
pay attention to those replies!
Yes, it is possible to check each message, but with alot of functions, dealing with strings becomes complicated, in that case you must deal with answer each time you send command as well as keep track on receiver buffer in idle state, since modem time to time will push something. I know that this code is working, and i had no problems.