edu.columbia.irt.mobiledyswis
Class BTSocket

java.lang.Object
  extended by edu.columbia.irt.mobiledyswis.BTSocket
All Implemented Interfaces:
java.lang.Runnable

public class BTSocket
extends java.lang.Object
implements java.lang.Runnable

Bluetooth Socket Plugin for PhoneGap

Author:
Jin Hyung Park(jp2105)

Constructor Summary
BTSocket(Context parent, java.lang.String id, WebView appView, java.lang.String macddr)
          BTSocket Constructor
 
Method Summary
 void close()
           
 void destroy()
          Clean up method.
 java.lang.String getId()
           
static BTSocket getInstance(Context parent, java.lang.String id, WebView appView, java.lang.String macddr)
          BTSocket instance getting method
 java.lang.String getLocalIpAddress()
          Function to get the device's local IP address
 void init(java.lang.String btRemoteName)
          Initialize this BTSocket instance.
 boolean isFailed()
          Checking Bluetooth initialization
 boolean isReady()
          Bluetooth connection check function
 void onMessage(java.lang.String msg)
          JavaScript onMessage Event Handling Function
 void run()
           
 void send(java.lang.String text)
          Writes a bytestream to the server
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BTSocket

public BTSocket(Context parent,
                java.lang.String id,
                WebView appView,
                java.lang.String macddr)
BTSocket Constructor

Parameters:
parent - This parent context should be PhoneGap's Main Context
Method Detail

getInstance

public static BTSocket getInstance(Context parent,
                                   java.lang.String id,
                                   WebView appView,
                                   java.lang.String macddr)
BTSocket instance getting method

Parameters:
parent - This parent context should be PhoneGap's Main Context
id - Unique ID for this instance
appView - This should point the web view.
macddr - Bluetooth Mac Address to connect
Returns:

isReady

public boolean isReady()
Bluetooth connection check function

Returns:
returns true if connection is successfully established.

isFailed

public boolean isFailed()
Checking Bluetooth initialization

Returns:
returns true if connection has failed explicitly.

init

public void init(java.lang.String btRemoteName)
Initialize this BTSocket instance.

Parameters:
btRemoteName - the name of the Bluetooth server device.

destroy

public void destroy()
Clean up method. Needs to be in onDestroy() in the main activity


send

public void send(java.lang.String text)
Writes a bytestream to the server

Parameters:
text - the bytes you wish to write.

onMessage

public final void onMessage(java.lang.String msg)
JavaScript onMessage Event Handling Function

Parameters:
msg - The actual message is sent to JavaScript

close

public void close()

getLocalIpAddress

public java.lang.String getLocalIpAddress()
Function to get the device's local IP address

Returns:
IP Address as a string

run

public void run()
Specified by:
run in interface java.lang.Runnable

getId

public java.lang.String getId()