Use new 'readMatch' routine to match start of the request to simplify state machine.

git-svn-id: svn+ssh://oldsvn/home/mlalondesvn/svn/cral@80 3ee9b42a-b53c-0410-a25e-f0b6218d5d5b
master
follower 17 years ago
parent e732cd1a42
commit 3d3d14263a

@ -277,31 +277,32 @@ 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 == '/')) {
if (state == STATE_G) {
if (readMatch("GET /")) {
state = STATE_READ;
} else if ((state == STATE_READ) && (theByte == '0')) {
} 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')) {
} 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;
}

Loading…
Cancel
Save