|
GettingStarted
How to get a grip on the BTstack
Featured IntroductionOn 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. See below for iPhone simulator usage. Requirements
Steps to compile and run a BTstack example on the iPhone
svn checkout http://btstack.googlecode.com/svn/trunk/ btstack cd btstack ./bootstrap.sh ./configure --target=iphone ./configure --target=iphone --with-sdk-version=3.2 make scp example/test mobile@192.168.3.102:. ssh mobile@192.168.3.102 ldid -S test ./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. Develop BTstack apps in the iPhone SimulatorTo develop iPhone apps on the Mac, you need a serial Bluetooth module like the Ericsson ROK Tester connected over a USB-to-Serial adapter, as the HCI_USB_Transport does not work yet. With such a setup, you can configure BTstack for running on the Mac host, not the iPhone as described above. You also have to specify the UART device, see ./configure --help For testing you run BTdaemon in one terminal before starting your app in the simulator. The app will then connect to the BTdaemon over the local UNIX domain socket. 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. |
Cydia packages are out: iPhoneInstallationViaCydia
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.
I'm probably missing something incredibly stupid, but I can't get the WiiMote? example to compile. I've been planning to add WiiMote? support to an app I'm working on, but for that I first need to get the WiiMote? demo to work as I want it before adding this capability into my app. I've been able to build the non-CocoaTouch? version of BTstack, but as soon as I try to do something with XCode, it fails to recognize or find anything under the format of <btstack/someHeader.h>. It's probably just some stupid mistake I made, but could you offer your advice?
if you'd like to use Bluetooth in your own application (whatever OS/HW), please join the BTstack Developer Forum. either install the headers in /usr/include or set the "header search path" in XCode to the btsack/include/ directory
I'm really hoping we can see a demo of RFCOMM working with those SE Bluetooth Watches soon! That'd rock!
iPhone Bluetooth Keyboard Driver v1.0 released! Demo version at BigBoss
Hi guys. I'm got a bicycle with an array of sensors and a bluetooth module. It would be great if I could get this sending serial info to an iPod Touch. I discovered that the Bluetooth module in the iPod/iPhone is severely locked up by apple. Is this the solution? Using the BTstack, can I talk to any bluetooth device? Thanks!
yes, you can.
Hi guys, I'm interesting to implemet in my application bluetooth using BTstack,Where I can find an example on using it with Xcode? I try with example in BTstack project but don't work.Can someone say me where I can found it? or where I can found documentation on using BTstack?
Hi, I wish to create a graphic appplication with bluetooth support but I don't see how to do this. run_loop_execute seem blocking the application. I use a linux box, consequently I'm not able to compiling xcodeproj app (like WiiMoteOpenGLDemo). How to use btstack for a graphic app with a linux box. Thank you very much
hi guys. join the dev group. ... either you write your app in an event driven way, by this your app gets caled by the run loop, or you could use an extra pthread for BTstack and use its intet-thread communication for signaling/data delivery.
how to get a hyperterminal working on the iphone and use btstack
Hi, I wish to create a printer appplication with bluetooth support but I don't see how to do this. How to use btstack?
Line Location bt_control_iphone.m:42: error: ../config.h: No such file or directory Line Location daemon.c:41: error: ../config.h: No such file or directory Line Location daemon.c:103: warning: unused variable 'handle' Line Location hci.c:47: error: ../include/btstack/version.h: No such file or directory Line Location hci.c:514: error: 'BTSTACK_MAJOR' undeclared (first use in this function) Line Location hci.c:515: error: 'BTSTACK_MINOR' undeclared (first use in this function) Line Location hci.c:516: error: 'BTSTACK_REVISION' undeclared (first use in this function) Line Location platform_iphone.c:40: error: ../config.h: No such file or directory Line Location run_loop.c:44: error: ../config.h: No such file or directory Line Location socket_connection.c:45: error: ../config.h: No such file or directory
gaoguilomg: please follow the instruction on this side to compile BTstack
ahadjeres: can you explain what exactly you'd like to do?
thank you ,I follow the instruction, but I want to develop in Xcode,how to start?
gaoguilomg: please follow the instruction on this page to compile BTstack. and then try using Xcode. You will have to set the include and libs used correctly.
Thank you
How to run this application ..... ? what is libBTstack.dylib ?
which app? libBTstack.dylib is the client library an app uses to access Bluetooth services, check out Architecture
I'm really new to this, please excuse me if my questions are so noobie :( In the requirements: - The autotools is already in Mac OS X leopard 10.5.5 right ? so i dont need to install it. if not, where to find it. - pkg-config: I dont know how to install it. You said about get it from MacPorts?, but I search on the site, can't find it anywhere :( Correct me if I'm wrong. What I understand is I need to compile the btstack to get the libBTstack.dylib and copy it to my usr/local/lib and then also copy all the file in the "include" fold (.h files) to my xcode project then I'm good to go ?
Ok, I got the them all compiled. Have btstack package installed from cydia. I copied the test file and the rfcomm to my iphone. But they didn't run, all I got was "Killed" in the console. Anyone know how to fix this ?
The guida miss one step ldid -S BTdaemon ldid -S test If you don't execute this , you just get "Killed" output.
hi. thanks for helping out. if you configure for iPhone and build with the Makefiles, ldid is automatically called on the executables.
also , I need run the BTdaemon and test use root role.
Thanks, I got it running :)
in the above tutorial i covered first 7 steps . but . 1) in step 8 can i using any bluetooth device, like nokia phone and so on. instead of WiiMote? , how i get ip address of a bluetooth phone, to connect with this. 2) when i build " make " by staying in btstack i am geting one error. ie make1?: execvp: ./get_version.sh: Permission denied make1?: [libBTstack.dylib] Error 127 make: [all-recursive] Error 1
how to rectify this error. ?
thanks and regards
jaleelpp: you can use inquiry command installed by the BTstack Cydia package. It will report remote baseband addresses (similar to MACs) and remote names. For the permission error, try "chmod +x get_version.sh" to make it executable.
Hi All,
when i execute inquiry in the mini mac os, i getting error such as
/dev/ttyS0: No such file or directory " how could i rectify this one ?, what is the reason for this error?
Thanks and regards jaleel
For non-iPhone/iPod, you need an external serial/h4 bluetooth module which can be accessed as a serial port like /dev/ttyS0 (ttyS0 being the default serial port on a linux system). I'm using the Rok Tester http://www.tik.ee.ethz.ch/~beutel/projects/bttester/bt_tester.html with an Keyspan USB-to-Serial adapter. Yes, one could also use an external BT dongle, or even the internal one, but the USB code is not working yet - feel free to look into that. :)
after made the application as above step. I ran it at my ipod touch 3rd. but ./BTdaemon: Bad CPU type in executable throw. How to fix? or ./configure -target=ipod?
And I also used xcode on my macbook pro (build in bluetooth chipset) built successfully the application but cannot be put to iphone-simulator (no app appears in ..../Applications folder)? Any progress to configure?
iPod is configure as iPhone described above. see the previous post (Feb 15) on using BTstack on Mac. The only app wiht Xcode is the example/WiiMote?... demo. Please join the BTstack Dev Group.
Another way to develop with Xcode and simulator.
run BTdaemon on iPhone/iPod in TCP socket mode (need a little code update on daemon.c) develop an application on iPhone simulator and connect to BTdaemon on iPhone (update socket_connection.c to change host name and update bt_stack.c to use TCP socket)
A great job! Is there a way to create a bluetooth virtual serial port on the itouch? so you can acess it with mobile terminal or any other program.
I guess this is also what ahadjeres is asking for
hi (and sorry for answering late). A real virtual port requires a kernel extensions which is not possible on the iPhone AFAIK. An app could create an ptty which is similar, but you would need that app running. Usually you want to build an app on top of it and it that case you could just use libBTstack. Another idea: add example/rfcomm.c to MobileTerminal? - there is a SDK version that can be compiled in Xcode.
Hi everybody, i just jailbroke my iphone with a 3.0 firmware and i am trying to run the example again. when i try to run: apt-get it says command not found.. , can anyone tell me the source to add to cydia to get apt-get command? Also, can someone tell me the source to get "ldid" and "BTstack daemon" on cydia?
i really appreciate that, thanks
BTstack and ldid are regular packages in Cydia (hosted by BigBoss?)
When i run ./BTdaemon, I get the following error ...
Socket created at /tmp/BTstack Error on bind() ...(Address already in use) BTdaemon started - stdout BTdaemon started - stderr
Furthermore, If i attempt running the apps test or rfcomm, these apps are killed rightaway. Help!
@adithya If you installed BTstack via Cydia, BTdaemon is automatically started by launchd whenever an app tries to use it. so, just don't start it. If a test app gets killed right away, you didn't code sign them with the ldid tool. It is done automatically on the mac if you have ldid installed, you can also sign them on the device with ldid from the ldid package.
Will PS3 controllers be supported?
@antonio BTstack can already communicate with PS3, but one has to make an app that makes use of it too. I'm on it... :)
Is there any New Progress for communicating with the PS3? :)
@lucleonhart no. no new progress. If nobody does, I'll do something with it in winter :)
After completing the above steps and test run, the XCode compiler get the error: 'Btstack/hci_cmds.h: No such file or directory' in the BTInquiryViewController. I could see the file if it exists!. Can you tell me whats happening? please
the CFLAGS and LDFLAGS are hard-coded, as I have no clue how use relative paths. please update them accordingly
In my sourcecode for test.c it has the wiimote mac address commented out and an ipad mac uncommented. I have an ipad, is that code for connecting my phone to my ipad?
im new to the jb scene but i have a question. will this make it to where i could use a bluetooth earpiece that i can connect to my phone, but connect it to my ipod to listen to music. i do not need to use the mic just simply for listening to music. im not sure what software i can use but i have a second generation ipod touch mc model running ios4 jailbroken. any help is much appreciated
Hello,
How can we send HCI commands with btstack ?
Thanks in advance for your help,
Hello, Will you be updating BTStack GPS for io 4.2.1? Thanks, great product!!
Please update BTstack package. Besides other bugs/details it forces an update of other components that caused crashes on 4.2.1. Everything's fine.
Hi, it took me a while to figure out my WiiMote? MAC Address. Now that I've figured it out, I thought a "how-to" would help:
- Download and install DarwiinRemote? http://sourceforge.net/projects/darwiin-remote/ - Use DarwiinRemote? to connect the WiiMote? to your computer. - On a Macintosh, you can get the WiiMote? MAC address by opening System Preferences > Bluetooth Preferences, selecting the connected WiiMote? (it will be listed as "Nintendo RVL-CNT-01"), and showing more info for this device.
I tried compiling on Linux. I don't see the libusb code/version in the svn above - or is it somewhere else in the tree or not in the repo?
Can't build it (step 8) - I get libBTstack.dylib error 1. Please your help
@tz2...: BTstack uses libusb 1.0. The USB driver was dormant for long as I thought it's broken/not working. However, over the holidays I tried again on Mac and as far as I could tell, it was fully working. So maybe libusb did fix some bugs, I did run into before.
linux on the mac, or mac osx on the mac using a usb bluetooth dongle?
I tried BTstack with libusb-1.0 from GIT on Mac OS X. Note: I did remove the IOBluetoothFamily.kext to get access to the internal USB Bluetooth module.
I used BTStack on my iPhone, my wifi often breaks down when using Bluetooth. Did you have methods to fix this bug. (Note: I must use wifi to connect to my server.)
@Terence: what app are you using with BTstack? The more you use Bluetooth, the less stable WiFi? gets, that's a physical problem. Doing inquires for extended amounts of time kills Wifi with high probability, sending much data, like with the Mouse app, seems to degrade Wifi performance.
I ran the BTStackCocoa on iPhone 3G, wifi will break down after 1 minute; iPad 3.2 had different performances, the longest time is 4 minutes.
Hi, i did everything on the getting started tutorial(, but i used another iphone as wiimote) but i cant get it to work. when i want to run the test it says this :
fannes-boombox:~ mobile$ ./test -sh: ./test: No such file or directory
this didnt work so i used :
fannes-boombox:~ mobile$ sh test.c test.c: line 1: /Applications: is a directory test.c: line 2: syntax error near unexpected token `(' test.c: line 2: ` Copyright (C) 2009 by Matthias Ringwald' fannes-boombox:~ mobile$
and this sais i get an error.
can anyone help me please ?
@Terence: prolonged inquiries make the Wifi break down, as both use the same spectrum. Same happens when you go Settings->General->Bluetooth and wait there for a few minutes.
It would be great if we can make BTstack work with touchscreen. So that we can play iPhone on a big touchscreen. ,I'm making a bluetooth device for a 42 inch touchscreen will code for BTstack to deal with the touchscreen data later.
would be nice to chat with you guys>>mail me : Sifer@ultra-realistic.com
@sifer: customGatz just release something like that, see http://www.customgadz.com/
none of this makes since. how to i download this my iphone says it needs to be reinstalled btstack but i cant find it any where i am not a programer so i do not know what any of this means. so speak english.
hello. is there a way to know bluetooth address of others' devices?