Main Page | Data Structures | File List | Data Fields | Globals

ATAVRBFLY_FILES/STATE_functions.c

Go to the documentation of this file.
00001 // This file has been prepared for Doxygen automatic documentation generation. 00023 //Includes 00024 #include<ioavr.h> 00025 #include<inavr.h> 00026 00027 #include"main.h" 00028 #include"LCD_functions.h" 00029 00030 #include"..\AVRGSM_FILES\AVRGSM_api.h" 00031 #include"..\AVRGSM_FILES\AVRGSM_com.h" 00032 #include"..\AVRGSM_FILES\AVRGSM_tools.h" 00033 00034 00035 //Variables 00036 static int index; //Index to read from 00037 00038 extern unsigned char msgbuff[161]; 00039 00040 00041 //Functions 00051 char ST_init_phone(char input) 00052 { 00053 //Local variables 00054 int result; 00055 00056 //Initialization 00057 result = 0; 00058 00059 result = API_modem_init(); //Setup phone 00060 00061 if( result == 1 ) 00062 { 00063 00064 COM_rx_reset( ); //Reset receive buffer after API_phoneinit() 00065 COM_setSearchString( CMTI_ ); //Wait for "+CMTI: ,Storage,index\r\n" 00066 COM_rx_on( ); //Ready to receive 00067 00068 return ST_AVR_READY; 00069 } 00070 00071 else if( result == 0 ) 00072 { 00073 00074 return ST_AVR_NO_ECHO; //Could not set echo off 00075 } 00076 00077 else if( result == -1 ) 00078 { 00079 00080 return ST_AVR_WRONG_STORAGE; //No such storage locations 00081 } 00082 00083 else 00084 { 00085 00086 return ST_AVR_WRONG_OPTION; //The chosen forward option is not valid for this GSM modem 00087 } 00088 } 00089 00090 00100 char ST_send(char input) 00101 { 00102 00103 API_sendmsg("ATMEL AVR"); 00104 00105 return ST_AVR_READY; 00106 } 00107 00108 00118 char ST_delete_msg( char input ) 00119 { 00120 API_deletemsg( index ); 00121 00122 index = 0; 00123 00124 COM_rx_reset( ); //Reset receive buffer after API_phoneinit() 00125 COM_setSearchString( CMTI_ ); //Wait for "+CMTI: ,Storage,index\r\n" 00126 COM_rx_on( ); //Ready to receive 00127 00128 return ST_AVR_READY; 00129 } 00130 00131 00141 char ST_get_index( char input ) 00142 { 00143 00144 index = TOOLS_decodeCMTI( ); //Find index 00145 return ST_AVR_NEW_SMS; 00146 } 00147 00148 00158 char ST_read( char input ) 00159 { 00160 00161 API_readmsg( index ); //Read new message, and decode 00162 LCD_puts((char *)msgbuff,1); //Cast pointer 00163 00164 COM_setSearchString( 1 ); //Set searchstring to "+CMTI: " again, wait for new message. 00165 COM_rx_reset( ); //Reset buffer and interrupt routine 00166 COM_rx_on( ); //Ready to receive*/ 00167 00168 return ST_AVR_DISPLAY; 00169 }

Generated on Tue Nov 1 16:21:39 2005 for AVR323 Interfacing GSM modems by doxygen 1.3.7