Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp@4:52361cf7f1d8, 2020-08-04 (annotated)
- Committer:
- molberry
- Date:
- Tue Aug 04 07:47:49 2020 +0000
- Revision:
- 4:52361cf7f1d8
- Parent:
- 3:2472790818a9
- Child:
- 5:7133730d405f
speed; btn; change; finish
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| molberry | 0:04482d11976f | 1 | #include "mbed.h" |
| molberry | 0:04482d11976f | 2 | |
| molberry | 0:04482d11976f | 3 | Serial pc(USBTX, USBRX); |
| molberry | 0:04482d11976f | 4 | Serial esp(p13, p14); // tx, rx |
| molberry | 0:04482d11976f | 5 | |
| molberry | 0:04482d11976f | 6 | enum MODE { |
| molberry | 0:04482d11976f | 7 | READY = -1, |
| molberry | 0:04482d11976f | 8 | ADVANCE = 1, |
| molberry | 0:04482d11976f | 9 | RIGHT, |
| molberry | 0:04482d11976f | 10 | LEFT, |
| molberry | 0:04482d11976f | 11 | BACK, |
| molberry | 0:04482d11976f | 12 | STOP, |
| molberry | 0:04482d11976f | 13 | LINE_TRACE, // 6:ライントレース |
| molberry | 0:04482d11976f | 14 | AVOIDANCE, // 7:障害物回避 |
| molberry | 0:04482d11976f | 15 | SPEED, // 8:スピード制御 |
| molberry | 0:04482d11976f | 16 | }; |
| molberry | 0:04482d11976f | 17 | |
| molberry | 0:04482d11976f | 18 | // Standard Mbed LED definitions |
| molberry | 0:04482d11976f | 19 | DigitalOut led1(LED1); |
| molberry | 0:04482d11976f | 20 | DigitalOut led2(LED2); |
| molberry | 0:04482d11976f | 21 | DigitalOut led3(LED3); |
| molberry | 0:04482d11976f | 22 | DigitalOut led4(LED4); |
| molberry | 0:04482d11976f | 23 | |
| molberry | 0:04482d11976f | 24 | Timer t1; |
| molberry | 0:04482d11976f | 25 | Timer t2; |
| molberry | 0:04482d11976f | 26 | |
| molberry | 0:04482d11976f | 27 | struct tm t; |
| molberry | 0:04482d11976f | 28 | |
| molberry | 0:04482d11976f | 29 | int flag_sp = 0; |
| molberry | 0:04482d11976f | 30 | int mode = ADVANCE; |
| molberry | 0:04482d11976f | 31 | int beforeMode = mode; |
| molberry | 0:04482d11976f | 32 | |
| molberry | 1:479303f0e488 | 33 | int bufflen, DataRX, ount, getcount, replycount, servreq, timeout; |
| molberry | 0:04482d11976f | 34 | int bufl, ipdLen, linkID, weberror, webcounter,click_flag; |
| molberry | 0:04482d11976f | 35 | float temperature, AdcIn, Ht; |
| molberry | 0:04482d11976f | 36 | float R1=100000, R2=10000; // resistor values to give a 10:1 reduction of measured AnalogIn voltage |
| molberry | 0:04482d11976f | 37 | char Vcc[10]; |
| molberry | 0:04482d11976f | 38 | char webcount[8]; |
| molberry | 0:04482d11976f | 39 | char type[16]; |
| molberry | 0:04482d11976f | 40 | char type1[16]; |
| molberry | 0:04482d11976f | 41 | char channel[2]; |
| molberry | 0:04482d11976f | 42 | char cmdbuff[32]; |
| molberry | 0:04482d11976f | 43 | char replybuff[1024]; |
| molberry | 0:04482d11976f | 44 | |
| molberry | 0:04482d11976f | 45 | char webdata[1024]; // This may need to be bigger depending on WEB browser used |
| molberry | 0:04482d11976f | 46 | char webbuff[4096*4]; // Currently using 1986 characters, Increase this if more web page data added |
| molberry | 0:04482d11976f | 47 | |
| molberry | 0:04482d11976f | 48 | |
| molberry | 0:04482d11976f | 49 | void SendCMD(),getreply(),ReadWebData(),startserver(),sendpage(),SendWEB(),sendcheck(),touchuan(); |
| molberry | 0:04482d11976f | 50 | |
| molberry | 0:04482d11976f | 51 | |
| molberry | 0:04482d11976f | 52 | int port =80; // set server port |
| molberry | 0:04482d11976f | 53 | int SERVtimeout =5; // set server timeout in seconds in case link breaks. |
| molberry | 0:04482d11976f | 54 | |
| molberry | 0:04482d11976f | 55 | char ssid[32] = "mbed02"; // enter WiFi router ssid inside the quotes |
| molberry | 0:04482d11976f | 56 | char pwd [32] = "0123456789a"; // enter WiFi router password inside the quotes |
| molberry | 0:04482d11976f | 57 | |
| molberry | 0:04482d11976f | 58 | // Serial Interrupt read ESP data |
| molberry | 0:04482d11976f | 59 | void callback() |
| molberry | 0:04482d11976f | 60 | { |
| molberry | 0:04482d11976f | 61 | //pc.printf("\n\r------------ callback is being called --------------\n\r"); |
| molberry | 0:04482d11976f | 62 | led3=1; |
| molberry | 0:04482d11976f | 63 | while (esp.readable()) { |
| molberry | 1:479303f0e488 | 64 | webbuff[ount] = esp.getc(); |
| molberry | 1:479303f0e488 | 65 | ount++; |
| molberry | 0:04482d11976f | 66 | } |
| molberry | 0:04482d11976f | 67 | if(strlen(webbuff)>bufflen) { |
| molberry | 0:04482d11976f | 68 | pc.printf("\f\n\r------------ webbuff over bufflen --------------\n\r"); |
| molberry | 0:04482d11976f | 69 | DataRX=1; |
| molberry | 0:04482d11976f | 70 | led3=0; |
| molberry | 0:04482d11976f | 71 | } |
| molberry | 0:04482d11976f | 72 | } |
| molberry | 0:04482d11976f | 73 | |
| molberry | 0:04482d11976f | 74 | int main() |
| molberry | 0:04482d11976f | 75 | { |
| molberry | 0:04482d11976f | 76 | pc.baud(115200); |
| molberry | 0:04482d11976f | 77 | |
| molberry | 0:04482d11976f | 78 | pc.printf("\f\n\r------------ ESP8266 Hardware Reset psq --------------\n\r"); |
| molberry | 0:04482d11976f | 79 | wait(0.5); |
| molberry | 0:04482d11976f | 80 | led1=1,led2=0,led3=0; |
| molberry | 0:04482d11976f | 81 | timeout=6000; |
| molberry | 0:04482d11976f | 82 | getcount=500; |
| molberry | 0:04482d11976f | 83 | getreply(); |
| molberry | 0:04482d11976f | 84 | esp.baud(115200); // ESP8266 baudrate. Maximum on KLxx' is 115200, 230400 works on K20 and K22F |
| molberry | 0:04482d11976f | 85 | startserver(); |
| molberry | 0:04482d11976f | 86 | |
| molberry | 0:04482d11976f | 87 | while(1) { |
| molberry | 0:04482d11976f | 88 | if(DataRX==1) { |
| molberry | 0:04482d11976f | 89 | pc.printf("\f\n\r------------ main while > if --------------\n\r"); |
| molberry | 0:04482d11976f | 90 | click_flag = 1; |
| molberry | 0:04482d11976f | 91 | ReadWebData(); |
| molberry | 0:04482d11976f | 92 | pc.printf("\f\n\r------------ click_flag=%d --------------\n\r",click_flag); |
| molberry | 0:04482d11976f | 93 | //if ((servreq == 1 && weberror == 0) && click_flag == 1) { |
| molberry | 0:04482d11976f | 94 | if (servreq == 1 && weberror == 0) { |
| molberry | 0:04482d11976f | 95 | pc.printf("\f\n\r------------ befor send page --------------\n\r"); |
| molberry | 0:04482d11976f | 96 | sendpage(); |
| molberry | 0:04482d11976f | 97 | } |
| molberry | 0:04482d11976f | 98 | pc.printf("\f\n\r------------ send_check begin --------------\n\r"); |
| molberry | 0:04482d11976f | 99 | |
| molberry | 0:04482d11976f | 100 | //sendcheck(); |
| molberry | 0:04482d11976f | 101 | pc.printf("\f\n\r------------ ssend_check end--------------\n\r"); |
| molberry | 0:04482d11976f | 102 | |
| molberry | 0:04482d11976f | 103 | esp.attach(&callback); |
| molberry | 0:04482d11976f | 104 | pc.printf(" IPD Data:\r\n\n Link ID = %d,\r\n IPD Header Length = %d \r\n IPD Type = %s\r\n", linkID, ipdLen, type); |
| molberry | 0:04482d11976f | 105 | pc.printf("\n\n HTTP Packet: \n\n%s\n", webdata); |
| molberry | 0:04482d11976f | 106 | pc.printf(" Web Characters sent : %d\n\n", bufl); |
| molberry | 0:04482d11976f | 107 | pc.printf(" -------------------------------------\n\n"); |
| molberry | 0:04482d11976f | 108 | servreq=0; |
| molberry | 0:04482d11976f | 109 | } |
| molberry | 0:04482d11976f | 110 | } |
| molberry | 0:04482d11976f | 111 | } |
| molberry | 0:04482d11976f | 112 | // Static WEB page |
| molberry | 0:04482d11976f | 113 | void sendpage() |
| molberry | 0:04482d11976f | 114 | { |
| molberry | 0:04482d11976f | 115 | // WEB page data |
| molberry | 0:04482d11976f | 116 | |
| molberry | 0:04482d11976f | 117 | strcpy(webbuff, "<!DOCTYPE html>"); |
| molberry | 0:04482d11976f | 118 | strcat(webbuff, "<html><head><title>RobotCar</title><meta name='viewport' content='width=device-width'/>"); |
| molberry | 2:4d51edb0a6c9 | 119 | strcat(webbuff, "<style type=\"text/css\">.noselect{ width:100px;height:60px;}.light{ width:100px;height:60px;background-color:#00ff66;}</style>"); |
| molberry | 0:04482d11976f | 120 | strcat(webbuff, "</head><body><center><p><strong>Robot Car Remot Controller"); |
| molberry | 0:04482d11976f | 121 | strcat(webbuff, "</strong></p><td style='vertical-align:top;'><strong>Battery level "); |
| molberry | 0:04482d11976f | 122 | strcat(webbuff, "<input type=\"text\" id=\"leftms\" size=4 value=250>%</strong>"); |
| molberry | 0:04482d11976f | 123 | strcat(webbuff, "</td></p>"); |
| molberry | 0:04482d11976f | 124 | strcat(webbuff, "<br>"); |
| molberry | 0:04482d11976f | 125 | strcat(webbuff, "<table><tr><td></td><td>"); |
| molberry | 0:04482d11976f | 126 | |
| molberry | 0:04482d11976f | 127 | switch(mode) { |
| molberry | 0:04482d11976f | 128 | case ADVANCE: |
| molberry | 0:04482d11976f | 129 | strcat(webbuff, "<button id='gobtn' type='button' class=\"light\" value=\"GO\" onClick='send_mes(this.id,this.value)'>GO"); |
| molberry | 0:04482d11976f | 130 | strcat(webbuff, "</button></td><td></td></tr><tr><td>"); |
| molberry | 0:04482d11976f | 131 | strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.id,this.value)' >LEFT"); |
| molberry | 0:04482d11976f | 132 | strcat(webbuff, "</button></td><td>"); |
| molberry | 0:04482d11976f | 133 | strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,this.value)' >STOP"); |
| molberry | 0:04482d11976f | 134 | strcat(webbuff, "</button></td><td>"); |
| molberry | 0:04482d11976f | 135 | strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.id,this.value)' >RIGHT"); |
| molberry | 0:04482d11976f | 136 | strcat(webbuff, "</button></td></tr><td></td><td>"); |
| molberry | 0:04482d11976f | 137 | strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.id,this.value)' >BACK"); |
| molberry | 0:04482d11976f | 138 | strcat(webbuff, "</button></td><td style='vertical-align:top; text-align:right;'></td></tr></table>"); |
| molberry | 0:04482d11976f | 139 | strcat(webbuff, "<strong>Mode</strong>"); |
| molberry | 4:52361cf7f1d8 | 140 | strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.id,this.value)' >"); |
| molberry | 0:04482d11976f | 141 | strcat(webbuff, "AVOIDANCE</button></td><td>"); |
| molberry | 4:52361cf7f1d8 | 142 | strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.id,this.value)' >LINE_TRACE"); |
| molberry | 0:04482d11976f | 143 | break; |
| molberry | 0:04482d11976f | 144 | case LEFT: |
| molberry | 0:04482d11976f | 145 | strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.id,this.value)'>GO"); |
| molberry | 0:04482d11976f | 146 | strcat(webbuff, "</button></td><td></td></tr><tr><td>"); |
| molberry | 0:04482d11976f | 147 | strcat(webbuff, "<button id='leftbtn' type='button' class=\"light\" value=\"LEFT\" onClick='send_mes(this.id,this.value)' >LEFT"); |
| molberry | 0:04482d11976f | 148 | strcat(webbuff, "</button></td><td>"); |
| molberry | 0:04482d11976f | 149 | strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,this.value)' >STOP"); |
| molberry | 0:04482d11976f | 150 | strcat(webbuff, "</button></td><td>"); |
| molberry | 0:04482d11976f | 151 | strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.id,this.value)' >RIGHT"); |
| molberry | 0:04482d11976f | 152 | strcat(webbuff, "</button></td></tr><td></td><td>"); |
| molberry | 0:04482d11976f | 153 | strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.id,this.value)' >BACK"); |
| molberry | 0:04482d11976f | 154 | strcat(webbuff, "</button></td><td style='vertical-align:top; text-align:right;'></td></tr></table>"); |
| molberry | 0:04482d11976f | 155 | strcat(webbuff, "<strong>Mode</strong>"); |
| molberry | 4:52361cf7f1d8 | 156 | strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.id,this.value)' >"); |
| molberry | 0:04482d11976f | 157 | strcat(webbuff, "AVOIDANCE</button></td><td>"); |
| molberry | 4:52361cf7f1d8 | 158 | strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.id,this.value)' >LINE_TRACE"); |
| molberry | 0:04482d11976f | 159 | break; |
| molberry | 0:04482d11976f | 160 | case STOP: |
| molberry | 0:04482d11976f | 161 | strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.id,this.value)'>GO"); |
| molberry | 0:04482d11976f | 162 | strcat(webbuff, "</button></td><td></td></tr><tr><td>"); |
| molberry | 0:04482d11976f | 163 | strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.id,this.value)' >LEFT"); |
| molberry | 0:04482d11976f | 164 | strcat(webbuff, "</button></td><td>"); |
| molberry | 0:04482d11976f | 165 | strcat(webbuff, "<button id='stopbtn' type='button' class=\"light\" value=\"STOP\" onClick='send_mes(this.id,this.value)' >STOP"); |
| molberry | 0:04482d11976f | 166 | strcat(webbuff, "</button></td><td>"); |
| molberry | 0:04482d11976f | 167 | strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.id,this.value)' >RIGHT"); |
| molberry | 0:04482d11976f | 168 | strcat(webbuff, "</button></td></tr><td></td><td>"); |
| molberry | 0:04482d11976f | 169 | strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.id,this.value)' >BACK"); |
| molberry | 0:04482d11976f | 170 | strcat(webbuff, "</button></td><td style='vertical-align:top; text-align:right;'></td></tr></table>"); |
| molberry | 0:04482d11976f | 171 | strcat(webbuff, "<strong>Mode</strong>"); |
| molberry | 4:52361cf7f1d8 | 172 | strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.id,this.value)' >"); |
| molberry | 0:04482d11976f | 173 | strcat(webbuff, "AVOIDANCE</button></td><td>"); |
| molberry | 4:52361cf7f1d8 | 174 | strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.id,this.value)' >LINE_TRACE"); |
| molberry | 0:04482d11976f | 175 | break; |
| molberry | 0:04482d11976f | 176 | case RIGHT: |
| molberry | 0:04482d11976f | 177 | strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.id,this.value)'>GO"); |
| molberry | 0:04482d11976f | 178 | strcat(webbuff, "</button></td><td></td></tr><tr><td>"); |
| molberry | 0:04482d11976f | 179 | strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.id,this.value)' >LEFT"); |
| molberry | 0:04482d11976f | 180 | strcat(webbuff, "</button></td><td>"); |
| molberry | 0:04482d11976f | 181 | strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,this.value)' >STOP"); |
| molberry | 0:04482d11976f | 182 | strcat(webbuff, "</button></td><td>"); |
| molberry | 0:04482d11976f | 183 | strcat(webbuff, "<button id='rightbtn' type='button' class=\"light\" value=\"RIGHT\" onClick='send_mes(this.id,this.value)' >RIGHT"); |
| molberry | 0:04482d11976f | 184 | strcat(webbuff, "</button></td></tr><td></td><td>"); |
| molberry | 0:04482d11976f | 185 | strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.id,this.value)' >BACK"); |
| molberry | 0:04482d11976f | 186 | strcat(webbuff, "</button></td><td style='vertical-align:top; text-align:right;'></td></tr></table>"); |
| molberry | 0:04482d11976f | 187 | strcat(webbuff, "<strong>Mode</strong>"); |
| molberry | 4:52361cf7f1d8 | 188 | strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.id,this.value)' >"); |
| molberry | 0:04482d11976f | 189 | strcat(webbuff, "AVOIDANCE</button></td><td>"); |
| molberry | 4:52361cf7f1d8 | 190 | strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.id,this.value)' >LINE_TRACE"); |
| molberry | 0:04482d11976f | 191 | break; |
| molberry | 0:04482d11976f | 192 | case BACK: |
| molberry | 0:04482d11976f | 193 | strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.id,this.value)'>GO"); |
| molberry | 0:04482d11976f | 194 | strcat(webbuff, "</button></td><td></td></tr><tr><td>"); |
| molberry | 0:04482d11976f | 195 | strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.id,this.value)' >LEFT"); |
| molberry | 0:04482d11976f | 196 | strcat(webbuff, "</button></td><td>"); |
| molberry | 0:04482d11976f | 197 | strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,this.value)' >STOP"); |
| molberry | 0:04482d11976f | 198 | strcat(webbuff, "</button></td><td>"); |
| molberry | 0:04482d11976f | 199 | strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.id,this.value)' >RIGHT"); |
| molberry | 0:04482d11976f | 200 | strcat(webbuff, "</button></td></tr><td></td><td>"); |
| molberry | 0:04482d11976f | 201 | strcat(webbuff, "<button id='backbtn' type='button' class=\"light\" value=\"BACK\" onClick='send_mes(this.id,this.value)' >BACK"); |
| molberry | 0:04482d11976f | 202 | strcat(webbuff, "</button></td><td style='vertical-align:top; text-align:right;'></td></tr><td>"); |
| molberry | 0:04482d11976f | 203 | strcat(webbuff, "<strong>Mode</strong>"); |
| molberry | 4:52361cf7f1d8 | 204 | strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.id,this.value)' >"); |
| molberry | 0:04482d11976f | 205 | strcat(webbuff, "AVOIDANCE</button></td><td>"); |
| molberry | 4:52361cf7f1d8 | 206 | strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.id,this.value)' >LINE_TRACE"); |
| molberry | 0:04482d11976f | 207 | break; |
| molberry | 0:04482d11976f | 208 | case AVOIDANCE: |
| molberry | 0:04482d11976f | 209 | strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.id,this.value)'>GO"); |
| molberry | 0:04482d11976f | 210 | strcat(webbuff, "</button></td><td></td></tr><tr><td>"); |
| molberry | 0:04482d11976f | 211 | strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.id,this.value)' >LEFT"); |
| molberry | 0:04482d11976f | 212 | strcat(webbuff, "</button></td><td>"); |
| molberry | 0:04482d11976f | 213 | strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,this.value)' >STOP"); |
| molberry | 0:04482d11976f | 214 | strcat(webbuff, "</button></td><td>"); |
| molberry | 0:04482d11976f | 215 | strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.id,this.value)' >RIGHT"); |
| molberry | 0:04482d11976f | 216 | strcat(webbuff, "</button></td></tr><td></td><td>"); |
| molberry | 0:04482d11976f | 217 | strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.id,this.value)' >BACK"); |
| molberry | 0:04482d11976f | 218 | strcat(webbuff, "</button></td><td style='vertical-align:top; text-align:right;'></td></tr></table>"); |
| molberry | 0:04482d11976f | 219 | strcat(webbuff, "<strong>Mode</strong>"); |
| molberry | 4:52361cf7f1d8 | 220 | strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"light\" value=\"AVOIDANCE\" onClick='send_mes(this.id,this.value)' >"); |
| molberry | 0:04482d11976f | 221 | strcat(webbuff, "AVOIDANCE</button></td><td>"); |
| molberry | 4:52361cf7f1d8 | 222 | strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.id,this.value)' >LINE_TRACE"); |
| molberry | 0:04482d11976f | 223 | break; |
| molberry | 0:04482d11976f | 224 | case LINE_TRACE: |
| molberry | 0:04482d11976f | 225 | strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.id,this.value)'>GO"); |
| molberry | 0:04482d11976f | 226 | strcat(webbuff, "</button></td><td></td></tr><tr><td>"); |
| molberry | 0:04482d11976f | 227 | strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.id,this.value)' >LEFT"); |
| molberry | 0:04482d11976f | 228 | strcat(webbuff, "</button></td><td>"); |
| molberry | 0:04482d11976f | 229 | strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,this.value)' >STOP"); |
| molberry | 0:04482d11976f | 230 | strcat(webbuff, "</button></td><td>"); |
| molberry | 0:04482d11976f | 231 | strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.id,this.value)' >RIGHT"); |
| molberry | 0:04482d11976f | 232 | strcat(webbuff, "</button></td></tr><td></td><td>"); |
| molberry | 0:04482d11976f | 233 | strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.id,this.value)' >BACK"); |
| molberry | 0:04482d11976f | 234 | strcat(webbuff, "</button></td><td style='vertical-align:top; text-align:right;'></td></tr></table>"); |
| molberry | 0:04482d11976f | 235 | strcat(webbuff, "<strong>Mode</strong>"); |
| molberry | 4:52361cf7f1d8 | 236 | strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.id,this.value)' >"); |
| molberry | 0:04482d11976f | 237 | strcat(webbuff, "AVOIDANCE</button></td><td>"); |
| molberry | 4:52361cf7f1d8 | 238 | strcat(webbuff, "<button id='tracebtn' type='button' class=\"light\" value=\"LINE_TRACE\" onClick='send_mes(this.id,this.value)' >LINE_TRACE"); |
| molberry | 0:04482d11976f | 239 | break; |
| molberry | 0:04482d11976f | 240 | default: |
| molberry | 0:04482d11976f | 241 | strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.id,this.value)'>GO"); |
| molberry | 0:04482d11976f | 242 | strcat(webbuff, "</button></td><td></td></tr><tr><td>"); |
| molberry | 0:04482d11976f | 243 | strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.id,this.value)' >LEFT"); |
| molberry | 0:04482d11976f | 244 | strcat(webbuff, "</button></td><td>"); |
| molberry | 0:04482d11976f | 245 | strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,this.value)' >STOP"); |
| molberry | 0:04482d11976f | 246 | strcat(webbuff, "</button></td><td>"); |
| molberry | 0:04482d11976f | 247 | strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.id,this.value)' >RIGHT"); |
| molberry | 0:04482d11976f | 248 | strcat(webbuff, "</button></td></tr><td></td><td>"); |
| molberry | 0:04482d11976f | 249 | strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.id,this.value)' >BACK"); |
| molberry | 0:04482d11976f | 250 | strcat(webbuff, "</button></td><td style='vertical-align:top; text-align:right;'></td></tr></table>"); |
| molberry | 0:04482d11976f | 251 | strcat(webbuff, "<strong>Mode</strong>"); |
| molberry | 4:52361cf7f1d8 | 252 | strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.id,this.value)' >"); |
| molberry | 0:04482d11976f | 253 | strcat(webbuff, "AVOIDANCE</button></td><td>"); |
| molberry | 4:52361cf7f1d8 | 254 | strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.id,this.value)' >LINE_TRACE"); |
| molberry | 0:04482d11976f | 255 | break; |
| molberry | 0:04482d11976f | 256 | } |
| molberry | 0:04482d11976f | 257 | strcat(webbuff, "</button></td></tr></table>"); |
| molberry | 0:04482d11976f | 258 | strcat(webbuff, "<strong>Speed</strong>"); |
| molberry | 0:04482d11976f | 259 | strcat(webbuff, "<table><tr><td>"); |
| molberry | 0:04482d11976f | 260 | //ready示速度だけ点灯 |
| molberry | 0:04482d11976f | 261 | switch (flag_sp) { |
| molberry | 0:04482d11976f | 262 | case 0: |
| molberry | 3:2472790818a9 | 263 | strcat(webbuff, "<button id='sp1btn' type='button' class=\"light\" value=\"Normal\" onClick='send_mes_spe(this.id,this.value)' >Normal"); |
| molberry | 0:04482d11976f | 264 | strcat(webbuff, "</button></td><td>"); |
| molberry | 3:2472790818a9 | 265 | strcat(webbuff, "<button id='sp2btn' type='button' class=\"noselect\" value=\"Fast\" onClick='send_mes_spe(this.id,this.value)' >Fast"); |
| molberry | 0:04482d11976f | 266 | strcat(webbuff, "</button></td><td>"); |
| molberry | 3:2472790818a9 | 267 | strcat(webbuff, "<button id='sp3btn' type='button' class=\"noselect\" value=\"VeryFast\" onClick='send_mes_spe(this.id,this.value)' >VeryFast"); |
| molberry | 0:04482d11976f | 268 | break; |
| molberry | 0:04482d11976f | 269 | case 1: |
| molberry | 4:52361cf7f1d8 | 270 | strcat(webbuff, "<button id='sp1btn' type='button' class=\"noselect\" value=\"Normal\" onClick='send_mes_spe(this.id,this.value)' >Normal"); |
| molberry | 0:04482d11976f | 271 | strcat(webbuff, "</button></td><td>"); |
| molberry | 4:52361cf7f1d8 | 272 | strcat(webbuff, "<button id='sp2btn' type='button' class=\"light\" value=\"Fast\" onClick='send_mes_spe(this.id,this.value)' >Fast"); |
| molberry | 0:04482d11976f | 273 | strcat(webbuff, "</button></td><td>"); |
| molberry | 4:52361cf7f1d8 | 274 | strcat(webbuff, "<button id='sp3btn' type='button' class=\"noselect\" value=\"BeryFast\" onClick='send_mes_spe(this.id,this.value)' >BeryFast"); |
| molberry | 0:04482d11976f | 275 | break; |
| molberry | 0:04482d11976f | 276 | case 2: |
| molberry | 4:52361cf7f1d8 | 277 | strcat(webbuff, "<button id='sp1btn' type='button' class=\"noselect\" value=\"Normal\" onClick='send_mes_spe(this.id,this.value)' >Normal"); |
| molberry | 0:04482d11976f | 278 | strcat(webbuff, "</button></td><td>"); |
| molberry | 4:52361cf7f1d8 | 279 | strcat(webbuff, "<button id='sp2btn' type='button' class=\"noselect\" value=\"Fast\" onClick='send_mes_spe(this.id,this.value)' >Fast"); |
| molberry | 0:04482d11976f | 280 | strcat(webbuff, "</button></td><td>"); |
| molberry | 4:52361cf7f1d8 | 281 | strcat(webbuff, "<button id='sp3btn' type='button' class=\"light\" value=\"BeryFast\" onClick='send_mes_spe(this.id,this.value)' >BeryFast"); |
| molberry | 0:04482d11976f | 282 | break; |
| molberry | 0:04482d11976f | 283 | default: |
| molberry | 4:52361cf7f1d8 | 284 | strcat(webbuff, "<button id='sp1btn' type='button' class=\"noselect\" value=\"Normal\" onClick='send_mes_spe(this.id,this.value)' >Normal"); |
| molberry | 0:04482d11976f | 285 | strcat(webbuff, "</button></td><td>"); |
| molberry | 4:52361cf7f1d8 | 286 | strcat(webbuff, "<button id='sp2btn' type='button' class=\"noselect\" value=\"Fast\" onClick='send_mes_spe(this.id,this.value)' >Fast"); |
| molberry | 0:04482d11976f | 287 | strcat(webbuff, "</button></td><td>"); |
| molberry | 4:52361cf7f1d8 | 288 | strcat(webbuff, "<button id='sp3btn' type='button' class=\"noselect\" value=\"BeryFast\" onClick='send_mes_spe(this.id,this.value)' >BeryFast"); |
| molberry | 0:04482d11976f | 289 | break; |
| molberry | 0:04482d11976f | 290 | } |
| molberry | 0:04482d11976f | 291 | strcat(webbuff, "</button></td></tr></table>"); |
| molberry | 0:04482d11976f | 292 | |
| molberry | 0:04482d11976f | 293 | strcat(webbuff, "</center>"); |
| molberry | 0:04482d11976f | 294 | strcat(webbuff, "</body>"); |
| molberry | 0:04482d11976f | 295 | strcat(webbuff, "</html>"); |
| molberry | 0:04482d11976f | 296 | strcat(webbuff, "<script language=\"javascript\" type=\"text/javascript\">"); |
| molberry | 0:04482d11976f | 297 | strcat(webbuff, "function htmlacs(url) {"); |
| molberry | 0:04482d11976f | 298 | strcat(webbuff, "var xhr = new XMLHttpRequest();"); |
| molberry | 0:04482d11976f | 299 | strcat(webbuff, "xhr.open(\"GET\", url);"); |
| molberry | 0:04482d11976f | 300 | strcat(webbuff, "xhr.send(\"\");"); |
| molberry | 0:04482d11976f | 301 | strcat(webbuff, "}"); |
| molberry | 0:04482d11976f | 302 | strcat(webbuff, "function send_mes(btnmes,btnval){"); |
| molberry | 2:4d51edb0a6c9 | 303 | strcat(webbuff, "console.log(btnval);"); |
| molberry | 2:4d51edb0a6c9 | 304 | |
| molberry | 2:4d51edb0a6c9 | 305 | strcat(webbuff, "switch(btnval){"); |
| molberry | 2:4d51edb0a6c9 | 306 | strcat(webbuff, "case \"GO\"):"); |
| molberry | 2:4d51edb0a6c9 | 307 | strcat(webbuff, "document.getElementById(\"gobtn\").className=\"light\";"); |
| molberry | 2:4d51edb0a6c9 | 308 | strcat(webbuff, "document.getElementById(\"leftbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 309 | strcat(webbuff, "document.getElementById(\"stopbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 310 | strcat(webbuff, "document.getElementById(\"rightbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 311 | strcat(webbuff, "document.getElementById(\"backbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 312 | strcat(webbuff, "document.getElementById(\"avoidbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 313 | strcat(webbuff, "document.getElementById(\"tracebtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 314 | strcat(webbuff, "break;"); |
| molberry | 2:4d51edb0a6c9 | 315 | strcat(webbuff, "case \"LEFT\"):"); |
| molberry | 2:4d51edb0a6c9 | 316 | strcat(webbuff, "document.getElementById(\"gobtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 317 | strcat(webbuff, "document.getElementById(\"leftbtn\").className=\"light\";"); |
| molberry | 2:4d51edb0a6c9 | 318 | strcat(webbuff, "document.getElementById(\"stopbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 319 | strcat(webbuff, "document.getElementById(\"rightbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 320 | strcat(webbuff, "document.getElementById(\"backbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 321 | strcat(webbuff, "document.getElementById(\"avoidbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 322 | strcat(webbuff, "document.getElementById(\"tracebtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 323 | strcat(webbuff, "break;"); |
| molberry | 2:4d51edb0a6c9 | 324 | strcat(webbuff, "case \"STOP\"):"); |
| molberry | 2:4d51edb0a6c9 | 325 | strcat(webbuff, "document.getElementById(\"gobtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 326 | strcat(webbuff, "document.getElementById(\"leftbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 327 | strcat(webbuff, "document.getElementById(\"stopbtn\").className=\"light\";"); |
| molberry | 2:4d51edb0a6c9 | 328 | strcat(webbuff, "document.getElementById(\"rightbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 329 | strcat(webbuff, "document.getElementById(\"backbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 330 | strcat(webbuff, "document.getElementById(\"avoidbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 331 | strcat(webbuff, "document.getElementById(\"tracebtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 332 | strcat(webbuff, "break;"); |
| molberry | 2:4d51edb0a6c9 | 333 | strcat(webbuff, "case \"RIGHT\"):"); |
| molberry | 2:4d51edb0a6c9 | 334 | strcat(webbuff, "document.getElementById(\"gobtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 335 | strcat(webbuff, "document.getElementById(\"leftbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 336 | strcat(webbuff, "document.getElementById(\"stopbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 337 | strcat(webbuff, "document.getElementById(\"rightbtn\").className=\"light\";"); |
| molberry | 2:4d51edb0a6c9 | 338 | strcat(webbuff, "document.getElementById(\"backbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 339 | strcat(webbuff, "document.getElementById(\"avoidbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 340 | strcat(webbuff, "document.getElementById(\"tracebtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 341 | strcat(webbuff, "break;"); |
| molberry | 2:4d51edb0a6c9 | 342 | strcat(webbuff, "case \"BACK\"):"); |
| molberry | 2:4d51edb0a6c9 | 343 | strcat(webbuff, "document.getElementById(\"gobtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 344 | strcat(webbuff, "document.getElementById(\"leftbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 345 | strcat(webbuff, "document.getElementById(\"stopbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 346 | strcat(webbuff, "document.getElementById(\"rightbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 347 | strcat(webbuff, "document.getElementById(\"backbtn\").className=\"light\";"); |
| molberry | 2:4d51edb0a6c9 | 348 | strcat(webbuff, "document.getElementById(\"avoidbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 349 | strcat(webbuff, "document.getElementById(\"tracebtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 350 | strcat(webbuff, "break;"); |
| molberry | 2:4d51edb0a6c9 | 351 | strcat(webbuff, "case \"AVOIDANCE\"):"); |
| molberry | 2:4d51edb0a6c9 | 352 | strcat(webbuff, "document.getElementById(\"gobtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 353 | strcat(webbuff, "document.getElementById(\"leftbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 354 | strcat(webbuff, "document.getElementById(\"stopbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 355 | strcat(webbuff, "document.getElementById(\"rightbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 356 | strcat(webbuff, "document.getElementById(\"backbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 357 | strcat(webbuff, "document.getElementById(\"avoidbtn\").className=\"light\";"); |
| molberry | 2:4d51edb0a6c9 | 358 | strcat(webbuff, "document.getElementById(\"tracebtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 359 | strcat(webbuff, "break;"); |
| molberry | 2:4d51edb0a6c9 | 360 | strcat(webbuff, "case \"LINE_TRACE\"):"); |
| molberry | 2:4d51edb0a6c9 | 361 | strcat(webbuff, "document.getElementById(\"gobtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 362 | strcat(webbuff, "document.getElementById(\"leftbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 363 | strcat(webbuff, "document.getElementById(\"stopbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 364 | strcat(webbuff, "document.getElementById(\"rightbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 365 | strcat(webbuff, "document.getElementById(\"backbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 366 | strcat(webbuff, "document.getElementById(\"avoidbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 367 | strcat(webbuff, "document.getElementById(\"tracebtn\").className=\"light\";"); |
| molberry | 2:4d51edb0a6c9 | 368 | strcat(webbuff, "break;"); |
| molberry | 4:52361cf7f1d8 | 369 | strcat(webbuff, "}"); |
| molberry | 2:4d51edb0a6c9 | 370 | strcat(webbuff, "default :"); |
| molberry | 2:4d51edb0a6c9 | 371 | strcat(webbuff, "document.getElementById(\"gobtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 372 | strcat(webbuff, "document.getElementById(\"leftbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 373 | strcat(webbuff, "document.getElementById(\"stopbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 374 | strcat(webbuff, "document.getElementById(\"rightbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 375 | strcat(webbuff, "document.getElementById(\"backbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 376 | strcat(webbuff, "document.getElementById(\"avoidbtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 377 | strcat(webbuff, "document.getElementById(\"tracebtn\").className=\"noselect\";"); |
| molberry | 2:4d51edb0a6c9 | 378 | strcat(webbuff, "break;"); |
| molberry | 4:52361cf7f1d8 | 379 | strcat(webbuff, "}"); |
| molberry | 0:04482d11976f | 380 | strcat(webbuff, "var url = \"http://\" + window.location.hostname + \"/cargo?a=\" + btnval;"); |
| molberry | 0:04482d11976f | 381 | strcat(webbuff, "htmlacs(url);"); |
| molberry | 0:04482d11976f | 382 | strcat(webbuff, "console.log(url);"); |
| molberry | 0:04482d11976f | 383 | strcat(webbuff, "}"); |
| molberry | 0:04482d11976f | 384 | strcat(webbuff, "function send_mes_spe(btnmes,btnval){"); |
| molberry | 4:52361cf7f1d8 | 385 | strcat(webbuff, "switch(btnval){"); |
| molberry | 4:52361cf7f1d8 | 386 | strcat(webbuff, "case \"Normal\"):"); |
| molberry | 4:52361cf7f1d8 | 387 | strcat(webbuff, "document.getElementById(\"sp1btn\").className=\"light\";"); |
| molberry | 4:52361cf7f1d8 | 388 | strcat(webbuff, "document.getElementById(\"sp2btn\").className=\"noselect\";"); |
| molberry | 4:52361cf7f1d8 | 389 | strcat(webbuff, "document.getElementById(\"sp3btn\").className=\"noselect\";"); |
| molberry | 4:52361cf7f1d8 | 390 | strcat(webbuff, "break;"); |
| molberry | 4:52361cf7f1d8 | 391 | strcat(webbuff, "case \"Fast\"):"); |
| molberry | 4:52361cf7f1d8 | 392 | strcat(webbuff, "document.getElementById(\"sp1btn\").className=\"noselect\";"); |
| molberry | 4:52361cf7f1d8 | 393 | strcat(webbuff, "document.getElementById(\"sp2btn\").className=\"light\";"); |
| molberry | 4:52361cf7f1d8 | 394 | strcat(webbuff, "document.getElementById(\"sp3btn\").className=\"noselect\";"); |
| molberry | 4:52361cf7f1d8 | 395 | strcat(webbuff, "break;"); |
| molberry | 4:52361cf7f1d8 | 396 | strcat(webbuff, "case \"BeryFast\"):"); |
| molberry | 4:52361cf7f1d8 | 397 | strcat(webbuff, "document.getElementById(\"sp1btn\").className=\"noselect\";"); |
| molberry | 4:52361cf7f1d8 | 398 | strcat(webbuff, "document.getElementById(\"sp2btn\").className=\"noselect\";"); |
| molberry | 4:52361cf7f1d8 | 399 | strcat(webbuff, "document.getElementById(\"sp3btn\").className=\"light\";"); |
| molberry | 4:52361cf7f1d8 | 400 | strcat(webbuff, "break;"); |
| molberry | 4:52361cf7f1d8 | 401 | strcat(webbuff, "default :"); |
| molberry | 4:52361cf7f1d8 | 402 | strcat(webbuff, "document.getElementById(\"sp1btn\").className=\"noselect\";"); |
| molberry | 4:52361cf7f1d8 | 403 | strcat(webbuff, "document.getElementById(\"sp2btn\").className=\"noselect\";"); |
| molberry | 4:52361cf7f1d8 | 404 | strcat(webbuff, "document.getElementById(\"sp3btn\").className=\"noselect\";"); |
| molberry | 4:52361cf7f1d8 | 405 | strcat(webbuff, "break;"); |
| molberry | 4:52361cf7f1d8 | 406 | strcat(webbuff, "}"); |
| molberry | 0:04482d11976f | 407 | strcat(webbuff, "var url = \"http://\" + window.location.hostname + \"/cargo?a=\" + btnval;"); |
| molberry | 0:04482d11976f | 408 | strcat(webbuff, "htmlacs(url);"); |
| molberry | 0:04482d11976f | 409 | strcat(webbuff, "console.log(url);"); |
| molberry | 0:04482d11976f | 410 | strcat(webbuff, "}"); |
| molberry | 0:04482d11976f | 411 | strcat(webbuff, "</script>"); |
| molberry | 0:04482d11976f | 412 | // end of WEB page data |
| molberry | 0:04482d11976f | 413 | bufl = strlen(webbuff); // get total page buffer length |
| molberry | 0:04482d11976f | 414 | //sprintf(cmdbuff,"AT+CIPSEND=%d,%d\r\n", linkID, bufl); // send IPD link channel and buffer character length. |
| molberry | 0:04482d11976f | 415 | |
| molberry | 0:04482d11976f | 416 | sprintf(cmdbuff,"AT+CIPSENDBUF=%d,%d\r\n", linkID, (bufl>2048?2048:bufl)); // send IPD link channel and buffer character length. |
| molberry | 0:04482d11976f | 417 | timeout=500; |
| molberry | 0:04482d11976f | 418 | getcount=40; |
| molberry | 0:04482d11976f | 419 | SendCMD(); |
| molberry | 0:04482d11976f | 420 | getreply(); |
| molberry | 0:04482d11976f | 421 | pc.printf(replybuff); |
| molberry | 0:04482d11976f | 422 | pc.printf("\n++++++++++ AT+CIPSENDBUF=%d,%d+++++++++\r\n", linkID, (bufl>2048?2048:bufl)); |
| molberry | 0:04482d11976f | 423 | |
| molberry | 0:04482d11976f | 424 | pc.printf("\n++++++++++ bufl is %d ++++++++++\r\n",bufl); |
| molberry | 0:04482d11976f | 425 | |
| molberry | 0:04482d11976f | 426 | //pastthrough mode |
| molberry | 0:04482d11976f | 427 | SendWEB(); // send web page |
| molberry | 0:04482d11976f | 428 | pc.printf("\n++++++++++ webbuff clear ++++++++++\r\n"); |
| molberry | 0:04482d11976f | 429 | |
| molberry | 0:04482d11976f | 430 | memset(webbuff, '\0', sizeof(webbuff)); |
| molberry | 0:04482d11976f | 431 | sendcheck(); |
| molberry | 0:04482d11976f | 432 | } |
| molberry | 0:04482d11976f | 433 | |
| molberry | 0:04482d11976f | 434 | // Large WEB buffer data send |
| molberry | 0:04482d11976f | 435 | void SendWEB() |
| molberry | 0:04482d11976f | 436 | { |
| molberry | 0:04482d11976f | 437 | int i=0; |
| molberry | 0:04482d11976f | 438 | if(esp.writeable()) { |
| molberry | 0:04482d11976f | 439 | while(webbuff[i]!='\0') { |
| molberry | 0:04482d11976f | 440 | esp.putc(webbuff[i]); |
| molberry | 0:04482d11976f | 441 | |
| molberry | 0:04482d11976f | 442 | //**** |
| molberry | 0:04482d11976f | 443 | //output at command when 2000 |
| molberry | 0:04482d11976f | 444 | if(((i%2047)==0) && (i>0)){ |
| molberry | 0:04482d11976f | 445 | //wait_ms(10); |
| molberry | 0:04482d11976f | 446 | sprintf(cmdbuff,"AT+CIPSENDBUF=%d,%d\r\n", linkID, (bufl-2048)>2048?2048:(bufl-2048)); // send IPD link channel and buffer character length. |
| molberry | 0:04482d11976f | 447 | pc.printf("\r\n++++++++++ AT+CIPSENDBUF=%d,%d ++++++++++\r\n", linkID, (bufl-2048)>2048?2048:(bufl-2048)); |
| molberry | 0:04482d11976f | 448 | timeout=600; |
| molberry | 0:04482d11976f | 449 | getcount=50; |
| molberry | 0:04482d11976f | 450 | SendCMD(); |
| molberry | 0:04482d11976f | 451 | getreply(); |
| molberry | 0:04482d11976f | 452 | pc.printf(replybuff); |
| molberry | 0:04482d11976f | 453 | pc.printf("\r\n+++++++++++++++++++\r\n"); |
| molberry | 0:04482d11976f | 454 | } |
| molberry | 0:04482d11976f | 455 | //**** |
| molberry | 0:04482d11976f | 456 | i++; |
| molberry | 0:04482d11976f | 457 | pc.printf("%c",webbuff[i]); |
| molberry | 0:04482d11976f | 458 | } |
| molberry | 0:04482d11976f | 459 | } |
| molberry | 0:04482d11976f | 460 | pc.printf("\n++++++++++ send web i= %dinfo ++++++++++\r\n",i); |
| molberry | 0:04482d11976f | 461 | } |
| molberry | 0:04482d11976f | 462 | |
| molberry | 0:04482d11976f | 463 | |
| molberry | 0:04482d11976f | 464 | |
| molberry | 0:04482d11976f | 465 | void sendcheck() |
| molberry | 0:04482d11976f | 466 | { |
| molberry | 0:04482d11976f | 467 | weberror=1; |
| molberry | 0:04482d11976f | 468 | timeout=500; |
| molberry | 0:04482d11976f | 469 | getcount=24; |
| molberry | 0:04482d11976f | 470 | t2.reset(); |
| molberry | 0:04482d11976f | 471 | t2.start(); |
| molberry | 0:04482d11976f | 472 | |
| molberry | 0:04482d11976f | 473 | /* |
| molberry | 0:04482d11976f | 474 | while(weberror==1 && t2.read() <5) { |
| molberry | 0:04482d11976f | 475 | getreply(); |
| molberry | 0:04482d11976f | 476 | if (strstr(replybuff, "SEND OK") != NULL) { |
| molberry | 0:04482d11976f | 477 | weberror=0; // wait for valid SEND OK |
| molberry | 0:04482d11976f | 478 | } |
| molberry | 0:04482d11976f | 479 | } |
| molberry | 0:04482d11976f | 480 | */ |
| molberry | 0:04482d11976f | 481 | if(weberror==1) { // restart connection |
| molberry | 0:04482d11976f | 482 | strcpy(cmdbuff, "AT+CIPMUX=1\r\n"); |
| molberry | 0:04482d11976f | 483 | timeout=500; |
| molberry | 0:04482d11976f | 484 | getcount=10; |
| molberry | 0:04482d11976f | 485 | SendCMD(); |
| molberry | 0:04482d11976f | 486 | getreply(); |
| molberry | 0:04482d11976f | 487 | pc.printf(replybuff); |
| molberry | 0:04482d11976f | 488 | sprintf(cmdbuff,"AT+CIPSERVER=1,%d\r\n", port); |
| molberry | 0:04482d11976f | 489 | timeout=500; |
| molberry | 0:04482d11976f | 490 | getcount=10; |
| molberry | 0:04482d11976f | 491 | SendCMD(); |
| molberry | 0:04482d11976f | 492 | getreply(); |
| molberry | 0:04482d11976f | 493 | pc.printf(replybuff); |
| molberry | 0:04482d11976f | 494 | } else { |
| molberry | 0:04482d11976f | 495 | sprintf(cmdbuff, "AT+CIPCLOSE=%s\r\n",channel); // close current connection |
| molberry | 0:04482d11976f | 496 | SendCMD(); |
| molberry | 0:04482d11976f | 497 | getreply(); |
| molberry | 0:04482d11976f | 498 | pc.printf(replybuff); |
| molberry | 0:04482d11976f | 499 | } |
| molberry | 0:04482d11976f | 500 | t2.reset(); |
| molberry | 0:04482d11976f | 501 | } |
| molberry | 0:04482d11976f | 502 | |
| molberry | 0:04482d11976f | 503 | // Reads and processes GET and POST web data |
| molberry | 0:04482d11976f | 504 | void ReadWebData() |
| molberry | 0:04482d11976f | 505 | { |
| molberry | 0:04482d11976f | 506 | pc.printf("+++++++++++++++++Read Web Data+++++++++++++++++++++\r\n"); |
| molberry | 0:04482d11976f | 507 | wait_ms(200); |
| molberry | 0:04482d11976f | 508 | esp.attach(NULL); |
| molberry | 1:479303f0e488 | 509 | ount=0; |
| molberry | 0:04482d11976f | 510 | DataRX=0; |
| molberry | 0:04482d11976f | 511 | weberror=0; |
| molberry | 0:04482d11976f | 512 | memset(webdata, '\0', sizeof(webdata)); |
| molberry | 0:04482d11976f | 513 | int x = strcspn (webbuff,"+"); |
| molberry | 0:04482d11976f | 514 | if(x) { |
| molberry | 0:04482d11976f | 515 | strcpy(webdata, webbuff + x); |
| molberry | 0:04482d11976f | 516 | weberror=0; |
| molberry | 0:04482d11976f | 517 | int numMatched = sscanf(webdata,"+IPD,%d,%d:%s", &linkID, &ipdLen, type); |
| molberry | 0:04482d11976f | 518 | //int i=0; |
| molberry | 0:04482d11976f | 519 | pc.printf("+++++++++++++++++succed rec begin+++++++++++++++++++++\r\n"); |
| molberry | 0:04482d11976f | 520 | pc.printf("%s",webdata); |
| molberry | 0:04482d11976f | 521 | pc.printf("+++++++++++++++++succed rec end+++++++++++++++++++++\r\n"); |
| molberry | 0:04482d11976f | 522 | if( strstr(webdata, "GO") != NULL ) { |
| molberry | 0:04482d11976f | 523 | pc.printf("+++++++++++++++++前進+++++++++++++++++++++\r\n"); |
| molberry | 0:04482d11976f | 524 | //run = ADVANCE; // 前進 |
| molberry | 0:04482d11976f | 525 | mode = READY; // モードs変更 |
| molberry | 0:04482d11976f | 526 | // display(); // ディスプレイ表示 |
| molberry | 0:04482d11976f | 527 | |
| molberry | 0:04482d11976f | 528 | } |
| molberry | 0:04482d11976f | 529 | |
| molberry | 0:04482d11976f | 530 | if( strstr(webdata, "LEFT") != NULL ) { |
| molberry | 0:04482d11976f | 531 | pc.printf("+++++++++++++++++左折+++++++++++++++++++++\r\n"); |
| molberry | 0:04482d11976f | 532 | //run = LEFT; |
| molberry | 0:04482d11976f | 533 | mode = READY; |
| molberry | 0:04482d11976f | 534 | // display(); // ディスプレイ表示 |
| molberry | 0:04482d11976f | 535 | } |
| molberry | 0:04482d11976f | 536 | |
| molberry | 0:04482d11976f | 537 | if( strstr(webdata, "STOP") != NULL ) { |
| molberry | 0:04482d11976f | 538 | pc.printf("+++++++++++++++++停止+++++++++++++++++++++\r\n"); |
| molberry | 0:04482d11976f | 539 | // run = STOP; |
| molberry | 0:04482d11976f | 540 | mode = READY; |
| molberry | 0:04482d11976f | 541 | // display(); // ディスプレイ表示 |
| molberry | 0:04482d11976f | 542 | } |
| molberry | 0:04482d11976f | 543 | |
| molberry | 0:04482d11976f | 544 | if( strstr(webdata, "RIGHT") != NULL ) { |
| molberry | 0:04482d11976f | 545 | pc.printf("+++++++++++++++++右折+++++++++++++++++++++\r\n"); |
| molberry | 0:04482d11976f | 546 | // run = RIGHT; |
| molberry | 0:04482d11976f | 547 | mode = READY; |
| molberry | 0:04482d11976f | 548 | // display(); // ディスプレイ表示 |
| molberry | 0:04482d11976f | 549 | } |
| molberry | 0:04482d11976f | 550 | |
| molberry | 0:04482d11976f | 551 | if( strstr(webdata, "BACK") != NULL ) { |
| molberry | 0:04482d11976f | 552 | pc.printf("+++++++++++++++++後進+++++++++++++++++++++\r\n"); |
| molberry | 0:04482d11976f | 553 | // run = BACK; |
| molberry | 0:04482d11976f | 554 | mode = READY; |
| molberry | 0:04482d11976f | 555 | // display(); // ディスプレイ表示 |
| molberry | 0:04482d11976f | 556 | } |
| molberry | 0:04482d11976f | 557 | pc.printf("+++++++++++++++++succed+++++++++++++++++++++"); |
| molberry | 0:04482d11976f | 558 | |
| molberry | 0:04482d11976f | 559 | if( strstr(webdata, "AVOIDANCE") != NULL ) { |
| molberry | 0:04482d11976f | 560 | pc.printf("+++++++++++++++++AVOIDANCE+++++++++++++++++++++"); |
| molberry | 0:04482d11976f | 561 | mode=AVOIDANCE; |
| molberry | 0:04482d11976f | 562 | // run = ADVANCE; |
| molberry | 0:04482d11976f | 563 | // display(); // ディスプレイ表示 |
| molberry | 0:04482d11976f | 564 | } |
| molberry | 2:4d51edb0a6c9 | 565 | if( strstr(webdata, "LINE_TRACE") != NULL ) { |
| molberry | 0:04482d11976f | 566 | pc.printf("+++++++++++++++++LINET RACE+++++++++++++++++++++"); |
| molberry | 0:04482d11976f | 567 | mode=LINE_TRACE; |
| molberry | 0:04482d11976f | 568 | // display(); // ディスプレイ表示 |
| molberry | 0:04482d11976f | 569 | } |
| molberry | 0:04482d11976f | 570 | if( strstr(webdata, "DEFAULT") != NULL ) {//プログラムなくね |
| molberry | 0:04482d11976f | 571 | pc.printf("+++++++++++++++++DEFAULT+++++++++++++++++++++"); |
| molberry | 0:04482d11976f | 572 | // run = STOP; |
| molberry | 0:04482d11976f | 573 | mode = READY; |
| molberry | 0:04482d11976f | 574 | // display(); // ディスプレイ表示 |
| molberry | 0:04482d11976f | 575 | |
| molberry | 0:04482d11976f | 576 | } |
| molberry | 3:2472790818a9 | 577 | if( strstr(webdata, "Normal") != NULL ) { |
| molberry | 4:52361cf7f1d8 | 578 | pc.printf("++++++++++++++++++Normal++++++++++++++++++++"); |
| molberry | 0:04482d11976f | 579 | mode = SPEED; // スピードモード |
| molberry | 0:04482d11976f | 580 | flag_sp = 0; |
| molberry | 0:04482d11976f | 581 | // display(); // ディスプレイ表示 |
| molberry | 0:04482d11976f | 582 | mode = beforeMode; // 現在のモードに前回のモードを設定 |
| molberry | 0:04482d11976f | 583 | } |
| molberry | 3:2472790818a9 | 584 | if( strstr(webdata, "Fast") != NULL ) { |
| molberry | 4:52361cf7f1d8 | 585 | pc.printf("++++++++++++++++++++Fast++++++++++++++++++"); |
| molberry | 0:04482d11976f | 586 | mode = SPEED; // スピードモード |
| molberry | 0:04482d11976f | 587 | flag_sp = 1; |
| molberry | 0:04482d11976f | 588 | // display(); // ディスプレイ表示 |
| molberry | 0:04482d11976f | 589 | mode = beforeMode; // 現在のモードに前回のモードを設定 |
| molberry | 0:04482d11976f | 590 | } |
| molberry | 3:2472790818a9 | 591 | if( strstr(webdata, "BeryFast") != NULL ) { |
| molberry | 4:52361cf7f1d8 | 592 | pc.printf("+++++++++++++++++++BERYFast+++++++++++++++++++"); |
| molberry | 0:04482d11976f | 593 | mode = SPEED; // スピードモード d |
| molberry | 0:04482d11976f | 594 | flag_sp = 2; |
| molberry | 0:04482d11976f | 595 | // display(); // ディスプレイ表示 |
| molberry | 0:04482d11976f | 596 | mode = beforeMode; // 現在のモードに前回のモードを設定 |
| molberry | 0:04482d11976f | 597 | } |
| molberry | 0:04482d11976f | 598 | sprintf(channel, "%d",linkID); |
| molberry | 0:04482d11976f | 599 | if (strstr(webdata, "GET") != NULL) { |
| molberry | 0:04482d11976f | 600 | servreq=1; |
| molberry | 0:04482d11976f | 601 | } |
| molberry | 0:04482d11976f | 602 | if (strstr(webdata, "POST") != NULL) { |
| molberry | 0:04482d11976f | 603 | servreq=1; |
| molberry | 0:04482d11976f | 604 | } |
| molberry | 0:04482d11976f | 605 | webcounter++; |
| molberry | 0:04482d11976f | 606 | sprintf(webcount, "%d",webcounter); |
| molberry | 0:04482d11976f | 607 | } else { |
| molberry | 0:04482d11976f | 608 | memset(webbuff, '\0', sizeof(webbuff)); |
| molberry | 0:04482d11976f | 609 | esp.attach(&callback); |
| molberry | 0:04482d11976f | 610 | weberror=1; |
| molberry | 0:04482d11976f | 611 | } |
| molberry | 0:04482d11976f | 612 | } |
| molberry | 0:04482d11976f | 613 | // Starts and restarts webserver if errors detected. |
| molberry | 0:04482d11976f | 614 | void startserver() |
| molberry | 0:04482d11976f | 615 | { |
| molberry | 0:04482d11976f | 616 | pc.printf("++++++++++ Resetting ESP ++++++++++\r\n"); |
| molberry | 0:04482d11976f | 617 | strcpy(cmdbuff,"AT+RST\r\n"); |
| molberry | 0:04482d11976f | 618 | timeout=8000; |
| molberry | 0:04482d11976f | 619 | getcount=1000; |
| molberry | 0:04482d11976f | 620 | SendCMD(); |
| molberry | 0:04482d11976f | 621 | getreply(); |
| molberry | 0:04482d11976f | 622 | pc.printf(replybuff); |
| molberry | 1:479303f0e488 | 623 | pc.printf("%d",ount); |
| molberry | 0:04482d11976f | 624 | if (strstr(replybuff, "OK") != NULL) { |
| molberry | 0:04482d11976f | 625 | pc.printf("\n++++++++++ Starting Server ++++++++++\r\n"); |
| molberry | 0:04482d11976f | 626 | strcpy(cmdbuff, "AT+CIPMUX=1\r\n"); // set multiple connections. |
| molberry | 0:04482d11976f | 627 | timeout=500; |
| molberry | 0:04482d11976f | 628 | getcount=20; |
| molberry | 0:04482d11976f | 629 | SendCMD(); |
| molberry | 0:04482d11976f | 630 | getreply(); |
| molberry | 0:04482d11976f | 631 | pc.printf(replybuff); |
| molberry | 0:04482d11976f | 632 | sprintf(cmdbuff,"AT+CIPSERVER=1,%d\r\n", port); |
| molberry | 0:04482d11976f | 633 | timeout=500; |
| molberry | 0:04482d11976f | 634 | getcount=20; |
| molberry | 0:04482d11976f | 635 | SendCMD(); |
| molberry | 0:04482d11976f | 636 | getreply(); |
| molberry | 0:04482d11976f | 637 | pc.printf(replybuff); |
| molberry | 0:04482d11976f | 638 | wait(1); |
| molberry | 0:04482d11976f | 639 | sprintf(cmdbuff,"AT+CIPSTO=%d\r\n",SERVtimeout); |
| molberry | 0:04482d11976f | 640 | timeout=500; |
| molberry | 0:04482d11976f | 641 | getcount=50; |
| molberry | 0:04482d11976f | 642 | SendCMD(); |
| molberry | 0:04482d11976f | 643 | getreply(); |
| molberry | 0:04482d11976f | 644 | pc.printf(replybuff); |
| molberry | 0:04482d11976f | 645 | wait(5); |
| molberry | 0:04482d11976f | 646 | pc.printf("\n Getting Server IP \r\n"); |
| molberry | 0:04482d11976f | 647 | strcpy(cmdbuff, "AT+CIFSR\r\n"); |
| molberry | 0:04482d11976f | 648 | timeout=2500; |
| molberry | 0:04482d11976f | 649 | getcount=200; |
| molberry | 0:04482d11976f | 650 | while(weberror==0) { |
| molberry | 0:04482d11976f | 651 | SendCMD(); |
| molberry | 0:04482d11976f | 652 | getreply(); |
| molberry | 0:04482d11976f | 653 | if (strstr(replybuff, "0.0.0.0") == NULL) { |
| molberry | 0:04482d11976f | 654 | weberror=1; // wait for valid IP |
| molberry | 0:04482d11976f | 655 | } |
| molberry | 0:04482d11976f | 656 | } |
| molberry | 0:04482d11976f | 657 | pc.printf("\n Enter WEB address (IP) found below in your browser \r\n\n"); |
| molberry | 0:04482d11976f | 658 | pc.printf("\n The MAC address is also shown below,if it is needed \r\n\n"); |
| molberry | 0:04482d11976f | 659 | replybuff[strlen(replybuff)-1] = '\0'; |
| molberry | 0:04482d11976f | 660 | //char* IP = replybuff + 5; |
| molberry | 0:04482d11976f | 661 | sprintf(webdata,"%s", replybuff); |
| molberry | 0:04482d11976f | 662 | pc.printf(webdata); |
| molberry | 0:04482d11976f | 663 | led2=1; |
| molberry | 0:04482d11976f | 664 | bufflen=200; |
| molberry | 0:04482d11976f | 665 | //bufflen=100; |
| molberry | 1:479303f0e488 | 666 | ount=0; |
| molberry | 0:04482d11976f | 667 | pc.printf("\n\n++++++++++ Ready ++++++++++\r\n\n"); |
| molberry | 0:04482d11976f | 668 | esp.attach(&callback); |
| molberry | 0:04482d11976f | 669 | } else { |
| molberry | 0:04482d11976f | 670 | pc.printf("\n++++++++++ ESP8266 error, check power/connections ++++++++++\r\n"); |
| molberry | 0:04482d11976f | 671 | led1=1; |
| molberry | 0:04482d11976f | 672 | led2=1; |
| molberry | 0:04482d11976f | 673 | led3=1; |
| molberry | 0:04482d11976f | 674 | led4=1; |
| molberry | 0:04482d11976f | 675 | while(1) { |
| molberry | 0:04482d11976f | 676 | led1=!led1; |
| molberry | 0:04482d11976f | 677 | led2=!led2; |
| molberry | 0:04482d11976f | 678 | led3=!led3; |
| molberry | 0:04482d11976f | 679 | led4=!led4; |
| molberry | 0:04482d11976f | 680 | wait(1); |
| molberry | 0:04482d11976f | 681 | } |
| molberry | 0:04482d11976f | 682 | } |
| molberry | 0:04482d11976f | 683 | t2.reset(); |
| molberry | 0:04482d11976f | 684 | t2.start(); |
| molberry | 0:04482d11976f | 685 | } |
| molberry | 0:04482d11976f | 686 | // ESP Command data send |
| molberry | 0:04482d11976f | 687 | void SendCMD() |
| molberry | 0:04482d11976f | 688 | { |
| molberry | 0:04482d11976f | 689 | esp.printf("%s", cmdbuff); |
| molberry | 0:04482d11976f | 690 | } |
| molberry | 0:04482d11976f | 691 | // Get Command and ESP status replies |
| molberry | 0:04482d11976f | 692 | void getreply() |
| molberry | 0:04482d11976f | 693 | { |
| molberry | 0:04482d11976f | 694 | memset(replybuff, '\0', sizeof(replybuff)); |
| molberry | 0:04482d11976f | 695 | t1.reset(); |
| molberry | 0:04482d11976f | 696 | t1.start(); |
| molberry | 0:04482d11976f | 697 | replycount=0; |
| molberry | 0:04482d11976f | 698 | while(t1.read_ms()< timeout && replycount < getcount) { |
| molberry | 0:04482d11976f | 699 | if(esp.readable()) { |
| molberry | 0:04482d11976f | 700 | replybuff[replycount] = esp.getc(); |
| molberry | 0:04482d11976f | 701 | replycount++; |
| molberry | 0:04482d11976f | 702 | } |
| molberry | 0:04482d11976f | 703 | } |
| molberry | 0:04482d11976f | 704 | t1.stop(); |
| molberry | 0:04482d11976f | 705 | } |