Skip to content

UPNP don't notify embedded child devices by default #4735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,14 @@ public interface UpnpDiscoveryParticipant {
default long getRemovalGracePeriodSeconds(RemoteDevice device) {
return 0;
}

/**
* The discovery always notifies participants about discovered root devices. And if the participant also
* wants to be notified about embedded child devices then it shall override this method.
*
* @return true if the participant wants to be also notified about embedded child devices.
*/
default boolean notifyChildDevices() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ protected void addUpnpDiscoveryParticipant(UpnpDiscoveryParticipant participant)

Collection<RemoteDevice> devices = upnpService.getRegistry().getRemoteDevices();
for (RemoteDevice device : devices) {
if (!device.isRoot() && !participant.notifyChildDevices()) {
continue;
}
DiscoveryResult result = participant.createResult(device);
if (result != null) {
final DiscoveryResult resultNew = getLocalizedDiscoveryResult(result,
Expand Down Expand Up @@ -171,6 +174,9 @@ protected synchronized void stopScan() {
@Override
public void remoteDeviceAdded(Registry registry, RemoteDevice device) {
for (UpnpDiscoveryParticipant participant : participants) {
if (!device.isRoot() && !participant.notifyChildDevices()) {
continue;
}
try {
DiscoveryResult result = participant.createResult(device);
if (result != null) {
Expand Down Expand Up @@ -200,6 +206,9 @@ private void cancelRemovalTask(UDN udn) {
@Override
public void remoteDeviceRemoved(Registry registry, RemoteDevice device) {
for (UpnpDiscoveryParticipant participant : participants) {
if (!device.isRoot() && !participant.notifyChildDevices()) {
continue;
}
try {
ThingUID thingUID = participant.getThingUID(device);
if (thingUID != null) {
Expand Down