mirror of
https://github.com/nymea/nymea-plugins.git
synced 2026-08-05 03:33:51 +02:00
added some comments
This commit is contained in:
parent
24163c75b1
commit
85d75b0ee7
@ -71,6 +71,7 @@ DevicePluginUdpCommander::DevicePluginUdpCommander()
|
|||||||
DeviceManager::DeviceSetupStatus DevicePluginUdpCommander::setupDevice(Device *device)
|
DeviceManager::DeviceSetupStatus DevicePluginUdpCommander::setupDevice(Device *device)
|
||||||
{
|
{
|
||||||
// check port
|
// check port
|
||||||
|
// TODO ports used by an input should be available for outputs and vice versa
|
||||||
if ((device->deviceClassId() == udpInputDeviceClassId) || (device->deviceClassId() == udpOutputDeviceClassId)) {
|
if ((device->deviceClassId() == udpInputDeviceClassId) || (device->deviceClassId() == udpOutputDeviceClassId)) {
|
||||||
bool portOk = false;
|
bool portOk = false;
|
||||||
int port = device->paramValue(portParamTypeId).toInt(&portOk);
|
int port = device->paramValue(portParamTypeId).toInt(&portOk);
|
||||||
@ -117,15 +118,7 @@ DeviceManager::DeviceError DevicePluginUdpCommander::executeAction(Device *devic
|
|||||||
|
|
||||||
void DevicePluginUdpCommander::deviceRemoved(Device *device)
|
void DevicePluginUdpCommander::deviceRemoved(Device *device)
|
||||||
{
|
{
|
||||||
if (device->deviceClassId() == udpInputDeviceClassId) {
|
if ((device->deviceClassId() == udpInputDeviceClassId) || (device->deviceClassId() == udpOutputDeviceClassId)){
|
||||||
|
|
||||||
QUdpSocket *socket = m_commanderList.key(device);
|
|
||||||
m_commanderList.remove(socket);
|
|
||||||
|
|
||||||
socket->close();
|
|
||||||
socket->deleteLater();
|
|
||||||
}
|
|
||||||
if (device->deviceClassId() == udpOutputDeviceClassId) {
|
|
||||||
|
|
||||||
QUdpSocket *socket = m_commanderList.key(device);
|
QUdpSocket *socket = m_commanderList.key(device);
|
||||||
m_commanderList.remove(socket);
|
m_commanderList.remove(socket);
|
||||||
@ -151,6 +144,7 @@ void DevicePluginUdpCommander::readPendingDatagrams()
|
|||||||
|
|
||||||
device->setStateValue(inputDataStateTypeId, datagram);
|
device->setStateValue(inputDataStateTypeId, datagram);
|
||||||
|
|
||||||
|
//TO CHECK remove command param and event, comparison may be done in the rule engine
|
||||||
if (datagram == device->paramValue(commandParamTypeId).toByteArray() ||
|
if (datagram == device->paramValue(commandParamTypeId).toByteArray() ||
|
||||||
datagram == device->paramValue(commandParamTypeId).toByteArray() + "\n") {
|
datagram == device->paramValue(commandParamTypeId).toByteArray() + "\n") {
|
||||||
qCDebug(dcUdpCommander) << device->name() << " got command from" << sender.toString() << senderPort;
|
qCDebug(dcUdpCommander) << device->name() << " got command from" << sender.toString() << senderPort;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user