James Cochrane
/
Client_Code_Rangefinder
working code
Fork of Working_Client_Code by
Diff: main.cpp
- Revision:
- 5:d25327fb7a14
- Parent:
- 4:d205b6061e66
- Child:
- 6:1c35ca876e09
diff -r d205b6061e66 -r d25327fb7a14 main.cpp --- a/main.cpp Thu Jun 09 10:51:33 2016 +0000 +++ b/main.cpp Thu Jun 09 14:32:09 2016 +0000 @@ -111,6 +111,8 @@ } int main() { + int range=3456; + buffer=(char *)calloc(BUFF_SIZE,1); reset=0; @@ -178,7 +180,7 @@ case 6: { resp=OKResponse(buffer,"OK"); if (resp!=NULL) { - wait(1); + wait(10); dev.printf("AT+CIFSR\r\n"); state++; } @@ -214,15 +216,39 @@ case 9: { resp=OKResponse(buffer,"OK"); if (resp!=NULL) { INFO("Ready"); + wait(2); + char buf[32]; + sprintf(buf,"Range=%04d\r\n",range); //dev.printf("AT+CIPSERVER= 1,6060"); - dev.printf("AT+CIPSEND=0,10\r\n"); //10 = length of string being sent - state++; + dev.printf("AT+CIPSEND=0,%d\r\n",strlen(buf)); //10 = length of string being sent + wait(2); + dev.printf("%s",buf); //10 = length of string being sent + range=(range++)%6000; + + state=9; } pc.printf("%s\n\r",buffer); break; } + case 10: { resp=OKResponse(buffer,">"); + if (resp!=NULL) { + INFO("Sending"); + //dev.printf("AT+CIPSERVER= 1,6060"); + // code to get range and format to max 4 digits to be added + dev.printf("Range=%04d\r\n",range); //10 = length of string being sent + range=(range+500)%6000; + wait(2); + state=9; + } + // pc.printf("%s\n\r",buffer); + + break; + + } + + }