mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
MQTT2_SERVER/MQTT2_CLIENT: addd topicConversion attribute (Forum #129206)
git-svn-id: https://svn.fhem.de/fhem/trunk@26405 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
df17a1fa41
commit
7c4caae9b3
@ -56,6 +56,7 @@ MQTT2_CLIENT_Initialize($)
|
|||||||
subscriptions
|
subscriptions
|
||||||
SSL
|
SSL
|
||||||
sslargs
|
sslargs
|
||||||
|
topicConversion:0,1
|
||||||
username
|
username
|
||||||
);
|
);
|
||||||
use warnings 'qw';
|
use warnings 'qw';
|
||||||
@ -517,7 +518,7 @@ MQTT2_CLIENT_Read($@)
|
|||||||
}
|
}
|
||||||
$val = substr($pl, $off);
|
$val = substr($pl, $off);
|
||||||
if($unicodeEncoding) {
|
if($unicodeEncoding) {
|
||||||
if(!$hash->{binaryTopicRegexp} || $tp !~ m/^$hash->{binaryTopicRegexp}$/) {
|
if(!$hash->{binaryTopicRegexp} || $tp !~ m/^$hash->{binaryTopicRegexp}$/){
|
||||||
$val = Encode::decode('UTF-8', $val);
|
$val = Encode::decode('UTF-8', $val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -530,10 +531,10 @@ MQTT2_CLIENT_Read($@)
|
|||||||
my $ir = AttrVal($name, "ignoreRegexp", undef);
|
my $ir = AttrVal($name, "ignoreRegexp", undef);
|
||||||
if(!defined($ir) || "$tp:$val" !~ m/$ir/) {
|
if(!defined($ir) || "$tp:$val" !~ m/$ir/) {
|
||||||
my $ac = AttrVal($name, "autocreate", "no");
|
my $ac = AttrVal($name, "autocreate", "no");
|
||||||
$ac = $ac eq "1" ? "simple" : ($ac eq "0" ? "no" : $ac); # backward comp.
|
$ac = $ac eq "1" ? "simple" : ($ac eq "0" ? "no" : $ac); #backward comp.
|
||||||
|
|
||||||
my $cid = makeDeviceName($hash->{clientId});
|
my $cid = makeDeviceName($hash->{clientId});
|
||||||
$tp =~ s/:/_/g; # 96608
|
$tp =~ s/:/_/g if(AttrVal($name, "topicConversion", 1)); # 96608
|
||||||
Dispatch($hash, "autocreate=$ac\0$cid\0$tp\0$val", undef, $ac eq "no");
|
Dispatch($hash, "autocreate=$ac\0$cid\0$tp\0$val", undef, $ac eq "no");
|
||||||
|
|
||||||
my $re = AttrVal($name, "rawEvents", undef);
|
my $re = AttrVal($name, "rawEvents", undef);
|
||||||
@ -942,6 +943,13 @@ MQTT2_CLIENT_feedTheList($$$)
|
|||||||
possible options documented in perldoc IO::Socket::SSL
|
possible options documented in perldoc IO::Socket::SSL
|
||||||
</li><br>
|
</li><br>
|
||||||
|
|
||||||
|
<a id="MQTT2_CLIENT-attr-topicConversion"></a>
|
||||||
|
<li>topicConversion [1|0]<br>
|
||||||
|
due to historic reasons colon (:) is converted in the topic to underscore
|
||||||
|
(_). Setting this attribute to 0 will disable this conversion. Default
|
||||||
|
is 1.
|
||||||
|
</li><br>
|
||||||
|
|
||||||
<a id="MQTT2_CLIENT-attr-username"></a>
|
<a id="MQTT2_CLIENT-attr-username"></a>
|
||||||
<li>username <username><br>
|
<li>username <username><br>
|
||||||
set the username. The password is set via the set command, and is stored
|
set the username. The password is set via the set command, and is stored
|
||||||
|
@ -49,6 +49,7 @@ MQTT2_SERVER_Initialize($)
|
|||||||
rawEvents
|
rawEvents
|
||||||
sslVersion
|
sslVersion
|
||||||
sslCertPrefix
|
sslCertPrefix
|
||||||
|
topicConversion:0,1
|
||||||
);
|
);
|
||||||
use warnings 'qw';
|
use warnings 'qw';
|
||||||
$hash->{AttrList} = join(" ", @attrList)." ".$readingFnAttributes;
|
$hash->{AttrList} = join(" ", @attrList)." ".$readingFnAttributes;
|
||||||
@ -540,8 +541,8 @@ MQTT2_SERVER_doPublish($$$$;$)
|
|||||||
# Save it
|
# Save it
|
||||||
my %nots = map { $_ => $server->{retain}{$_}{val} }
|
my %nots = map { $_ => $server->{retain}{$_}{val} }
|
||||||
keys %{$server->{retain}};
|
keys %{$server->{retain}};
|
||||||
my $rname = AttrVal($server->{NAME}, "hideRetain", 0) ? ".RETAIN" : "RETAIN";
|
my $rname = AttrVal($server->{NAME}, "hideRetain", 0) ? ".RETAIN":"RETAIN";
|
||||||
setReadingsVal($server, $rname, toJSON(\%nots), FmtDateTime(gettimeofday()));
|
setReadingsVal($server, $rname, toJSON(\%nots),FmtDateTime(gettimeofday()));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $clName (keys %{$server->{clients}}) {
|
foreach my $clName (keys %{$server->{clients}}) {
|
||||||
@ -553,7 +554,7 @@ MQTT2_SERVER_doPublish($$$$;$)
|
|||||||
return if(defined($ir) && "$tp:$val" =~ m/$ir/);
|
return if(defined($ir) && "$tp:$val" =~ m/$ir/);
|
||||||
|
|
||||||
my $cid = $src->{cid};
|
my $cid = $src->{cid};
|
||||||
$tp =~ s/:/_/g; # 96608
|
$tp =~ s/:/_/g if(AttrVal($serverName, "topicConversion", 1)); # 96608
|
||||||
if(defined($cid) || # "real" MQTT client
|
if(defined($cid) || # "real" MQTT client
|
||||||
AttrVal($serverName, "rePublish", undef)) {
|
AttrVal($serverName, "rePublish", undef)) {
|
||||||
$cid = $src->{NAME} if(!defined($cid));
|
$cid = $src->{NAME} if(!defined($cid));
|
||||||
@ -900,6 +901,13 @@ MQTT2_SERVER_ReadDebug($$)
|
|||||||
also the SSL attribute.
|
also the SSL attribute.
|
||||||
</li><br>
|
</li><br>
|
||||||
|
|
||||||
|
<a id="MQTT2_SERVER-attr-topicConversion"></a>
|
||||||
|
<li>topicConversion [1|0]<br>
|
||||||
|
due to historic reasons colon (:) is converted in the topic to underscore
|
||||||
|
(_). Setting this attribute to 0 will disable this conversion. Default
|
||||||
|
is 1.
|
||||||
|
</li><br>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
=end html
|
=end html
|
||||||
|
Loading…
x
Reference in New Issue
Block a user