Skip to content

Commit

Permalink
Merge pull request #1 from aschor/rl-06
Browse files Browse the repository at this point in the history
add mqtt user/pass feature
  • Loading branch information
RalfJL authored Oct 24, 2018
2 parents 71ceb2d + 9eb0aa3 commit ce06b20
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mqttGateway2.pl
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ sub imessageTypeToIdx {
my $mqttHost = 'localhost'; # Hostname of MQTT broker
my $mqttPort = 1883; # Port of MQTT broker
my $mqttClientId = "MySensors-".$$; # Unique client ID to broker
my $mqttUser = undef;
my $mqttPasswd = undef;

# -- Settings when using Ethernet gateway
my $mysnsHost = undef; # IP of MySensors Ethernet gateway
Expand Down Expand Up @@ -189,6 +191,8 @@ sub imessageTypeToIdx {
'topic2node:s' => \$topic2node,
'mqtthost:s' => \$mqttHost,
'mqttport:i' => \$mqttPort,
'mqttuser:s' => \$mqttUser,
'mqttpasswd:s' => \$mqttPasswd,
'gwhost:s' => \$mysnsHost,
'gwport:i' => \$mysnsPort,
'storage:s' => \$subscriptionStorageFile,
Expand Down Expand Up @@ -750,6 +754,8 @@ sub onSigHUP {
host => $mqttHost,
port => $mqttPort,
keep_alive_timer => $keep_alive_timer,
user_name => $mqttUser,
password => $mqttPasswd,
on_error => sub {
my ($fatal, $message) = @_;
if ($fatal) {
Expand Down Expand Up @@ -872,7 +878,7 @@ sub PrintHelpAndExit
Usage: mqttGateway2 [--serial dev [--baud baudrate] [--bits bits] [--parity [none|odd|even]] [--stop numbits]]
[--gwhost hostip [--gwport port]]
[--root mqttroot] [--topicC2N mqttcontrq] [--topic2node mqttnodeq]
[--mqtthost mqtthost] [--mqttport mqttport]
[--mqtthost mqtthost] [--mqttport mqttport] [--mqttuser mqttuser] [--mqttpasswd mqttpassword]
[--storage file] [--log file]
mqttGateway2 --help
Expand All @@ -893,6 +899,8 @@ sub PrintHelpAndExit
--topic2node MQTT topic used to send any message to a sensor node, defaults to /mySensors2node
--mqtthost IP address of MQTT broker, defaults to localhost
--mqttport Port of MQTT broker, defaults to 1883
--mqttuser the username used to authenticate to mqtt server
--mqttpasswd the password used to authenticate to mqtt server
--storage File used for storing active subscriptions, defaults to /var/run/mqttMySensors/Gateway_xxx
--log File to log to, defaults to stdout
If you do not have a controller and the gateway should assigne nodeID's
Expand All @@ -903,3 +911,4 @@ sub PrintHelpAndExit
SYNTAX
exit 1;
}

0 comments on commit ce06b20

Please sign in to comment.