maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   BLUEZ: How to determine if known device is reachable (https://talk.maemo.org/showthread.php?t=35256)

skomialek 2009-11-27 15:26

BLUEZ: How to determine if known device is reachable
 
Hi,

I'm trying to use bluetooth to determine what devices are around me (context awareness). For this purpose I use bluez api in a way that I turn bt on, start device scanning and than I catch signals DeviceFound. The problem is that this signal is emitted only if devices are not paired. If for example I have my computer which has been paired with my phone I won't get signal that this device has been found.

The question is: how can I determine if known devices are in range (in a nice way :) ) - any ideas?

My first idea was to try to connect to every possible known device and catch errors but this is not the thing...


Thank you for your answers,
Best regards,
Skomialek

aboaboit 2009-11-27 15:36

Re: BLUEZ: How to determine if known device is reachable
 
Quote:

Originally Posted by skomialek (Post 396176)
The question is: how can I determine if known devices are in range (in a nice way :) ) - any ideas?

An acceptable way would be to ping it but that would still be polling. Unless all known devices are instructed to reconnect automatically, I guess you can't rely on a passive notification.

skomialek 2009-11-27 15:42

Re: BLUEZ: How to determine if known device is reachable
 
Quote:

Originally Posted by aboaboit (Post 396190)
An acceptable way would be to ping it but that would still be polling. Unless all known devices are instructed to reconnect automatically, I guess you can't rely on a passive notification.

Is there any way to simply 'ping' the device using bluez api (I mean without manual connect/disconnect procedure)

fredoll 2009-11-27 15:45

Re: BLUEZ: How to determine if known device is reachable
 
I suppose you could look at BlueProximity ...

skomialek 2009-11-27 15:53

Re: BLUEZ: How to determine if known device is reachable
 
Quote:

Originally Posted by fredoll (Post 396218)
I suppose you could look at BlueProximity ...

Thanks, but I'm not looking for a desktop app. What I'm trying to do is to make maemo based device aware what BT devices are in its range :)

Khertan 2009-11-27 16:05

Re: BLUEZ: How to determine if known device is reachable
 
You can simply do a bluetooth scan ... which will give you a list of device at promity with their mac address ... store this and compare.

ali1234 2009-11-27 16:12

Re: BLUEZ: How to determine if known device is reachable
 
Quote:

Originally Posted by Khertan (Post 396274)
You can simply do a bluetooth scan ... which will give you a list of device at promity with their mac address ... store this and compare.

Only ones which are set to discoverable. Even if you're paired, but the other device is not discoverable, you won't see it this way.

Since non-discoverable devices will only respond to direct requests, the only way to see them is with direct requests such as L2CAP echo requests (aka bluetooth ping.) Sure, this is polling, but repeated scans are also a form of polling.

fredoll 2009-11-27 16:12

Re: BLUEZ: How to determine if known device is reachable
 
Quote:

Originally Posted by skomialek (Post 396246)
Thanks, but I'm not looking for a desktop app. What I'm trying to do is to make maemo based device aware what BT devices are in its range :)

I was thinking that you could look the source code ...

skomialek 2009-11-27 16:32

Re: BLUEZ: How to determine if known device is reachable
 
Quote:

Originally Posted by Khertan (Post 396274)
You can simply do a bluetooth scan ... which will give you a list of device at promity with their mac address ... store this and compare.

yes ... this is what i've been do' . it turns out that it lists paired devices but doesn't list connected ones (but those I can check in device properties) . The problem was probably in my other phone's bt power saving properties. If I leave the phone and don't use it it doesn't get detected ... when I was angry that it doesn't get detected I simply removed pairing on both devices and this way bt got awaken :)...

sorry for bothering you... problem solved (actually it's never existed..)

Best regards,
Skomialek

ali1234 2009-11-27 16:34

Re: BLUEZ: How to determine if known device is reachable
 
Quote:

Originally Posted by fredoll (Post 396285)
I was thinking that you could look the source code ...

http://blueproximity.svn.sourceforge...py?view=markup

It seems to establish an rfcomm connection to the known device, in order to get the signal strength (RSSI) and make an estimation of the distance to the device.

skomialek 2009-11-27 16:35

Re: BLUEZ: How to determine if known device is reachable
 
Quote:

Originally Posted by fredoll (Post 396285)
I was thinking that you could look the source code ...

yeah .. :) sorry - misunderstanding :)... I'm bit to tired..
anyway - problem solved :)

lma 2009-11-27 20:16

Re: BLUEZ: How to determine if known device is reachable
 
I think l2ping (in package bluez-test, from the tools repository) does what you want (at the L2CAP level, ie without needing RFCOMM channels etc), but the catch is that it requires root permissions to create the raw bluetooth socket.

Sveinn 2009-12-05 02:18

Re: BLUEZ: How to determine if known device is reachable
 
Hi Skomialek,

I am trying to do the same thing as you actually. Can you tell me a little bit more about how you do a bluetooth scan using the bluez api (like what api calls and stuff) ?

Thanks,
Sveinn

hopbeat 2009-12-05 21:01

Re: BLUEZ: How to determine if known device is reachable
 
Hello @Sveinn.
@Skomialek is still struggling with this issue (we are doing the project together :) ). It should be ready in a few days, we will be happy to help you with this. Please also note, that it will be a part of a library (context toolbox), so if our functionality will be enough, you could just use it :)
Drop me a PM so I can keep a track of people interested in APIs :)


All times are GMT. The time now is 17:01.

vBulletin® Version 3.8.8