70_PHTV: refactoring pairing request structures

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@13450 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2017-02-19 15:56:54 +00:00
parent 672bbb18e4
commit b77c57fc20

View File

@ -360,11 +360,14 @@ sub PHTV_Set($@) {
return "Not in pairing mode"
unless ( defined( $hash->{pairing} )
&& defined( $hash->{pairing}{auth_key} )
&& defined( $hash->{pairing}{timestamp} ) );
&& defined( $hash->{pairing}{timestamp} )
&& defined( $hash->{pairing}{request} )
&& defined( $hash->{pairing}{request}{device} ) );
readingsSingleUpdate( $hash, "state", "pairing-grant", 1 );
$hash->{pairing}{grant} = {
auth => {
auth_AppId => 1,
pin => trim( $a[2] ),
auth_timestamp => $hash->{pairing}{timestamp},
@ -373,6 +376,8 @@ sub PHTV_Set($@) {
$a[2],
"ZmVay1EQVFOaZhwQ4Kv81ypLAZNczV9sG4KkseXWn1NEk6cXmPKO/MCa9sryslvLCFMnNe4Z4CPXzToowvhHvA=="
),
},
device => $hash->{pairing}{request}{device},
};
PHTV_SendCommand( $hash, "pair/grant", $hash->{pairing}{grant} );
}
@ -1705,13 +1710,15 @@ sub PHTV_ReceiveCommand($$$) {
delete $hash->{PAIRING_BEGIN} if ( defined( $hash->{PAIRING_BEGIN} ) );
delete $hash->{PAIRING_END} if ( defined( $hash->{PAIRING_END} ) );
$hash->{pairing}{request} = {
device => {
device_name => 'fhem',
device_os => 'Android',
app_name => 'FHEM PHTV',
type => 'native',
scope => [ "read", "write", "control" ],
app_id => 'org.fhem.PHTV',
id => $device_id,
},
scope => [ "read", "write", "control" ],
};
PHTV_SendCommand( $hash, "pair/request", $hash->{pairing}{request} );