Skip to content

Latest commit

 

History

History
282 lines (190 loc) · 5.15 KB

Documentation.md

File metadata and controls

282 lines (190 loc) · 5.15 KB

Radio Class

Basic usage

$Radio = new Radio($host,$pin);

Node Values

Get the value of an node

$Radio->GetSet('netRemote.nav.state');

Set the value of an node

$Radio->GetSet('netRemote.nav.state',1);

Node Lists

Get all list entries

$Radio->GetSetList('netRemote.nav.presets');

Select a list entry

$Radio->GetSetList('netRemote.nav.presets',1);

Simple usage

Toggle

Toggle the state of an node

$Radio->toggle('netRemote.nav.state');

Volume

Set the devices volume to 5

$Radio->volume(5);

Increase the volume

$Radio->volume('up');

Decrease the volume

$Radio->volume('down');

Radio

Tune the radio frequency in mhz

$Radio->radioFrequency(106.4);

Switches

switches can have the arguments 'toggle', 'on' or 'off'

toggle the power state of the device

$Radio->power('toggle');

sets the power state of the device to on

$Radio->power('on');

sets the power state of the device to off

$Radio->power('off');

The following switches are implemented

$Radio->power($value); // sets  / toglles the power state
$Radio->mute($value); // sets / toggles the mute state
$Radio->shuffle($value); // sets / toggles the shuffle state

Lists

Lists have a setter and a getter method.

List all modes known on the device

$Radio->listModes();

Select the mode 2 from the above list

$Radio->selectMode(2);

For some lists it is necessary to activate the navigation:

$Radio->setNavState(1);

You can count the available navigation items with:

$Radio->numItems();

The following Lists are implemented

$Radio->listModes(); // List all modes
$Radio->selectMode($value); // Select list entry from modes list

$Radio->listEqs(); // List all equalizers
$Radio->selectEq($value); // Select list entry from equalizer list

$Radio->listFavs(); // List all favorites
$Radio->selectFav($value); // Select list entry from favorites list

$Radio->listNavs(); // List all navigation items
$Radio->selectNav($value); // Select list entry from navigation list

The following Lists are implemented and can not be set

$Radio->listDabFreqs(); // List all fab frequencies

$Radio->listEqBands(); // List all equalizer bands

Controls

Controls determines the state of the radio

$Radio->control('stop');
$Radio->control('play');
$Radio->control('pause');
$Radio->control('next');
$Radio->control('previous');

SSDP Class

Basic usage

To create an SSDP object you have to create a Scanner object first. This is to be able to mock the scanner result for unit-tests.

$Scanner = new Scanner();
$SSDP = new SSDP($Scanner);

Now you can perform an SSDP Scan on the given sheme.

$response = $SSDP->doScan('urn:schemas-frontier-silicon-com:fs_reference:fsapi:1');

FSAPI Class

To create an FSAPI object you have to create a Request object first. This is to be able to mock the response from the device for unit-tests.

$Request = new Request($host,$session_id,$pin);
$FSAPI = new FSAPI($Request);

Now you can send requests to the device to get a session-id

$response = $FSAPI->doRequest('CREATE_SESSION');
$Request->setSID($response);

or get a nodes value:

$response = $FSAPI->doRequest('GET',$node);

or set a nodes value:

$response = $FSAPI->doRequest('SET',$node,array('value' => $value));

or get list entries

$response = $FSAPI->doRequest('LIST_GET_NEXT',$node,array('maxItems' => 100), -1);

Advanced usage

List Setters

Lists have a special node to select an list entry. To avoid hardcoding this, the node object knows its setter node.

$NodesFactory = new NodesFactory();
$Node = $NodesFactory->getNodeByName($node);
$Setter = $Node->getSetter();
$response = $FSAPI->doRequest('LIST_GET_NEXT',$Setter,array('maxItems' => 100), -1);

In some lists there is a setter based on the entry type. In this case the node knows a Setter for each type-index, which is provided in the list answer

$response = $FSAPI->doRequest('LIST_GET_NEXT',$node,array('maxItems' => 100), -1);

The simplified result will look like this

array(0 => array('type' => 1));

which leads to

$value = 0;
$item_type = 1;

which can be used to determine the right setter and set the value

$NodesFactory = new NodesFactory();
$Node = $NodesFactory->getNodeByName($node);
$Setter = $Node->getSetter($item_type);
$response = $FSAPI->doRequest('SET',$Setter,array('value' => $value));

Converters

Converters are used to translate the output and input values from and to a human radable format. This is done with a static translation table in the node definition.

$Converter = $Node->getConverter();
$value = $Converter->convertInput($value);
$Converter = $Node->getConverter();
$value = $Converter->convertOutput($value);

In some cases you want to control this behavior from the outside of the node.

$Converter = $Node->getConverter();
$Converter->setTranslationTable(array(0 => 'zero', 1 => 'one'));
$value = $Converter->convertOutput($value);