Coder Social home page Coder Social logo

hexatatweer / bluetooth-smart-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kristinaheyerdahlelfving/bluetooth-smart-plugin

0.0 3.0 0.0 2.25 MB

Bluetooth Smart Plugin to use in Cordova (PhoneGap) applications for the iOS platform

bluetooth-smart-plugin's Introduction

Bluetooth-Smart-Plugin

by Kristina Heyerdahl Elfving

DESCRIPTON

This is a Bluetooth Low Energy (Bluetooth version 4, also called Bluetooth Smart) Plugin to use in Cordova (PhoneGap) projects targeted for the iOS platform. The plugin allow use of Bluetooth Smart in Cordova applications for iOS, and using the plugin require using Cordova. Some parts of the native code in the plugin is based on the Bluetooth Smart Health Thermometer profile, but can still be used with other Bluetoth Smart devices with some modification.

Bluetooth Smart is not yet (April 2013) supported by the Android operating system.

The plugin can be used for the following Bluetooth Smart actions:

  • Search for Bluetooth Smart peripherals
  • Connect to a discovered peripheral
  • Discover services for peripheral
  • Receive data from peripheral
  • Disconnect from the connected peripheral

SAMPLE APPLICATION

A sample application using the plugin is included in the "Sample Application" folder. The application can be run on an iPhone 4s or iPhone 5, and a Bluetooth Smart peripheral is needed for testing.

PLUGIN SETUP FOR IOS

Make sure Cordova is installed.

Copy the files in the www and blePlugin folders into your Cordova project. The www folder contains a cordova file, a plugin file, pluginFile.js, and a index.html file. The index.html is used for the interface, and can be replaced, but contains some examples showing how to use the plugin. pluginFile.js contains the JavaScript mappings for the plugin.

Call the native code from the JavaScript interface in index.html. This is done using the mapping functions. An example:

search.callBlePSearch( blePSearchResultHandler, blePSearchErrorHandler, returnSuccess );

To retrieve data from the peripheral, some parts of the native code in the plugin may have to be changed. The Objective-C function blePNotify in blePluginClass.m is used for setting notification for Bluetooth Smart services, and here the UUID of the service and characteristic must be specified:

[self.CBP setNotificationForCharacteristic:self.CBP.currentPeripheral sUUID:@"1809" cUUID:@"2a1c" enable:TRUE];

FEEDBACK AND IMPROVEMENTS

Please give feedback! The code will be improved if somebody have any suggestions or find bugs.

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.