Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A module for appcelerator that allows two iOS devices to communicate bidirectionally over bluetooth.

branch: master
Octocat-spinner-32 Classes Documentation January 11, 2011
Octocat-spinner-32 bluetoothmodule.xcodeproj Documentation January 11, 2011
Octocat-spinner-32 documentation Initial commit October 30, 2010
Octocat-spinner-32 example Initial commit October 30, 2010
Octocat-spinner-32 hooks Initial commit October 30, 2010
Octocat-spinner-32 ComSmontgomerieBluetooth_Prefix.pch Added files January 11, 2011
Octocat-spinner-32 LICENSE Added license January 11, 2011
Octocat-spinner-32 README Added files January 11, 2011
Octocat-spinner-32 README.rdoc January 14, 2011
Octocat-spinner-32 build.py Initial commit October 30, 2010
Octocat-spinner-32 manifest Initial commit October 30, 2010
Octocat-spinner-32 module.xcconfig Initial commit October 30, 2010
Octocat-spinner-32 titanium.xcconfig Documentation January 11, 2011
README.rdoc

Appcelerator Bluetooth Module

A module for appcelerator that allows two iOS devices to communicate bidirectionally over bluetooth.

Building


First download the code: git clone git@github.com:smontgomerie/Appcelerator-iPhone-Bluetooth-Module.git cd Appcelerator-iPhone-Bluetooth-Module

Then build the code. ./build.py

If you get an error, it's likely that the Titanium SDK is wrong. Modify the “titanium.xconfig” file:

TITANIUM_SDK_VERSION = 1.4.0 (or whatever version of the mobile SDK you're using).

This directory should be present: TITANIUM_SDK = ${HOME}/Library/Application Support/Titanium/mobilesdk/osx/$(TITANIUM_SDK_VERSION)

If not, modify it to the installation of your Titanium Mobile SDK.

Next, install the calendar into your app. cp com.smontgomerie.bluetooth-iphone-xxx.zip ~/Library/Application\ Support/Titanium/

Finally, in your app's tiapp.xml file: <modules>

	  <module version="xxx">com.smontgomerie.bluetooth</module>
	</modules>

Make sure to change the “xxx” to the version of the module that's been compiled.

You'll need to at least touch your iPhone app before including it (assuming you're building with Xcode, not Titanium).

Basic Usage


First, we'll need to add the Framework in Xcode. Select Frame-works in your project folder, right click “Add -> Existing Frameworks” and select the menu item. *Add GameKit.framework*

Next, we'll want to require this module in our Appcelerator Javascript code:

var bluetooth = require(“com.smontgomerie.bluetooth”); Ti.API.info(“module is => ” + bluetooth);

Next, some example code to start connecting:

// Create a button called connectBtn

connectBtn.addEventListener(“click”, function() { bluetooth.startPicker(); });

Do something useful when another user connects:

bluetooth.addEventListener(“didConnect”, function(e) { var peerID = e.peerID; });

Now, send some data to our peer: // Create a button called “sendBtn” sendBtn.addEventListener(“click”, function() { bluetooth.send({ data: “Hi” }); });

And do something when we receive data:

bluetooth.addEventListener(“receive”, function(e) { Ti.API.info(e); Ti.API.info(e.data); });

That's pretty much it! Any edits/improvements are appreciated.

TODO

  • Support multiplayer

  • Support voice chat

  • Support more events, such as the client will disconnect

  • Right now the module connects where both clients can be servers. Allow the user to choose a server or client mode.

  • Allow a custom peer picker UI. Apple's Gamekit PeerPicker UI sucks.

Something went wrong with that request. Please try again.