Giter Club home page Giter Club logo

appcelerator-iphone-bluetooth-module's Introduction

Appcelerator Bluetooth Module

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

Building


First download the code: git clone [email protected]: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.

appcelerator-iphone-bluetooth-module's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.