1. Go to this page and download the library: Download rossel/mwu-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rossel / mwu-sdk example snippets
$config = new \Rossel\MwuSdk\Dto\Client\DefaultConfiguration\MwuConfig(
[
new \Rossel\MwuSdk\Dto\Client\DefaultConfiguration\Infrastructure\SwitchConfig(
ipAddress: '144.56.46.30',
port: 5003,
lightModulesGeneratorConfig: new \Rossel\MwuSdk\Dto\Client\DefaultConfiguration\Infrastructure\LightModulesGeneratorConfig(
firstModuleId: 1,
incrementBetweenModuleIds: 1,
numberOfModules: 4,
)
),
],
// ...
);
use MwuSdk\Builder\Command\Write\WriteCommandBuilder;use MwuSdk\Client\MwuLightModule\MwuLightModuleInterface;use MwuSdk\Enum\ConfigurationParameterValues\Display\LightColor;use MwuSdk\Enum\ConfigurationParameterValues\Display\LightMode;use MwuSdk\Factory\Entity\Command\Client\Write\WriteCommandModeArrayFactory;
class MyClass {
public function __construct(
private WriteCommandModeArrayFactory $writeCommandModeArrayFactory,
) {
}
public function myFunction(
MwuLightModuleInterface $lightModule,
): void {
$commandBuilder = new WriteCommandBuilder($this->writeCommandModeArrayFactory);
// Optional: Configure the builder as you want, so that the generated commands follow these specifications.
$commandBuilder
->withLightColor(LightColor::RED)
->withLightMode(LightMode::FLASH);
// Send a "write" instruction to the light module.
$lightModule->write($commandBuilder, '0001');
}
}
use MwuSdk\Builder\Command\Write\WriteCommandBuilder;use MwuSdk\Client\MwuSwitch\MwuSwitchInterface;use MwuSdk\Enum\ConfigurationParameterValues\Display\LightColor;use MwuSdk\Enum\ConfigurationParameterValues\Display\LightMode;use MwuSdk\Factory\Entity\Command\Client\Write\WriteCommandModeArrayFactory;
class MyClass {
public function __construct(
private WriteCommandModeArrayFactory $writeCommandModeArrayFactory,
) {
}
public function myFunction(
MwuSwitchInterface $switch,
): void {
$commandBuilder = new WriteCommandBuilder($this->writeCommandModeArrayFactory);
// Optional: Configure the builder as you want, so that the generated commands follow these specifications.
$commandBuilder
->withLightColor(LightColor::RED)
->withLightMode(LightMode::FLASH);
// Method 1: Send a "write" instruction to the specified light modules connected to the switch.
$switch->write(
$switch->getLightModulesByIds([1, 2, 3])
$commandBuilder,
'0001',
);
// Method 2: Send a "write" instruction to all the light modules connected to the switch.
$switch->broadcastWrite($commandBuilder, '0001');
}
}
class MwuService extends \MwuSdk\Client\Mwu\Mwu {
}
use MwuSdk\Builder\Command\Write\WriteCommandBuilder;use MwuSdk\Client\Mwu\MwuServiceInterface;use MwuSdk\Enum\ConfigurationParameterValues\Display\LightColor;use MwuSdk\Enum\ConfigurationParameterValues\Display\LightMode;use MwuSdk\Factory\Entity\Command\Client\Write\WriteCommandModeArrayFactory;
class MyClass {
public function __construct(
private WriteCommandModeArrayFactory $writeCommandModeArrayFactory,
) {
}
public function myFunction(
MwuServiceInterface $mwuService
): void {
$commandBuilder = new WriteCommandBuilder($this->writeCommandModeArrayFactory);
// Optional: Configure the builder as you want, so that the generated commands follow these specifications.
$commandBuilder
->withLightColor(LightColor::RED)
->withLightMode(LightMode::FLASH);
// Method 1: Send a "write" instruction to all light modules connected to the specified switches.
$mwuService->write(
[
$mwu->getSwitchById(0),
$mwu->getSwitchById(1),
],
$commandBuilder,
'0001'
);
// Method 2: Send a "write" instruction to all light modules of all connected switches.
$mwuService->broadcastWrite($commandBuilder, $commandBuilder, '0001');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.