Code Monkey home page Code Monkey logo

novarumbluetooth's Introduction

NovarumBluetooth

Appcelerator Titanium Bluetooth Module for Android

Update:

--Right now running as a background service is supported. To activate it, you should call novarumbluetooth.useService() and if data is received from bluetooth while the application is not running then application will be started again and you can get the data from the intent. Please check the example for details.

--New event (nb_onLowMemory) added for background service to be fired when the device is running low on memory.

Note: This is not an official bluetooth module nor 100% ready code for production. Please use it at your own risk.

Right now only connecting as a client is supported. Tested especially for connecting bluetooth modules such as JY-MCU

Accessing the novarumbluetooth Module

To access this module from JavaScript, you would do the following:

var novarumbluetooth = require("com.novarum.bluetooth");

The novarumbluetooth variable is a reference to the Module object.

Reference

novarumbluetooth.Disconnect

Disconnects from the bluetooth and if service is used, destroys the service

novarumbluetooth.useService

Enables the background service to be used for bluetooth communication. If this function is called, even when the application is not running bluetooth connection will be kept alive and on receiving data main activity will be started with the data (as intent extra) Please check the example for the details

novarumbluetooth.enableBluetooth

Enables bluetooth adapter

novarumbluetooth.disableBluetooth

Disables bluetooth adapter

novarumbluetooth.searchDevices

Searches for bluetooth devices

novarumbluetooth.getPairedDevices

Retrieves already paired bluetooth devices. You can connect to them using connect method and providing mac address

novarumbluetooth.connect(macadress)

connects to the device with the given mac address

novarumbluetooth.sendData(data)

if device is connected, it sends the given text data to the other end. To receive data, you must register nb_onReceiveData event

novarumbluetooth.isConnected()

checks if the device is connected

novarumbluetooth.startServer()

starts server. Note that this functions are not fully implemented yet and may not work

novarumbluetooth.stopServer()

stops server. Note that this functions are not fully implemented yet and may not work

novarumbluetooth.setServerName(name)

sets the server name. Note that this functions are not fully implemented yet and may not work

novarumbluetooth.setUUID(uuid)

sets the uuid will be used. Default is: 00001101-0000-1000-8000-00805F9B34FB

novarumbluetooth.makeDiscoverable()

makes the device be discoverable for 300 seconds

Events

###nb_onLowMemory

If background service is used, this is fired when the phone is running low on memory. It's advised to clean up some code or the service can be destroyed by the system

###nb_DevicesFound

Fired when a new bluetooth device is found. This event is fired after searchDevices function call

###nb_onConnect

Fired when a new successfull connection is made

###nb_onReceiveData

Fired when new data recevied

###nb_onError

Fired when an error ocurred. Contains the details of the error

###nb_onServerStarted

Fired when server is started successfully.

Usage

If you don't want to build it from the source code, please copy the module zip file provided to your project folder. Please refer to example app, it covers the main functionality.

Author

Halil Kabaca [email protected]

License

The MIT License (MIT)


Stuff our legal folk make us say:

Appcelerator, Appcelerator Titanium and associated marks and logos are trademarks of Appcelerator, Inc.

Titanium is Copyright (c) 2009-2012 by Appcelerator, Inc. All Rights Reserved.

Titanium is licensed under the Apache Public License (Version 2). Please see the LICENSE file for the full license.

novarumbluetooth's People

Watchers

James Cloos avatar Naresh 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.