mirror of https://github.com/sfeakes/AqualinkD.git
pull/11/head
parent
5168855287
commit
0050ec8b11
BIN
aq_programmer.o
BIN
aq_programmer.o
Binary file not shown.
BIN
aq_serial.o
BIN
aq_serial.o
Binary file not shown.
BIN
aqualinkd.o
BIN
aqualinkd.o
Binary file not shown.
|
@ -1,138 +0,0 @@
|
|||
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "aq_serial.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define SLOG_MAX 80
|
||||
#define PACKET_MAX 10000000000
|
||||
|
||||
bool _keepRunning = true;
|
||||
|
||||
void intHandler(int dummy) {
|
||||
_keepRunning = false;
|
||||
logMessage(LOG_NOTICE, "Stopping!");
|
||||
}
|
||||
|
||||
|
||||
void printHex(char *pk, int length)
|
||||
{
|
||||
int i=0;
|
||||
for (i=0;i<length;i++)
|
||||
{
|
||||
printf("0x%02hhx|",pk[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void printPacket(unsigned char ID, unsigned char *packet_buffer, int packet_length)
|
||||
{
|
||||
if (packet_buffer[PKT_DEST] != 0x00)
|
||||
printf("\n");
|
||||
|
||||
printf("%4.4s 0x%02hhx of type %8.8s", (packet_buffer[PKT_DEST]==0x00?"From":"To"), (packet_buffer[PKT_DEST]==0x00?ID:packet_buffer[PKT_DEST]), get_packet_type(packet_buffer, packet_length));
|
||||
printf(" | HEX: ");
|
||||
printHex((char *)packet_buffer, packet_length);
|
||||
|
||||
if (packet_buffer[PKT_CMD] == CMD_MSG || packet_buffer[PKT_CMD] == CMD_MSG_LONG) {
|
||||
printf(" Message : ");
|
||||
//fwrite(packet_buffer + 4, 1, AQ_MSGLEN+1, stdout);
|
||||
fwrite(packet_buffer + 4, 1, packet_length-7, stdout);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int rs_fd;
|
||||
int packet_length;
|
||||
unsigned char packet_buffer[AQ_MAXPKTLEN];
|
||||
unsigned char lastID;
|
||||
int received_packets = 0;
|
||||
|
||||
|
||||
if (getuid() != 0) {
|
||||
fprintf(stderr, "ERROR %s Can only be run as root\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
//if (idMode)
|
||||
setLoggingPrms(LOG_DEBUG, false, false);
|
||||
//else
|
||||
// setLoggingPrms(LOG_DEBUG_SERIAL, false, false);
|
||||
|
||||
if (argc < 2) {
|
||||
logMessage(LOG_DEBUG, "ERROR, first param must be serial port, ie:-\n %s /dev/ttyUSB0\n\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rs_fd = init_serial_port(argv[1]);
|
||||
|
||||
signal(SIGINT, intHandler);
|
||||
signal(SIGTERM, intHandler);
|
||||
|
||||
while (_keepRunning == true) {
|
||||
if (rs_fd < 0) {
|
||||
logMessage(LOG_DEBUG, "ERROR, serial port disconnect\n");
|
||||
}
|
||||
|
||||
packet_length = get_packet(rs_fd, packet_buffer);
|
||||
received_packets++;
|
||||
|
||||
if (packet_length == -1) {
|
||||
// Unrecoverable read error. Force an attempt to reconnect.
|
||||
logMessage(LOG_DEBUG, "ERROR, on serial port\n");
|
||||
_keepRunning = false;
|
||||
} else if (packet_length == 0) {
|
||||
// Nothing read
|
||||
|
||||
} else if (packet_length > 0) {
|
||||
if ((packet_buffer[PKT_DEST] == DEV_MASTER && (lastID == 0x50 || lastID == 0x58))
|
||||
|| packet_buffer[PKT_DEST] == 0x50 || packet_buffer[PKT_DEST] == 0x58)
|
||||
printPacket(lastID, packet_buffer, packet_length);
|
||||
else if (packet_buffer[PKT_CMD] == CMD_MSG || packet_buffer[PKT_CMD] == CMD_MSG_LONG) {
|
||||
printf(" To 0x%02hhx of Type Message | ",packet_buffer[PKT_DEST]);
|
||||
fwrite(packet_buffer + 4, 1, packet_length-7, stdout);
|
||||
printf("\n");
|
||||
} else {
|
||||
printPacket(lastID, packet_buffer, packet_length);
|
||||
}
|
||||
|
||||
//send_messaged(0, 0x00, "AquaPure");
|
||||
|
||||
/*
|
||||
if (received_packets == 10 || received_packets == 20) {
|
||||
send_test_cmd(rs_fd, 0x50, 0x11, 0x32, 0x7d);
|
||||
//send_test_cmd(rs_fd, 0x80, CMD_PROBE, NUL, NUL);
|
||||
//send_test_cmd(rs_fd, 0x50, 0x11, 0x0a, NUL); // Set salt to 10%
|
||||
//send_test_cmd(rs_fd, 0x50, 0x14, 0x01, 0x77); // Send initial string AquaPure (0x14 is the comand, others should be NUL)
|
||||
//0x10|0x02|0x50|0x14|0x01|0x77|0x10|0x03|
|
||||
//0x10|0x02|0x50|0x14|0x01|0x77|0x10|0x03|
|
||||
// 10 02 50 11 0a 7d 10 03
|
||||
|
||||
// 0x11 is set %
|
||||
|
||||
printf(" *** SENT TEST *** \n");
|
||||
}
|
||||
*/
|
||||
lastID = packet_buffer[PKT_DEST];
|
||||
//received_packets++;
|
||||
|
||||
//delay(100);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
|
||||
if (received_packets >= PACKET_MAX) {
|
||||
_keepRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
init_buttons.o
BIN
init_buttons.o
Binary file not shown.
BIN
json_messages.o
BIN
json_messages.o
Binary file not shown.
BIN
mongoose.o
BIN
mongoose.o
Binary file not shown.
BIN
net_services.o
BIN
net_services.o
Binary file not shown.
|
@ -1,121 +0,0 @@
|
|||
# aqualinkd.conf
|
||||
#
|
||||
|
||||
# The directory where the web files are stored
|
||||
|
||||
web_directory=/var/www/aqualinkd/
|
||||
|
||||
# Log to file, comment out if you do not want to log to file
|
||||
#log_file=/var/log/aqualinkd.log
|
||||
|
||||
# The log level. [DEBUG, INFO, NOTICE, WARNING, ERROR]
|
||||
# Pick the highest level, and all levels below will be sent to syslog.
|
||||
# your syslog settings may be set to only display messages above a certian level
|
||||
# in which case make sure you use the log_file settings to capture everything
|
||||
# you want when debugging
|
||||
# so, NOTICE also prints WARNING & ERROR
|
||||
# DEBUG would print everything possible
|
||||
|
||||
#log_level=DEBUG_SERIAL
|
||||
#log_level=DEBUG
|
||||
#log_level=INFO
|
||||
log_level=NOTICE
|
||||
|
||||
# The socket port that the daemon listens to
|
||||
# If you change this from 80, remember to update aqualink.service.avahi
|
||||
socket_port=80
|
||||
|
||||
# The serial port the daemon access to read the Aqualink RS8
|
||||
serial_port=/dev/ttyUSB0
|
||||
|
||||
override_freeze_protect = no
|
||||
|
||||
# mqtt stuff
|
||||
mqtt_address = trident:1883
|
||||
#mqtt_user = someusername
|
||||
#mqtt_passwd = somepassword
|
||||
|
||||
#mqtt_dz_pub_topic = domoticz/in
|
||||
#mqtt_dz_sub_topic = domoticz/out
|
||||
mqtt_aq_topic = aqualinkd
|
||||
|
||||
# The id of the Aqualink terminal device. Devices probed by RS8 master are:
|
||||
# 08-0b, 10-13, 18-1b, 20-23, 28-2b, 30-33, 38-3b, 40-43
|
||||
#
|
||||
# Working RS 0x0a 0x0b 0x09 0x08
|
||||
device_id=0x0a
|
||||
#device_id=0x09
|
||||
|
||||
convert_mqtt_temp_to_c = yes
|
||||
convert_dz_temp_to_c = yes
|
||||
flash_mqtt_buttons = yes
|
||||
|
||||
# by default use pool temp as spa temp when spa is off, enable below to report 0 as spa temp when off.
|
||||
report_zero_spa_temp = no
|
||||
|
||||
#device_id=0x60
|
||||
#pda_mode = yes
|
||||
|
||||
# Button inxed light probramming button is assigned to. (look at your button labels below)
|
||||
light_programming_button = 6
|
||||
|
||||
# Light probramming mode. 0=safe mode, but slow.
|
||||
# any number greater is seconds to wait between button presses.
|
||||
# 0.4 seems to be the minimum. (workd for light modes below 10 presses)
|
||||
# 0.6 seems to work about 95% of the time, but above 20 presses can be hit or miss.
|
||||
# 0 will simply wait for the controler to send the response back before sending the next, so is equivelent to about 1.2
|
||||
light_programming_mode=0
|
||||
|
||||
# Light programming assumes light needs to be on before sending pulse (above setting)
|
||||
# If the light is off when request is made to change "light show", then the below value are used
|
||||
light_programming_initial_on=15
|
||||
|
||||
# Turn the light off for below time before start programmig puleses.
|
||||
light_programming_initial_off=12
|
||||
|
||||
# Domoticz ID's for temps.
|
||||
air_temp_dzidx=13
|
||||
pool_water_temp_dzidx=14
|
||||
spa_water_temp_dzidx=15
|
||||
#SWG_percent_dzidx=998
|
||||
#SWG_PPM_dzidx=999
|
||||
SWG_percent_dzidx=153
|
||||
SWG_PPM_dzidx=152
|
||||
SWG_Status_dzidx=157
|
||||
|
||||
# Labels for standard butons (shown in web UI), and domoticz idx's
|
||||
button_01_label=Filter Pump
|
||||
button_01_dzidx=37
|
||||
|
||||
button_02_label=Spa Mode
|
||||
button_02_dzidx=38
|
||||
|
||||
button_03_label=Cleaner
|
||||
button_03_dzidx=39
|
||||
|
||||
button_04_label=Waterfall
|
||||
button_04_dzidx=40
|
||||
|
||||
button_05_label=Spa Blower
|
||||
button_05_dzidx=41
|
||||
|
||||
button_06_label=Pool Light
|
||||
button_06_dzidx=42
|
||||
|
||||
button_07_label=Spa Light
|
||||
button_07_dzidx=43
|
||||
|
||||
button_08_label=NONE
|
||||
button_08_dzidx=NONE
|
||||
|
||||
button_09_label=NONE
|
||||
button_09_dzidx=NONE
|
||||
|
||||
button_10_label=Pool Heater
|
||||
button_10_dzidx=44
|
||||
|
||||
button_11_label=Spa Heater
|
||||
button_11_dzidx=56
|
||||
|
||||
button_12_label=Solar Heater
|
||||
button_12_dzidx=NONE
|
Loading…
Reference in New Issue