⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 avrgsm__api_8c-source.html

📁 SMS傳送Sourcode,compiler with C,AT command
💻 HTML
📖 第 1 页 / 共 2 页
字号:
00172   <span class="keywordflow">if</span>( ( payload_len = <a class="code" href="AVRGSM__zip_8h.html#a3">ZIP_compress</a>( msg, &amp;jump, <a class="code" href="AVRGSM__api_8c.html#a1">msgbuff</a>) ) == 0 ) <span class="comment">//Convert user text to pdu format</span>00173   {00174     <span class="keywordflow">return</span> 0;                                                     <span class="comment">//Something wrong happend during compression</span>00175   }00176 00177   <span class="comment">//Compression ok</span>00178   <span class="keywordflow">else</span>00179   {00180     <a class="code" href="AVRGSM__zip_8h.html#a7">ZIP_itoh</a>(payload_len, &amp;payload_len_c[0]);                     <span class="comment">//Convert Integer payload to hex in string format</span>00181     len = <a class="code" href="AVRGSM__header_8h.html#a0">HEADER_LEN</a> + payload_len - jump;                        <span class="comment">//Calculate overall length</span>00182 00183     <a class="code" href="AVRGSM__com_8c.html#a13">COM_rx_reset</a>( );                                              <span class="comment">//Clear rx_buff</span>00184     <a class="code" href="AVRGSM__com_8h.html#a11">COM_setSearchString</a>( <a class="code" href="AVRGSM__com_8h.html#a5">READY_</a> );                                <span class="comment">//Set "&gt; " to be search string</span>00185     <a class="code" href="AVRGSM__com_8h.html#a15">COM_putsf</a>( <a class="code" href="AVRGSM__api_8c.html#a7">AT_CMGS</a> );                                         <span class="comment">//Send message</span>00186     <a class="code" href="AVRGSM__com_8h.html#a13">COM_put_integer</a>( len );                                       <span class="comment">//append length</span>00187     <a class="code" href="AVRGSM__com_8h.html#a15">COM_putsf</a>( <a class="code" href="AVRGSM__api_8c.html#a8">CRLF</a> );                                            <span class="comment">//CR+LF</span>00188     <a class="code" href="AVRGSM__com_8c.html#a14">COM_rx_on</a>( );                                                 <span class="comment">//Receiver on</span>00189 00190     <span class="comment">//Append payload</span>00191     <span class="keywordflow">if</span>( <a class="code" href="AVRGSM__api_8c.html#a9">API_check_acknowledge</a>() &gt; 0 )                             <span class="comment">//Wait for acknowledge = "&gt; "</span>00192     {00193       <a class="code" href="AVRGSM__com_8c.html#a13">COM_rx_reset</a>( );                                            <span class="comment">//Clear rx_buff</span>00194       <a class="code" href="AVRGSM__com_8h.html#a11">COM_setSearchString</a>( <a class="code" href="AVRGSM__com_8h.html#a3">OK_</a> );                                 <span class="comment">//Set "OK" to be search string</span>00195       <a class="code" href="AVRGSM__com_8h.html#a15">COM_putsf</a>( <a class="code" href="AVRGSM__header_8h.html#a1">PDU_HEADER</a> );00196       <a class="code" href="AVRGSM__com_8h.html#a14">COM_puts</a>( payload_len_c );00197       <a class="code" href="AVRGSM__com_8h.html#a14">COM_puts</a>( <a class="code" href="AVRGSM__api_8c.html#a1">msgbuff</a> );00198       <a class="code" href="AVRGSM__com_8h.html#a12">COM_putchar</a>( 26 );00199       <a class="code" href="AVRGSM__com_8c.html#a14">COM_rx_on</a>( );                                               <span class="comment">//Receiver on</span>00200 00201       <span class="keywordflow">if</span>( <a class="code" href="AVRGSM__api_8c.html#a9">API_check_acknowledge</a>() &gt; 0 )                           <span class="comment">//Acknowledge = OK</span>00202       {00203         <span class="keywordflow">return</span> 1;00204       }00205 00206       <span class="keywordflow">else</span>                                                        <span class="comment">//Acknowledge != OK</span>00207       {00208         <span class="keywordflow">return</span> -2;00209       }00210 00211     }00212 00213     <span class="keywordflow">else</span>                                                          <span class="comment">//Acknowledge != "&gt; "</span>00214     {00215         <span class="keywordflow">return</span> -1;00216     }00217   }00218 }00219 00220 <a name="l00232"></a><a class="code" href="AVRGSM__api_8h.html#a3">00232</a> <span class="keywordtype">int</span> <a class="code" href="AVRGSM__api_8h.html#a3">API_readmsg</a>( <span class="keywordtype">int</span> ind )00233 {00234 00236     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *encodedmsg;                      <span class="comment">//Pointer to encoded message</span>00237     <span class="keywordtype">int</span> i;00238 00239     <span class="comment">//Init</span>00240     encodedmsg = <span class="charliteral">'\0'</span>;00241     i = 0;00242 00243     <a class="code" href="AVRGSM__com_8c.html#a13">COM_rx_reset</a>( );                                <span class="comment">//Reset system</span>00244     <a class="code" href="AVRGSM__com_8h.html#a11">COM_setSearchString</a>( <a class="code" href="AVRGSM__com_8h.html#a3">OK_</a> );                     <span class="comment">//Set OK to be search string</span>00245     <a class="code" href="AVRGSM__com_8h.html#a15">COM_putsf</a>( <a class="code" href="AVRGSM__api_8c.html#a6">AT_CMGR</a> );                           <span class="comment">//Read message</span>00246     <a class="code" href="AVRGSM__com_8h.html#a13">COM_put_integer</a>( ind );                         <span class="comment">//@index</span>00247     <a class="code" href="AVRGSM__com_8h.html#a15">COM_putsf</a>( <a class="code" href="AVRGSM__api_8c.html#a8">CRLF</a> );                              <span class="comment">//CR+LF</span>00248     <a class="code" href="AVRGSM__com_8c.html#a14">COM_rx_on</a>( );                                   <span class="comment">//Receiver on, wait for acknowledge</span>00249 00250     <span class="keywordflow">if</span>( <a class="code" href="AVRGSM__api_8c.html#a9">API_check_acknowledge</a>() &gt; 0 )               <span class="comment">//Read = OK</span>00251     {00252         encodedmsg = <a class="code" href="AVRGSM__tools_8h.html#a1">TOOLS__decodeCMGR</a>( ind );      <span class="comment">//Get encoded message from the data returned from the phone</span>00253         i = <a class="code" href="AVRGSM__zip_8h.html#a4">ZIP_decompress</a>( encodedmsg, <a class="code" href="AVRGSM__api_8c.html#a1">msgbuff</a> );  <span class="comment">//Decompress this message</span>00254 00255         <span class="comment">//COM_puts( msgbuff );                      //Could be used during test, where the GSM modem is switched with a terminal application</span>00256 00257         <span class="keywordflow">return</span> i;00258     }00259 00260     <span class="keywordflow">else</span>                                            <span class="comment">//Read != OK</span>00261     {00262         <span class="keywordflow">return</span> 0;00263     }00264 }00265 00266 <a name="l00278"></a><a class="code" href="AVRGSM__api_8c.html#a9">00278</a> <span class="keywordtype">int</span> <a class="code" href="AVRGSM__api_8c.html#a9">API_check_acknowledge</a>( <span class="keywordtype">void</span> )00279 {00280 00282     <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i, ii;00283 00284     <span class="keywordflow">for</span>( i = 0; ( <a class="code" href="AVRGSM__api_8c.html#a0">rx_ack</a> == 0 ) &amp;&amp; ( i &lt; 65535 ); i++ ) <span class="comment">//Wait loop</span>00285     {00286         <span class="keywordflow">for</span>( ii = 0; ii &lt; 10; ii++ )00287         {00288             ;00289         }00290     }00291 00292     <span class="keywordflow">if</span>( <a class="code" href="AVRGSM__api_8c.html#a0">rx_ack</a> &gt; 0 )                                    <span class="comment">//Everything worked out fine...rx turned off</span>00293     {00294         <a class="code" href="AVRGSM__api_8c.html#a0">rx_ack</a> = 0;                                     <span class="comment">//Reset flag</span>00295         <span class="keywordflow">return</span> 1;00296     }00297 00298     <span class="keywordflow">else</span>                                                <span class="comment">//A timeout could result from no acknowledge, wrong acknowledge or buffer overrun</span>00299     {00300         <a class="code" href="AVRGSM__com_8c.html#a15">COM_rx_off</a>( );                                  <span class="comment">//Receiver off</span>00301         <a class="code" href="AVRGSM__com_8c.html#a13">COM_rx_reset</a>( );                                <span class="comment">//Reset buffer and interrupt routine</span>00302         <span class="keywordflow">return</span> 0;                                       <span class="comment">//Timed out, or wrong acknowledge from phone</span>00303     }00304 }</div></pre><hr size="1"><address style="align: right;"><small>Generated on Tue Nov 1 16:21:39 2005 for AVR323 Interfacing GSM modems by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.7 </small></address></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -