📄 at.lis
字号:
011C ; bool failed = false;
011C ; bool connect = false;
011C ;
011C ; if (c != 13)
011C ; {
011C ; if (c < 32) return; // ignore control charcters
011C ; if (MainBufferWr_Rx >= (sizeof(MainBuffer) - 1)) return; // buffer overflow - ignore character
011C ; if (MainBufferWr_Rx < 0) MainBufferWr_Rx = 0;
011C ; MainBuffer[MainBufferWr_Rx++] = tolower((char)c);
011C ; MainBuffer[MainBufferWr_Rx] = 0;
011C ; return;
011C ; }
011C ;
011C ; // CR
011C ;
011C ; strtrim(MainBuffer, ' ');
011C ; MainBufferWr_Rx = 0;
011C ;
011C ; if (MainBuffer[0] == 0) return; // empty line
011C ;
011C ; #ifdef Debug
011C ; SendDebugStr(MainBuffer);
011C ; SendDebugStr("\n");
011C ; #endif
011C ;
011C ; if (strcmp((char*)MainBuffer, "ok") == 0) ok = true;
011C ; else
011C ; if (strcmp((char*)MainBuffer, "error") == 0) error = true;
011C ; else
011C ; if (strcmp((char*)MainBuffer, "ring") == 0) ring = true;
011C ; else
011C ; if (strcmp((char*)MainBuffer, "busy") == 0) failed = true;
011C ; else
011C ; if (strcmp((char*)MainBuffer, "no dialtone") == 0) failed = true;
011C ; else
011C ; if (strcmp((char*)MainBuffer, "no answer") == 0) failed = true;
011C ; else
011C ; if (strcmp((char*)MainBuffer, "no carrier") == 0) failed = true;
011C ; else
011C ; if ((strlen((char*)MainBuffer) >= 7) && (strncmp((char*)MainBuffer, "connect", 7) == 0)) connect = true;
011C ;
011C ; memset(MainBuffer, 0, sizeof(MainBuffer));
011C ;
011C ; if ((AT.Stage != AT_Dial) && failed)
011C ; {
011C ; AT_Stage(AT_Idle);
011C ; return;
011C ; }
011C ;
011C ; switch (AT.Stage)
011C ; {
011C ; case AT_DialInit1 : if (ok) AT_Stage(AT_DialInit2);
011C ; break;
011C ; case AT_DialInit2 : if (ok) AT_Stage(AT_DialInit3);
011C ; break;
011C ; case AT_DialInit3 : if (ok) AT_Stage(AT_Dial);
011C ; break;
011C ; case AT_Dial : if (failed || error)
011C ; {
011C ; u16_Put(&AT.Retry_Timer, AT_Dial_Retry_Time); // try again in 6 seconds
011C ; break;
011C ; }
011C ; case AT_Idle : if (connect)
011C ; {
011C ; AT_Stage(AT_PPP);
011C ; PPP_Start(PPP_Rom_Username, PPP_Rom_Password); // start a PPP session
011C ; }
011C ; break;
011C ; case AT_PPP : break; // PPP is using the modem
011C ; case AT_Disc1 : if (ok || error) AT_Stage(AT_Disc2); // the modem has come out of data mode - we used the '+++' thingy
011C ; break;
011C ; case AT_Disc2 : if (ok) AT_Stage(AT_Idle); // the modem accepted the hangup command(s)
011C ; break;
011C ; default : AT_Stage(AT_Idle);
011C ; break;
011C ; }
011C ; #endif
011C ; }
011C ;
011C ; //*************************************************************************************
011C ; // call this every 10ms - say from a timer interrupt
011C ;
011C ; void AT_10ms_Timer(void)
011C ; { // call this every 10ms
011C .dbline -2
011C L31:
011C .dbline 0 ; func end
011C 0895 ret
011E .dbend
011E .dbfunc e AT_Process _AT_Process fV
011E ; c -> R20
.even
011E _AT_Process::
011E 0E940000 xcall push_gset1
0122 .dbline -1
0122 .dbline 265
0122 ; #ifndef WindowsPPP
0122 ; if (AT.Stage == AT_Idle) return;
0122 ;
0122 ; if (AT.Retry_Timer >= 10)
0122 ; AT.Retry_Timer -= 10;
0122 ; else
0122 ; AT.Retry_Timer = 0;
0122 ; #endif
0122 ; }
0122 ;
0122 ; //*************************************************************************************
0122 ; // call this as often as possible from your executive loop - NOT from an interrupt
0122 ; // it takes care of all the AT modem stuff for you
0122 ;
0122 ; void AT_Process(void)
0122 ; {
0122 .dbline 270
0122 ; u8 c;
0122 ;
0122 ; #ifdef WindowsPPP
0122 ; //
0122 ; if (PPP.Stage != PPPS_None) return; //
0122 20900900 lds R2,_PPP+9
0126 2220 tst R2
0128 09F0 breq L33
012A .dbline 270
012A 2DC0 xjmp L32
012C L33:
012C .dbline 272
012C ; //
012C ; if (!MainBufferWr_Tx)
012C 20900000 lds R2,_MainBufferWr_Tx
0130 30900100 lds R3,_MainBufferWr_Tx+1
0134 2220 tst R2
0136 11F5 brne L36
0138 3320 tst R3
013A 01F5 brne L36
013C X2:
013C .dbline 273
013C ; {
013C 19C0 xjmp L39
013E L38:
013E .dbline 275
013E ; while (UART1_RxBufferRd != UART1_RxBufferWr)
013E ; {
013E .dbline 276
013E ; c = (u8)UART1_RxBuffer[UART1_RxBufferRd++]; // get rx'ed byte
013E 20900000 lds R2,_UART1_RxBufferRd
0142 3324 clr R3
0144 822D mov R24,R2
0146 8F5F subi R24,255 ; addi 1
0148 80930000 sts _UART1_RxBufferRd,R24
014C 80E0 ldi R24,<_UART1_RxBuffer
014E 90E0 ldi R25,>_UART1_RxBuffer
0150 E22D mov R30,R2
0152 FF27 clr R31
0154 E80F add R30,R24
0156 F91F adc R31,R25
0158 4081 ldd R20,z+0
015A .dbline 277
015A ; if (UART1_RxBufferRd >= sizeof(UART1_RxBuffer)) UART1_RxBufferRd -= sizeof(UART1_RxBuffer); // wap awound
015A 80910000 lds R24,_UART1_RxBufferRd
015E 8036 cpi R24,96
0160 28F0 brlo L41
0162 .dbline 277
0162 80910000 lds R24,_UART1_RxBufferRd
0166 8056 subi R24,96
0168 80930000 sts _UART1_RxBufferRd,R24
016C L41:
016C .dbline 278
016C 042F mov R16,R20
016E D5DF xcall _AT_AddNewRxByte
0170 .dbline 279
0170 L39:
0170 .dbline 274
0170 20900000 lds R2,_UART1_RxBufferWr
0174 30900000 lds R3,_UART1_RxBufferRd
0178 3214 cp R3,R2
017A 09F7 brne L38
017C .dbline 280
017C ; AT_AddNewRxByte(c); // pass the byte onto the AT RX routine
017C ; }
017C ; }
017C L36:
017C .dbline 283
017C ;
017C ; #ifdef ModemHandShaking
017C ; HardwareFlowControl(ModemUart); // tell em to hold it - if need be
017C 01E0 ldi R16,1
017E 0E940000 xcall _HardwareFlowControl
0182 .dbline 286
0182 ; #endif
0182 ; //
0182 ; AT_Stage(AT_Idle); //
0182 0027 clr R16
0184 99DF xcall _AT_Stage
0186 .dbline -2
0186 L32:
0186 0E940000 xcall pop_gset1
018A .dbline 0 ; func end
018A 0895 ret
018C .dbsym r c 20 c
018C .dbend
.area bss(ram, con, rel)
0000 .dbfile C:\AVR\AT-Modem__PPP__UDP__IC\at.c
0000 _AT::
0000 .blkb 4
0004 .dbstruct 0 4 TAT
0004 .dbfield 0 Retries c
0004 .dbfield 1 Retry_Timer s
0004 .dbfield 3 Stage c
0004 .dbend
0004 .dbsym e AT _AT S[TAT]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -