Skip to content

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

License

Notifications You must be signed in to change notification settings

avenauche/Appcelerator-iPhone-Bluetooth-Module

 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published