Version 1.3.8a

pull/101/merge v1.3.8a
sfeakes 2019-10-18 08:52:20 -05:00
parent 62f776fa31
commit 9da96ecc5f
10 changed files with 62 additions and 27 deletions

View File

@ -48,6 +48,7 @@
#define SWG_ON 2
#define SWG_OFF 0
#define MQTT_FLASH "2"
#define MQTT_ON "1"
#define MQTT_OFF "0"

View File

@ -357,17 +357,19 @@ void send_pentair_command(int fd, unsigned char *packet_buffer, int size)
//packet[i++] = 0x00; // from
//packet[i++] = // to
for (i=5; i-4 < size; i++) {
for (i=5; i-5 < size; i++) {
//printf("added 0x%02hhx at position %d\n",packet_buffer[i-4],i);
if (i==6) {
// Replace source
packet[i] = 0x00;
//packet[i] = 0x00;
// Don't replace source
packet[i] = packet_buffer[i-5];
} else if (i==9) {
// Replace length
//packet[i] = 0xFF;
packet[i] = (unsigned char)size-6;
packet[i] = (unsigned char)size-5;
} else {
packet[i] = packet_buffer[i-4];
packet[i] = packet_buffer[i-5];
}
//packet[i] = packet_buffer[i-4];
@ -383,26 +385,18 @@ void send_pentair_command(int fd, unsigned char *packet_buffer, int size)
send_packet(fd,packet,i);
}
//unsigned char packet_buffer[] = {PCOL_PENTAIR, 0x07, 0x0F, 0x10, 0x08, 0x0D, 0x55, 0x55, 0x5B, 0x2A, 0x2B, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00};
//unsigned char packet_buffer[] = {PCOL_JANDY, 0x07, 0x0F, 0x00, 0x00};
void send_command(int fd, unsigned char *packet_buffer, int size)
void send_jandy_command(int fd, unsigned char *packet_buffer, int size)
{
unsigned char packet[AQ_MAXPKTLEN];
int i=0;
if (packet_buffer[0] != PCOL_JANDY) {
//logMessage(LOG_ERR, "Only Jandy protocol supported at present!\n");
send_pentair_command(fd, packet_buffer, size);
return;
}
packet[0] = NUL;
packet[1] = DLE;
packet[2] = STX;
for (i=3; i-2 < size; i++) {
for (i=3; i-3 < size; i++) {
//printf("added 0x%02hhx at position %d\n",packet_buffer[i-2],i);
packet[i] = packet_buffer[i-2];
packet[i] = packet_buffer[i-3];
}
packet[++i] = DLE;
@ -414,6 +408,25 @@ void send_command(int fd, unsigned char *packet_buffer, int size)
send_packet(fd,packet,++i);
}
//unsigned char packet_buffer[] = {PCOL_PENTAIR, 0x07, 0x0F, 0x10, 0x08, 0x0D, 0x55, 0x55, 0x5B, 0x2A, 0x2B, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00};
//unsigned char packet_buffer[] = {PCOL_JANDY, 0x07, 0x0F, 0x00, 0x00};
void send_command(int fd, unsigned char *packet_buffer, int size)
{
//unsigned char packet[AQ_MAXPKTLEN];
//int i=0;
if (packet_buffer[0] == PCOL_JANDY) {
//logMessage(LOG_ERR, "Only Jandy protocol supported at present!\n");
send_jandy_command(fd, &packet_buffer[1], size-1);
return;
}
if (packet_buffer[0] == PCOL_PENTAIR) {
//logMessage(LOG_ERR, "Only Jandy protocol supported at present!\n");
send_pentair_command(fd, &packet_buffer[1], size-1);
return;
}
}
void send_packet(int fd, unsigned char *packet, int length)
{

View File

@ -138,6 +138,7 @@
#define SOLAR_HTR_LED_INDEX 19
#define LNG_MSG_SERVICE_ACTIVE "SERVICE MODE IS ACTIVE"
#define LNG_MSG_TIMEOUT_ACTIVE "TIMEOUT MODE IS ACTIVE"
#define LNG_MSG_POOL_TEMP_SET "POOL TEMP IS SET TO"
#define LNG_MSG_SPA_TEMP_SET "SPA TEMP IS SET TO"
#define LNG_MSG_FREEZE_PROTECTION_SET "FREEZE PROTECTION IS SET TO"
@ -267,12 +268,18 @@ void send_extended_ack(int fd, unsigned char ack_type, unsigned char command);
int get_packet(int file_descriptor, unsigned char* packet);
int get_packet_lograw(int fd, unsigned char* packet);
int get_packet_new(int fd, unsigned char* packet);
int get_packet_new_lograw(int fd, unsigned char* packet);
//int get_packet_new(int fd, unsigned char* packet);
//int get_packet_new_lograw(int fd, unsigned char* packet);
//void close_serial_port(int file_descriptor, struct termios* oldtio);
//void process_status(void const * const ptr);
void process_status(unsigned char* ptr);
const char* get_packet_type(unsigned char* packet , int length);
void send_jandy_command(int fd, unsigned char *packet_buffer, int size);
void send_pentair_command(int fd, unsigned char *packet_buffer, int size);
void send_command(int fd, unsigned char *packet_buffer, int size);
//void send_test_cmd(int fd, unsigned char destination, unsigned char b1, unsigned char b2, unsigned char b3);
//void send_command(int fd, unsigned char destination, unsigned char b1, unsigned char b2, unsigned char b3);
//void send_messaged(int fd, unsigned char destination, char *message);

View File

@ -243,7 +243,7 @@ void processMessage(char *message)
// Don't do any message counts if we are programming
if (_aqualink_data.active_thread.thread_id == 0) {
// If we have more than 10 messages without "Service Mode is active" assume it's off.
if (_aqualink_data.service_mode_state == ON && service_msg_count++ > 10) {
if (_aqualink_data.service_mode_state != OFF && service_msg_count++ > 10) {
_aqualink_data.service_mode_state = OFF;
service_msg_count = 0;
}
@ -371,6 +371,13 @@ void processMessage(char *message)
_aqualink_data.service_mode_state = ON;
service_msg_count = 0;
}
else if (stristr(msg, LNG_MSG_TIMEOUT_ACTIVE) != NULL)
{
if (_aqualink_data.service_mode_state == OFF)
logMessage(LOG_NOTICE, "AqualinkD set to Timeout Mode\n");
_aqualink_data.service_mode_state = FLASH;
service_msg_count = 0;
}
else if (stristr(msg, LNG_MSG_FREEZE_PROTECTION_ACTIVATED) != NULL)
{
_aqualink_data.frz_protect_state = ON;
@ -1102,7 +1109,6 @@ void main_loop()
_aqualink_data.single_device = false;
_aqualink_data.service_mode_state = OFF;
_aqualink_data.frz_protect_state = OFF;
_aqualink_data.service_mode_state = OFF;
_aqualink_data.battery = OK;
_aqualink_data.open_websockets = 0;
@ -1285,8 +1291,11 @@ void main_loop()
interestedInNextAck = true;
// Only read message from controller to SWG to set SWG Percent if we are not programming, as we might be changing this
if (packet_buffer[3] == CMD_PERCENT && _aqualink_data.active_thread.thread_id == 0)
{
if (packet_buffer[3] == CMD_PERCENT && _aqualink_data.active_thread.thread_id == 0 && packet_buffer[4] != 0xFF)
{
// In service or timeout mode SWG set % message is very strange. AR %% | HEX: 0x10|0x02|0x50|0x11|0xff|0x72|0x10|0x03|
// Not really sure what to do with this, just ignore 0xff / 255 for the moment. (if statment above)
// SWG can get ~10 messages to set to 0 then go back again for some reason, so don't go to 0 until 10 messages are received
if (swg_zero_cnt <= _config_parameters.swg_zero_ignore && packet_buffer[4] == 0x00 && packet_buffer[5] == 0x73) {
logMessage(LOG_DEBUG, "Ignoring SWG set to %d due to packet packet count %d <= %d from control panel to SWG 0x%02hhx 0x%02hhx\n", (int)packet_buffer[4],swg_zero_cnt,_config_parameters.swg_zero_ignore,packet_buffer[4],packet_buffer[5]);

View File

@ -46,8 +46,11 @@ const char* getStatus(struct aqualinkdata *aqdata)
return JSON_PROGRAMMING;
}
if (aqdata->last_message != NULL && stristr(aqdata->last_message, "SERVICE") != NULL ) {
//if (aqdata->last_message != NULL && stristr(aqdata->last_message, "SERVICE") != NULL ) {
if (aqdata->service_mode_state == ON) {
return JSON_SERVICE;
} else if (aqdata->service_mode_state == FLASH) {
return JSON_TIMEOUT;
}
if (aqdata->last_display_message[0] != '\0') {

View File

@ -20,7 +20,8 @@
#define JSON_LOW "low"
#define JSON_PROGRAMMING "Programming"
#define JSON_SERVICE "Service"
#define JSON_SERVICE "Service Mode"
#define JSON_TIMEOUT "Timeout Mode"
#define JSON_READY "Ready"
struct JSONkeyvalue{

View File

@ -313,7 +313,7 @@ void mqtt_broadcast_aqualinkstate(struct mg_connection *nc)
if (_aqualink_data->service_mode_state != _last_mqtt_aqualinkdata.service_mode_state) {
_last_mqtt_aqualinkdata.service_mode_state = _aqualink_data->service_mode_state;
send_mqtt_string_msg(nc, SERVICE_MODE_TOPIC, _aqualink_data->service_mode_state==ON?MQTT_ON:MQTT_OFF);
send_mqtt_string_msg(nc, SERVICE_MODE_TOPIC, _aqualink_data->service_mode_state==OFF?MQTT_OFF:(_aqualink_data->service_mode_state==FLASH?MQTT_FLASH:MQTT_ON));
}
if (_aqualink_data->air_temp != TEMP_UNKNOWN && _aqualink_data->air_temp != _last_mqtt_aqualinkdata.air_temp) {
@ -369,12 +369,12 @@ void mqtt_broadcast_aqualinkstate(struct mg_connection *nc)
_last_mqtt_aqualinkdata.spa_htr_set_point = _aqualink_data->spa_htr_set_point;
send_mqtt_setpoint_msg(nc, BTN_SPA_HTR, _aqualink_data->spa_htr_set_point);
}
/*
if (_aqualink_data->service_mode_state != _last_mqtt_aqualinkdata.service_mode_state) {
_last_mqtt_aqualinkdata.service_mode_state = _aqualink_data->service_mode_state;
send_mqtt_string_msg(nc, SERVICE_MODE_TOPIC, _aqualink_data->service_mode_state==ON?MQTT_ON:MQTT_OFF);
}
*/
if (_aqualink_data->frz_protect_set_point != TEMP_UNKNOWN && _aqualink_data->frz_protect_set_point != _last_mqtt_aqualinkdata.frz_protect_set_point) {
_last_mqtt_aqualinkdata.frz_protect_set_point = _aqualink_data->frz_protect_set_point;
send_mqtt_setpoint_msg(nc, FREEZE_PROTECT, _aqualink_data->frz_protect_set_point);
@ -1296,6 +1296,7 @@ void start_mqtt(struct mg_mgr *mgr) {
_last_mqtt_aqualinkdata.battery = -1;
_last_mqtt_aqualinkdata.frz_protect_state = -1;
_last_mqtt_aqualinkdata.boost = -1;
_last_mqtt_aqualinkdata.service_mode_state = -1;
_mqtt_exit_flag = false; // set here to stop multiple connects, if it fails truley fails it will get set to false.
}
}

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,4 @@
#define AQUALINKD_NAME "Aqualink Daemon"
#define AQUALINKD_VERSION "1.3.8"
#define AQUALINKD_VERSION "1.3.8a"