|
GettingStarted
How to get a grip on the BTstack
IntroductionAlthough in an early stage, the BTstack can already used to create connections to other devices using the L2CAP protocol. This allows for example to receive keypress events from an Bluetooth keyboard or movement data from a WiiMote. On this page, we provide a quick walk-through to run example/test.c on an iPhone 3G(S) or iPod touch 2G/3G and connect to a WiiMote, while displaying acceleration and button reports. Requirements
Steps
svn checkout http://btstack.googlecode.com/svn/trunk/ btstack cd btstack in bootstrap.sh: change aclocal to aclocal -I /opt/local/share/aclocal in configure.in: change the SDK_VERSION variable to the SDK you want to use/have. BTstack works with all versions. ./bootstrap.sh ./configure --target=iphone make scp src/BTdaemon src/libBTstack.dylib example/test mobile@192.168.3.102:. ssh mobile@192.168.3.102 ldid -S BTdaemon ldid -S test ldid -S libBTstack.dylib su cp libBTstack.dylib /usr/local/lib exit ./BTdaemon ssh mobile@192.168.3.102 ./test Important: My WLAN often breaks down when using Bluetooth. When logged in via SSH this looks like the app would not work or hang, when in reality the WLAN is just not working properly. Check the WLAN icon in the status bar. After the introduction of Internet tethering, I highly recommend to connect the iPhone via USB and use this connection for SSH. When using USB Tethering, my machine receives the IP address 192.168.20.3, and the iPhone can be accessed at 192.168.20.1. DetailsIn main, the BTstack is opened and packet handlers are registered before the BTstack is asked to boot with the btstack_set_power_mode command. All commands to control the BTstack are send asynchronously with the bt_send_cmd. Finally the run_loop is executed. From there on, the rest of the test app runs as a finite state machine which processes events received from the BTstack. Be aware that error handling is barely performed. :) Anyway, the different steps of the program are visible in the event handler. First, it reacts to the successful startup of the BTstack and set the local Bluetooth name. Then, pairing is enabled/disabled with the hci_write_authentication_enable HCI command, which is caused by the command complete event of the hci_hci_write_local_name. Again, a command complete event will trigger the next action. Now, the BTstack is asked to open an L2CAP channel to the hard-coded WiiMote at PSM 0x13 (HID Interrupt) where reports from the HID device are received. Upon success, a second channel for PSM 0x11 (HID Control) is opened. This channel is necessary to enable the reporting of acceleration readings and send the command to set LEDs which also stops the LEDs from blinking. Finally, we're ready to receive HID status reports. See the HID and the WiiMote documentation for more details on this. As this event handler shows, everything is event-triggered. After sending a command to the BTdaemon, which in turn sends it to the Bluetooth chipset, we wait for the corresponding event to continue with our application. Instead of writing this single even handler, it is much better to follow the concept of finite state machines. Based on our current state, an event such as HCI events, triggers the next action and the transition to another state. For more insight inton finite state machine, I highly recommend the book by Miro Samek. ReferencesHelpIf you really want to try the example app on your iPhone, but didn't get it to work although you've followed the instructions here, or, if you'd like to use Bluetooth in your own application (whatever OS/HW), please join the BTstack Developer Forum. |
Sign in to add a comment
hello mathias, AS i understood, btstack 0.1 is out right?
I don't own a wiimote but well, I'd still like to dl it from cydia if possible, what's the source to add in order to install it?
regards G.
Cydia packages are out: iPhoneInstallationViaCydia
I'd like to connect with a ps3 using the iPhones keyboard for input within pshome... What would it take to achieve something like that?
I don't know what's used for the PS3. If you can use a regular Bluetooth keyboard, it should be possible BTstack on the iPhone too. Please join the BTstack Developer Group for further discussion.
great mathias, alright, I'll install it up as soon as I get back home, thank you
U can use a bluetooth keyboard on ps3, It would be the same as turning the iPhone into a bluetooth keyboard for pc/mac... I'll join
Is there a way that I can install btstack on my jailbroken Ipod Touch and use it to pair a headset for skype or whatever voip app? From what I understand, Itouch can't pair natively to headsets, only headphones.... was wondering if btstack was supposed to work on its own... I installed btstack and tried to enable bluetooth using the normal way, no pairing possible, and couldn't find any btstack icons or whatever...
thx
BTstack is an alternative to Apple's on the iPhone. No support for the Headphone or the A2DP protocol yet. Even then, integrating it into the OS will be tricky.
The thing is, I know it works for the iphone, Apple just didn't want to include the profiles into the Ipod touch. So Apple's BT stack would work for me. I'm just somehow surprised no little cracker managed (or bothered to try) to rip those profiles from the IPhone to include them in a jailbroken ipod touch yet... maybe it's harder than I think... thx for your reply...
Ok, I could see my keyboard, without crash but nothing more so far... there will be a switch to disable it soon, right? regards.
So when's "next";) ?
@goonie. BTstack is not integrated into Apple's. Keyboard will be provided by a separate app that allows to connect and to configure your keyboard. I've got cursor support working now (no keyboard -> no cursor support in the OS). And it won't take much longer. I'll promise to release something before Christmas...
I tried to look around before posting so as not to sound like an idiot, but I'm afraid that I've run into a dead end. The intro says that BTstack for the iPhone works with keyboards, but I can't find any data/instructions on the topic. Is it possible to connect a bluetooth keyboard to an iPhone with Btstack at this time? And if so, is it similar to the process outlined here? Thanks for your time and keep up the good work.
thank you matthias, You mean we won't have to run a vnc app ;)))
I'll love christmas this year.