Skip to content
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

Can makeDiscoverable by service like NSD? #12

Open
hienlt0610 opened this issue Jan 20, 2020 · 2 comments
Open

Can makeDiscoverable by service like NSD? #12

hienlt0610 opened this issue Jan 20, 2020 · 2 comments

Comments

@hienlt0610
Copy link

hienlt0610 commented Jan 20, 2020

I have a lot of devices and I want to group them by service, can you do it?
ex:
makeDiscoverable (String hostName, String serviceName);

makeDiscoverable ("My android device", "printer.tcp");

Look for devices that have the "printer.tcp" service registered instead of searching for them all
startDiscovery ("printer.tcp")

@DatL4g
Copy link
Contributor

DatL4g commented Jan 22, 2020

This doesn't work.
But even if it did, everything is searched and then filterd out. (No performance advantage)

And you can build a filter by yourself (e.g. a specific string inside the hostname)

@DatL4g
Copy link
Contributor

DatL4g commented Jan 28, 2020

When @adroitandroid creates Release v2.0
you can use it like this:

Kotlin

val nearDiscovery = NearDiscovery.Builder()
.setContext(this)
.setDiscoverableTimeoutMillis(DISCOVERABLE_TIMEOUT_MILLIS)
.setDiscoveryTimeoutMillis(DISCOVERY_TIMEOUT_MILLIS)
.setDiscoverablePingIntervalMillis(DISCOVERABLE_PING_INTERVAL_MILLIS)
.setDiscoveryListener(getNearDiscoveryListener(), Looper.getMainLooper())
.setFilter(Regex("printer.tcp")) // shows only devices with parameter "printer.tcp"
.build()

Java

NearDiscovery nearDiscovery = new NearDiscovery.Builder()
.setContext(this)
.setDiscoverableTimeoutMillis(DISCOVERABLE_TIMEOUT_MILLIS)
.setDiscoveryTimeoutMillis(DISCOVERY_TIMEOUT_MILLIS)
.setDiscoverablePingIntervalMillis(DISCOVERABLE_PING_INTERVAL_MILLIS)
.setDiscoveryListener(getNearDiscoveryListener(), Looper.getMainLooper())
.setFilter(Regex("printer.tcp")) // shows only devices with parameter "printer.tcp"
.build()

Setting Parameter

nearDiscovery.makeDiscoverable("hostName", "printer.tcp")

And the issue can be closed then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants