Commit 9b1eba1f authored by Roman Ondráček's avatar Roman Ondráček

IQRF net: disable FRC embedded peripheral configuration for DPA 4.xx, rename...

IQRF net: disable FRC embedded peripheral configuration for DPA 4.xx, rename TR configuration write button (fix #220)
Signed-off-by: Roman Ondráček's avatarRoman Ondráček <ondracek.roman@centrum.cz>
parent 2e12ad4c
Pipeline #2305 failed with stages
in 6 minutes and 15 seconds
......@@ -27,6 +27,7 @@ use App\IqrfNetModule\Exceptions\UserErrorException;
use App\IqrfNetModule\Models\TrConfigManager;
use App\IqrfNetModule\Presenters\TrConfigPresenter;
use Nette\Application\UI\Form;
use Nette\Forms\Controls\Checkbox;
use Nette\Forms\Controls\TextInput;
use Nette\SmartObject;
use Nette\Utils\JsonException;
......@@ -190,10 +191,22 @@ class TrConfigFormFactory {
}
}
}
$changeablePeripherals = ['eeprom', 'eeeprom', 'ram', 'ledr', 'ledg', 'spi', 'io', 'thermometer', 'uart', 'frc'];
$changeablePeripherals = ['eeprom', 'eeeprom', 'ram', 'ledr', 'ledg', 'spi', 'io', 'thermometer', 'uart'];
foreach ($changeablePeripherals as $peripheral) {
$embeddedPeripherals->addCheckbox($peripheral, 'embPers.' . $peripheral);
}
$dpaVersion = $this->presenter->template->dpaVersion ?? '99.99';
if (version_compare($dpaVersion, '4.00', '>=')) {
if ($this->presenter->getUser()->isInRole('power')) {
$frc = $embeddedPeripherals->addCheckbox('frc', 'embPers.frc')
->setDisabled();
if (isset($this->configuration->embPers)) {
$frc->setDefaultValue($this->configuration->embPers->frc);
}
}
} else {
$embeddedPeripherals->addCheckbox('frc', 'embPers.frc');
}
}
/**
......
......@@ -27,6 +27,7 @@ use App\IqrfNetModule\Exceptions\UserErrorException;
use App\IqrfNetModule\Forms\ChangeAddressFormFactory;
use App\IqrfNetModule\Forms\SecurityFormFactory;
use App\IqrfNetModule\Forms\TrConfigFormFactory;
use App\IqrfNetModule\Models\EnumerationManager;
use App\IqrfNetModule\Models\TrConfigManager;
use Nette\Application\UI\Form;
use Nette\Utils\JsonException;
......@@ -54,6 +55,11 @@ class TrConfigPresenter extends ProtectedPresenter {
*/
public $securityFormFactory;
/**
* @var EnumerationManager IQRF TR enumeration manager
*/
private $enumerationManager;
/**
* @var TrConfigManager IQRF TR configuration manager
*/
......@@ -61,9 +67,11 @@ class TrConfigPresenter extends ProtectedPresenter {
/**
* Constructor
* @param EnumerationManager $enumerationManager IQRF TR enumeration manager
* @param TrConfigManager $manager IQRF TR configuration manager
*/
public function __construct(TrConfigManager $manager) {
public function __construct(EnumerationManager $enumerationManager, TrConfigManager $manager) {
$this->enumerationManager = $enumerationManager;
$this->manager = $manager;
parent::__construct();
}
......@@ -97,7 +105,11 @@ class TrConfigPresenter extends ProtectedPresenter {
*/
public function loadConfiguration(): void {
try {
$dpa = $this->manager->read((int) $this->getParameter('address'));
$address = (int) $this->getParameter('address');
$enumeration = $this->enumerationManager->device($address);
$dpaVersion = $enumeration['response']->data->rsp->peripheralEnumeration->dpaVer ?? '99.99';
$this->template->dpaVersion = ltrim($dpaVersion, '0');
$dpa = $this->manager->read($address);
if (!array_key_exists('response', $dpa)) {
$this->template->configuration = null;
$this->flashError('iqrfnet.trConfiguration.read.failure');
......
......@@ -175,7 +175,7 @@ trConfig:
rfChannel916: RF Channel has to be in range from 0 to 255.
rxFilter: RX filter have to be integer from 0 to 63.
txPower: TX Power have to be integer from 0 to 7.
save: Save
save: Write
security:
title: Security
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment