change code in all function

This commit is contained in:
Marko Oldenburg 2021-04-10 16:24:01 +02:00
parent 9e17e9eb68
commit 9fe9ff002f

View File

@ -134,39 +134,6 @@ if ($@) {
} }
} }
# Declare functions
sub LGTV_WebOS_Initialize($);
sub LGTV_WebOS_Define($$);
sub LGTV_WebOS_Undef($$);
sub LGTV_WebOS_Set($@);
sub LGTV_WebOS_Open($);
sub LGTV_WebOS_Close($);
sub LGTV_WebOS_Read($);
sub LGTV_WebOS_Write($@);
sub LGTV_WebOS_Attr(@);
sub LGTV_WebOS_Handshake($);
sub LGTV_WebOS_ResponseProcessing($$);
sub LGTV_WebOS_Header2Hash($);
sub LGTV_WebOS_Pairing($);
sub LGTV_WebOS_CreateSendCommand($$$;$);
sub LGTV_WebOS_Hybi10Encode($;$$);
sub LGTV_WebOS_WriteReadings($$);
sub LGTV_WebOS_GetCurrentChannel($);
sub LGTV_WebOS_GetForgroundAppInfo($);
sub LGTV_WebOS_GetAudioStatus($);
sub LGTV_WebOS_TimerStatusRequest($);
sub LGTV_WebOS_GetExternalInputList($);
sub LGTV_WebOS_ProcessRead($$);
sub LGTV_WebOS_ParseMsg($$);
sub LGTV_WebOS_Get3DStatus($);
sub LGTV_WebOS_GetChannelProgramInfo($);
sub LGTV_WebOS_FormartStartEndTime($);
sub LGTV_WebOS_Presence($);
sub LGTV_WebOS_PresenceRun($);
sub LGTV_WebOS_PresenceDone($);
sub LGTV_WebOS_PresenceAborted($);
sub LGTV_WebOS_WakeUp_Udp($@);
my %lgCommands = ( my %lgCommands = (
"getServiceList" => ["ssap://api/getServiceList"], "getServiceList" => ["ssap://api/getServiceList"],
@ -236,7 +203,7 @@ my %openApps = (
my %openAppsPackageName = reverse %openApps; my %openAppsPackageName = reverse %openApps;
sub LGTV_WebOS_Initialize($) { sub LGTV_WebOS_Initialize {
my ($hash) = @_; my ($hash) = @_;
@ -261,7 +228,7 @@ sub LGTV_WebOS_Initialize($) {
return FHEM::Meta::InitMod( __FILE__, $hash ); return FHEM::Meta::InitMod( __FILE__, $hash );
} }
sub LGTV_WebOS_Define($$) { sub LGTV_WebOS_Define {
my ( $hash, $def ) = @_; my ( $hash, $def ) = @_;
@ -306,7 +273,7 @@ sub LGTV_WebOS_Define($$) {
return undef; return undef;
} }
sub LGTV_WebOS_Undef($$) { sub LGTV_WebOS_Undef {
my ( $hash, $arg ) = @_; my ( $hash, $arg ) = @_;
@ -323,7 +290,7 @@ sub LGTV_WebOS_Undef($$) {
return undef; return undef;
} }
sub LGTV_WebOS_Attr(@) { sub LGTV_WebOS_Attr {
my ( $cmd, $name, $attrName, $attrVal ) = @_; my ( $cmd, $name, $attrName, $attrVal ) = @_;
my $hash = $defs{$name}; my $hash = $defs{$name};
@ -360,7 +327,7 @@ sub LGTV_WebOS_Attr(@) {
return undef; return undef;
} }
sub LGTV_WebOS_TimerStatusRequest($) { sub LGTV_WebOS_TimerStatusRequest {
my $hash = shift; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -440,7 +407,7 @@ sub LGTV_WebOS_TimerStatusRequest($) {
$hash ); $hash );
} }
sub LGTV_WebOS_Set($@) { sub LGTV_WebOS_Set {
my ( $hash, $name, $cmd, @args ) = @_; my ( $hash, $name, $cmd, @args ) = @_;
my ( $arg, @params ) = @args; my ( $arg, @params ) = @args;
@ -673,7 +640,7 @@ sub LGTV_WebOS_Set($@) {
LGTV_WebOS_CreateSendCommand( $hash, $uri, \%payload ); LGTV_WebOS_CreateSendCommand( $hash, $uri, \%payload );
} }
sub LGTV_WebOS_Open($) { sub LGTV_WebOS_Open {
my $hash = shift; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -703,7 +670,7 @@ sub LGTV_WebOS_Open($) {
} }
sub LGTV_WebOS_Close($) { sub LGTV_WebOS_Close {
my $hash = shift; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -720,7 +687,7 @@ sub LGTV_WebOS_Close($) {
Log3 $name, 4, "LGTV_WebOS ($name) - Socket Disconnected"; Log3 $name, 4, "LGTV_WebOS ($name) - Socket Disconnected";
} }
sub LGTV_WebOS_Write($@) { sub LGTV_WebOS_Write {
my ( $hash, $string ) = @_; my ( $hash, $string ) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -735,7 +702,7 @@ sub LGTV_WebOS_Write($@) {
return undef; return undef;
} }
sub LGTV_WebOS_Read($) { sub LGTV_WebOS_Read {
my $hash = shift; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -784,7 +751,7 @@ sub LGTV_WebOS_Read($) {
} }
} }
sub LGTV_WebOS_ProcessRead($$) { sub LGTV_WebOS_ProcessRead {
my ( $hash, $data ) = @_; my ( $hash, $data ) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -853,7 +820,7 @@ sub LGTV_WebOS_ProcessRead($$) {
Log3 $name, 5, "LGTV_WebOS ($name) - PARTIAL: " . $hash->{PARTIAL}; Log3 $name, 5, "LGTV_WebOS ($name) - PARTIAL: " . $hash->{PARTIAL};
} }
sub LGTV_WebOS_Handshake($) { sub LGTV_WebOS_Handshake {
my $hash = shift; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -882,7 +849,7 @@ sub LGTV_WebOS_Handshake($) {
Log3 $name, 4, "LGTV_WebOS ($name) - start pairing routine"; Log3 $name, 4, "LGTV_WebOS ($name) - start pairing routine";
} }
sub LGTV_WebOS_ResponseProcessing($$) { sub LGTV_WebOS_ResponseProcessing {
my ( $hash, $response ) = @_; my ( $hash, $response ) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -964,7 +931,7 @@ sub LGTV_WebOS_ResponseProcessing($$) {
Log3 $name, 4, "LGTV_WebOS ($name) - no Match found"; Log3 $name, 4, "LGTV_WebOS ($name) - no Match found";
} }
sub LGTV_WebOS_WriteReadings($$) { sub LGTV_WebOS_WriteReadings {
my ( $hash, $decode_json ) = @_; my ( $hash, $decode_json ) = @_;
@ -1255,7 +1222,7 @@ sub LGTV_WebOS_WriteReadings($$) {
readingsEndUpdate( $hash, 1 ); readingsEndUpdate( $hash, 1 );
} }
sub LGTV_WebOS_Pairing($) { sub LGTV_WebOS_Pairing {
my $hash = shift; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -1336,7 +1303,7 @@ sub LGTV_WebOS_Pairing($) {
Log3 $name, 4, "LGTV_WebOS ($name) - Send pairing informations"; Log3 $name, 4, "LGTV_WebOS ($name) - Send pairing informations";
} }
sub LGTV_WebOS_CreateSendCommand($$$;$) { sub LGTV_WebOS_CreateSendCommand {
my ( $hash, $uri, $payload, $type ) = @_; my ( $hash, $uri, $payload, $type ) = @_;
@ -1364,12 +1331,12 @@ sub LGTV_WebOS_CreateSendCommand($$$;$) {
return undef; return undef;
} }
sub LGTV_WebOS_Hybi10Encode($;$$) { sub LGTV_WebOS_Hybi10Encode {
my ( $payload, $type, $masked ) = @_; my $payload = shift;
my $type = shift // 'text';
my $masked = shift // 1;
$type //= "text";
$masked //= 1;
my @frameHead; my @frameHead;
my $frame = ""; my $frame = "";
@ -1465,7 +1432,7 @@ sub LGTV_WebOS_Hybi10Encode($;$$) {
return $frame; return $frame;
} }
sub LGTV_WebOS_GetAudioStatus($) { sub LGTV_WebOS_GetAudioStatus {
my $hash = shift; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -1476,7 +1443,7 @@ sub LGTV_WebOS_GetAudioStatus($) {
if ( $hash->{helper}{device}{runsetcmd} == 0 ); if ( $hash->{helper}{device}{runsetcmd} == 0 );
} }
sub LGTV_WebOS_GetCurrentChannel($) { sub LGTV_WebOS_GetCurrentChannel {
my $hash = shift; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -1488,7 +1455,7 @@ sub LGTV_WebOS_GetCurrentChannel($) {
if ( $hash->{helper}{device}{runsetcmd} == 0 ); if ( $hash->{helper}{device}{runsetcmd} == 0 );
} }
sub LGTV_WebOS_GetForgroundAppInfo($) { sub LGTV_WebOS_GetForgroundAppInfo {
my $hash = shift; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -1501,7 +1468,7 @@ sub LGTV_WebOS_GetForgroundAppInfo($) {
if ( $hash->{helper}{device}{runsetcmd} == 0 ); if ( $hash->{helper}{device}{runsetcmd} == 0 );
} }
sub LGTV_WebOS_GetExternalInputList($) { sub LGTV_WebOS_GetExternalInputList {
my $hash = shift; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -1514,7 +1481,7 @@ sub LGTV_WebOS_GetExternalInputList($) {
if ( $hash->{helper}{device}{runsetcmd} == 0 ); if ( $hash->{helper}{device}{runsetcmd} == 0 );
} }
sub LGTV_WebOS_Get3DStatus($) { sub LGTV_WebOS_Get3DStatus {
my $hash = shift; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -1526,7 +1493,7 @@ sub LGTV_WebOS_Get3DStatus($) {
if ( $hash->{helper}{device}{runsetcmd} == 0 ); if ( $hash->{helper}{device}{runsetcmd} == 0 );
} }
sub LGTV_WebOS_GetChannelProgramInfo($) { sub LGTV_WebOS_GetChannelProgramInfo {
my $hash = shift; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -1541,9 +1508,10 @@ sub LGTV_WebOS_GetChannelProgramInfo($) {
############################################# #############################################
### my little Helper ### my little Helper
sub LGTV_WebOS_ParseMsg($$) { sub LGTV_WebOS_ParseMsg {
my ( $hash, $buffer ) = @_; my $hash = shift;
my $buffer = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $open = 0; my $open = 0;
@ -1593,7 +1561,7 @@ sub LGTV_WebOS_ParseMsg($$) {
return ( $msg, $tail ); return ( $msg, $tail );
} }
sub LGTV_WebOS_Header2Hash($) { sub LGTV_WebOS_Header2Hash {
my $string = shift; my $string = shift;
my %hash = (); my %hash = ();
@ -1609,7 +1577,7 @@ sub LGTV_WebOS_Header2Hash($) {
return \%hash; return \%hash;
} }
sub LGTV_WebOS_FormartStartEndTime($) { sub LGTV_WebOS_FormartStartEndTime {
my $string = shift; my $string = shift;
@ -1620,7 +1588,7 @@ sub LGTV_WebOS_FormartStartEndTime($) {
} }
############ Presence Erkennung Begin ################# ############ Presence Erkennung Begin #################
sub LGTV_WebOS_Presence($) { sub LGTV_WebOS_Presence {
my $hash = shift; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -1631,7 +1599,7 @@ sub LGTV_WebOS_Presence($) {
unless ( exists( $hash->{helper}{RUNNING_PID} ) ); unless ( exists( $hash->{helper}{RUNNING_PID} ) );
} }
sub LGTV_WebOS_PresenceRun($) { sub LGTV_WebOS_PresenceRun {
my $string = shift; my $string = shift;
my ( $name, $host ) = split( "\\|", $string ); my ( $name, $host ) = split( "\\|", $string );
@ -1665,9 +1633,9 @@ sub LGTV_WebOS_PresenceRun($) {
return $response; return $response;
} }
sub LGTV_WebOS_PresenceDone($) { sub LGTV_WebOS_PresenceDone {
my ($string) = @_; my $string = shift;
my ( $name, $response ) = split( "\\|", $string ); my ( $name, $response ) = split( "\\|", $string );
my $hash = $defs{$name}; my $hash = $defs{$name};
@ -1686,9 +1654,9 @@ sub LGTV_WebOS_PresenceDone($) {
Log3 $name, 4, "Sub LGTV_WebOS_PresenceDone ($name) - presence done"; Log3 $name, 4, "Sub LGTV_WebOS_PresenceDone ($name) - presence done";
} }
sub LGTV_WebOS_PresenceAborted($) { sub LGTV_WebOS_PresenceAborted {
my ($hash) = @_; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
delete( $hash->{helper}{RUNNING_PID} ); delete( $hash->{helper}{RUNNING_PID} );
@ -1698,9 +1666,10 @@ sub LGTV_WebOS_PresenceAborted($) {
"Sub LGTV_WebOS_PresenceAborted ($name) - The BlockingCall Process terminated unexpectedly. Timedout!"; "Sub LGTV_WebOS_PresenceAborted ($name) - The BlockingCall Process terminated unexpectedly. Timedout!";
} }
sub LGTV_WebOS_SocketClosePresenceAbsent($$) { sub LGTV_WebOS_SocketClosePresenceAbsent {
my ( $hash, $presence ) = @_; my $hash = shift;
my $presence = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -1710,7 +1679,7 @@ sub LGTV_WebOS_SocketClosePresenceAbsent($$) {
# Sobald pingPresence absent meldet und der Socket noch steht soll er geschlossen werden, da sonst FHEM nach 4-6 min für 10 min blockiert # Sobald pingPresence absent meldet und der Socket noch steht soll er geschlossen werden, da sonst FHEM nach 4-6 min für 10 min blockiert
} }
sub LGTV_WebOS_WakeUp_Udp($@) { sub LGTV_WebOS_WakeUp_Udp {
my ( $hash, $mac_addr, $host, $port ) = @_; my ( $hash, $mac_addr, $host, $port ) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};