Merge branch 'master' of git://git.gag.com/fw/altos
authorMike Beattie <mike@ethernal.org>
Tue, 7 Aug 2012 18:46:56 +0000 (06:46 +1200)
committerMike Beattie <mike@ethernal.org>
Tue, 7 Aug 2012 18:46:56 +0000 (06:46 +1200)
23 files changed:
.gitignore
altosdroid/.classpath
altosdroid/.gitignore
altosdroid/AndroidManifest.xml
altosdroid/Makefile.am
altosdroid/build.properties [deleted file]
altosdroid/libs/.gitignore [new file with mode: 0644]
altosdroid/local.properties.in
altosdroid/res/drawable-hdpi/am_status.png [deleted file]
altosdroid/res/drawable-hdpi/am_status_c.png [new file with mode: 0644]
altosdroid/res/drawable-hdpi/am_status_g.png [new file with mode: 0644]
altosdroid/res/drawable-mdpi/am_status.png [deleted file]
altosdroid/res/drawable-mdpi/am_status_c.png [new file with mode: 0644]
altosdroid/res/drawable-mdpi/am_status_g.png [new file with mode: 0644]
altosdroid/res/layout/main.xml
altosdroid/res/menu/option_menu.xml
altosdroid/res/values/strings.xml
altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
altosdroid/src/org/altusmetrum/AltosDroid/BluetoothChatService.java
altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java
altosui/.gitignore
ao-tools/ao-stmload/Makefile.am
configure.ac

index 1773096d3a940df68d749ea26e26017e193cef27..782be7f62cbcd373897a7b07878851cf6d07162d 100644 (file)
@@ -33,6 +33,7 @@ ao-tools/ao-list/ao-list
 ao-tools/ao-load/ao-load
 ao-tools/ao-postflight/ao-postflight
 ao-tools/ao-rawload/ao-rawload
+ao-tools/ao-send-telem/ao-send-telem
 ao-tools/ao-view/ao-view
 ao-view/Makefile
 ao-view/ao-view
index d260cafa9fa7daecc06482f74eba146785e19742..0ca188f976cb1ad5ecb928955d6393cf283d7a0d 100644 (file)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
        <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
-       <classpathentry kind="lib" path="lib/AltosLib.jar"/>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="src" path="gen"/>
-       <classpathentry kind="output" path="bin"/>
+       <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+       <classpathentry kind="output" path="bin/classes"/>
 </classpath>
index 44f249ee45e16c594a5674f9af38f4ec709c577a..c0bb8dd49fe499ffa29593dba371369e85d71f0d 100644 (file)
@@ -1,4 +1,3 @@
 local.properties
 bin
 gen
-local.properties
index 1d55737dac47788f12cf51a6501bb7521cfb807d..96fe5ac70164c29a52412e03619af6c2721374a4 100644 (file)
@@ -17,7 +17,7 @@
       package="org.altusmetrum.AltosDroid"
       android:versionCode="1"
       android:versionName="1.0">
-    <uses-sdk minSdkVersion="6" />
+    <uses-sdk android:targetSdkVersion="10" android:minSdkVersion="10"/>
     <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
     <uses-permission android:name="android.permission.BLUETOOTH" />
 
index 0732087b437cc32bbf281605658b963d8f030bd5..6ee984c2588f2aaa43956a16d803bff20fa9959a 100644 (file)
@@ -15,6 +15,11 @@ APKBUILDER=$(SDK)/tools/apkbuilder
 ZIPALIGN=$(SDK)/tools/zipalign
 
 SRC_DIR=src/org/altusmetrum/AltosDroid
+EXT_LIBDIR=libs
+ALTOSLIB_SRCDIR=../altoslib
+ALTOSLIB_JAR=AltosLib.jar
+
+ALTOSLIB=$(EXT_LIBDIR)/$(ALTOSLIB_JAR)
 
 SRC=\
        $(SRC_DIR)/AltosDroid.java \
@@ -25,11 +30,9 @@ SRC=\
 
 all: $(all_target)
 
-ALTOSLIB=bin/classes/AltosLib.jar
-
-$(ALTOSLIB):
-       mkdir -p bin/classes
-       cd bin/classes && ln -s ../../../altoslib/AltosLib.jar .
+$(ALTOSLIB): $(ALTOSLIB_SRCDIR)/$(ALTOSLIB_JAR)
+       mkdir -p $(EXT_LIBDIR)
+       cd $(EXT_LIBDIR) && ln -s $(shell echo $(EXT_LIBDIR) | sed 's|[^/]\+|..|g')/$(ALTOSLIB_SRCDIR)/$(ALTOSLIB_JAR) .
 
 if ANDROID
 install-release: bin/AltosDroid-release.apk
diff --git a/altosdroid/build.properties b/altosdroid/build.properties
deleted file mode 100644 (file)
index 63d080c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-jar.libs.dir=../altoslib
\ No newline at end of file
diff --git a/altosdroid/libs/.gitignore b/altosdroid/libs/.gitignore
new file mode 100644 (file)
index 0000000..b4e68f6
--- /dev/null
@@ -0,0 +1 @@
+AltosLib.jar
index 543ce2081e565c9bbbcfb1f1c63bb21a569cb1c1..14df0494361de26fac8c85bb7f9815ae951443f6 100644 (file)
@@ -8,4 +8,3 @@
 # For customization when using a Version Control System, please read the
 # header note.
 sdk.dir=@ANDROID_SDK@
-extensible.libs.classpath=../altoslib
diff --git a/altosdroid/res/drawable-hdpi/am_status.png b/altosdroid/res/drawable-hdpi/am_status.png
deleted file mode 100644 (file)
index 03f9dd7..0000000
Binary files a/altosdroid/res/drawable-hdpi/am_status.png and /dev/null differ
diff --git a/altosdroid/res/drawable-hdpi/am_status_c.png b/altosdroid/res/drawable-hdpi/am_status_c.png
new file mode 100644 (file)
index 0000000..d439321
Binary files /dev/null and b/altosdroid/res/drawable-hdpi/am_status_c.png differ
diff --git a/altosdroid/res/drawable-hdpi/am_status_g.png b/altosdroid/res/drawable-hdpi/am_status_g.png
new file mode 100644 (file)
index 0000000..03f9dd7
Binary files /dev/null and b/altosdroid/res/drawable-hdpi/am_status_g.png differ
diff --git a/altosdroid/res/drawable-mdpi/am_status.png b/altosdroid/res/drawable-mdpi/am_status.png
deleted file mode 100644 (file)
index 07f7f07..0000000
Binary files a/altosdroid/res/drawable-mdpi/am_status.png and /dev/null differ
diff --git a/altosdroid/res/drawable-mdpi/am_status_c.png b/altosdroid/res/drawable-mdpi/am_status_c.png
new file mode 100644 (file)
index 0000000..30a8d29
Binary files /dev/null and b/altosdroid/res/drawable-mdpi/am_status_c.png differ
diff --git a/altosdroid/res/drawable-mdpi/am_status_g.png b/altosdroid/res/drawable-mdpi/am_status_g.png
new file mode 100644 (file)
index 0000000..07f7f07
Binary files /dev/null and b/altosdroid/res/drawable-mdpi/am_status_g.png differ
index 17025f6bbd9b691cd80ab5637c1237a8e0d0a385..070928a55a0c9f529fa7aa6390796c65ad5ed15b 100644 (file)
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     >
-    <ListView android:id="@+id/in"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:stackFromBottom="true"
-        android:transcriptMode="alwaysScroll"
+
+    <TextView
+        android:id="@+id/in"
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent"
         android:layout_weight="1"
-    />
+        android:gravity="bottom"
+        android:scrollbars="vertical"
+        android:textSize="7dp"
+        android:typeface="monospace" />
+
     <LinearLayout
         android:orientation="horizontal"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         >
-        <EditText android:id="@+id/edit_text_out"
+
+        <EditText
+            android:id="@+id/edit_text_out"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_weight="1"
             android:layout_gravity="bottom"
-        />
+            android:layout_weight="1"
+            android:inputType="text|textNoSuggestions" />
+
         <Button android:id="@+id/button_send"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
index 27625e9c3bda21bb8309d59ac7b585ceb9f784fc..feb5668ea0e42c58f664735cab1b30f8783b1ec7 100644 (file)
      limitations under the License.
 -->
 <menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:id="@+id/connect_scan"
+          android:icon="@android:drawable/ic_menu_search"
+          android:title="@string/connect_device" />
     <item android:id="@+id/telemetry_service_control"
           android:icon="@android:drawable/ic_menu_manage"
           android:title="@string/telemetry_service_control" />
     <item android:id="@+id/telemetry_service_bind"
           android:icon="@android:drawable/ic_menu_rotate"
           android:title="@string/telemetry_service_bind" />
-    <item android:id="@+id/secure_connect_scan"
-          android:icon="@android:drawable/ic_menu_search"
-          android:title="@string/secure_connect" />
-    <item android:id="@+id/insecure_connect_scan"
-          android:icon="@android:drawable/ic_menu_search"
-          android:title="@string/insecure_connect" />
-    <item android:id="@+id/discoverable"
-          android:icon="@android:drawable/ic_menu_mylocation"
-          android:title="@string/discoverable" />
 </menu>
index 0b2f922749b26e33181d9bc78b5488e5475eab4a..72a4ddec2b03c0932535d9f58ad41bd645217648 100644 (file)
     <string name="send">Send</string>
     <string name="not_connected">You are not connected to a device</string>
     <string name="bt_not_enabled_leaving">Bluetooth was not enabled. Leaving Bluetooth Chat.</string>
-    <string name="title_connecting">connecting...</string>
+    <string name="title_connecting">connecting</string>
     <string name="title_connected_to">connected: </string>
     <string name="title_not_connected">not connected</string>
 
     <!--  DeviceListActivity -->
-    <string name="scanning">scanning for devices...</string>
+    <string name="scanning">scanning for devices</string>
     <string name="select_device">select a device to connect</string>
     <string name="none_paired">No devices have been paired</string>
     <string name="none_found">No devices found</string>
     <string name="button_scan">Scan for devices</string>
 
     <!-- Options Menu -->
-    <string name="secure_connect">Connect a device - Secure</string>
-    <string name="insecure_connect">Connect a device - Insecure</string>
-    <string name="discoverable">Make discoverable</string>
+    <string name="connect_device">Connect a device</string>
+    <string name="telemetry_service_control">Control Service</string>
+    <string name="telemetry_service_bind">(Un)Bind Service</string>
+
+
 
     <!-- Service -->
-    <string name="telemetry_service_label">AltOS Telemetry Service</string>
+    <string name="telemetry_service_label">AltosDroid Telemetry Service</string>
     <string name="telemetry_service_started">Telemetry Service Started</string>
     <string name="telemetry_service_stopped">Telemetry Service Stopped</string>
 
-
-
-    <string name="telemetry_service_control">Start/Stop Service</string>
-    <string name="telemetry_service_bind">Bind/Unbind Service</string>
-
-    <string name="activity_telemetry_service_controller">App/Service/Local Service Controller</string>
-    <string name="telemetry_service_controller">This demonstrates how you can implement persistent services that
-        may be started and stopped as desired.</string>
+    <!-- Service control activity - temporary! -->
+    <string name="activity_telemetry_service_controller">Telemetry Service Controller</string>
+    <string name="telemetry_service_controller">Use the following buttons to start and stop the Telemetry
+        service.</string>
     <string name="start_service">Start Service</string>
     <string name="stop_service">Stop Service</string>
 
-    <string name="activity_telemetry_service_binding">App/Service/Local Service Binding</string>
+    <string name="activity_telemetry_service_binding">Telemetry Service Binding</string>
     <string name="telemetry_service_binding">This demonstrates how you can connect with a persistent
         service.  Notice how it automatically starts for you, and play around with the
         interaction between this and Local Service Controller.</string>
     <string name="bind_service">Bind Service</string>
     <string name="unbind_service">Unbind Service</string>
+
     <string name="telemetry_service_connected">Connected to local service</string>
     <string name="telemetry_service_disconnected">Disconnected from local service</string>
 
index b4a3227cde7664d4e4b8d1a99f1c9edf84ec8352..b4725e220c41d27a4a3ce90f4467ae25f6a2f199 100644 (file)
@@ -23,6 +23,7 @@ import android.content.Intent;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
+import android.text.method.ScrollingMovementMethod;
 import android.util.Log;
 import android.view.KeyEvent;
 import android.view.Menu;
@@ -32,10 +33,8 @@ import android.view.View;
 import android.view.Window;
 import android.view.View.OnClickListener;
 import android.view.inputmethod.EditorInfo;
-import android.widget.ArrayAdapter;
 import android.widget.Button;
 import android.widget.EditText;
-import android.widget.ListView;
 import android.widget.TextView;
 import android.widget.Toast;
 import org.altusmetrum.AltosDroid.R;
@@ -46,11 +45,9 @@ import org.altusmetrum.AltosLib.*;
  */
 public class AltosDroid extends Activity {
     // Debugging
-    private static final String TAG = "BluetoothChat";
+    private static final String TAG = "AltosDroid";
     private static final boolean D = true;
 
-    private static final AltosLine q = new AltosLine();
-
     // Message types sent from the BluetoothChatService Handler
     public static final int MESSAGE_STATE_CHANGE = 1;
     public static final int MESSAGE_READ = 2;
@@ -63,20 +60,17 @@ public class AltosDroid extends Activity {
     public static final String TOAST = "toast";
 
     // Intent request codes
-    private static final int REQUEST_CONNECT_DEVICE_SECURE = 1;
-    private static final int REQUEST_CONNECT_DEVICE_INSECURE = 2;
-    private static final int REQUEST_ENABLE_BT = 3;
+    private static final int REQUEST_CONNECT_DEVICE = 1;
+    private static final int REQUEST_ENABLE_BT      = 2;
 
     // Layout Views
     private TextView mTitle;
-    private ListView mConversationView;
+    private TextView mSerialView;
     private EditText mOutEditText;
     private Button mSendButton;
 
     // Name of the connected device
     private String mConnectedDeviceName = null;
-    // Array adapter for the conversation thread
-    private ArrayAdapter<String> mConversationArrayAdapter;
     // String buffer for outgoing messages
     private StringBuffer mOutStringBuffer;
     // Local Bluetooth adapter
@@ -144,13 +138,35 @@ public class AltosDroid extends Activity {
         }
     }
 
+    @Override
+    public synchronized void onPause() {
+        super.onPause();
+        if(D) Log.e(TAG, "- ON PAUSE -");
+    }
+
+    @Override
+    public void onStop() {
+        super.onStop();
+        if(D) Log.e(TAG, "-- ON STOP --");
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+        // Stop the Bluetooth chat services
+        if (mChatService != null) mChatService.stop();
+        if(D) Log.e(TAG, "--- ON DESTROY ---");
+    }
+
+
+
     private void setupChat() {
         Log.d(TAG, "setupChat()");
 
-        // Initialize the array adapter for the conversation thread
-        mConversationArrayAdapter = new ArrayAdapter<String>(this, R.layout.message);
-        mConversationView = (ListView) findViewById(R.id.in);
-        mConversationView.setAdapter(mConversationArrayAdapter);
+        mSerialView = (TextView) findViewById(R.id.in);
+        mSerialView.setMovementMethod(new ScrollingMovementMethod());
+        mSerialView.setClickable(false);
+        mSerialView.setLongClickable(false);
 
         // Initialize the compose field with a listener for the return key
         mOutEditText = (EditText) findViewById(R.id.edit_text_out);
@@ -174,36 +190,6 @@ public class AltosDroid extends Activity {
         mOutStringBuffer = new StringBuffer("");
     }
 
-    @Override
-    public synchronized void onPause() {
-        super.onPause();
-        if(D) Log.e(TAG, "- ON PAUSE -");
-    }
-
-    @Override
-    public void onStop() {
-        super.onStop();
-        if(D) Log.e(TAG, "-- ON STOP --");
-    }
-
-    @Override
-    public void onDestroy() {
-        super.onDestroy();
-        // Stop the Bluetooth chat services
-        if (mChatService != null) mChatService.stop();
-        if(D) Log.e(TAG, "--- ON DESTROY ---");
-    }
-
-    private void ensureDiscoverable() {
-        if(D) Log.d(TAG, "ensure discoverable");
-        if (mBluetoothAdapter.getScanMode() !=
-            BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
-            Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
-            discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
-            startActivity(discoverableIntent);
-        }
-    }
-
     /**
      * Sends a message.
      * @param message  A string of text to send.
@@ -252,7 +238,7 @@ public class AltosDroid extends Activity {
                 case BluetoothChatService.STATE_CONNECTED:
                     mTitle.setText(R.string.title_connected_to);
                     mTitle.append(mConnectedDeviceName);
-                    mConversationArrayAdapter.clear();
+                    mSerialView.setText("");
                     break;
                 case BluetoothChatService.STATE_CONNECTING:
                     mTitle.setText(R.string.title_connecting);
@@ -267,13 +253,13 @@ public class AltosDroid extends Activity {
                 byte[] writeBuf = (byte[]) msg.obj;
                 // construct a string from the buffer
                 String writeMessage = new String(writeBuf);
-                mConversationArrayAdapter.add("Me:  " + writeMessage);
+                mSerialView.append(writeMessage + '\n');
                 break;
             case MESSAGE_READ:
                 byte[] readBuf = (byte[]) msg.obj;
                 // construct a string from the valid bytes in the buffer
                 String readMessage = new String(readBuf, 0, msg.arg1);
-                mConversationArrayAdapter.add(mConnectedDeviceName+":  " + readMessage);
+                mSerialView.append(readMessage);
                 break;
             case MESSAGE_DEVICE_NAME:
                 // save the connected device's name
@@ -292,16 +278,10 @@ public class AltosDroid extends Activity {
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         if(D) Log.d(TAG, "onActivityResult " + resultCode);
         switch (requestCode) {
-        case REQUEST_CONNECT_DEVICE_SECURE:
-            // When DeviceListActivity returns with a device to connect
+        case REQUEST_CONNECT_DEVICE:
+            // When DeviceListActivity returns with a device to connect to
             if (resultCode == Activity.RESULT_OK) {
-                connectDevice(data, true);
-            }
-            break;
-        case REQUEST_CONNECT_DEVICE_INSECURE:
-            // When DeviceListActivity returns with a device to connect
-            if (resultCode == Activity.RESULT_OK) {
-                connectDevice(data, false);
+                connectDevice(data);
             }
             break;
         case REQUEST_ENABLE_BT:
@@ -318,14 +298,14 @@ public class AltosDroid extends Activity {
         }
     }
 
-    private void connectDevice(Intent data, boolean secure) {
+    private void connectDevice(Intent data) {
         // Get the device MAC address
         String address = data.getExtras()
             .getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS);
         // Get the BLuetoothDevice object
         BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
         // Attempt to connect to the device
-        mChatService.connect(device, secure);
+        mChatService.connect(device);
     }
 
     @Override
@@ -347,19 +327,10 @@ public class AltosDroid extends Activity {
             serverIntent = new Intent(this, TelemetryServiceActivities.Binding.class);
             startActivity(serverIntent);
             return true;
-        case R.id.secure_connect_scan:
-            // Launch the DeviceListActivity to see devices and do scan
-            serverIntent = new Intent(this, DeviceListActivity.class);
-            startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE_SECURE);
-            return true;
-        case R.id.insecure_connect_scan:
+        case R.id.connect_scan:
             // Launch the DeviceListActivity to see devices and do scan
             serverIntent = new Intent(this, DeviceListActivity.class);
-            startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE_INSECURE);
-            return true;
-        case R.id.discoverable:
-            // Ensure this device is discoverable by others
-            ensureDiscoverable();
+            startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
             return true;
         }
         return false;
index 93cb75de8b6e9092899f61e14b54e904b612851d..a93c08d6efac8a5f4e074cfedfa6dcc5e298bfd9 100644 (file)
@@ -19,9 +19,7 @@ package org.altusmetrum.AltosDroid;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-//import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
+import java.util.UUID;
 import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothDevice;
 import android.bluetooth.BluetoothSocket;
@@ -103,9 +101,8 @@ public class BluetoothChatService {
     /**
      * Start the ConnectThread to initiate a connection to a remote device.
      * @param device  The BluetoothDevice to connect
-     * @param secure Socket Security type - Secure (true) , Insecure (false)
      */
-    public synchronized void connect(BluetoothDevice device, boolean secure) {
+    public synchronized void connect(BluetoothDevice device) {
         if (D) Log.d(TAG, "connect to: " + device);
 
         // Cancel any thread attempting to make a connection
@@ -117,7 +114,7 @@ public class BluetoothChatService {
         if (mConnectedThread != null) {mConnectedThread.cancel(); mConnectedThread = null;}
 
         // Start the thread to connect with the given device
-        mConnectThread = new ConnectThread(device, secure);
+        mConnectThread = new ConnectThread(device);
         mConnectThread.start();
         setState(STATE_CONNECTING);
     }
@@ -127,9 +124,8 @@ public class BluetoothChatService {
      * @param socket  The BluetoothSocket on which the connection was made
      * @param device  The BluetoothDevice that has been connected
      */
-    public synchronized void connected(BluetoothSocket socket, BluetoothDevice
-            device, final String socketType) {
-        if (D) Log.d(TAG, "connected, Socket Type:" + socketType);
+    public synchronized void connected(BluetoothSocket socket, BluetoothDevice device) {
+        if (D) Log.d(TAG, "connected");
 
         // Cancel the thread that completed the connection
         if (mConnectThread != null) {mConnectThread.cancel(); mConnectThread = null;}
@@ -138,7 +134,7 @@ public class BluetoothChatService {
         if (mConnectedThread != null) {mConnectedThread.cancel(); mConnectedThread = null;}
 
         // Start the thread to manage the connection and perform transmissions
-        mConnectedThread = new ConnectedThread(socket, socketType);
+        mConnectedThread = new ConnectedThread(socket);
         mConnectedThread.start();
 
         // Send the name of the connected device back to the UI Activity
@@ -224,37 +220,25 @@ public class BluetoothChatService {
      * succeeds or fails.
      */
     private class ConnectThread extends Thread {
+        private final UUID SPP_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
         private final BluetoothSocket mmSocket;
         private final BluetoothDevice mmDevice;
-        private String mSocketType;
 
-        public ConnectThread(BluetoothDevice device, boolean secure) {
+               public ConnectThread(BluetoothDevice device) {
             mmDevice = device;
             BluetoothSocket tmp = null;
-            mSocketType = secure ? "Secure" : "Insecure";
 
-            // Get a BluetoothSocket for a connection with the
-            // given BluetoothDevice
             try {
-                if (secure) {
-                       Method m = device.getClass().getMethod("createRfcommSocket", new Class[] {int.class});
-                       tmp = (BluetoothSocket) m.invoke(device, 2);
-//                    tmp = device.createRfcommSocket(1);
-                } else {
-                       Method m = device.getClass().getMethod("createInsecureRfcommSocket", new Class[] {int.class});
-                       tmp = (BluetoothSocket) m.invoke(device, 2);
-//                    tmp = device.createInsecureRfcommSocket(1);
-                }
-            } catch (Exception e) {
-                Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e);
+                               tmp = mmDevice.createInsecureRfcommSocketToServiceRecord(SPP_UUID);
+                       } catch (IOException e) {
                                e.printStackTrace();
                        }
             mmSocket = tmp;
         }
 
         public void run() {
-            Log.i(TAG, "BEGIN mConnectThread SocketType:" + mSocketType);
-            setName("ConnectThread" + mSocketType);
+            Log.i(TAG, "BEGIN mConnectThread");
+            setName("ConnectThread");
 
             // Always cancel discovery because it will slow down a connection
             mAdapter.cancelDiscovery();
@@ -269,8 +253,7 @@ public class BluetoothChatService {
                 try {
                     mmSocket.close();
                 } catch (IOException e2) {
-                    Log.e(TAG, "unable to close() " + mSocketType +
-                            " socket during connection failure", e2);
+                    Log.e(TAG, "unable to close() socket during connection failure", e2);
                 }
                 connectionFailed();
                 return;
@@ -282,14 +265,14 @@ public class BluetoothChatService {
             }
 
             // Start the connected thread
-            connected(mmSocket, mmDevice, mSocketType);
+            connected(mmSocket, mmDevice);
         }
 
         public void cancel() {
             try {
                 mmSocket.close();
             } catch (IOException e) {
-                Log.e(TAG, "close() of connect " + mSocketType + " socket failed", e);
+                Log.e(TAG, "close() of connect socket failed", e);
             }
         }
     }
@@ -303,8 +286,8 @@ public class BluetoothChatService {
         private final InputStream mmInStream;
         private final OutputStream mmOutStream;
 
-        public ConnectedThread(BluetoothSocket socket, String socketType) {
-            Log.d(TAG, "create ConnectedThread: " + socketType);
+        public ConnectedThread(BluetoothSocket socket) {
+            Log.d(TAG, "create ConnectedThread");
             mmSocket = socket;
             InputStream tmpIn = null;
             OutputStream tmpOut = null;
@@ -333,7 +316,7 @@ public class BluetoothChatService {
                     bytes = mmInStream.read(buffer);
 
                     // Send the obtained bytes to the UI Activity
-                    mHandler.obtainMessage(AltosDroid.MESSAGE_READ, bytes, -1, buffer)
+                    mHandler.obtainMessage(AltosDroid.MESSAGE_READ, bytes, -1, buffer.clone())
                             .sendToTarget();
                 } catch (IOException e) {
                     Log.e(TAG, "disconnected", e);
@@ -350,6 +333,7 @@ public class BluetoothChatService {
         public void write(byte[] buffer) {
             try {
                 mmOutStream.write(buffer);
+                mmOutStream.write('\n');
 
                 // Share the sent message back to the UI Activity
                 mHandler.obtainMessage(AltosDroid.MESSAGE_WRITE, -1, -1, buffer)
index 40dff3549dc74e19eee79a31ddbc0b99c4e9b373..c0a32c9208ae6566dabed2dd7d9caaeefeddc6ae 100644 (file)
@@ -37,7 +37,7 @@ public class TelemetryService extends Service {
 
     // Unique Identification Number for the Notification.
     // We use it on Notification start, and to cancel it.
-    private int NOTIFICATION = R.string.telemetry_service_started;
+    private int NOTIFICATION = R.string.telemetry_service_label;
 
     /**
      * Class for clients to access.  Because we know this service always
@@ -52,15 +52,32 @@ public class TelemetryService extends Service {
 
     @Override
     public void onCreate() {
+        // Create a reference to the NotificationManager so that we can update our notifcation text later
         mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
-
-        // Display a notification about us starting.  We put an icon in the status bar.
-        showNotification();
     }
 
     @Override
     public int onStartCommand(Intent intent, int flags, int startId) {
         Log.i("TelemetryService", "Received start id " + startId + ": " + intent);
+
+        CharSequence text = getText(R.string.telemetry_service_started);
+
+        // Create notification to be displayed while the service runs
+        Notification notification = new Notification(R.drawable.am_status_c, text, 0);
+
+        // The PendingIntent to launch our activity if the user selects this notification
+        PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
+                new Intent(this, TelemetryServiceActivities.Controller.class), 0);
+
+        // Set the info for the views that show in the notification panel.
+        notification.setLatestEventInfo(this, getText(R.string.telemetry_service_label), text, contentIntent);
+
+        // Set the notification to be in the "Ongoing" section.
+        notification.flags |= Notification.FLAG_ONGOING_EVENT;
+
+        // Move us into the foreground.
+        startForeground(NOTIFICATION, notification);
+
         // We want this service to continue running until it is explicitly
         // stopped, so return sticky.
         return START_STICKY;
@@ -68,8 +85,8 @@ public class TelemetryService extends Service {
 
     @Override
     public void onDestroy() {
-        // Cancel the persistent notification.
-        mNM.cancel(NOTIFICATION);
+        // Demote us from the foreground, and cancel the persistent notification.
+        stopForeground(true);
 
         // Tell the user we stopped.
         Toast.makeText(this, R.string.telemetry_service_stopped, Toast.LENGTH_SHORT).show();
@@ -84,26 +101,4 @@ public class TelemetryService extends Service {
     // RemoteService for a more complete example.
     private final IBinder mBinder = new TelemetryBinder();
 
-    /**
-     * Show a notification while this service is running.
-     */
-    private void showNotification() {
-        // In this sample, we'll use the same text for the ticker and the expanded notification
-        CharSequence text = getText(R.string.telemetry_service_started);
-
-        // Set the icon, scrolling text and timestamp
-        Notification notification = new Notification(R.drawable.am_status, text,
-                System.currentTimeMillis());
-
-        // The PendingIntent to launch our activity if the user selects this notification
-        PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
-                new Intent(this, TelemetryServiceActivities.Controller.class), 0);
-
-        // Set the info for the views that show in the notification panel.
-        notification.setLatestEventInfo(this, getText(R.string.telemetry_service_label),
-                       text, contentIntent);
-
-        // Send the notification.
-        mNM.notify(NOTIFICATION, notification);
-    }
 }
index 6d65611f7059e3c7fe199491cacfeec4111e8c0b..6d2d8c23f8cab1f96a3012893cf958f8a4d3ec59 100644 (file)
@@ -5,6 +5,7 @@ fat/
 Manifest.txt
 Manifest-fat.txt
 AltosVersion.java
+Info.plist
 libaltosJNI
 classes
 altosui
index 375896ea22af09343837a1474c416d9e0205cf25..5aea7db4ab48ceeb4a3c31e33c34f2279d2474c7 100644 (file)
@@ -1,3 +1,5 @@
+if LIBSTLINK
+
 bin_PROGRAMS=ao-stmload
 
 LIBSTLINKDIR=/local/src/stlink
@@ -9,3 +11,5 @@ ao_stmload_LDADD=$(LIBSTLINK_LIBS) $(LIBUSB_LIBS) -lelf
 ao_stmload_SOURCES=ao-stmload.c
 
 man_MANS = ao-stmload.1
+
+endif
index c59261afb96046aea487a038b1a8babd5c599548..a54ef626494dbe8e03699fe57f56c12ce7097776 100644 (file)
@@ -139,7 +139,9 @@ PKG_CHECK_MODULES([LIBUSB], [libusb-1.0])
 AC_CHECK_HEADERS(libelf.h libelf/libelf.h, [break])
 AC_CHECK_HEADERS(gelf.h libelf/gelf.h, [break])
 
-PKG_CHECK_MODULES([LIBSTLINK], [stlink])
+PKG_CHECK_MODULES([LIBSTLINK], [stlink], [HAVE_STLINK=yes], [HAVE_STLINK=no])
+
+AM_CONDITIONAL([LIBSTLINK], [test x$HAVE_STLINK != xno])
 
 AC_OUTPUT([
 Makefile