fixed avr discovery
parent
6b1b22fa46
commit
4db6b6bddb
|
|
@ -64,9 +64,41 @@ Device::DeviceError DevicePluginDenon::discoverDevices(const DeviceClassId &devi
|
|||
Q_UNUSED(params)
|
||||
|
||||
if (deviceClassId == AVRX1000DeviceClassId) {
|
||||
if (!m_serviceBrowser) {
|
||||
m_serviceBrowser = hardwareManager()->zeroConfController()->createServiceBrowser();
|
||||
connect(m_serviceBrowser, &ZeroConfServiceBrowser::serviceEntryAdded, this, &DevicePluginDenon::onAvahiServiceEntryAdded);
|
||||
connect(m_serviceBrowser, &ZeroConfServiceBrowser::serviceEntryRemoved, this, &DevicePluginDenon::onAvahiServiceEntryRemoved);
|
||||
}
|
||||
QStringList discoveredIds;
|
||||
|
||||
UpnpDiscoveryReply *reply = hardwareManager()->upnpDiscovery()->discoverDevices("urn:schemas-upnp-org:device:MediaRenderer:1", "nymea", 7000);
|
||||
connect(reply, &UpnpDiscoveryReply::finished, this, &DevicePluginDenon::onUpnpDiscoveryFinished);
|
||||
QList<DeviceDescriptor> deviceDescriptors;
|
||||
foreach (const ZeroConfServiceEntry &service, m_serviceBrowser->serviceEntries()) {
|
||||
if (service.txt().contains("am=AVRX1000")) {
|
||||
|
||||
QString id = service.name().split("@").first();
|
||||
QString name = service.name().split("@").last();
|
||||
QString address = service.hostAddress().toString();
|
||||
qCDebug(dcDenon) << "service discovered" << name << "ID:" << id;
|
||||
if (discoveredIds.contains(id))
|
||||
break;
|
||||
|
||||
discoveredIds.append(id);
|
||||
DeviceDescriptor deviceDescriptor(AVRX1000DeviceClassId, name, address);
|
||||
ParamList params;
|
||||
params.append(Param(AVRX1000DeviceIpParamTypeId, address));
|
||||
params.append(Param(AVRX1000DeviceIdParamTypeId, id));
|
||||
deviceDescriptor.setParams(params);
|
||||
foreach (Device *existingDevice, myDevices()) {
|
||||
if (existingDevice->paramValue(AVRX1000DeviceIdParamTypeId).toString() == id) {
|
||||
deviceDescriptor.setDeviceId(existingDevice->id());
|
||||
break;
|
||||
}
|
||||
}
|
||||
deviceDescriptors.append(deviceDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
emit devicesDiscovered(AVRX1000DeviceClassId, deviceDescriptors);
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
|
|
@ -500,9 +532,6 @@ void DevicePluginDenon::onUpnpDiscoveryFinished()
|
|||
if (!heosDescriptors.isEmpty()) {
|
||||
emit devicesDiscovered(heosDeviceClassId, heosDescriptors);
|
||||
}
|
||||
if (!avrDescriptors.isEmpty()) {
|
||||
emit devicesDiscovered(AVRX1000DeviceClassId, avrDescriptors);
|
||||
}
|
||||
}
|
||||
|
||||
void DevicePluginDenon::onHeosConnectionChanged()
|
||||
|
|
@ -608,3 +637,12 @@ void DevicePluginDenon::onHeosNowPlayingMediaStatusReceived(int playerId, QStrin
|
|||
}
|
||||
}
|
||||
|
||||
void DevicePluginDenon::onAvahiServiceEntryAdded(const ZeroConfServiceEntry &serviceEntry)
|
||||
{
|
||||
qCDebug(dcDenon()) << "Avahi service entry added:" << serviceEntry;
|
||||
}
|
||||
|
||||
void DevicePluginDenon::onAvahiServiceEntryRemoved(const ZeroConfServiceEntry &serviceEntry)
|
||||
{
|
||||
qCDebug(dcDenon()) << "Avahi service entry removed:" << serviceEntry;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,11 +24,14 @@
|
|||
#ifndef DEVICEPLUGINDENON_H
|
||||
#define DEVICEPLUGINDENON_H
|
||||
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "plugintimer.h"
|
||||
#include "avrconnection.h"
|
||||
#include "heos.h"
|
||||
#include "avrconnection.h"
|
||||
#include "plugintimer.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "network/zeroconf/zeroconfservicebrowser.h"
|
||||
#include "network/zeroconf/zeroconfserviceentry.h"
|
||||
|
||||
#include <QProcess>
|
||||
#include <QPair>
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
|
|
@ -54,6 +57,8 @@ public:
|
|||
|
||||
private:
|
||||
PluginTimer *m_pluginTimer = nullptr;
|
||||
ZeroConfServiceBrowser *m_serviceBrowser = nullptr;
|
||||
|
||||
QHash<Device *, AvrConnection*> m_avrConnections;
|
||||
QHash<Device *, Heos*> m_heos;
|
||||
|
||||
|
|
@ -77,6 +82,8 @@ private slots:
|
|||
void onHeosVolumeStatusReceived(int playerId, int volume);
|
||||
void onHeosNowPlayingMediaStatusReceived(int playerId, QString source, QString artist, QString album, QString Song, QString artwork);
|
||||
|
||||
void onAvahiServiceEntryAdded(const ZeroConfServiceEntry &serviceEntry);
|
||||
void onAvahiServiceEntryRemoved(const ZeroConfServiceEntry &serviceEntry);
|
||||
void onAvrConnectionChanged(bool status);
|
||||
void onAvrSocketError();
|
||||
void onAvrVolumeChanged(int volume);
|
||||
|
|
|
|||
|
|
@ -13,14 +13,20 @@
|
|||
"name": "AVRX1000",
|
||||
"displayName": "AVR X1000",
|
||||
"createMethods": ["discovery"],
|
||||
"interfaces": ["connectable", "power", "extendedvolumecontroller"],
|
||||
"interfaces": ["extendedvolumecontroller", "connectable", "power"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "a54b98b4-b78f-41dd-a257-14425c6cf9ab",
|
||||
"name": "ip",
|
||||
"displayName": "ip",
|
||||
"displayName": "Ip",
|
||||
"type" : "QString",
|
||||
"inputType": "IPv4Address"
|
||||
},
|
||||
{
|
||||
"id": "2e8806cb-f6f3-4e9a-b6ea-0b35f75e61c5",
|
||||
"name": "id",
|
||||
"displayName": "Id",
|
||||
"type" : "QString"
|
||||
}
|
||||
],
|
||||
"stateTypes": [
|
||||
|
|
@ -194,7 +200,7 @@
|
|||
"name": "heosPlayer",
|
||||
"displayName": "Heos player",
|
||||
"createMethods": ["auto"],
|
||||
"interfaces": ["connectable", "extendedmediacontroller", "extendedvolumecontroller", "mediametadataprovider", "shufflerepeat" ],
|
||||
"interfaces": ["extendedmediacontroller", "extendedvolumecontroller", "mediametadataprovider", "shufflerepeat", "connectable"],
|
||||
"paramTypes":[
|
||||
{
|
||||
"id": "89629008-6ad8-4e92-863d-b86e0e012d0b",
|
||||
|
|
|
|||
Loading…
Reference in New Issue