James Cochrane
/
Client_Code_Rangefinder
working code
Fork of Working_Client_Code by
Diff: main.cpp
- Revision:
- 3:c99ef21cb4b3
- Parent:
- 1:e2385bba1ab1
- Child:
- 4:d205b6061e66
diff -r 6c150720937c -r c99ef21cb4b3 main.cpp --- a/main.cpp Wed Jun 08 11:06:45 2016 +0000 +++ b/main.cpp Thu Jun 09 09:55:10 2016 +0000 @@ -34,10 +34,10 @@ #define BUFF_SIZE 2048 RawSerial pc(USBTX, USBRX); //RawSerial dev(D1, D0); -RawSerial dev(p28, p27); //tx,rx +RawSerial dev(p9, p10); //tx,rx DigitalOut led1(LED1); DigitalOut led4(LED4); -DigitalOut reset(p26,1); +DigitalOut reset(p21,1); volatile int state=0; volatile int ready=0; @@ -58,16 +58,16 @@ while(dev.readable()) { c = (char)dev.getc(); #ifdef DEBUG - // pc.putc(c); + pc.putc(c); #endif buffer[bufferPnt]=c; bufferPnt++; if (bufferPnt>1024) { ready=1; } - if ((c==0x0a)||(c==0x0d)){ - ready=1; - }else + // if ((c==0x0a)||(c==0x0d)){ + // ready=1; + // }else if (c==0x0a) { if (bufferPnt>1) { if (buffer[bufferPnt -2]==0x0d) { @@ -90,6 +90,10 @@ c=(char)pc.getc(); dev.putc(c); pc.putc(c); + if(c==13) { + dev.putc(10); + pc.putc(10); + } } } @@ -114,7 +118,7 @@ dev.baud(115200); pc.attach(&pc_recv, Serial::RxIrq); dev.attach(&dev_recv, Serial::RxIrq); - pc.printf("Start up\n\r"); + pc.printf("Start up 3\n\r"); wait(1.5); reset=1; char * resp=NULL; @@ -200,15 +204,37 @@ resp=OKResponse(buffer,"OK"); if (resp!=NULL) { INFO("Ready"); + dev.printf("AT+CIPSERVER= 1,6060\r\n"); + //dev.printf("AT+CIPSTART=0,\"TCP\",192.168.1.8, 6060"); state++; } break; } + case 9: { resp=OKResponse(buffer,"OK"); + if (resp!=NULL) { + INFO("Ready"); + //dev.printf("AT+CIPSERVER= 1,6060"); + //dev.printf("AT+CIPSEND= 0,10"); //10 = length of string being sent + state++; + } + pc.printf("%s\n\r",buffer); + break; } + + case 10: { resp=OKResponse(buffer,"OK"); + if (resp!=NULL) { + INFO("Ready"); + // dev.printf("AT+CIPSERVER= 1[,6060]"); + state++; + } + + break; + } + } } __WFI(); } -} \ No newline at end of file +}