Skip to content

Commit 9da96ec

Browse files
committed
Version 1.3.8a
1 parent 62f776f commit 9da96ec

10 files changed

+62
-27
lines changed

aq_mqtt.h

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#define SWG_ON 2
4949
#define SWG_OFF 0
5050

51+
#define MQTT_FLASH "2"
5152
#define MQTT_ON "1"
5253
#define MQTT_OFF "0"
5354

aq_serial.c

+28-15
Original file line numberDiff line numberDiff line change
@@ -357,17 +357,19 @@ void send_pentair_command(int fd, unsigned char *packet_buffer, int size)
357357

358358
//packet[i++] = 0x00; // from
359359
//packet[i++] = // to
360-
for (i=5; i-4 < size; i++) {
360+
for (i=5; i-5 < size; i++) {
361361
//printf("added 0x%02hhx at position %d\n",packet_buffer[i-4],i);
362362
if (i==6) {
363363
// Replace source
364-
packet[i] = 0x00;
364+
//packet[i] = 0x00;
365+
// Don't replace source
366+
packet[i] = packet_buffer[i-5];
365367
} else if (i==9) {
366368
// Replace length
367369
//packet[i] = 0xFF;
368-
packet[i] = (unsigned char)size-6;
370+
packet[i] = (unsigned char)size-5;
369371
} else {
370-
packet[i] = packet_buffer[i-4];
372+
packet[i] = packet_buffer[i-5];
371373
}
372374

373375
//packet[i] = packet_buffer[i-4];
@@ -383,26 +385,18 @@ void send_pentair_command(int fd, unsigned char *packet_buffer, int size)
383385
send_packet(fd,packet,i);
384386
}
385387

386-
//unsigned char packet_buffer[] = {PCOL_PENTAIR, 0x07, 0x0F, 0x10, 0x08, 0x0D, 0x55, 0x55, 0x5B, 0x2A, 0x2B, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00};
387-
//unsigned char packet_buffer[] = {PCOL_JANDY, 0x07, 0x0F, 0x00, 0x00};
388-
void send_command(int fd, unsigned char *packet_buffer, int size)
388+
void send_jandy_command(int fd, unsigned char *packet_buffer, int size)
389389
{
390390
unsigned char packet[AQ_MAXPKTLEN];
391391
int i=0;
392392

393-
if (packet_buffer[0] != PCOL_JANDY) {
394-
//logMessage(LOG_ERR, "Only Jandy protocol supported at present!\n");
395-
send_pentair_command(fd, packet_buffer, size);
396-
return;
397-
}
398-
399393
packet[0] = NUL;
400394
packet[1] = DLE;
401395
packet[2] = STX;
402396

403-
for (i=3; i-2 < size; i++) {
397+
for (i=3; i-3 < size; i++) {
404398
//printf("added 0x%02hhx at position %d\n",packet_buffer[i-2],i);
405-
packet[i] = packet_buffer[i-2];
399+
packet[i] = packet_buffer[i-3];
406400
}
407401

408402
packet[++i] = DLE;
@@ -414,6 +408,25 @@ void send_command(int fd, unsigned char *packet_buffer, int size)
414408
send_packet(fd,packet,++i);
415409
}
416410

411+
//unsigned char packet_buffer[] = {PCOL_PENTAIR, 0x07, 0x0F, 0x10, 0x08, 0x0D, 0x55, 0x55, 0x5B, 0x2A, 0x2B, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00};
412+
//unsigned char packet_buffer[] = {PCOL_JANDY, 0x07, 0x0F, 0x00, 0x00};
413+
void send_command(int fd, unsigned char *packet_buffer, int size)
414+
{
415+
//unsigned char packet[AQ_MAXPKTLEN];
416+
//int i=0;
417+
418+
if (packet_buffer[0] == PCOL_JANDY) {
419+
//logMessage(LOG_ERR, "Only Jandy protocol supported at present!\n");
420+
send_jandy_command(fd, &packet_buffer[1], size-1);
421+
return;
422+
}
423+
if (packet_buffer[0] == PCOL_PENTAIR) {
424+
//logMessage(LOG_ERR, "Only Jandy protocol supported at present!\n");
425+
send_pentair_command(fd, &packet_buffer[1], size-1);
426+
return;
427+
}
428+
}
429+
417430
void send_packet(int fd, unsigned char *packet, int length)
418431
{
419432

aq_serial.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
#define SOLAR_HTR_LED_INDEX 19
139139

140140
#define LNG_MSG_SERVICE_ACTIVE "SERVICE MODE IS ACTIVE"
141+
#define LNG_MSG_TIMEOUT_ACTIVE "TIMEOUT MODE IS ACTIVE"
141142
#define LNG_MSG_POOL_TEMP_SET "POOL TEMP IS SET TO"
142143
#define LNG_MSG_SPA_TEMP_SET "SPA TEMP IS SET TO"
143144
#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);
267268
int get_packet(int file_descriptor, unsigned char* packet);
268269
int get_packet_lograw(int fd, unsigned char* packet);
269270

270-
int get_packet_new(int fd, unsigned char* packet);
271-
int get_packet_new_lograw(int fd, unsigned char* packet);
271+
//int get_packet_new(int fd, unsigned char* packet);
272+
//int get_packet_new_lograw(int fd, unsigned char* packet);
272273
//void close_serial_port(int file_descriptor, struct termios* oldtio);
273274
//void process_status(void const * const ptr);
274275
void process_status(unsigned char* ptr);
275276
const char* get_packet_type(unsigned char* packet , int length);
277+
278+
279+
void send_jandy_command(int fd, unsigned char *packet_buffer, int size);
280+
void send_pentair_command(int fd, unsigned char *packet_buffer, int size);
281+
void send_command(int fd, unsigned char *packet_buffer, int size);
282+
276283
//void send_test_cmd(int fd, unsigned char destination, unsigned char b1, unsigned char b2, unsigned char b3);
277284
//void send_command(int fd, unsigned char destination, unsigned char b1, unsigned char b2, unsigned char b3);
278285
//void send_messaged(int fd, unsigned char destination, char *message);

aqualinkd.c

+13-4
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ void processMessage(char *message)
243243
// Don't do any message counts if we are programming
244244
if (_aqualink_data.active_thread.thread_id == 0) {
245245
// If we have more than 10 messages without "Service Mode is active" assume it's off.
246-
if (_aqualink_data.service_mode_state == ON && service_msg_count++ > 10) {
246+
if (_aqualink_data.service_mode_state != OFF && service_msg_count++ > 10) {
247247
_aqualink_data.service_mode_state = OFF;
248248
service_msg_count = 0;
249249
}
@@ -371,6 +371,13 @@ void processMessage(char *message)
371371
_aqualink_data.service_mode_state = ON;
372372
service_msg_count = 0;
373373
}
374+
else if (stristr(msg, LNG_MSG_TIMEOUT_ACTIVE) != NULL)
375+
{
376+
if (_aqualink_data.service_mode_state == OFF)
377+
logMessage(LOG_NOTICE, "AqualinkD set to Timeout Mode\n");
378+
_aqualink_data.service_mode_state = FLASH;
379+
service_msg_count = 0;
380+
}
374381
else if (stristr(msg, LNG_MSG_FREEZE_PROTECTION_ACTIVATED) != NULL)
375382
{
376383
_aqualink_data.frz_protect_state = ON;
@@ -1102,7 +1109,6 @@ void main_loop()
11021109
_aqualink_data.single_device = false;
11031110
_aqualink_data.service_mode_state = OFF;
11041111
_aqualink_data.frz_protect_state = OFF;
1105-
_aqualink_data.service_mode_state = OFF;
11061112
_aqualink_data.battery = OK;
11071113
_aqualink_data.open_websockets = 0;
11081114

@@ -1285,8 +1291,11 @@ void main_loop()
12851291
interestedInNextAck = true;
12861292

12871293
// Only read message from controller to SWG to set SWG Percent if we are not programming, as we might be changing this
1288-
if (packet_buffer[3] == CMD_PERCENT && _aqualink_data.active_thread.thread_id == 0)
1289-
{
1294+
if (packet_buffer[3] == CMD_PERCENT && _aqualink_data.active_thread.thread_id == 0 && packet_buffer[4] != 0xFF)
1295+
{
1296+
// In service or timeout mode SWG set % message is very strange. AR %% | HEX: 0x10|0x02|0x50|0x11|0xff|0x72|0x10|0x03|
1297+
// Not really sure what to do with this, just ignore 0xff / 255 for the moment. (if statment above)
1298+
12901299
// 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
12911300
if (swg_zero_cnt <= _config_parameters.swg_zero_ignore && packet_buffer[4] == 0x00 && packet_buffer[5] == 0x73) {
12921301
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]);

json_messages.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ const char* getStatus(struct aqualinkdata *aqdata)
4646
return JSON_PROGRAMMING;
4747
}
4848

49-
if (aqdata->last_message != NULL && stristr(aqdata->last_message, "SERVICE") != NULL ) {
49+
//if (aqdata->last_message != NULL && stristr(aqdata->last_message, "SERVICE") != NULL ) {
50+
if (aqdata->service_mode_state == ON) {
5051
return JSON_SERVICE;
52+
} else if (aqdata->service_mode_state == FLASH) {
53+
return JSON_TIMEOUT;
5154
}
5255

5356
if (aqdata->last_display_message[0] != '\0') {

json_messages.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
#define JSON_LOW "low"
2121

2222
#define JSON_PROGRAMMING "Programming"
23-
#define JSON_SERVICE "Service"
23+
#define JSON_SERVICE "Service Mode"
24+
#define JSON_TIMEOUT "Timeout Mode"
2425
#define JSON_READY "Ready"
2526

2627
struct JSONkeyvalue{

net_services.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ void mqtt_broadcast_aqualinkstate(struct mg_connection *nc)
313313

314314
if (_aqualink_data->service_mode_state != _last_mqtt_aqualinkdata.service_mode_state) {
315315
_last_mqtt_aqualinkdata.service_mode_state = _aqualink_data->service_mode_state;
316-
send_mqtt_string_msg(nc, SERVICE_MODE_TOPIC, _aqualink_data->service_mode_state==ON?MQTT_ON:MQTT_OFF);
316+
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));
317317
}
318318

319319
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)
369369
_last_mqtt_aqualinkdata.spa_htr_set_point = _aqualink_data->spa_htr_set_point;
370370
send_mqtt_setpoint_msg(nc, BTN_SPA_HTR, _aqualink_data->spa_htr_set_point);
371371
}
372-
372+
/*
373373
if (_aqualink_data->service_mode_state != _last_mqtt_aqualinkdata.service_mode_state) {
374374
_last_mqtt_aqualinkdata.service_mode_state = _aqualink_data->service_mode_state;
375375
send_mqtt_string_msg(nc, SERVICE_MODE_TOPIC, _aqualink_data->service_mode_state==ON?MQTT_ON:MQTT_OFF);
376376
}
377-
377+
*/
378378
if (_aqualink_data->frz_protect_set_point != TEMP_UNKNOWN && _aqualink_data->frz_protect_set_point != _last_mqtt_aqualinkdata.frz_protect_set_point) {
379379
_last_mqtt_aqualinkdata.frz_protect_set_point = _aqualink_data->frz_protect_set_point;
380380
send_mqtt_setpoint_msg(nc, FREEZE_PROTECT, _aqualink_data->frz_protect_set_point);
@@ -1296,6 +1296,7 @@ void start_mqtt(struct mg_mgr *mgr) {
12961296
_last_mqtt_aqualinkdata.battery = -1;
12971297
_last_mqtt_aqualinkdata.frz_protect_state = -1;
12981298
_last_mqtt_aqualinkdata.boost = -1;
1299+
_last_mqtt_aqualinkdata.service_mode_state = -1;
12991300
_mqtt_exit_flag = false; // set here to stop multiple connects, if it fails truley fails it will get set to false.
13001301
}
13011302
}

release/aqualinkd

52 Bytes
Binary file not shown.

release/serial_logger

348 Bytes
Binary file not shown.

version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22

33
#define AQUALINKD_NAME "Aqualink Daemon"
4-
#define AQUALINKD_VERSION "1.3.8"
4+
#define AQUALINKD_VERSION "1.3.8a"

0 commit comments

Comments
 (0)