@@ -79,7 +79,6 @@ config_t config;
79
79
static char rlabels [MAX_NUM_RELAYS ][32 ] = {"My appliance 1" , "My appliance 2" , "My appliance 3" , "My appliance 4" ,
80
80
"My appliance 5" , "My appliance 6" , "My appliance 7" , "My appliance 8" };
81
81
82
-
83
82
/**********************************************************
84
83
* Function: config_cb()
85
84
*
@@ -134,6 +133,10 @@ static int config_cb(void* user, const char* section, const char* name, const ch
134
133
{
135
134
pconfig -> relay8_label = strdup (value );
136
135
}
136
+ else if (MATCH ("HTTP server" , "pulse_duration" ))
137
+ {
138
+ pconfig -> pulse_duration = atoi (value );
139
+ }
137
140
else if (MATCH ("GPIO drv" , "num_relays" ))
138
141
{
139
142
pconfig -> gpio_num_relays = atoi (value );
@@ -483,13 +486,13 @@ int process_http_request(int sock)
483
486
if (rstate [relay - 1 ] == ON )
484
487
{
485
488
crelay_set_relay (com_port , relay , OFF , serial );
486
- sleep (1 );
489
+ sleep (config . pulse_duration );
487
490
crelay_set_relay (com_port , relay , ON , serial );
488
491
}
489
492
else
490
493
{
491
494
crelay_set_relay (com_port , relay , ON , serial );
492
- sleep (1 );
495
+ sleep (config . pulse_duration );
493
496
crelay_set_relay (com_port , relay , OFF , serial );
494
497
}
495
498
}
@@ -668,6 +671,7 @@ int main(int argc, char *argv[])
668
671
if (config .relay6_label != NULL ) syslog (LOG_DAEMON | LOG_NOTICE , "relay6_label: %s\n" , config .relay6_label );
669
672
if (config .relay7_label != NULL ) syslog (LOG_DAEMON | LOG_NOTICE , "relay7_label: %s\n" , config .relay7_label );
670
673
if (config .relay8_label != NULL ) syslog (LOG_DAEMON | LOG_NOTICE , "relay8_label: %s\n" , config .relay8_label );
674
+ if (config .pulse_duration != 0 ) syslog (LOG_DAEMON | LOG_NOTICE , "pulse_duration: %u\n" , config .pulse_duration );
671
675
if (config .gpio_num_relays != 0 ) syslog (LOG_DAEMON | LOG_NOTICE , "gpio_num_relays: %u\n" , config .gpio_num_relays );
672
676
if (config .gpio_active_value >= 0 ) syslog (LOG_DAEMON | LOG_NOTICE , "gpio_active_value: %u\n" , config .gpio_active_value );
673
677
if (config .relay1_gpio_pin != 0 ) syslog (LOG_DAEMON | LOG_NOTICE , "relay1_gpio_pin: %u\n" , config .relay1_gpio_pin );
@@ -705,11 +709,18 @@ int main(int argc, char *argv[])
705
709
{
706
710
port = config .server_port ;
707
711
}
712
+
708
713
}
709
714
else
710
715
{
711
716
syslog (LOG_DAEMON | LOG_NOTICE , "Can't load %s, using default parameters\n" , CONFIG_FILE );
712
717
}
718
+
719
+ /* Ensure pulse duration is valid **/
720
+ if (config .pulse_duration == 0 )
721
+ {
722
+ config .pulse_duration = 1 ;
723
+ }
713
724
714
725
/* Parse command line for relay labels (overrides config file)*/
715
726
for (i = 0 ; i < argc - 2 && i < MAX_NUM_RELAYS ; i ++ )
0 commit comments