Bluetooth Access using NDK on HTC EVO

735 views
Skip to first unread message

Nalaka

unread,
Sep 28, 2010, 5:07:24 PM9/28/10
to android-ndk

Hi All,

I am given a task to implement a library for android using C++ which
requires communicating with another bluetooth enabled device. I've
been doing a lot of searching and there's not many resources available
on how to do that using the NDK since there's no bluetooth library
included in the NDK. Wherever there's a post regarding this subject,
the answerer recommends sticking to JAVA which is not an option for
me.

HTC has given out the bluez source codes (http://developer.htc.com/)
for the HTC EVO but I am not sure how to use it. Should I build it
first using the NDK and then include it in the NDK project ?

Please help me out !

Thanks.

Nalaka K.

Dianne Hackborn

unread,
Sep 28, 2010, 7:19:11 PM9/28/10
to andro...@googlegroups.com
The information you have been given is correct.  There are no native Bluetooth APIs.  You need to use the Java APIs.

There is of course some native implementation inside of the platform for bluetooth, but any use of that is outside the scope of the NDK (and thus not guaranteed to work on any device or any particular platform version).


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.




--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Christian Linne

unread,
Sep 29, 2010, 2:06:49 AM9/29/10
to andro...@googlegroups.com
The fact that Android uses the Bluez library is an implementation detail.
This is not guaranteed on all Android devices; even which exact version of
Bluez is being used may vary (and has varied in the past, which is why we
had to delay exposing some of the BT APIs from Java).
That's what David Turner answered when I asked for the same. I have already worked with different devices that are using Android - almost any of them had another version of BlueZ inside, some of them also used something different (with similar bindings, so that the Java-API remains usable).
Using BlueZ may work on HTC-devices, but there is no guarantee that it will work anywhere else. Legal issues are coming along with it, also (as far as I remember, BlueZ itself is only available with GPL license).
2010/9/29 Dianne Hackborn <hac...@android.com>



--
_________
Mit freundlichen Grüßen
Yours sincerely

Christian Linne

Mail (private): linn...@aol.com
Mail (official): Christi...@googlemail.com,
ICQ: 293253013

Nalaka

unread,
Oct 7, 2010, 10:56:07 AM10/7/10
to android-ndk

Hi Dianne,

Thank you so much for your reply.

Does the NDK allow me to open a serial communication socket if the
bluetooth connection is already established by the Android OS ?

Thanks.

Nalaka K.
> > android-ndk...@googlegroups.com<android-ndk%2Bunsubscribe@googlegr oups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/android-ndk?hl=en.
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com

Nalaka

unread,
Oct 7, 2010, 10:58:18 AM10/7/10
to android-ndk

Hi Christian,

Do I have the option of using a serial communication method through
NDK if the bluetooth connection is already established by the Android
OS ?


Thanks.

Nalaka K.







On Sep 28, 11:06 pm, Christian Linne <christian.li...@googlemail.com>
wrote:
> > The fact that Android uses the Bluez library is an implementation detail.
> > This is not guaranteed on all Android devices; even which exact version of
> > Bluez is being used may vary (and has varied in the past, which is why we
> > had to delay exposing some of the BT APIs from Java).
>
> That's what David Turner answered when I asked for the same. I have already
> worked with different devices that are using Android - almost any of them
> had another version of BlueZ inside, some of them also used something
> different (with similar bindings, so that the Java-API remains usable).
> Using BlueZ may work on HTC-devices, but there is no guarantee that it will
> work anywhere else. Legal issues are coming along with it, also (as far as I
> remember, BlueZ itself is only available with GPL license).
> 2010/9/29 Dianne Hackborn <hack...@android.com>
>
>
>
>
>
> > The information you have been given is correct.  There are no native
> > Bluetooth APIs.  You need to use the Java APIs.
>
> > There is of course some native implementation inside of the platform for
> > bluetooth, but any use of that is outside the scope of the NDK (and thus not
> > guaranteed to work on any device or any particular platform version).
>
> > On Tue, Sep 28, 2010 at 2:07 PM, Nalaka <kahawa...@gmail.com> wrote:
>
> >> Hi All,
>
> >> I am given a task to implement a library for android using C++ which
> >> requires communicating with another bluetooth enabled device. I've
> >> been doing a lot of searching and there's not many resources available
> >> on how to do that using the NDK since there's no bluetooth library
> >> included in the NDK. Wherever there's a post regarding this subject,
> >> the answerer recommends sticking to JAVA which is not an option for
> >> me.
>
> >> HTC has given out the bluez source codes (http://developer.htc.com/)
> >> for the HTC EVO but I am not sure how to use it. Should I build it
> >> first using the NDK and then include it in the NDK project ?
>
> >> Please help me out !
>
> >> Thanks.
>
> >> Nalaka K.
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "android-ndk" group.
> >> To post to this group, send email to andro...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> android-ndk...@googlegroups.com<android-ndk%2Bunsubscribe@googlegr oups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/android-ndk?hl=en.
>
> > --
> > Dianne Hackborn
> > Android framework engineer
> > hack...@android.com
>
> > Note: please don't send private questions to me, as I don't have time to
> > provide private support, and so won't reply to such e-mails.  All such
> > questions should be posted on public forums, where I and others can see and
> > answer them.
>
> >   --
> > You received this message because you are subscribed to the Google Groups
> > "android-ndk" group.
> > To post to this group, send email to andro...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > android-ndk...@googlegroups.com<android-ndk%2Bunsubscribe@googlegr oups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/android-ndk?hl=en.
>
> --
> _________
> Mit freundlichen Grüßen
> Yours sincerely
>
> Christian Linne
>
> Mail (private): linne2...@aol.com
> Mail (official): Christian.Li...@googlemail.com,
> ICQ: 293253013

Christian Linne

unread,
Oct 11, 2010, 2:13:22 AM10/11/10
to andro...@googlegroups.com
Sorry for answering that late, I was a little busy during the last days...
 
I suppose you are talking about using the SPP-connection from the native part of your app directly after it has been established. As far as I know, this is not possible generally. On some devices, this may work, yes, but you have to get the port-number which cannot be chosen manually on startup, and you cannot ask for it. Furthermore, some devices react quite curious if an existing connection is touched by a thread that did not start it - seems to depend on the configuration the publisher uses (apart from the network interface, which works fine anyhow). If you need to use bluetooth, you will have to use the Java-API, otherwise, you do not have any guarantee that your app will run on every device that uses android. And, as I've experienced that, it's not that bad regarding its performance.
2010/10/7 Nalaka <kaha...@gmail.com>
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.




--
_________
Mit freundlichen Grüßen
Yours sincerely

Christian Linne

Reply all
Reply to author
Forward
0 new messages