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