|
|
|
@ -201,12 +201,27 @@ uint8_t readByte() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int readMatch(char *stringToMatch) {
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
Routine to read and match bytes received.
|
|
|
|
|
|
|
|
|
|
(Essentially strcmp replacement without requiring a large receive buffer.)
|
|
|
|
|
|
|
|
|
|
NOTE: Failed matches drop all bytes read so far. (i.e. you can't check for
|
|
|
|
|
a bunch of possible matches from the same starting position).
|
|
|
|
|
TODO: Fix this.
|
|
|
|
|
|
|
|
|
|
Note: This blocks if there isn't enough data in the rx buffer.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
while (getSn_RX_RSR(testSocket) < strlen(stringToMatch)) {
|
|
|
|
|
// block
|
|
|
|
|
// TODO: Return error or wait or "too short"?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: Do fancy string-matching techniques to avoid reading the whole string
|
|
|
|
|
// on non-matches. :-)
|
|
|
|
|
for (int currCharIdx = 0; currCharIdx < strlen(stringToMatch); currCharIdx++) {
|
|
|
|
|
if (readByte() != stringToMatch[currCharIdx]) {
|
|
|
|
|
return 0;
|
|
|
|
|