|
|
|
@ -277,34 +277,35 @@ void loop() {
|
|
|
|
|
|
|
|
|
|
while (getSn_SR(testSocket) == SOCK_ESTABLISHED) {
|
|
|
|
|
while (getSn_RX_RSR(testSocket) > 0) {
|
|
|
|
|
theByte = readByte();
|
|
|
|
|
Serial.print(theByte, BYTE);
|
|
|
|
|
if ((state == STATE_G) && (theByte == 'G')) {
|
|
|
|
|
state = STATE_E;
|
|
|
|
|
} else if ((state == STATE_E) && (theByte == 'E')) {
|
|
|
|
|
state = STATE_T;
|
|
|
|
|
} else if ((state == STATE_T) && (theByte == 'T')) {
|
|
|
|
|
state = STATE_SPACE;
|
|
|
|
|
} else if ((state == STATE_SPACE) && (theByte == ' ')) {
|
|
|
|
|
state = STATE_SLASH;
|
|
|
|
|
} else if ((state == STATE_SLASH) && (theByte == '/')) {
|
|
|
|
|
state = STATE_READ;
|
|
|
|
|
} else if ((state == STATE_READ) && (theByte == '0')) {
|
|
|
|
|
|
|
|
|
|
if (state == STATE_G) {
|
|
|
|
|
if (readMatch("GET /")) {
|
|
|
|
|
state = STATE_READ;
|
|
|
|
|
} else {
|
|
|
|
|
state = STATE_ERR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (state == STATE_READ) {
|
|
|
|
|
|
|
|
|
|
theByte = readByte();
|
|
|
|
|
|
|
|
|
|
if (theByte == '0') {
|
|
|
|
|
digitalWrite(PIN_LED, LOW);
|
|
|
|
|
ledState = 0;
|
|
|
|
|
//state = STATE_END;
|
|
|
|
|
delay(100);
|
|
|
|
|
} else if ((state == STATE_READ) && (theByte == '1')) {
|
|
|
|
|
delay(100);
|
|
|
|
|
} else if (theByte == '1') {
|
|
|
|
|
digitalWrite(PIN_LED, HIGH);
|
|
|
|
|
ledState = 1;
|
|
|
|
|
//state = STATE_END;
|
|
|
|
|
delay(100);
|
|
|
|
|
} else if (state == STATE_READ) {
|
|
|
|
|
} else {
|
|
|
|
|
// It's not a valid byte.
|
|
|
|
|
state = STATE_END;
|
|
|
|
|
} else {
|
|
|
|
|
state = STATE_ERR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
state = STATE_ERR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((state == STATE_ERR) || (state == STATE_END)) {
|
|
|
|
|
Serial.println("");
|
|
|
|
|