diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml
index dac7f47..d7a770d 100644
--- a/res/layout/activity_main.xml
+++ b/res/layout/activity_main.xml
@@ -2,10 +2,42 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:baselineAligned="false"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
- android:baselineAligned="false"
tools:context=".MainActivity" >
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml
index 62a954b..ab243ab 100644
--- a/res/values-es/strings.xml
+++ b/res/values-es/strings.xml
@@ -7,7 +7,7 @@
Cámara abierta exitosamente
La cámara no pudo abrirse
Conectar con NxtAR
- Conectar con dispositivo controlador
+ Comenzar streaming de video
CamActivity
Dirección IP de NxtAR
La dirección IP no es válida
@@ -17,6 +17,13 @@
Cancelar
Encender
El radio del WiFi está encendido
- Esta app no puede funcionar sin wifi. Cerrando.
+ Esta app no puede funcionar sin wifi, cerrando.
+ Este dispositivo no soporta Bluetooth
+ Esta app no puede funcionar sin Bluetooth, cerrando
+ Ícono de lente
+ Conectar con el robot
+ Escoja un robot
+ Conexión exitosa con el robot
+ No se pudo conectar con el robot
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 463e6d1..3ba7e3c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -8,7 +8,7 @@
Camera could not be opened
CamActivity
Connect with NxtAR
- Connect with controller device
+ Start video streaming
NxtAR IP Address
Invalid IP address
Fill out the IP address field
@@ -16,7 +16,14 @@
Turn on the WiFi?
Cancel
Turn on
- The Wifi radio is on now
- This app cannot work without wifi. Closing.
+ The WiFi radio is on now
+ This app cannot work without WiFi, closing
+ This device does not support Bluetooth
+ This app cannot work without Bluetooth, closing
+ Image lens icon
+ Connect with robot
+ Pick a robot
+ Successfully connected with the robot
+ Could not connect with the robot
-
+
\ No newline at end of file
diff --git a/src/ve/ucv/ciens/ccg/nxtcam/MainActivity.java b/src/ve/ucv/ciens/ccg/nxtcam/MainActivity.java
index bf7024e..feb3835 100644
--- a/src/ve/ucv/ciens/ccg/nxtcam/MainActivity.java
+++ b/src/ve/ucv/ciens/ccg/nxtcam/MainActivity.java
@@ -5,12 +5,16 @@ import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;
+import ve.ucv.ciens.ccg.nxtcam.dialogs.ConnectRobotDialog;
+import ve.ucv.ciens.ccg.nxtcam.dialogs.ConnectRobotDialog.ConnectRobotDialogListener;
import ve.ucv.ciens.ccg.nxtcam.dialogs.WifiOnDialog;
import ve.ucv.ciens.ccg.nxtcam.dialogs.WifiOnDialog.WifiOnDialogListener;
+import ve.ucv.ciens.ccg.nxtcam.network.BTCommunicator;
import ve.ucv.ciens.ccg.nxtcam.utils.Logger;
import ve.ucv.ciens.ccg.nxtcam.utils.ProjectConstants;
import android.app.Activity;
import android.app.DialogFragment;
+import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.WifiManager;
@@ -18,6 +22,8 @@ import android.net.wifi.WifiManager.MulticastLock;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
import android.widget.Toast;
/**
@@ -33,16 +39,23 @@ import android.widget.Toast;
* @author miky
*
*/
-public class MainActivity extends Activity implements WifiOnDialogListener{
+public class MainActivity extends Activity implements WifiOnDialogListener, ConnectRobotDialogListener{
// Cosntant fields.
private final String TAG = "NXTCAM_MAIN";
private final String CLASS_NAME = MainActivity.class.getSimpleName();
+ private static final int REQUEST_ENABLE_BT = 1;
+
+ // Gui components
+ private Button startButton;
+ private Button connectButton;
// Resources.
+ private BTCommunicator btManager;
private WifiManager wifiManager;
// Variables.
private boolean wifiOnByMe;
+ private boolean btOnByMe;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -51,18 +64,33 @@ public class MainActivity extends Activity implements WifiOnDialogListener{
// Set up fields.
wifiOnByMe = false;
+ btOnByMe = false;
+
+ // Set up gui components.
+ startButton = (Button)findViewById(R.id.startButton);
+ startButton.setEnabled(false);
+ connectButton = (Button)findViewById(R.id.connectButton);
// Set up services.
+ btManager = BTCommunicator.getInstance();
wifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
+
+ if(!btManager.isBTSupported()){
+ // El dispositivo no soporta BlueTooth.
+ Toast.makeText(this, R.string.bt_no_support, Toast.LENGTH_LONG).show();
+ finish();
+ System.exit(0);
+ }
}
@Override
public void onResume(){
super.onResume();
- if(!wifiManager.isWifiEnabled()){
- DialogFragment wifiOn = new WifiOnDialog();
- wifiOn.show(getFragmentManager(), "wifi_on");
+ if(!btManager.isBTEnabled()){
+ enableBT();
+ }else if(btManager.isBTEnabled() && !wifiManager.isWifiEnabled()){
+ enableWifi();
}
}
@@ -70,10 +98,24 @@ public class MainActivity extends Activity implements WifiOnDialogListener{
public void onPause(){
super.onPause();
+ if(btManager.isBTEnabled() && btOnByMe)
+ btManager.disableBT();
+
if(wifiManager.isWifiEnabled() && wifiOnByMe)
setWifi(false);
}
+ @Override
+ public void onDestroy(){
+ if(btManager.isConnected()){
+ try{
+ btManager.stopConnection();
+ }catch(IOException io){
+ Logger.log_e(TAG, CLASS_NAME + ".onDestroy() :: Error closing the connection with the robot: " + io.getMessage());
+ }
+ }
+ }
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
@@ -81,6 +123,15 @@ public class MainActivity extends Activity implements WifiOnDialogListener{
return true;
}
+ protected void onActivityResult(int request, int result, Intent data){
+ if(request == REQUEST_ENABLE_BT && result == RESULT_OK){
+ if(!wifiManager.isWifiEnabled())
+ enableWifi();
+ }else{
+ Toast.makeText(this, R.string.bt_on_fail, Toast.LENGTH_LONG).show();
+ }
+ }
+
/**
* Start the camera capture activity if a server was found through service discovery.
*
@@ -113,6 +164,25 @@ public class MainActivity extends Activity implements WifiOnDialogListener{
wifiOnByMe = false;
}
+ private void enableWifi(){
+ if(!wifiManager.isWifiEnabled()){
+ DialogFragment wifiOn = new WifiOnDialog();
+ ((WifiOnDialog)wifiOn).setWifiManager(wifiManager);
+ wifiOn.show(getFragmentManager(), "wifi_on");
+ }
+ }
+
+ private void enableBT(){
+ Logger.log_d(TAG, CLASS_NAME + ".enableBT() :: Enabling the Bluetooth radio.");
+ Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
+ startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
+ btOnByMe = true;
+ }
+
+ protected void showToast(int stringId, int length){
+ Toast.makeText(this, stringId, length).show();
+ }
+
/**
* Asynchronous task for ad hoc UDP service discovery.
*
@@ -185,17 +255,70 @@ public class MainActivity extends Activity implements WifiOnDialogListener{
}
}
- /* ServiceDiscoveryTask serviceDiscovery = new ServiceDiscoveryTask();
- serviceDiscovery.execute(); */
+ private class ConnectRobotTask extends AsyncTask{
+ private final String CLASS_NAME = ConnectRobotTask.class.getSimpleName();
+ private String macAddress;
+
+ public ConnectRobotTask(String macAddress){
+ this.macAddress = macAddress;
+ }
+
+ @Override
+ protected Boolean doInBackground(Void... params){
+ boolean connSet;
+ Logger.log_d(TAG, CLASS_NAME + "doInBackground() :: Establishing connection with the robot.");
+ try{
+ connSet = btManager.establishConnection(macAddress);
+ }catch(IOException e){
+ Logger.log_e(TAG, CLASS_NAME + "doInBackground() :: Error during the connection attempt.");
+ connSet = false;
+ }
+ return connSet;
+ }
+
+ @Override
+ protected void onPostExecute(Boolean result){
+ if(result){
+ Logger.log_d(TAG, CLASS_NAME + "doInBackground() :: Connection successful.");
+ showToast(R.string.conn_established, Toast.LENGTH_SHORT);
+ }else{
+ Logger.log_d(TAG, CLASS_NAME + "doInBackground() :: Connection failed.");
+ showToast(R.string.conn_failed, Toast.LENGTH_LONG);
+ connectButton.setEnabled(true);
+ }
+ }
+ }
@Override
public void onWifiOnDialogPositiveClick(DialogFragment dialog) {
Toast.makeText(this, R.string.wifi_on_success, Toast.LENGTH_SHORT).show();
+ wifiOnByMe = true;
}
@Override
public void onWifiOnDialogNegativeClick(DialogFragment dialog) {
- Toast.makeText(this, R.string.wifi_on_fail, Toast.LENGTH_SHORT).show();
- System.exit(0);
+ Toast.makeText(this, R.string.wifi_on_fail, Toast.LENGTH_LONG).show();
+ finish();
};
+
+ public void connectWithRobot(View view){
+ if(btManager.isBTEnabled()){
+ DialogFragment connectBot = new ConnectRobotDialog();
+ connectBot.show(getFragmentManager(), "connect_bot");
+ }
+ }
+
+ public void startConnections(View view){
+ ServiceDiscoveryTask serviceDiscovery = new ServiceDiscoveryTask();
+ serviceDiscovery.execute();
+ }
+
+ @Override
+ public void onConnectRobotDialogItemClick(DialogFragment dialog, String item) {
+ String macAddress = item.substring(item.indexOf('\n')+1);
+ Logger.log_d(TAG, CLASS_NAME + ".onConnectRobotDialogItemClick() :: MAC address: " + macAddress);
+ connectButton.setEnabled(false);
+ ConnectRobotTask robotTask = new ConnectRobotTask(macAddress);
+ robotTask.execute();
+ }
}
diff --git a/src/ve/ucv/ciens/ccg/nxtcam/dialogs/ConnectRobotDialog.java b/src/ve/ucv/ciens/ccg/nxtcam/dialogs/ConnectRobotDialog.java
index ef0d08e..ef03188 100644
--- a/src/ve/ucv/ciens/ccg/nxtcam/dialogs/ConnectRobotDialog.java
+++ b/src/ve/ucv/ciens/ccg/nxtcam/dialogs/ConnectRobotDialog.java
@@ -1,10 +1,18 @@
package ve.ucv.ciens.ccg.nxtcam.dialogs;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
import ve.ucv.ciens.ccg.nxtcam.R;
+import ve.ucv.ciens.ccg.nxtcam.network.BTCommunicator;
+import ve.ucv.ciens.ccg.nxtcam.utils.Logger;
+import ve.ucv.ciens.ccg.nxtcam.utils.ProjectConstants;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
+import android.bluetooth.BluetoothDevice;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -13,10 +21,12 @@ public class ConnectRobotDialog extends DialogFragment {
private final String CLASS_NAME = ConnectRobotDialog.class.getSimpleName();
private ConnectRobotDialogListener listener;
+ private BTCommunicator btManager;
+ private List devices;
+ private String[] devicesArray;
public interface ConnectRobotDialogListener{
- public void onConnectRobotDialogPositiveClick(DialogFragment dialog);
- public void onConnectRobotDialogNegativeClick(DialogFragment dialog);
+ public void onConnectRobotDialogItemClick(DialogFragment dialog, String item);
}
@Override
@@ -24,16 +34,28 @@ public class ConnectRobotDialog extends DialogFragment {
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- builder.setMessage(R.string.wifi_on_msg).setPositiveButton(R.string.wifi_on_button, new DialogInterface.OnClickListener() {
+ // Fill a list with all the paired LEGO robots.
+ btManager = BTCommunicator.getInstance();
+ devices = new ArrayList();
+ Set pairedDevices = btManager.getPairedDevices();
+ for (BluetoothDevice device : pairedDevices) {
+ // Put the device in the list only if it's MAC address belongs to LEGO.
+ if(device.getAddress().substring(0, 8).compareTo(ProjectConstants.OUI_LEGO) == 0)
+ devices.add(device.getName() + "\n" + device.getAddress());
+ }
+ devicesArray = devices.toArray(new String[devices.size()]);
- public void onClick(DialogInterface dialog, int id){
+ builder.setTitle(R.string.robot_choice).setItems(devicesArray, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which){
+ Logger.log_d(TAG, CLASS_NAME + ".setItems().onClick( :: User chose: " + devices.get(which));
+ listener.onConnectRobotDialogItemClick(ConnectRobotDialog.this, devices.get(which));
}
}).setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id){
-
+ Logger.log_d(TAG, CLASS_NAME + ".setNegativeButton().onClick( :: User canceled.");
}
});
diff --git a/src/ve/ucv/ciens/ccg/nxtcam/dialogs/WifiOnDialog.java b/src/ve/ucv/ciens/ccg/nxtcam/dialogs/WifiOnDialog.java
index fa39884..af21fad 100644
--- a/src/ve/ucv/ciens/ccg/nxtcam/dialogs/WifiOnDialog.java
+++ b/src/ve/ucv/ciens/ccg/nxtcam/dialogs/WifiOnDialog.java
@@ -11,9 +11,10 @@ import android.net.wifi.WifiManager;
import android.os.Bundle;
public class WifiOnDialog extends DialogFragment {
- private final String TAG = "NXTCAM_MAIN";
+ private final String TAG = "NXTCAM_WIFI_DIALOG";
private final String CLASS_NAME = WifiOnDialog.class.getSimpleName();
+ private WifiOnDialogListener listener;
private WifiManager wifiManager;
public interface WifiOnDialogListener{
@@ -26,23 +27,32 @@ public class WifiOnDialog extends DialogFragment {
}
@Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
+ public Dialog onCreateDialog(Bundle savedInstanceState){
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(R.string.wifi_on_msg).setPositiveButton(R.string.wifi_on_button, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
+ public void onClick(DialogInterface dialog, int id){
if(wifiManager != null){
wifiManager.setWifiEnabled(true);
- Logger.log_d(TAG, CLASS_NAME + " :: setting wifi to on.");
- }else
- Logger.log_wtf(TAG, CLASS_NAME + " :: wifiManager is null! Doing nothing.");
+ Logger.log_d(TAG, CLASS_NAME + ".setPositiveButton().onClick() :: setting wifi to on.");
+ if(listener != null)
+ listener.onWifiOnDialogPositiveClick(WifiOnDialog.this);
+ }else{
+ Logger.log_wtf(TAG, CLASS_NAME + ".setPositiveButton().onClick( :: wifiManager is null! Doing nothing.");
+ if(listener != null)
+ listener.onWifiOnDialogNegativeClick(WifiOnDialog.this);
+ }
}
}).setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) { }
+ public void onClick(DialogInterface dialog, int id){
+ Logger.log_d(TAG, CLASS_NAME + ".setPositiveButton().onClick( :: User canceled.");
+ if(listener != null)
+ listener.onWifiOnDialogNegativeClick(WifiOnDialog.this);
+ }
});
@@ -52,11 +62,13 @@ public class WifiOnDialog extends DialogFragment {
@Override
public void onAttach(Activity activity){
+ super.onAttach(activity);
+
try{
- @SuppressWarnings("unused")
- WifiOnDialogListener listener = (WifiOnDialogListener)activity;
+ listener = (WifiOnDialogListener)activity;
}catch(ClassCastException cce){
- throw new ClassCastException(activity.toString() + "Must implement WifiOnDialogListener.");
+ listener = null;
+ throw new ClassCastException(CLASS_NAME + ".onAttach() :: " + activity.toString() + "Must implement WifiOnDialogListener.");
}
}
}
diff --git a/src/ve/ucv/ciens/ccg/nxtcam/network/BTCommunicator.java b/src/ve/ucv/ciens/ccg/nxtcam/network/BTCommunicator.java
index f530187..a6e5772 100644
--- a/src/ve/ucv/ciens/ccg/nxtcam/network/BTCommunicator.java
+++ b/src/ve/ucv/ciens/ccg/nxtcam/network/BTCommunicator.java
@@ -4,10 +4,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Set;
-import java.util.UUID;
-import ve.ucv.ciens.ccg.nxtcam.MainActivity;
import ve.ucv.ciens.ccg.nxtcam.utils.Logger;
+import ve.ucv.ciens.ccg.nxtcam.utils.ProjectConstants;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
@@ -22,17 +21,14 @@ import android.util.Log;
*/
public class BTCommunicator{
private static final String TAG = "NXT_TEST_BTCOMM";
- private final String CLASS_NAME = MainActivity.class.getSimpleName();
-
- private static final UUID SERIAL_PORT_SERVICE_CLASS_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
- private static final String OUI_LEGO = "00:16:53";
+ private final String CLASS_NAME = BTCommunicator.class.getSimpleName();
private boolean connected;
- private BluetoothAdapter bt_adapter = null;
- private BluetoothSocket bt_socket = null;
- private OutputStream nxt_out_stream = null;
- private InputStream nxt_in_stream = null;
-
+ private BluetoothAdapter btAdapter = null;
+ private BluetoothSocket btSocket = null;
+ private OutputStream nxtOutputStream = null;
+ private InputStream nxtInputStream = null;
+
private static class SingletonHolder{
public static final BTCommunicator INSTANCE = new BTCommunicator();
}
@@ -51,10 +47,10 @@ public class BTCommunicator{
*/
private BTCommunicator(){
connected = false;
- bt_adapter = BluetoothAdapter.getDefaultAdapter();
- bt_socket = null;
- nxt_in_stream = null;
- nxt_out_stream = null;
+ btAdapter = BluetoothAdapter.getDefaultAdapter();
+ btSocket = null;
+ nxtInputStream = null;
+ nxtOutputStream = null;
}
/**
@@ -63,7 +59,7 @@ public class BTCommunicator{
* @return true if the default Bluetooth adapter exists, otherwise false.
*/
public boolean isBTSupported(){
- return bt_adapter != null;
+ return btAdapter != null;
}
/**
@@ -81,7 +77,7 @@ public class BTCommunicator{
* @see android.bluetooth.BluetoothAdapter
*/
public boolean isBTEnabled(){
- return bt_adapter.isEnabled();
+ return btAdapter.isEnabled();
}
/**
@@ -90,7 +86,7 @@ public class BTCommunicator{
* @see android.bluetooth.BluetoothAdapter
*/
public void disableBT(){
- bt_adapter.disable();
+ btAdapter.disable();
}
/**
@@ -99,7 +95,7 @@ public class BTCommunicator{
* @return A set containing all devices paired to this device.
*/
public Set getPairedDevices(){
- return bt_adapter.getBondedDevices();
+ return btAdapter.getBondedDevices();
}
/**
@@ -108,42 +104,42 @@ public class BTCommunicator{
* Verifies if the target device is a valid NXT robot by checking agains Lego's OUI.
* Also creates the socket and the streams associated with the connection
*
- * @param mac_address The mac address of the target device.
+ * @param macAddress The mac address of the target device.
* @return true if the connection was established succesfully, otherwise false.
* @throws IOException
*/
- public boolean establishConnection(String mac_address) throws IOException{
- if (!bt_adapter.isEnabled()){
+ public boolean establishConnection(String macAddress) throws IOException{
+ if (!btAdapter.isEnabled()){
return false;
}
if(connected){
return false;
}
- if(bt_adapter.isEnabled()){
- if(mac_address == "NONE"){
+ if(btAdapter.isEnabled()){
+ if(macAddress == "NONE"){
return false;
}else{
- if(mac_address.substring(0, 8).compareTo(OUI_LEGO) != 0){
- Logger.log_d(TAG, CLASS_NAME + ".establishConnection() :: Not a Lego MAC. Prefix : " + mac_address.substring(0, 8) + " :: OUI : " + OUI_LEGO);
+ if(macAddress.substring(0, 8).compareTo(ProjectConstants.OUI_LEGO) != 0){
+ Logger.log_d(TAG, CLASS_NAME + ".establishConnection() :: Not a Lego MAC. Prefix : " + macAddress.substring(0, 8) + " :: OUI : " + ProjectConstants.OUI_LEGO);
return false;
}else{
try{
- Logger.log_d(TAG, CLASS_NAME + ".establishConnection() :: Getting device with mac address: " + mac_address);
+ Logger.log_d(TAG, CLASS_NAME + ".establishConnection() :: Getting device with mac address: " + macAddress);
BluetoothDevice nxtDevice = null;
- nxtDevice = bt_adapter.getRemoteDevice(mac_address);
+ nxtDevice = btAdapter.getRemoteDevice(macAddress);
if (nxtDevice == null) {
Logger.log_e(TAG, CLASS_NAME + ".establishConnection() :: No device found.");
throw new IOException();
}
Logger.log_d(TAG, CLASS_NAME + ".establishConnection() :: Opening socket.");
- bt_socket = nxtDevice.createRfcommSocketToServiceRecord(SERIAL_PORT_SERVICE_CLASS_UUID);
+ btSocket = nxtDevice.createRfcommSocketToServiceRecord(ProjectConstants.SERIAL_PORT_SERVICE_CLASS_UUID);
Logger.log_d(TAG, CLASS_NAME + ".establishConnection() :: Connecting.");
- bt_socket.connect();
+ btSocket.connect();
Logger.log_d(TAG, CLASS_NAME + ".establishConnection() :: Opening IO streams.");
- nxt_in_stream = bt_socket.getInputStream();
- nxt_out_stream = bt_socket.getOutputStream();
+ nxtInputStream = btSocket.getInputStream();
+ nxtOutputStream = btSocket.getOutputStream();
Logger.log_d(TAG, CLASS_NAME + ".establishConnection() :: Connection established.");
connected = true;
@@ -171,12 +167,12 @@ public class BTCommunicator{
*/
public boolean stopConnection() throws IOException{
try{
- if(bt_socket != null){
+ if(btSocket != null){
Logger.log_d(TAG, CLASS_NAME + ".stopConnection() :: Closing connection.");
- bt_socket.close();
- bt_socket = null;
- nxt_in_stream = null;
- nxt_out_stream = null;
+ btSocket.close();
+ btSocket = null;
+ nxtInputStream = null;
+ nxtOutputStream = null;
connected = false;
Logger.log_d(TAG, CLASS_NAME + ".stopConnection() :: Connection closed.");
return true;
@@ -198,7 +194,7 @@ public class BTCommunicator{
public synchronized void writeMessage(byte[] message) throws IOException{
if(connected){
try{
- nxt_out_stream.write(message);
+ nxtOutputStream.write(message);
}catch(IOException e){
Logger.log_e(TAG, CLASS_NAME + ".writeMessage()");
Logger.log_e(TAG, Log.getStackTraceString(e));
@@ -220,7 +216,7 @@ public class BTCommunicator{
for(int i = 0; i < message.length; ++i){
message[i] = 0x00;
}
- nxt_in_stream.read(message, 0, bytes);
+ nxtInputStream.read(message, 0, bytes);
return message;
}catch(IOException e){
Logger.log_e(TAG, CLASS_NAME + ".readMessage()");
diff --git a/src/ve/ucv/ciens/ccg/nxtcam/utils/ProjectConstants.java b/src/ve/ucv/ciens/ccg/nxtcam/utils/ProjectConstants.java
index aed7b89..24ca455 100644
--- a/src/ve/ucv/ciens/ccg/nxtcam/utils/ProjectConstants.java
+++ b/src/ve/ucv/ciens/ccg/nxtcam/utils/ProjectConstants.java
@@ -1,11 +1,14 @@
package ve.ucv.ciens.ccg.nxtcam.utils;
+import java.util.UUID;
+
public abstract class ProjectConstants {
public static final int SERVER_UDP_PORT = 8889;
public static final int SERVER_TCP_PORT_1 = 9989;
public static final int SERVER_TCP_PORT_2 = 9990;
-
+ public static final UUID SERIAL_PORT_SERVICE_CLASS_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
+ public static final String OUI_LEGO = "00:16:53";
public static final String MULTICAST_ADDRESS = "230.0.0.1";
-
+
public static final boolean DEBUG = true;
}