mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
fix: Nanoleaf - Udp Network init was missing (#698)
* Fix Nanoleaf - Udp Network init was missing * ProviderUdp - Add init error handling
This commit is contained in:
parent
a2dbbcdd0d
commit
f955af29fd
@ -166,7 +166,7 @@ int LedDevice::updateLeds(const std::vector<ColorRgb>& ledValues)
|
|||||||
int retval = 0;
|
int retval = 0;
|
||||||
if ( !_deviceReady || _deviceInError)
|
if ( !_deviceReady || _deviceInError)
|
||||||
{
|
{
|
||||||
std::cout << "LedDevice::updateLeds(), LedDevice NOT ready!" << std::endl;
|
//std::cout << "LedDevice::updateLeds(), LedDevice NOT ready!" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -256,11 +256,18 @@ int LedDeviceNanoleaf::open()
|
|||||||
|
|
||||||
if ( init(_devConfig) )
|
if ( init(_devConfig) )
|
||||||
{
|
{
|
||||||
if ( initLeds() )
|
if ( !initNetwork() )
|
||||||
{
|
{
|
||||||
_deviceReady = true;
|
this->setInError( "UDP Network error!" );
|
||||||
setEnable(true);
|
}
|
||||||
retval = 0;
|
else
|
||||||
|
{
|
||||||
|
if ( initLeds() )
|
||||||
|
{
|
||||||
|
_deviceReady = true;
|
||||||
|
setEnable(true);
|
||||||
|
retval = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -76,10 +76,21 @@ bool ProviderUdp::init(const QJsonObject &deviceConfig)
|
|||||||
|
|
||||||
bool ProviderUdp::initNetwork()
|
bool ProviderUdp::initNetwork()
|
||||||
{
|
{
|
||||||
bool isInitOK = true;
|
bool isInitOK = false;
|
||||||
|
|
||||||
|
_udpSocket =new QUdpSocket(this);
|
||||||
|
|
||||||
|
if ( _udpSocket != nullptr)
|
||||||
|
{
|
||||||
|
QHostAddress localAddress = QHostAddress::Any;
|
||||||
|
quint16 localPort = 0;
|
||||||
|
if ( !_udpSocket->bind(localAddress, localPort) )
|
||||||
|
{
|
||||||
|
Warning ( _log, "Could not bind local address: %s", strerror(errno));
|
||||||
|
}
|
||||||
|
isInitOK = true;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Add Network-Error handling
|
|
||||||
_udpSocket = new QUdpSocket(this);
|
|
||||||
return isInitOK;
|
return isInitOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,17 +104,10 @@ int ProviderUdp::open()
|
|||||||
{
|
{
|
||||||
if ( ! initNetwork())
|
if ( ! initNetwork())
|
||||||
{
|
{
|
||||||
this->setInError( "Network error!" );
|
this->setInError( "UDP Network error!" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QHostAddress localAddress = QHostAddress::Any;
|
|
||||||
quint16 localPort = 0;
|
|
||||||
|
|
||||||
if ( !_udpSocket->bind(localAddress, localPort) )
|
|
||||||
{
|
|
||||||
Warning ( _log, "Could not bind local address: %s", strerror(errno));
|
|
||||||
}
|
|
||||||
// Everything is OK -> enable device
|
// Everything is OK -> enable device
|
||||||
_deviceReady = true;
|
_deviceReady = true;
|
||||||
setEnable(true);
|
setEnable(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user