mirror of https://github.com/sfeakes/AqualinkD.git
String comparison changes
parent
36d5439c5b
commit
61ef0872b1
|
@ -20,7 +20,7 @@
|
|||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
#include "aqualink.h"
|
||||
#include "utils.h"
|
||||
|
@ -723,20 +723,7 @@ bool waitForEitherMessage(struct aqualinkdata *aq_data, char* message1, char* me
|
|||
return true;
|
||||
}
|
||||
|
||||
char* stristr(const char* haystack, const char* needle) {
|
||||
do {
|
||||
const char* h = haystack;
|
||||
const char* n = needle;
|
||||
while (tolower((unsigned char) *h) == tolower((unsigned char ) *n) && *n) {
|
||||
h++;
|
||||
n++;
|
||||
}
|
||||
if (*n == 0) {
|
||||
return (char *) haystack;
|
||||
}
|
||||
} while (*haystack++);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool waitForMessage(struct aqualinkdata *aq_data, char* message, int numMessageReceived)
|
||||
{
|
||||
|
|
10
aqualinkd.c
10
aqualinkd.c
|
@ -183,18 +183,18 @@ void processMessage(char *message)
|
|||
// Check long messages in this if/elseif block first, as some messages are similar.
|
||||
// ie "POOL TEMP" and "POOL TEMP IS SET TO" so want correct match first.
|
||||
//
|
||||
if(strstr(message, LNG_MSG_BATTERY_LOW) != NULL) {
|
||||
if(stristr(message, LNG_MSG_BATTERY_LOW) != NULL) {
|
||||
_aqualink_data.battery = LOW;
|
||||
}
|
||||
else if(strstr(message, LNG_MSG_POOL_TEMP_SET) != NULL) {
|
||||
else if(stristr(message, LNG_MSG_POOL_TEMP_SET) != NULL) {
|
||||
//logMessage(LOG_DEBUG, "pool htr long message: %s", &message[20]);
|
||||
_aqualink_data.pool_htr_set_point = atoi(message+20);
|
||||
}
|
||||
else if(strstr(message, LNG_MSG_SPA_TEMP_SET) != NULL) {
|
||||
else if(stristr(message, LNG_MSG_SPA_TEMP_SET) != NULL) {
|
||||
//logMessage(LOG_DEBUG, "spa htr long message: %s", &message[19]);
|
||||
_aqualink_data.spa_htr_set_point = atoi(message+19);
|
||||
}
|
||||
else if(strstr(message, LNG_MSG_FREEZE_PROTECTION_SET) != NULL) {
|
||||
else if(stristr(message, LNG_MSG_FREEZE_PROTECTION_SET) != NULL) {
|
||||
//logMessage(LOG_DEBUG, "frz protect long message: %s", &message[28]);
|
||||
_aqualink_data.frz_protect_set_point = atoi(message+28);
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ void processMessage(char *message)
|
|||
_initWithRS = true;
|
||||
}
|
||||
}
|
||||
else if(strstr(msg, " TURNS ON") != NULL) {
|
||||
else if(stristr(msg, " TURNS ON") != NULL) {
|
||||
logMessage(LOG_NOTICE, "Program data '%s'\n",msg);
|
||||
}
|
||||
else {
|
||||
|
|
Binary file not shown.
15
utils.c
15
utils.c
|
@ -420,3 +420,18 @@ void delay (unsigned int howLong) // Microseconds (1000000 = 1 second)
|
|||
|
||||
nanosleep (&sleeper, &dummy) ;
|
||||
}
|
||||
|
||||
char* stristr(const char* haystack, const char* needle) {
|
||||
do {
|
||||
const char* h = haystack;
|
||||
const char* n = needle;
|
||||
while (tolower((unsigned char) *h) == tolower((unsigned char ) *n) && *n) {
|
||||
h++;
|
||||
n++;
|
||||
}
|
||||
if (*n == 0) {
|
||||
return (char *) haystack;
|
||||
}
|
||||
} while (*haystack++);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue