?? cheshi.lst
字號:
244 4 ES=1; //設置發送指針
245 4 receive_count=0;
246 4 send_count=0xff;
247 4 }
248 3 else if(uart_buff[0]=='4'||uart_buff[0]=='3') //錯誤指令和 無法接通
249 3 { AT_Command_Status=COMMAND_ERROR;}
250 3 else AT_Command_Status=COMMAND_UNKNOW;
251 3 txd_rxd_bit=1; //接收成功
252 3
253 3 uart_buff[receive_count]=0; //receive_count=2 ;
254 3 return;
255 3 }
256 2
257 2 else if(((receive_count>=3)
258 2 &&uart_buff[receive_count-1]==0x0d)
259 2 &&(uart_buff[receive_count-3]==0x0a)
260 2 &&((uart_buff[receive_count-2]=='0')))
261 2
262 2 { ///可能是包含為其他信息的命令返回
263 3 uart_buff[receive_count]=0;//RECEIV OK ANSWER, with some message
264 3 AT_Command_Status=COMMAND_OK;
265 3 txd_rxd_bit=1;
266 3
267 3 }
268 2
269 2 else if((AT_Command_Type==SMS_CMGS||AT_Command_Type==AT_COMMAND)&&uart_buff[2]=='>')
270 2 { AT_Command_Status=COMMAND_OK; txd_rxd_bit=1;
271 3 return;
272 3 }
273 2
274 2
275 2 }//End of if(RI)
276 1 }
277 /*********************************************************************
278 * C51中字符串函數的擴充 *
279 *********************************************************************/
280
281 uchar strsearch(uchar *ptr2)//查字符串*ptr2在*ptr1中的位置
282 //本函數是用來檢查字符串*ptr2是否完全包含在*ptr1中
283 //返回: 0 沒有找到
284 // 1-255 從第N個字符開始相同
285 {
286 1 //、 uchar max_length;
287 1 uchar i,j,k;
288 1 uchar flag;
289 1 if(ptr2[0]==0) return(0);
290 1 flag=0;
291 1 for(i=0,j=0;i<MAX_TM-2;i++)
292 1 {
293 2 if(uart_buff[i]==ptr2[j])
294 2 {//第一個字符相同
295 3 for(k=i;k<MAX_TM-2;k++,j++)
296 3 {
297 4 if(ptr2[j]==0)//比較正確
298 4 return(i+1); //返回值是整數,不含0
299 4 if(uart_buff[k]!=ptr2[j]) break;
300 4 }
301 3 j=0;
302 3 }
303 2 }
C51 COMPILER V7.50 CHESHI 11/16/2008 00:57:23 PAGE 6
304 1 return(0);
305 1 }
306 //=============================================================================
307 // 話機被叫程序
308 //=============================================================================
309 //=============================================================================
310 // 話機被叫程序
311 //=============================================================================
312 uchar Read_Call_ID(void)//讀出來電顯示的號碼
313 //正確 TRUE
314 //錯誤 FALSE
315 //號碼 string_temp[0..16],最多顯示前16位
316 //呼叫方式 stringt_temp[20]
317 {
318 1 uchar i,j,r;
319 1
320 1 Send_AT_Command(CALL_ID);//+CLCC:1,1,4,0,0,"02138950224",129
321 1 // 語音呼入
322 1
323 1 //string_temp[0]=0;
324 1 //string_temp[20]=0; //讀來電顯示出錯時設為1
325 1 if(receive_count<15) return(FALSE);
326 1 uart_buff[receive_count]=0;
327 1 ring_bit=0;
328 1
329 1 ES=1; //設置發送指針
330 1 receive_count=0;
331 1 send_count=0xff;
332 1 RI=0 ;
333 1 j=0;
334 1 // i=strsearch(uart_buff,"CLCC");//查第一個CLCC
335 1 i=strsearch("CLCC");//查第一個CLCC
336 1 if(i==0) return(FALSE);
337 1 j=j+i;
338 1 for(r=0;r<9;r++)
339 1 {
340 2 if(uart_buff[j]==',') break;
341 2 else j=j+1;
342 2 }
343 1 if(r>=9) return(FALSE);
344 1 j=j+1;
345 1 for(r=0;r<4;r++)
346 1 {
347 2 if(uart_buff[j]==',') break;
348 2 else j=j+1;
349 2 }
350 1 if(r>=4) return(FALSE);
351 1 j=j+1;
352 1 //檢查是否為來話呼叫
353 1 if(uart_buff[j]!='4') return(FALSE);
354 1 for(r=0;r<4;r++)
355 1 {
356 2 if(uart_buff[j]==',') break;
357 2 else j=j+1;
358 2 }
359 1 if(r>=4) return(FALSE);
360 1 j=j+1;
361 1 // string_temp[20]=uart_buff[j];//讀出呼叫類型
362 1 //只要能讀出呼叫類型就認為正確
363 1 // i=strsearch(&uart_buff[j],"\x22");//查第一個"號
364 1 for(r=0;r<6;r++)
365 1 {
C51 COMPILER V7.50 CHESHI 11/16/2008 00:57:23 PAGE 7
366 2 if(uart_buff[j]=='\x22') break;
367 2 else j=j+1;
368 2 }
369 1
370 1 if(r>=6)
371 1 return(FALSE);
372 1 j=j+1;
373 1 i=j;
374 1 // i=strsearch(&uart_buff[j],"\x22");//查第二個"號
375 1 for(r=0;r<20;r++)
376 1 {
377 2 if(uart_buff[j]=='\x22') break;
378 2 else j=j+1;
379 2 }
380 1 if(i<=2) return(FALSE);//沒有來電號碼
381 1 for(r=0;r<22;r++)
382 1 {
383 2 para_temp[r+2]=uart_buff[i++];
384 2 if(uart_buff[i]=='\x22')
385 2 { para_temp[r+3]=0x0d;para_temp[r+4]=0x00;uart_buff[i++]=0x0d;uart_buff[i++]=0; break;}
386 2
387 2 }
388 1 uart_buff[i++]=0;uart_buff[i++]=0;
389 1 return(TRUE);
390 1 }
391
392 void ring_auto() //自動監聽 當有電話呼入,只有車主電話可以監聽,別的電話會自動掛機
393 { uchar i=0;
394 1 ring_bit=0;
395 1 ring_cnt=1;
396 1 LED_INT6=0;
397 1 timercount=0;
398 1 i=0;
399 1
400 1 if(Read_Call_ID()) //讀來電顯示
401 1 { ring_cnt=0;
402 2 timer_S_cnt=0; while(timer_S_cnt<6) watch_dog_clear;
403 2 if(ring_cnt>=1)
404 2 { ring_cnt=0; Send_AT_Command(PICK_UP);
405 3 ES=1; //設置發送指針
406 3 receive_count=0;
407 3 send_count=0xff;
408 3 uart_buff[0]=0;
409 3 RI=0 ;
410 3 AT_Command_Status=COMMAND_WAIT; //設置接收成功標志
411 3 while((AT_Command_Status==COMMAND_WAIT)) watch_dog_clear;
412 3 }
413 2 Send_AT_Command(HOOKOFF);
414 2 ring_bit=0;
415 2 ring_cnt=0;
416 2 LED_INT6=1;
417 2 return;
418 2
419 2 }
420 1 else { LED_INT6=1; return; }
421 1
422 1
423 1
424 1 LED_INT6=1;
425 1 }
426 //----------------------------------------------
427 //---------這里進行中斷查詢如果有中斷馬上處理----------------------
C51 COMPILER V7.50 CHESHI 11/16/2008 00:57:23 PAGE 8
428 uchar P2_INIT()
429 {
430 1 //---------------------------------------
431 1 send_count=0xffff; AT_Command_Status=COMMAND_WAIT;
432 1 if(!io_p00_on )
433 1 { io_p00_on=1;system_server=SYS_START; return(0); }
434 1 else if(!io_p02_on) { io_p02_on=1; system_server=SYS_SBC;return(0); }
435 1 if(ring_bit) { ring_auto(); return(0); }
436 1
437 1
438 1 if(!io_p03_on )
439 1 { io_p03_on=1;
440 2 BELL=0;
441 2 for(tmp_j=0;tmp_j<8;tmp_j++) //燈閃三下
442 2 { timercount=0; while(timercount<10) watch_dog_clear; }
443 2 BELL=1;
444 2 system_server=SYS_DIAL;
445 2 return(0);
446 2 }
447 1 //---------------------------------------------------
448 1 return(1);
449 1 }
450 //----------------------------------------------------------------
451 //-----燈閃與 無線接鍵處理,--------------------------------------------
452 void LED_1()
453 {
454 1 LED_P0++;
455 1 if(LED_P0>=16) LED_P0=0;
456 1 if((PT2272_TMP>0)) //513M中斷后處理。這里只是讓燈亮幾秒鐘
457 1 { P0=0;
458 2 if(PT2272_D0==1) //A鍵 D1燈亮
459 2 { P0_7=1;
460 3 timercount=0; while(timercount<215) watch_dog_clear;
461 3 P0_7=0;PT2272_D0=0;
462 3 }
463 2 if(PT2272_D1==1) //B鍵 D6燈亮
464 2 { P0_6=1;
465 3 timercount=0; while(timercount<215) watch_dog_clear;
466 3 P0_6=0; PT2272_D1=0;
467 3 }
468 2 if(PT2272_D2==1) ////C鍵 D8燈亮
469 2 { P0_5=1;
470 3 timercount=0; while(timercount<215) watch_dog_clear;
471 3 P0_5=0; PT2272_D2=0;
472 3 }
473 2 if(PT2272_D3==1) // //D鍵 D9燈亮
474 2 { P0_4=1;
475 3 timercount=0; while(timercount<215) watch_dog_clear;
476 3 P0_4=0; PT2272_D3=0;
477 3 }
478 2
479 2 }
480 1 else
481 1 {
482 2 if(LED_P0<=7) //流水燈
483 2 {
484 3 P0=(0x80>>LED_P0);
485 3 }
486 2 else
487 2 {P0=(0x80>>LED_P0-8);}
488 2 }
489 1
C51 COMPILER V7.50 CHESHI 11/16/2008 00:57:23 PAGE 9
490 1
491 1
492 1
493 1 }
494
495 //
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -