Merge pull request #9 from mysensors/ethernet-improvement-feature
Added a-lurkers proposed changes to speed up message porcessing.
This commit is contained in:
@@ -127,34 +127,39 @@ void processEthernetMessages()
|
|||||||
// bytes available to read via the client object
|
// bytes available to read via the client object
|
||||||
EthernetClient client = server.available();
|
EthernetClient client = server.available();
|
||||||
|
|
||||||
if (client)
|
if (client)
|
||||||
{
|
{
|
||||||
// read the bytes incoming from the client
|
// if got 1 or more bytes
|
||||||
char inChar = client.read();
|
if (client.available())
|
||||||
|
{
|
||||||
|
// read the bytes incoming from the client
|
||||||
|
char inChar = client.read();
|
||||||
|
|
||||||
// echo the bytes to the serial port
|
if (inputPos<MAX_RECEIVE_LENGTH-1) {
|
||||||
Serial.print(inChar);
|
// if newline then command is complete
|
||||||
|
if (inChar == '\n')
|
||||||
|
{ // a command was issued by the client
|
||||||
|
// we will now try to send it to the actuator
|
||||||
|
inputString[inputPos] = 0;
|
||||||
|
|
||||||
if (inputPos<MAX_RECEIVE_LENGTH-1) {
|
// echo the string to the serial port
|
||||||
// if newline then command is complete
|
Serial.print(inputString);
|
||||||
if (inChar == '\n')
|
|
||||||
{ // a command was issued by the client
|
|
||||||
// we will now try to send it to the actuator
|
|
||||||
inputString[inputPos] = 0;
|
|
||||||
gw.parseAndSend(inputString);
|
|
||||||
|
|
||||||
// clear the string:
|
gw.parseAndSend(inputString);
|
||||||
|
|
||||||
|
// clear the string:
|
||||||
|
inputPos = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // add it to the inputString:
|
||||||
|
inputString[inputPos] = inChar;
|
||||||
|
inputPos++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Incoming message too long. Throw away
|
||||||
inputPos = 0;
|
inputPos = 0;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{ // add it to the inputString:
|
|
||||||
inputString[inputPos] = inChar;
|
|
||||||
inputPos++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Incoming message too long. Throw away
|
|
||||||
inputPos = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user