Using BTStack with XCode

477 views
Skip to first unread message

David Warner

unread,
Apr 3, 2012, 12:21:02 PM4/3/12
to btstack-dev
Hey everyone,

I am new to BTStack and trying to get an iPhone program working with
multiple accelerometer Bluetooth sensors for my Senior Project. So far
I have looked at the Getting Started example with the WiiMote and got
that working. I used that and managed to get all 3 accelerometers
connected to the iPhone using the rfcomm-cat example that is included.
However now I am working on trying to get this integrated with XCode
and really have no idea how to proceed. I have spent hours looking
around on both this site and the developer forum and have been unable
to find any real examples or advice on how to integrate BTStack with
an XCode project.

If any of you have some advice on how to proceed I would greatly
appreciate it. I only have a bit of iOS programming experience from my
previous semester but have been looking at what has been posted and
really don't have any idea on how to proceed into incorporating this
with an app.

Matthias Ringwald

unread,
Apr 3, 2012, 1:12:39 PM4/3/12
to btsta...@googlegroups.com
Hi David

The CocoaTouch source folder contains a small test that shows a discovery view. It did compile with Xcode the last time I tried.

That said, I'm not using Xcode for iOS JB development anymore. It's a good IDE, but it messes up stuff to often for me.

I suggest to switch to the theos build system: http://iphonedevwiki.net/index.php/Theos/Getting_Started

From the software side, the only difference is that you should specify RUN_LOOP_COCOA in the run_loop_init call. Everything else is the same.
For your convenience, BTstackManager handles initialization and discovery in Objective-C. (No connections there, but you get the data, too)

Best
 Matthias

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


David Warner

unread,
Apr 4, 2012, 1:56:46 PM4/4/12
to btstack-dev
Hi Matthias,

Thanks for your quick response. After looking at your response our
immediate question is do we rework BTstackManager and then integrate
with rfcomm-cat.c so that we post data from the sensors we are using
to our mobile phone before sending it off to a secure server?

If not, how do we go from where we are now; getting multiple
connections using rfcomm-cat.c while running it actually on the iPhone
to being able to establish these connections and get data from the
sensors using an iPhone application built in Xcode or Theos.

If anyone else has examples to help illustrate this process it would
be greatly appreciated.



On Apr 3, 1:12 pm, Matthias Ringwald <matthias.ringw...@gmail.com>
wrote:

Matthias Ringwald

unread,
Apr 4, 2012, 2:13:55 PM4/4/12
to David Warner, btstack-dev
Hi

I guess I should create a wiki page on how to use BTstack for iOS apps using Xcode or theos.

BTstackManager isn't complete (it doesn't cover creating connections), but it doesn't need to be modified either. I'm using it the svn version in both my apps and daemons.
While you use BTstackManager to boot up and do inquries, you can still use bt_send_cmd to create the RFCOMM connection and bt_send_rfcomm to send data. The events and data will arrive in the btstackManager:handlePacketWithType:forChannel:andData:withLen: of your BTstackManagerDelegate

After you get the activatedBTstackManager: callback, you can open the first RFCOMM connection right away (or even start all of them in parallel - BTstack is supposed to handle that while I didn't actually try that).

Best
Matthias

David Warner

unread,
Apr 5, 2012, 5:18:48 PM4/5/12
to btstack-dev
Hey again Matthias,

Thanks for your help so far.

We are still working on getting the BTStacks integrated with XCode. We
imported the entire BTStack directory that we got through svn into our
project. However we do not know which files need to be utilized in
order to use bt_send_cmd and bt_send_rfcomm in our application. I know
you're busy and probably have a lot on your hands but do you have any
advice on how to proceed in utilizing these commands with our
application?

Thanks for all your help

David

On Apr 4, 2:13 pm, Matthias Ringwald <matthias.ringw...@gmail.com>

Matthias Ringwald

unread,
Apr 6, 2012, 7:09:49 AM4/6/12
to btsta...@googlegroups.com
Hi David

BTstack clients are supposed to link against libBTstack.dylib. This is true for both command line examples as well as CocoaTouch application.
Please have a look at btstack/CocoaTouch/BTstackCocoa.xcodeproj

It links against libBTstack.dylib and shows a discovery view.

Best
Matthias

David Warner

unread,
Apr 11, 2012, 9:02:02 PM4/11/12
to btstack-dev
Hi again Matthias,

Thanks again for you help so far, it has helped us with our project
immensely.

We still had a couple of questions however. First off we looked at the
CocoaTouch application and got it successfully integrated, built and
running through Xcode. However we were unable to use it to establish a
connection with any of our Bluetooth Sensors. We were able to get it
to discover all of our sensors but it was unable to connect with any
of them. In order to connect do we need to incorporate the bt_send_cmd
you had mentioned previously? If so where exactly would we want to
implement that?

Also once we get the connection established and data passing from the
sensors where is this data stored on the device? We are going to need
to do some manipulation of the data once we get it flowing and are not
sure where to look for the data.

Thanks again for all your help. We really appreciate it.

David

On Apr 6, 7:09 am, Matthias Ringwald <matthias.ringw...@gmail.com>

ala...@free.fr

unread,
Apr 21, 2012, 11:43:56 AM4/21/12
to btstack-dev


Hello David and mathias,

I'd tested BTstack in xcode. I did find an example of cocoaTouch but
the library "LibBTstack.dyLib" is missing to compile?
I do not know how?
Thank you for your help

Matthias Ringwald

unread,
Apr 29, 2012, 2:44:28 PM4/29/12
to btsta...@googlegroups.com
Hi

please follow the "GettingStarted" wiki page to configure BTstack and build libBTstack.dylib. You can also copy the one from your iOS device (which is at /usr/local/lib) but you have to configure BTstack to use anything.

Best
Matthias
Reply all
Reply to author
Forward
0 new messages