Updates for case changes

pull/46/head
shaun feakes 2018-02-18 07:53:18 -06:00
parent 3c10e8a769
commit 36d5439c5b
4 changed files with 21 additions and 4 deletions

View File

@ -20,6 +20,7 @@
#include <pthread.h> #include <pthread.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <ctype.h>
#include "aqualink.h" #include "aqualink.h"
#include "utils.h" #include "utils.h"
@ -722,6 +723,21 @@ bool waitForEitherMessage(struct aqualinkdata *aq_data, char* message1, char* me
return true; 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) bool waitForMessage(struct aqualinkdata *aq_data, char* message, int numMessageReceived)
{ {
//logMessage(LOG_DEBUG, "waitForMessage %s %d %d\n",message,numMessageReceived,cmd); //logMessage(LOG_DEBUG, "waitForMessage %s %d %d\n",message,numMessageReceived,cmd);
@ -744,7 +760,7 @@ bool waitForMessage(struct aqualinkdata *aq_data, char* message, int numMessageR
logMessage(LOG_DEBUG, "Programming mode: loop %d of %d looking for '%s' received message '%s'\n",i,numMessageReceived,message,aq_data->last_message); logMessage(LOG_DEBUG, "Programming mode: loop %d of %d looking for '%s' received message '%s'\n",i,numMessageReceived,message,aq_data->last_message);
if (message != NULL) { if (message != NULL) {
ptr = strstr(aq_data->last_message, msgS); ptr = stristr(aq_data->last_message, msgS);
if (ptr != NULL) { // match if (ptr != NULL) { // match
if (msgS == message) // match & don't care if first char if (msgS == message) // match & don't care if first char
break; break;

View File

@ -198,7 +198,7 @@ void processMessage(char *message)
//logMessage(LOG_DEBUG, "frz protect long message: %s", &message[28]); //logMessage(LOG_DEBUG, "frz protect long message: %s", &message[28]);
_aqualink_data.frz_protect_set_point = atoi(message+28); _aqualink_data.frz_protect_set_point = atoi(message+28);
} }
else if(strncmp(msg, MSG_AIR_TEMP, MSG_AIR_TEMP_LEN) == 0) { else if(strncasecmp(msg, MSG_AIR_TEMP, MSG_AIR_TEMP_LEN) == 0) {
_aqualink_data.air_temp = atoi(msg+8); _aqualink_data.air_temp = atoi(msg+8);
if (msg[strlen(msg)-1] == 'F') if (msg[strlen(msg)-1] == 'F')
_aqualink_data.temp_units = FAHRENHEIT; _aqualink_data.temp_units = FAHRENHEIT;
@ -207,10 +207,10 @@ void processMessage(char *message)
else else
_aqualink_data.temp_units = UNKNOWN; _aqualink_data.temp_units = UNKNOWN;
} }
else if(strncmp(message, MSG_POOL_TEMP, MSG_POOL_TEMP_LEN) == 0) { else if(strncasecmp(message, MSG_POOL_TEMP, MSG_POOL_TEMP_LEN) == 0) {
_aqualink_data.pool_temp = atoi(message+9); _aqualink_data.pool_temp = atoi(message+9);
} }
else if(strncmp(message, MSG_SPA_TEMP, MSG_SPA_TEMP_LEN) == 0) { else if(strncasecmp(message, MSG_SPA_TEMP, MSG_SPA_TEMP_LEN) == 0) {
_aqualink_data.spa_temp = atoi(message+8); _aqualink_data.spa_temp = atoi(message+8);
} }
else if(msg[2] == '/' && msg[5] == '/' && msg[8] == ' ') {// date in format '08/29/16 MON' else if(msg[2] == '/' && msg[5] == '/' && msg[8] == ' ') {// date in format '08/29/16 MON'

View File

@ -18,6 +18,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdbool.h>
#include "aqualink.h" #include "aqualink.h"
#include "config.h" #include "config.h"

Binary file not shown.