Skip to content

Commit

Permalink
now the right one
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJL committed Sep 4, 2016
1 parent 6ace051 commit 25bdc42
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions mqttGateway2.pl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
# Created by Ivo Pullens, Emmission, 2014-2016 -- www.emmission.nl
#
# Tested with:
# * MySensors 2.0.0
# * MySensors 1.5.x
# * Mosquitto 1.4.2 MQTT Broker (mosquitto.org)
# * Ubuntu Linux 12.04.5 & 15.10.
# * CentOS 6.x
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -47,7 +49,7 @@
use List::Util qw(first);
use Storable;
use Time::Zone;
use v5.14; # Requires support for given/when constructs
use v5.10; # Requires support for given/when constructs
use Device::SerialPort;
use Getopt::Long;
use Fcntl ':flock';
Expand Down Expand Up @@ -270,10 +272,10 @@ sub subTypeToStr
# Convert subtype to string, depending on message type
given ($cmd)
{
$subType = (sensorTypesToStr)[$subType] when C_PRESENTATION;
$subType = (variableTypesToStr)[$subType] when C_SET;
$subType = (variableTypesToStr)[$subType] when C_REQ;
$subType = (internalMessageTypesToStr)[$subType] when C_INTERNAL;
when (C_PRESENTATION) { $subType = (sensorTypesToStr)[$subType]; }
when (C_SET) { $subType = (variableTypesToStr)[$subType]; }
when (C_REQ) { $subType = (variableTypesToStr)[$subType]; }
when (C_INTERNAL) { $subType = (internalMessageTypesToStr)[$subType]; }
default { $subType = "<UNKNOWN_$subType>" }
}
return $subType;
Expand Down Expand Up @@ -499,7 +501,8 @@ sub onCtrlC
if ($useSerial)
{
$gw_handle = AnyEvent::Handle->new(
fh => $serialDevice->{'HANDLE'},
# fh => $serialDevice->{'HANDLE'},
fh => new_from_fd IO::Handle( $serialDevice->{FD}, "w" ),
on_error => sub {
my ($handle, $fatal, $message) = @_;
$handle->destroy;
Expand Down

0 comments on commit 25bdc42

Please sign in to comment.