diff --git a/aq_programmer.c b/aq_programmer.c index 6ad03d5..7446577 100644 --- a/aq_programmer.c +++ b/aq_programmer.c @@ -1033,6 +1033,7 @@ void _aq_programmer(program_type r_type, char *args, struct aqualinkdata *aq_dat LOG(PROG_LOG, LOG_ERR, "could not create thread\n"); return; } + break; #endif #ifdef AQ_PDA case AQ_PDA_INIT: @@ -1376,10 +1377,9 @@ void *set_aqualink_SWG( void *ptr ) #ifdef AQ_PDA if (isPDA_PANEL) { - if (set_PDA_aqualink_SWG_setpoint(aq_data, val)) - setSWGpercent(aq_data, val); // Don't use chageSWGpercent as we are in programming mode. - cleanAndTerminateThread(threadCtrl); - return ptr; + set_PDA_aqualink_SWG_setpoint(aq_data, val); + cleanAndTerminateThread(threadCtrl); + return ptr; } #endif diff --git a/aqualinkd.c b/aqualinkd.c index 12b4367..61657c4 100644 --- a/aqualinkd.c +++ b/aqualinkd.c @@ -999,7 +999,7 @@ void action_delayed_request() { //LOG(AQUA_LOG,LOG_NOTICE, "SWG BOST to %d\n", _aqualink_data.unactioned.value); //if (_aqualink_data.ar_swg_status == SWG_STATUS_OFF) { - if (_aqualink_data.swg_led_state == OFF) { + if ((_aqualink_data.swg_led_state == OFF) && (_aqualink_data.boost == false)) { LOG(AQUA_LOG,LOG_ERR, "SWG is off, can't Boost pool\n"); } else if (_aqualink_data.unactioned.value == _aqualink_data.boost ) { LOG(AQUA_LOG,LOG_ERR, "Request to turn Boost %s ignored, Boost is already %s\n",_aqualink_data.unactioned.value?"On":"Off", _aqualink_data.boost?"On":"Off"); diff --git a/devices_jandy.c b/devices_jandy.c index 8833915..7fce4e3 100644 --- a/devices_jandy.c +++ b/devices_jandy.c @@ -109,6 +109,13 @@ bool processPacketToSWG(unsigned char *packet, int packet_length, struct aqualin static int swg_zero_cnt = 0; bool changedAnything = false; + if (getLogLevel(DJAN_LOG) == LOG_DEBUG) { + char buff[1024]; + beautifyPacket(buff, packet, packet_length, false); + LOG(DJAN_LOG,LOG_DEBUG, "%s", buff); + } + + // Only read message from controller to SWG to set SWG Percent if we are not programming, as we might be changing this if (packet[3] == CMD_PERCENT && aqdata->active_thread.thread_id == 0 && packet[4] != 0xFF) { // In service or timeout mode SWG set % message is very strange. AR %% | HEX: 0x10|0x02|0x50|0x11|0xff|0x72|0x10|0x03| @@ -154,6 +161,12 @@ bool processPacketFromSWG(unsigned char *packet, int packet_length, struct aqual bool changedAnything = false; _swg_noreply_cnt = 0; + if (getLogLevel(DJAN_LOG) == LOG_DEBUG) { + char buff[1024]; + beautifyPacket(buff, packet, packet_length, true); + LOG(DJAN_LOG,LOG_DEBUG, "%s", buff); + } + if (packet[PKT_CMD] == CMD_PPM) { //aqdata->ar_swg_device_status = packet[5]; setSWGdeviceStatus(aqdata, JANDY_DEVICE, packet[5]); @@ -278,6 +291,7 @@ bool setSWGboost(struct aqualinkdata *aqdata, bool on) { } else { aqdata->boost = true; aqdata->swg_percent = 101; + aqdata->swg_led_state = ON; } return true; diff --git a/pda.c b/pda.c index b315d4d..ed410c0 100644 --- a/pda.c +++ b/pda.c @@ -134,20 +134,30 @@ void set_pda_led(struct aqualinkled *led, char state) void equiptment_update_cycle(int eqID) { // If you have a -1, it's a reset to clear / update information. int i; + // :TODO: need to add freeze protect and boost support to bitmask, perhaps sercive_mode + // TOTAL_BUTTONS is 20 so bits 21-31 should be available static uint32_t update_equiptment_bitmask = 0; if (eqID == -1) { - LOG(PDA_LOG,LOG_DEBUG, "Start new equiptment cycle\n"); + LOG(PDA_LOG,LOG_DEBUG, "Start new equipment cycle\n"); for (i=0; i < _aqualink_data->total_buttons - 2 ; i++) { // total_buttons - 2 because we don't get heaters in this cycle if ((update_equiptment_bitmask & (1 << (i+1))) != (1 << (i+1))) { if (_aqualink_data->aqbuttons[i].led->state != OFF) { _aqualink_data->aqbuttons[i].led->state = OFF; _aqualink_data->updated = true; - LOG(PDA_LOG,LOG_DEBUG, "Turn off equiptment id %d %s not seen in last cycle\n", i, _aqualink_data->aqbuttons[i].name); + LOG(PDA_LOG,LOG_DEBUG, "Turn off equipment id %d %s not seen in last cycle\n", i, _aqualink_data->aqbuttons[i].name); } } } + // :TODO: This needs to go into the equipment status processing to turn FP off + // if (_aqualink_data->frz_protect_state == ON) { + // _aqualink_data->frz_protect_state = ENABLE; + // } + // :TODO: This needs to go into the equipment status processing to turn boost off + // if (_aqualink_data->boost) { + // setSWGboost(_aqualink_data, false); + // } update_equiptment_bitmask = 0; } else { update_equiptment_bitmask |= (1 << (eqID+1)); @@ -235,14 +245,13 @@ void process_pda_packet_msg_long_equipment_control(const char *msg) { LOG(PDA_LOG,LOG_DEBUG, "*** Found EQ CTL Status for %s = '%.*s'\n", _aqualink_data->aqbuttons[i].label, AQ_MSGLEN, msg); set_pda_led(_aqualink_data->aqbuttons[i].led, msg[AQ_MSGLEN - 1]); + // Force SWG off if pump is off. + if ((i==0) && (_aqualink_data->aqbuttons[0].led->state == OFF )) { + setSWGoff(_aqualink_data); + } } } - // Force SWG off if pump is off. - if (_aqualink_data->aqbuttons[0].led->state == OFF ) - setSWGoff(_aqualink_data); - //_aqualink_data->ar_swg_status = SWG_STATUS_OFF; - // NSF I think we need to check TEMP1 and TEMP2 and set Pool HEater and Spa heater directly, to support single device. if (isSINGLE_DEV_PANEL){ if (strcasecmp(stripwhitespace(labelBuff), "TEMP1") == 0) @@ -387,29 +396,43 @@ void process_pda_packet_msg_long_freeze_protect(const char *msg) } } -void process_pda_packet_msg_long_SWG(const char *msg) +void process_pda_packet_msg_long_SWG(int index, const char *msg) { - //PDA Line 0 = SET AquaPure - //PDA Line 1 = - //PDA Line 2 = - //PDA Line 3 = SET POOL TO: 45% - //PDA Line 4 = SET SPA TO: 0% - - // If spa is on, read SWG for spa, if not set SWG for pool - if (_aqualink_data->aqbuttons[SPA_INDEX].led->state != OFF) { - if (strncasecmp(msg, "SET SPA TO:", 11) == 0) - { - //_aqualink_data->swg_percent = atoi(msg + 13); - setSWGpercent(_aqualink_data, atoi(msg + 13)); + char *ptr = NULL; + // Single Setpoint + // PDA Line 0 = SET AquaPure + // PDA Line 1 = + // PDA Line 2 = + // PDA Line 3 = SET TO 100% + + // PDA Line 0 = SET AquaPure + // PDA Line 1 = + // PDA Line 2 = + // PDA Line 3 = SET TO: 20% + + // Dual Setpoint + // PDA Line 0 = SET AquaPure + // PDA Line 1 = + // PDA Line 2 = + // PDA Line 3 = SET POOL TO: 45% + // PDA Line 4 = SET SPA TO: 0% + + // Note: use pda_m_line(index) instead of msg because it is NULL terminated + if ((ptr = strcasestr(pda_m_line(index), "SET TO")) != NULL) { + setSWGpercent(_aqualink_data, atoi(ptr+7)); + LOG(PDA_LOG,LOG_DEBUG, "swg_percent = %d\n", _aqualink_data->swg_percent); + } else if ((ptr = strcasestr(pda_m_line(index), "SET SPA TO")) != NULL) { + if (_aqualink_data->aqbuttons[SPA_INDEX].led->state != OFF) { + setSWGpercent(_aqualink_data, atoi(ptr+11)); LOG(PDA_LOG,LOG_DEBUG, "SPA swg_percent = %d\n", _aqualink_data->swg_percent); } - } else { - if (strncasecmp(msg, "SET POOL TO:", 12) == 0) - { - //_aqualink_data->swg_percent = atoi(msg + 13); - setSWGpercent(_aqualink_data, atoi(msg + 13)); + } else if ((ptr = strcasestr(pda_m_line(index), "SET POOL TO")) != NULL) { + if (_aqualink_data->aqbuttons[SPA_INDEX].led->state == OFF) { + setSWGpercent(_aqualink_data, atoi(ptr + 12)); LOG(PDA_LOG,LOG_DEBUG, "POOL swg_percent = %d\n", _aqualink_data->swg_percent); - } + } + } else if (index == 3) { + LOG(PDA_LOG,LOG_ERR, "process msg SWG POOL idx %d unmatched %s\n", index, pda_m_line(index)); } } @@ -604,6 +627,12 @@ void process_pda_packet_msg_long_equiptment_status(const char *msg_line, int lin // FILTER PUMP // CLEANER // + // EQUIPMENT STATUS + // + // BOOST + // 23:59 REMAIN + // SALT 25500 PPM + // FILTER PUMP // VSP Pumps are not read here, since they are over multiple lines. @@ -619,6 +648,14 @@ void process_pda_packet_msg_long_equiptment_status(const char *msg_line, int lin _aqualink_data->frz_protect_state = ON; LOG(PDA_LOG,LOG_DEBUG, "Freeze Protect is on\n"); } + else if ((index = rsm_strncasestr(msg, "BOOST", AQ_MSGLEN)) != NULL) + { + setSWGboost(_aqualink_data, true); + } + else if ((_aqualink_data->boost) && ((index = rsm_strncasestr(msg, "REMAIN", AQ_MSGLEN)) != NULL)) + { + snprintf(_aqualink_data->boost_msg, sizeof(_aqualink_data->boost_msg), "%s", msg+2); + } else if ((index = rsm_strncasestr(msg, MSG_SWG_PCT, AQ_MSGLEN)) != NULL) { changeSWGpercent(_aqualink_data, atoi(index + strlen(MSG_SWG_PCT))); @@ -835,7 +872,7 @@ bool process_pda_packet(unsigned char *packet, int length) process_pda_packet_msg_long_freeze_protect(msg); break; case PM_AQUAPURE: - process_pda_packet_msg_long_SWG(msg); + process_pda_packet_msg_long_SWG(index, msg); break; case PM_AUX_LABEL_DEVICE: process_pda_packet_msg_long_level_aux_device(msg); diff --git a/pda_aq_programmer.c b/pda_aq_programmer.c index 251a981..da1ddcf 100644 --- a/pda_aq_programmer.c +++ b/pda_aq_programmer.c @@ -203,6 +203,7 @@ bool find_pda_menu_item(struct aqualinkdata *aq_data, char *menuText, int charli int max_index = -1; int index = -1; int cnt = 0; + bool bLookingForBoost = false; LOG(PDA_LOG,LOG_DEBUG, "PDA Device programmer looking for menu text '%s' (limit=%d)\n",menuText,charlimit); @@ -242,51 +243,83 @@ bool find_pda_menu_item(struct aqualinkdata *aq_data, char *menuText, int charli } if (strncasecmp(pda_m_line(9)," ^^ MORE", 10) != 0) { - if (pda_m_type() == PM_HOME) { - min_index = 4; - max_index = 9; - } else if (pda_m_type() == PM_EQUIPTMENT_CONTROL) { - min_index = 1; - max_index = 9; - } else if (pda_m_type() == PM_MAIN) { - // Line 0 = MAIN MENU - // Line 1 = - // Line 2 = HELP > - // Line 3 = PROGRAM > - // Line 4 = SET TEMP > - // Line 5 = SET TIME > - // Line 6 = PDA OPTIONS > - // Line 7 = SYSTEM SETUP > - // Line 8 = - // Line 9 = - - // Line 0 = MAIN MENU - // Line 1 = HELP > - // Line 2 = PROGRAM > - // Line 3 = SET TEMP > - // Line 4 = SET TIME > - // Line 5 = SET AquaPure > - // Line 6 = PDA OPTIONS > - // Line 7 = SYSTEM SETUP > - // Line 8 = - // Line 9 = BOOST - - // "SET AquaPure" and "BOOST" are only present when filter pump is running - if (strncasecmp(pda_m_line(9)," BOOST ", 16) == 0) { - min_index = 1; - max_index = 8; // to account for 8 missing - if (index == 9) { // looking for boost - index = 8; - } - } else { - min_index = 2; - max_index = 7; + if (pda_m_type() == PM_HOME) { + min_index = 4; + max_index = 9; + } else if (pda_m_type() == PM_EQUIPTMENT_CONTROL) { + min_index = 1; + max_index = 9; + } else if (pda_m_type() == PM_MAIN) { + // Line 0 = MAIN MENU + // Line 1 = + // Line 2 = HELP > + // Line 3 = PROGRAM > + // Line 4 = SET TEMP > + // Line 5 = SET TIME > + // Line 6 = PDA OPTIONS > + // Line 7 = SYSTEM SETUP > + // Line 8 = + // Line 9 = + + // Line 0 = MAIN MENU + // Line 1 = HELP > + // Line 2 = PROGRAM > + // Line 3 = SET TEMP > + // Line 4 = SET TIME > + // Line 5 = SET AquaPure > + // Line 6 = PDA OPTIONS > + // Line 7 = SYSTEM SETUP > + // Line 8 = + // Line 9 = BOOST + + // "SET AquaPure" and "BOOST" are only present when filter pump is running + if (strncasecmp(pda_m_line(9)," BOOST ", 16) == 0) { + min_index = 1; + max_index = 8; // to account for 8 missing + if (index == 9) { // looking for boost + bLookingForBoost = true; + index = 8; } + } else { + min_index = 2; + max_index = 7; } + } else if (pda_m_type() == PM_BOOST) { + // PDA Line 0 = BOOST + // PDA Line 1 = + // PDA Line 2 = Operate the + // PDA Line 3 = AquaPure + // PDA Line 4 = chlorinator + // PDA Line 5 = at 100% + // PDA Line 6 = for 24 hrs. + // PDA Line 7 = + // PDA Line 8 = START + // PDA Line 9 = GO BACK + + // PDA Line 0 = BOOST + // PDA Line 1 = + // PDA Line 2 = + // PDA Line 3 = TIME REMAINING + // PDA Line 4 = 23:59 + // PDA Line 5 = + // PDA Line 6 = + // PDA Line 7 = PAUSE + // PDA Line 8 = RESTART + // PDA Line 9 = STOP + + if (strncasecmp(pda_m_line(9)," STOP", 10) == 0) { + min_index = 7; + max_index = 9; + } else { + min_index = 8; + max_index = 9; + + } + } } - LOG(PDA_LOG,LOG_DEBUG, "find_pda_menu_item i=%d idx=%d min=%d max=%d\n", - i, index, min_index, max_index); + LOG(PDA_LOG,LOG_DEBUG, "find_pda_menu_item i=%d idx=%d min=%d max=%d boost=%d\n", + i, index, min_index, max_index, bLookingForBoost?1:0); if (i < index) { if ((min_index != -1) && ((index - i) > (i - min_index + max_index - index + 1))) { @@ -315,8 +348,7 @@ bool find_pda_menu_item(struct aqualinkdata *aq_data, char *menuText, int charli } } } - - return waitForPDAMessageHighlight(aq_data, index, 10); + return waitForPDAMessageHighlight(aq_data, bLookingForBoost?9:index, 10); } bool _select_pda_menu_item(struct aqualinkdata *aq_data, char *menuText, bool waitForNextMenu, bool loose); @@ -466,7 +498,7 @@ bool goto_pda_menu(struct aqualinkdata *aq_data, pda_menu_type menu) { if (pda_m_type() == PM_HOME) { ret = select_pda_menu_item(aq_data, "MENU", true); } else if (pda_m_type() == PM_MAIN) { - ret = select_pda_menu_item_loose(aq_data, "BOOST", true); + ret = select_pda_menu_item_loose(aq_data, " BOOST", true); } else { send_cmd(KEY_PDA_BACK); ret = waitForPDAnextMenu(aq_data); @@ -892,31 +924,17 @@ bool waitForPDAMessageTypes(struct aqualinkdata *aq_data, unsigned char mtype1, } /* - Use -1 for cur_val if you want this to find the delected value and change it. + Use -1 for cur_val if you want this to find the current value and change it. Use number for cur_val to increase / decrease from known start point */ bool set_PDA_numeric_field_value(struct aqualinkdata *aq_data, int val, int cur_val, char *select_label, int step) { int i=0; + LOG(PDA_LOG,LOG_DEBUG, "set_PDA_numeric_field_value %s from %d to %d step %d\n", select_label, cur_val, val, step); if (select_label != NULL) { - // :TODO: Should probably change below to call find_pda_menu_item(), rather than doing it here - // If we lease this, need to limit on the number of loops - //while ( strncasecmp(pda_m_hlight(), select_label, 8) != 0 ) { - //while ( strncasecmp(pda_m_hlight(), select_label, strlen(select_label)) != 0 ) { - while ( rsm_strncmp(pda_m_hlight(), select_label, strlen(select_label)) != 0 ) { - LOG(PDA_LOG,LOG_DEBUG, "Numeric selector selecting '%s' current selection '%s'\n", select_label, pda_m_hlight()); - send_cmd(KEY_PDA_DOWN); - //delay(500); // Last message probably was CMD_PDA_HIGHLIGHT, so wait before checking. - waitfor_queue2empty(); - waitForPDAMessageType(aq_data,CMD_PDA_HIGHLIGHT,1,0); - if (i > 10) { - LOG(PDA_LOG,LOG_ERR, "Numeric selector could not find string '%s'\n", select_label); - return false; - } - i++; + if ( ! select_pda_menu_item(aq_data, select_label, false) ) { + return false; } - LOG(PDA_LOG,LOG_DEBUG, "Numeric selector, selecting '%s'\n", pda_m_hlight()); - send_cmd(KEY_PDA_SELECT); } if (cur_val == -1) { @@ -964,15 +982,21 @@ bool set_PDA_aqualink_SWG_setpoint(struct aqualinkdata *aq_data, int val) { LOG(PDA_LOG,LOG_ERR, "Error finding SWG setpoints menu\n"); return false; } - - if (aq_data->aqbuttons[SPA_INDEX].led->state != OFF) { - //int cur_val = atoi + // wait for menu to display to capture current value with process_pda_packet_msg_long_SWG + waitForPDAMessageTypes(aq_data,CMD_PDA_HIGHLIGHT,CMD_PDA_HIGHLIGHTCHARS,2,0); + + if (pda_find_m_index("SET POOL") < 0) { + // Single Setpoint Screen + return set_PDA_numeric_field_value(aq_data, val, -1, NULL, 5); + } else if (aq_data->aqbuttons[SPA_INDEX].led->state != OFF) { + // Dual Setpoint Screen with SPA mode enabled + // :TODO: aq_data should have 2 swg_precent values and GUI should be updated to + // display and modify both values. return set_PDA_numeric_field_value(aq_data, val, -1, "SET SPA", 5); } else { + // Dual Setpoint Screen with SPA mode disabled return set_PDA_numeric_field_value(aq_data, val, -1, "SET POOL", 5); } - - //return true; } bool set_PDA_aqualink_boost(struct aqualinkdata *aq_data, bool val) @@ -981,38 +1005,22 @@ bool set_PDA_aqualink_boost(struct aqualinkdata *aq_data, bool val) LOG(PDA_LOG,LOG_ERR, "Error finding BOOST menu\n"); return false; } - - - // Should be on the START menu item if (val == true) { // Turn on should just be enter - if (strstr(pda_m_hlight(), "START") != NULL) - send_cmd(KEY_PDA_SELECT); - else { - LOG(PDA_LOG,LOG_ERR, "Error finding BOOST START menu\n"); - return false; - } + select_pda_menu_item_loose(aq_data, "START", false); } else { - /* - // Should be select options PAUSE | RESTART | STOP - int i=0; - for (i=0; i < 6; i++) { - send_cmd(KEY_PDA_DOWN); - waitForPDAMessageTypes(aq_data,CMD_PDA_HIGHLIGHT,CMD_PDA_HIGHLIGHTCHARS,10); - if (strstr(pda_m_hlight(), "STOP") != NULL) { - send_cmd(KEY_PDA_SELECT); - break; - } - } - if (i >= 6) - LOG(PDA_LOG,LOG_ERR, "Error finding BOOST STOP menu\n"); - // Should be select options PAUSE | RESTART | STOP - // so press down twice then select - */ - // NSF This is really crap, but can't get above to work, need to come back and check menu items against selections. - send_cmd(KEY_PDA_DOWN); - send_cmd(KEY_PDA_DOWN); - send_cmd(KEY_PDA_SELECT); + // PDA Line 0 = BOOST + // PDA Line 1 = + // PDA Line 2 = + // PDA Line 3 = TIME REMAINING + // PDA Line 4 = 23:59 + // PDA Line 5 = + // PDA Line 6 = + // PDA Line 7 = PAUSE + // PDA Line 8 = RESTART + // PDA Line 9 = STOP + + select_pda_menu_item_loose(aq_data, "STOP", false); } return true; @@ -1282,16 +1290,31 @@ PDA Line 7 = BOOST POOL PDA Line 8 = PDA Line 9 = **************** OPTION 2 FOR THIS MENU ******************** -PDA Line 0 = MAIN MENU -PDA Line 1 = -PDA Line 2 = HELP > -PDA Line 3 = PROGRAM > -PDA Line 4 = SET TEMP > -PDA Line 5 = SET TIME > -PDA Line 6 = PDA OPTIONS > -PDA Line 7 = SYSTEM SETUP > + +PDA Line 0 = MAIN MENU +PDA Line 1 = HELP > +PDA Line 2 = PROGRAM > +PDA Line 3 = SET TEMP > +PDA Line 4 = SET TIME > +PDA Line 5 = SET AquaPure > +PDA Line 6 = PDA OPTIONS > +PDA Line 7 = SYSTEM SETUP > PDA Line 8 = -PDA Line 9 = BOOST +PDA Line 9 = BOOST + + +PDA Line 0 = BOOST +PDA Line 1 = +PDA Line 2 = Operate the +PDA Line 3 = AquaPure +PDA Line 4 = chlorinator +PDA Line 5 = at 100% +PDA Line 6 = for 24 hrs. +PDA Line 7 = +PDA Line 8 = START +PDA Line 9 = GO BACK + + ********** Guess at SYSTEM SETUP Menu (not on Rev MMM or before)************ // PDA Line 0 = SYSTEM SETUP // PDA Line 1 = LABEL AUX >