Skip to content

Commit

Permalink
Merge pull request #9 from awlayton/master
Browse files Browse the repository at this point in the history
Demo Improvements
  • Loading branch information
awlayton committed Jul 7, 2014
2 parents 6b8fb59 + d030304 commit 7660a1d
Show file tree
Hide file tree
Showing 11 changed files with 337 additions and 117 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ jdk:
- oraclejdk7
- openjdk7

script: mvn clean package
install: mvn dependency:resolve dependency:resolve-plugins

before_script: mvn clean

script: mvn package
23 changes: 23 additions & 0 deletions libISOBlue-aar/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Author: Alex Layton <[email protected]>
Copyright (c) 2014 Purdue University
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

Expand Down
28 changes: 28 additions & 0 deletions libISOBlue-example/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Author: Alex Layton <[email protected]>
Copyright (c) 2014 Purdue University
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -27,6 +50,11 @@
<artifactId>libisoblue-aar</artifactId>
<type>aar</type>
</dependency>
<dependency>
<groupId>com.mcxiaoke.volley</groupId>
<artifactId>library</artifactId>
<type>aar</type>
</dependency>
</dependencies>

<build>
Expand Down
116 changes: 75 additions & 41 deletions libISOBlue-example/res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,73 +15,107 @@
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:orientation="horizontal" >
android:orientation="vertical" >

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/cur_view"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:baselineAligned="false"
android:orientation="vertical" >
android:orientation="horizontal" >

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/eng_list_title" />

<ListView
android:id="@+id/eng"
android:layout_width="fill_parent"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:transcriptMode="alwaysScroll" />
android:baselineAligned="false"
android:orientation="vertical" >

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/buf_eng_list_title" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/eng_list_title" />

<ListView
android:id="@+id/buf_eng"
android:layout_width="fill_parent"
<ListView
android:id="@+id/eng"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:transcriptMode="alwaysScroll" />
</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:transcriptMode="alwaysScroll" />
android:baselineAligned="false"
android:orientation="vertical" >

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/imp_list_title" />

<ListView
android:id="@+id/imp"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:transcriptMode="alwaysScroll" />
</LinearLayout>
</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/buf_view"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:baselineAligned="false"
android:orientation="vertical" >

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/imp_list_title" />
android:orientation="horizontal" >

<ListView
android:id="@+id/imp"
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:transcriptMode="alwaysScroll" />
android:baselineAligned="false"
android:orientation="vertical" >

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/buf_imp_list_title" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/buf_eng_list_title" />

<ListView
android:id="@+id/buf_imp"
<ListView
android:id="@+id/buf_eng"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:transcriptMode="alwaysScroll" />
</LinearLayout>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:transcriptMode="alwaysScroll" />
android:baselineAligned="false"
android:orientation="vertical" >

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/buf_imp_list_title" />

<ListView
android:id="@+id/buf_imp"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:transcriptMode="alwaysScroll" />
</LinearLayout>
</LinearLayout>

</LinearLayout>
5 changes: 5 additions & 0 deletions libISOBlue-example/res/menu/option_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
android:icon="@android:drawable/ic_menu_search"
android:showAsAction="ifRoom|withText"
android:title="@string/insecure_connect"/>
<item
android:id="@+id/get_past_data"
android:showAsAction="never"
android:checkable="true"
android:title="@string/get_past_data"/>
<item
android:id="@+id/select_pgns"
android:showAsAction="ifRoom|withText"
Expand Down
1 change: 1 addition & 0 deletions libISOBlue-example/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

<!-- Options Menu -->
<string name="insecure_connect">Connect a device</string>
<string name="get_past_data">Get Buffered Data</string>
<string name="discoverable">Make discoverable</string>
<string name="select_pgns">Select PGNs</string>
<string name="about_button">About</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class BluetoothService {
private ConnectedThread mBufEngConnectedThread, mBufImpConnectedThread;
private int mState;

private boolean mPast;

// Constants that indicate the current connection state
public static final int STATE_NONE = 0; // we're doing nothing
public static final int STATE_LISTEN = 1; // now listening for incoming
Expand Down Expand Up @@ -122,12 +124,13 @@ public synchronized void start() {
*
* @param device
* The BluetoothDevice to connect
* @param past
* @param secure
* Socket Security type - Secure (true) , Insecure (false)
* @throws InterruptedException
* @throws IOException
*/
public synchronized void connect(BluetoothDevice device)
public synchronized void connect(BluetoothDevice device, boolean past)
throws IOException, InterruptedException {
// Cancel any thread attempting to make a connection
if (mState == STATE_CONNECTING) {
Expand All @@ -147,6 +150,8 @@ public synchronized void connect(BluetoothDevice device)
mImpConnectedThread = null;
}

mPast = past;

// Start the thread to connect with the given device
try {
mConnectThread = new ConnectThread(device);
Expand Down Expand Up @@ -189,14 +194,20 @@ public synchronized void connected(ISOBUSSocket engSocket,
}

// Start the thread to manage the connection and perform transmissions
mEngConnectedThread = new ConnectedThread(engSocket, ISOBlueDemo.MESSAGE_ARG1_NEW);
mEngConnectedThread = new ConnectedThread(engSocket,
ISOBlueDemo.MESSAGE_ARG1_NEW);
mEngConnectedThread.start();
mImpConnectedThread = new ConnectedThread(impSocket, ISOBlueDemo.MESSAGE_ARG1_NEW);
mImpConnectedThread = new ConnectedThread(impSocket,
ISOBlueDemo.MESSAGE_ARG1_NEW);
mImpConnectedThread.start();
mBufEngConnectedThread = new ConnectedThread(bufEngSocket, ISOBlueDemo.MESSAGE_ARG1_BUF);
mBufEngConnectedThread.start();
mBufImpConnectedThread = new ConnectedThread(bufImpSocket, ISOBlueDemo.MESSAGE_ARG1_BUF);
mBufImpConnectedThread.start();
if (mPast) {
mBufEngConnectedThread = new ConnectedThread(bufEngSocket,
ISOBlueDemo.MESSAGE_ARG1_BUF);
mBufEngConnectedThread.start();
mBufImpConnectedThread = new ConnectedThread(bufImpSocket,
ISOBlueDemo.MESSAGE_ARG1_BUF);
mBufImpConnectedThread.start();
}

// Send the name of the connected device back to the UI Activity
Message msg = mHandler.obtainMessage(ISOBlueDemo.MESSAGE_DEVICE_NAME);
Expand Down Expand Up @@ -307,10 +318,12 @@ public void run() {
mmImpSocket = new ISOBUSSocket(mmDevice.getImplementBus(),
null, pgns);

ISOBUSSocket[] bufSocks = mmDevice
.createBufferedISOBUSSockets(0);
mmBufEngSocket = bufSocks[0];
mmBufImpSocket = bufSocks[1];
if (mPast) {
ISOBUSSocket[] bufSocks = mmDevice
.createBufferedISOBUSSockets(0);
mmBufEngSocket = bufSocks[0];
mmBufImpSocket = bufSocks[1];
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand Down
Loading

0 comments on commit 7660a1d

Please sign in to comment.