summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crook <idcrook@users.noreply.github.com>2019-05-25 13:01:22 -0600
committerDavid Crook <idcrook@users.noreply.github.com>2019-05-25 13:01:22 -0600
commit19fbededcfc77c83ca2c076026412157ee5fc956 (patch)
tree2dad126f3982f41e241716fb727fb3027349768b
parentc677006541e93c5a40406accc670d9a65e68cbb9 (diff)
mqtt port config changes
1. update example shairport-sync.conf file 2. update config file mqtt port parsing Signed-off-by: David Crook <idcrook@users.noreply.github.com>
-rw-r--r--scripts/shairport-sync.conf4
-rw-r--r--shairport.c13
2 files changed, 9 insertions, 8 deletions
diff --git a/scripts/shairport-sync.conf b/scripts/shairport-sync.conf
index 7b030d6..cd342d8 100644
--- a/scripts/shairport-sync.conf
+++ b/scripts/shairport-sync.conf
@@ -31,7 +31,7 @@ general =
// volume_control_profile = "standard" ; // use this advanced setting to specify how the airplay volume is transferred to the mixer volume.
// "standard" makes the volume change more quickly at lower volumes and slower at higher volumes.
// "flat" makes the volume change at the same rate at all volumes.
-// volume_range_combined_hardware_priority = "no"; // when extending the volume range by combining the built-in software attenuator with the hardware mixer attenuator, set this to "yes" to reduce volume by using the hardware mixer first, then the built-in software attenuator.
+// volume_range_combined_hardware_priority = "no"; // when extending the volume range by combining the built-in software attenuator with the hardware mixer attenuator, set this to "yes" to reduce volume by using the hardware mixer first, then the built-in software attenuator.
// run_this_when_volume_is_set = "/full/path/to/application/and/args"; // Run the specified application whenever the volume control is set or changed.
// The desired AirPlay volume is appended to the end of the command line – leave a space if you want it treated as an extra argument.
// AirPlay volume goes from 0 to -30 and -144 means "mute".
@@ -199,7 +199,7 @@ mqtt =
{
// enabled = "no"; // set this to yes to enable the mqtt-metadata-service
// hostname = "iot.eclipse.org"; // Hostname of the MQTT Broker
-// port = "1883";
+// port = 1883; // Port on the MQTT Broker to connect to
// username = NULL; //set this to a string with your username, to enable username authentication
// password = NULL; //set this to a string with your password, to enable username & password authentication
// capath = NULL; //set this to the folder with the CA-Certificates to be accepted for the server certificate. If not set, TLS is not used
diff --git a/shairport.c b/shairport.c
index 9e9400b..667a565 100644
--- a/shairport.c
+++ b/shairport.c
@@ -992,7 +992,6 @@ int parse_options(int argc, char **argv) {
#endif
#ifdef CONFIG_MQTT
- int tmpval = 0;
config_set_lookup_bool(config.cfg, "mqtt.enabled", &config.mqtt_enabled);
if (config.mqtt_enabled && !config.metadata_enabled) {
die("You need to have metadata enabled in order to use mqtt");
@@ -1001,11 +1000,13 @@ int parse_options(int argc, char **argv) {
config.mqtt_hostname = (char *)str;
// TODO: Document that, if this is false, whole mqtt func is disabled
}
- if (config_lookup_int(config.cfg, "mqtt.port", &tmpval)) {
- config.mqtt_port = tmpval;
- } else {
- // TODO: Is this the correct way to set a default value?
- config.mqtt_port = 1883;
+ config.mqtt_port = 1883;
+ if (config_lookup_int(config.cfg, "mqtt.port", &value)) {
+ if ((value < 0) || (value > 65535))
+ die("Invalid mqtt port number \"%sd\". It should be between 0 and 65535, default is 1883",
+ value);
+ else
+ config.mqtt_port = value;
}
if (config_lookup_string(config.cfg, "mqtt.username", &str)) {