diff --git a/Makefile b/Makefile index b6b5a14..3606bc5 100755 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ AQ_PDA = true AQ_ONETOUCH = true AQ_IAQTOUCH = true AQ_MANAGER =true + #AQ_RS_EXTRA_OPTS = false #AQ_CONTAINER = false // this is for compiling for containers #AQ_MEMCMP = true // Not implimented correctly yet. diff --git a/a.out b/a.out new file mode 100755 index 0000000..80722d4 Binary files /dev/null and b/a.out differ diff --git a/aq_programmer.c b/aq_programmer.c index 191dcab..5e12322 100644 --- a/aq_programmer.c +++ b/aq_programmer.c @@ -756,8 +756,11 @@ void _aq_programmer(program_type r_type, char *args, struct aqualinkdata *aq_dat type = AQ_SET_IAQTOUCH_DEVICE_ON_OFF; } break; + // This isn;t going to work outside of PDA mode, if the labels are incorrect. case AQ_SET_LIGHTCOLOR_MODE: - type = AQ_SET_IAQTOUCH_LIGHTCOLOR_MODE; + if (isPDA_IAQT) { + type = AQ_SET_IAQTOUCH_LIGHTCOLOR_MODE; + } break; default: type = r_type; @@ -1556,7 +1559,7 @@ void *set_aqualink_light_colormode( void *ptr ) use_current_mode = true; LOG(PROG_LOG, LOG_INFO, "Light Programming #: %d, on button: %s, color light type: %d, using current mode\n", val, button->label, typ); } else { - mode_name = light_mode_name(typ, val-1); + mode_name = light_mode_name(typ, val-1, ALLBUTTON); use_current_mode = false; if (mode_name == NULL) { LOG(PROG_LOG, LOG_ERR, "Light Programming #: %d, on button: %s, color light type: %d, couldn't find mode name '%s'\n", val, button->label, typ, mode_name); diff --git a/aqualink.h b/aqualink.h index ac6ec1d..6ea9466 100644 --- a/aqualink.h +++ b/aqualink.h @@ -205,6 +205,7 @@ struct aqualinkdata char time[AQ_MSGLEN]; char last_message[AQ_MSGLONGLEN+1]; // Last ascii message from panel - allbutton (or PDA) protocol char last_display_message[AQ_MSGLONGLEN+1]; // Last message to display in web UI + bool is_display_message_programming; aqled aqualinkleds[TOTAL_LEDS]; aqkey aqbuttons[TOTAL_BUTTONS]; unsigned short total_buttons; diff --git a/aqualinkd.c b/aqualinkd.c index cdcace6..13e5326 100644 --- a/aqualinkd.c +++ b/aqualinkd.c @@ -1516,6 +1516,7 @@ void main_loop() int blank_read_reconnect = MAX_ZERO_READ_BEFORE_RECONNECT_BLOCKING; // Will get reset if non blocking sprintf(_aqualink_data.last_display_message, "%s", "Connecting to Control Panel"); + _aqualink_data.is_display_message_programming = false; //_aqualink_data.simulate_panel = false; _aqualink_data.active_thread.thread_id = 0; _aqualink_data.air_temp = TEMP_UNKNOWN; diff --git a/color_lights.c b/color_lights.c index e43245f..4f8ef5f 100644 --- a/color_lights.c +++ b/color_lights.c @@ -6,6 +6,7 @@ //#define COLOR_LIGHTS_C_ #include "color_lights.h" + /****** This list MUST be in order of clight_type enum *******/ const char *_color_light_options[NUMBER_LIGHT_COLOR_TYPES][LIGHT_COLOR_OPTIONS] = { @@ -52,7 +53,7 @@ const char *_color_light_options[NUMBER_LIGHT_COLOR_TYPES][LIGHT_COLOR_OPTIONS] "Voodoo Lounge", "Deep Blue Sea", //"Royal Blue", - "Afternoon Skies", + "Afternoon Skies", // 'Afternoon Sky' on allbutton, Skies on iaqtouch //"Aqua Green", "Emerald", "Sangria", @@ -91,8 +92,15 @@ const char *_color_light_options[NUMBER_LIGHT_COLOR_TYPES][LIGHT_COLOR_OPTIONS] }; -const char *light_mode_name(clight_type type, int index) +const char *light_mode_name(clight_type type, int index, emulation_type protocol) { + // Rename any modes depending on emulation type + if (protocol == ALLBUTTON) { + if (strcmp(_color_light_options[type][index],"Afternoon Skies") == 0) { + return "Afternoon Sky"; + } + } + return _color_light_options[type][index]; } diff --git a/color_lights.h b/color_lights.h index f96981b..11bc441 100644 --- a/color_lights.h +++ b/color_lights.h @@ -3,6 +3,7 @@ #define COLOR_LIGHTS_H_ #include "aqualink.h" +#include "aq_programmer.h" #define LIGHT_COLOR_NAME 16 #define LIGHT_COLOR_OPTIONS 17 @@ -19,7 +20,8 @@ typedef enum clight_type { LC_INTELLIB } clight_type; */ -const char *light_mode_name(clight_type type, int index); +//const char *light_mode_name(clight_type type, int index); +const char *light_mode_name(clight_type type, int index, emulation_type protocol); int build_color_lights_js(struct aqualinkdata *aqdata, char* buffer, int size); diff --git a/iaqtouch.c b/iaqtouch.c index 4af519f..97260cc 100644 --- a/iaqtouch.c +++ b/iaqtouch.c @@ -718,6 +718,7 @@ bool process_iaqtouch_packet(unsigned char *packet, int length, struct aqualinkd // Reset and messages on new page aq_data->last_display_message[0] = ' '; aq_data->last_display_message[1] = '\0'; + aq_data->is_display_message_programming = false; LOG(IAQT_LOG,LOG_DEBUG, "Turning IAQ SEND off\n"); set_iaq_cansend(false); _currentPageLoading = packet[PKT_IAQT_PAGTYPE]; @@ -789,11 +790,25 @@ bool process_iaqtouch_packet(unsigned char *packet, int length, struct aqualinkd } } } else if (isPDA_PANEL && packet[PKT_CMD] == CMD_IAQ_MSG_LONG) { + char *sp; // Set disply message if PDA panel memset(message, 0, AQ_MSGLONGLEN + 1); rsm_strncpy(message, packet + 6, AQ_MSGLONGLEN, length-9); LOG(IAQT_LOG,LOG_NOTICE, "Popup message '%s'\n",message); + + // Change this message, since you can't press OK. 'Light will turn off in 5 seconds. To change colors press Ok now.' + if ((sp = rsm_strncasestr(message, "To change colors press Ok now", strlen(message))) != NULL) + { + *sp = '\0'; + } + strcpy(aq_data->last_display_message, message); // Also display the message on web UI + + if (in_programming_mode(aq_data)) { + aq_data->is_display_message_programming = true; + } else { + aq_data->is_display_message_programming = false; + } /* for(int i=0; ilabel, typ); } else { - mode_name = light_mode_name(typ, val-1); + mode_name = light_mode_name(typ, val-1, IAQTOUCH); use_current_mode = false; if (mode_name == NULL) { LOG(IAQT_LOG, LOG_ERR, "Light Programming #: %d, button: %s, color light type: %d, couldn't find mode name '%s'\n", val, key->label, typ, mode_name); @@ -633,6 +633,7 @@ void *set_aqualink_iaqtouch_light_colormode( void *ptr ) if (use_current_mode) { // Their is no message for this, so give one. sprintf(aq_data->last_display_message, "Light will turn on in 5 seconds"); + aq_data->is_display_message_programming = true; aq_data->updated = true; } // Wait for next page maybe? @@ -756,7 +757,9 @@ void *set_aqualink_iaqtouch_pump_rpm( void *ptr ) //send_aqt_cmd(0x80); // Go to status page on startup to read devices - goto_iaqt_page(IAQ_PAGE_STATUS, aq_data); + // This is too soon + //goto_iaqt_page(IAQ_PAGE_STATUS, aq_data); + //waitfor_iaqt_nextPage(aq_data); f_end: goto_iaqt_page(IAQ_PAGE_HOME, aq_data); diff --git a/json_messages.c b/json_messages.c index 5d0940a..a6679fe 100644 --- a/json_messages.c +++ b/json_messages.c @@ -98,6 +98,11 @@ const char* _getStatus(struct aqualinkdata *aqdata, const char *blankmsg) return programtypeDisplayName(aqdata->active_thread.ptype); } */ + if (aqdata->active_thread.thread_id != 0) { + if (!aqdata->is_display_message_programming || rsm_isempy(aqdata->last_display_message,strlen(aqdata->last_display_message))){ + return programtypeDisplayName(aqdata->active_thread.ptype); + } + } //if (aqdata->last_message != NULL && stristr(aqdata->last_message, "SERVICE") != NULL ) { if (aqdata->service_mode_state == ON) { diff --git a/release/aqualinkd b/release/aqualinkd deleted file mode 100755 index f6f840c..0000000 Binary files a/release/aqualinkd and /dev/null differ diff --git a/release/serial_logger b/release/serial_logger index c0b4b1d..985c0db 100755 Binary files a/release/serial_logger and b/release/serial_logger differ diff --git a/rs_msg_utils.c b/rs_msg_utils.c index 8263bf5..818d82f 100644 --- a/rs_msg_utils.c +++ b/rs_msg_utils.c @@ -147,6 +147,18 @@ char *rsm_charafterstr(const char *haystack, const char *needle, int length) return ++sp; } +/* + Check if string has printable chars and is not empty +*/ +bool rsm_isempy(const char *src, int length) +{ + int i; + for(i=0; i < length; i++) { + if (src[i] > 32 && src[i] < 127) // 32 is space + return true; + } + return false; +} /* Can probably replace this with rsm_strncasestr in all code. */ diff --git a/rs_msg_utils.h b/rs_msg_utils.h index 34284b4..f5481a9 100644 --- a/rs_msg_utils.h +++ b/rs_msg_utils.h @@ -8,6 +8,7 @@ int rsm_get_boardcpu(char *dest, int dest_len, const char *src, int src_len); char *rsm_charafterstr(const char *haystack, const char *needle, int length); +bool rsm_isempy(const char *src, int length); char *rsm_strstr(const char *haystack, const char *needle); //char *rsm_strnstr(const char *haystack, const char *needle, int length); char *rsm_strnstr(const char *haystack, const char *needle, size_t slen); diff --git a/util.c b/util.c deleted file mode 100644 index e69de29..0000000 diff --git a/web/config.js b/web/config.js index 6d3417a..ac41723 100644 --- a/web/config.js +++ b/web/config.js @@ -35,8 +35,8 @@ "Spa_Water", "Freeze_Protect", "CHEM/pH", - "CHEM/ORP" - //"Solar_Heater", + "CHEM/ORP", + "Solar_Heater", ]; // This get's picked up by dynamic_config.js and used as mode 0