How to discover devices leaving or re-joining the network?

asked 2014-11-03 02:40:46 -0700

anszom gravatar image

My application has a screen similiar to the Alljoyn ON sample. I need to display and update in real-time the list of devices which are discoverable on the network.

For discovering new devices, I'm using the About service client (RegisterAnnounceHandler). When a new device joins the network, I get a callback almost immediately. To find out when a device leaves the network, I use BusAttachment::Ping called on a timer. If a device fails to respond, then I assume that it's not available now.

Currently, I need to ping the device forever, even after it has left the network, the About client doesn't notify me when it comes back. Reading the logs from Alljoyn ON suggests that the sample application follows the same logic.

I would like to "forget" about the device, and get notified with a callback when it joins the network again, without polling for its presence "forever". Is it possible?

edit retag flag offensive close merge delete


autopinger might be of interest to you: https://jira.allseenalliance.org/browse/ASACORE-918

praveenb ( 2014-11-05 00:29:05 -0700 )edit

As I understand, autopinger only hides the ugliness of polling the devices for availability. I understand that some kind of polling needs to be done to detect if a device has left the network. My problem is with pinging devices that were once seen but are long gone.

anszom ( 2014-11-05 00:53:51 -0700 )edit

Hi, have you tried to build an Android app similar to About service, which can be discovered by Alljoyn ON? Thanks.

Curtis ( 2015-06-25 05:53:27 -0700 )edit

2 answers

Sort by » oldest newest most voted

answered 2014-11-11 19:20:54 -0700

tashi gravatar image

I have done this by registering SessionListener once session with device in question is successful

class MySessionListener : public SessionListener { void SessionLost(SessionId id, SessionLostReason reasion) { printf("Session lost with device");



So when nextime, device sends About data, we can again create session.

edit flag offensive delete publish link more


That solution has two drawbacks: 1. I would need to establish a session with every device. This could be acceptable, but 2. When the device leaves the network and then rejoins it (while keeping the same unique name - for example a phone app with a bundled router), I will NOT get another About announcement!

anszom ( 2014-11-12 01:37:26 -0700 )edit

answered 2014-11-13 08:22:42 -0700

anszom gravatar image

updated 2014-11-13 08:33:31 -0700

Accidentally I've stumbled upon a piece of comment inside alljoyn audio framework source code, which describes "tracking device presence" (from multimedia/audio/SinkSearcher.cpp):

There are a number of strategies for tracking device presence.

One is to leave outstanding find requests for each device of interest. This is what is below. However, this can lead to false negatives if multicast traffic does not make it through, and may take up to 40 seconds to find the device again after a false negative.

Another is to force a refresh by cancelling any finds and re-issuing them. The found response should occur relative quickly after re-issue if the device is present. See Refresh below.

It seems that the author makes a FindAdvertisedName for each uniqueName seen on the bus. It seems to go against FIndAdvertisedName's intent to search for well-known names, not unique names.

This approach would have the advantage of not having to actively ping (possibly countless) devices. On the other hand it still requires the application to track all devices seen during the session.

edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools



Asked: 2014-11-03 02:40:46 -0700

Seen: 248 times

Last updated: Nov 13 '14