mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2025-12-21 16:34:23 +01:00
UART API exposed for other apps, e.g. Tasker. Support library v.22.1.1, build tools 22.0.1.
The app is still using ActionBarActivity instead of AppCompatActivity.
This commit is contained in:
@@ -85,12 +85,12 @@
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" exported="" name="appcompat-v7-22.1.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="gson-2.3.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-v4-22.0.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="nrf-logger-v2.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-annotations-22.0.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="achartengine-1.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="appcompat-v7-22.0.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-v4-22.1.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-annotations-22.1.1" level="project" />
|
||||
<orderEntry type="module" module-name="dfu" exported="" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -2,13 +2,13 @@ apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 22
|
||||
buildToolsVersion '22.0.0'
|
||||
buildToolsVersion '22.0.1'
|
||||
defaultConfig {
|
||||
applicationId "no.nordicsemi.android.nrftoolbox"
|
||||
minSdkVersion 18
|
||||
targetSdkVersion 22
|
||||
versionCode 31
|
||||
versionName "1.13.0"
|
||||
versionCode 32
|
||||
versionName "1.13.1"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
@@ -20,7 +20,7 @@ android {
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.android.support:appcompat-v7:22.0.0'
|
||||
compile 'com.android.support:appcompat-v7:22.1.1'
|
||||
compile project(':..:DFULibrary:dfu')
|
||||
compile files('libs/achartengine-1.1.0.jar')
|
||||
compile files('libs/nrf-logger-v2.0.jar')
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="no.nordicsemi.android.nrftoolbox"
|
||||
android:installLocation="auto"
|
||||
android:versionCode="31"
|
||||
android:versionName="1.13.0" >
|
||||
android:versionCode="32"
|
||||
android:versionName="1.13.1" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="18"
|
||||
|
||||
@@ -43,6 +43,11 @@ public class UARTService extends BleProfileService implements UARTManagerCallbac
|
||||
public static final String BROADCAST_UART_RX = "no.nordicsemi.android.nrftoolbox.uart.BROADCAST_UART_RX";
|
||||
public static final String EXTRA_DATA = "no.nordicsemi.android.nrftoolbox.uart.EXTRA_DATA";
|
||||
|
||||
/** A broadcast message with this action and the message in {@link Intent#EXTRA_TEXT} will be sent t the UART device. */
|
||||
private final static String ACTION_SEND = "no.nordicsemi.android.nrftoolbox.uart.ACTION_SEND";
|
||||
/** A broadcast message with this action is triggered when a message is received from the UART device. */
|
||||
private final static String ACTION_RECEIVE = "no.nordicsemi.android.nrftoolbox.uart.ACTION_RECEIVE";
|
||||
/** Action send when user press the DISCONNECT button on the notification. */
|
||||
private final static String ACTION_DISCONNECT = "no.nordicsemi.android.nrftoolbox.uart.ACTION_DISCONNECT";
|
||||
|
||||
private final static int NOTIFICATION_ID = 349; // random
|
||||
@@ -79,9 +84,8 @@ public class UARTService extends BleProfileService implements UARTManagerCallbac
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
final IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(ACTION_DISCONNECT);
|
||||
registerReceiver(mDisconnectActionBroadcastReceiver, filter);
|
||||
registerReceiver(mDisconnectActionBroadcastReceiver, new IntentFilter(ACTION_DISCONNECT));
|
||||
registerReceiver(mIntentBroadcastReceiver, new IntentFilter(ACTION_SEND));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,6 +93,7 @@ public class UARTService extends BleProfileService implements UARTManagerCallbac
|
||||
// when user has disconnected from the sensor, we have to cancel the notification that we've created some milliseconds before using unbindService
|
||||
cancelNotification();
|
||||
unregisterReceiver(mDisconnectActionBroadcastReceiver);
|
||||
unregisterReceiver(mIntentBroadcastReceiver);
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
@@ -118,10 +123,15 @@ public class UARTService extends BleProfileService implements UARTManagerCallbac
|
||||
final Intent broadcast = new Intent(BROADCAST_UART_RX);
|
||||
broadcast.putExtra(EXTRA_DATA, data);
|
||||
LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast);
|
||||
|
||||
// send the data received to other apps, e.g. the Tasker
|
||||
final Intent globalBroadcast = new Intent(ACTION_RECEIVE);
|
||||
globalBroadcast.putExtra(Intent.EXTRA_TEXT, data);
|
||||
sendBroadcast(globalBroadcast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataSent(String data) {
|
||||
public void onDataSent(final String data) {
|
||||
Logger.a(getLogSession(), "\"" + data + "\" sent");
|
||||
|
||||
final Intent broadcast = new Intent(BROADCAST_UART_TX);
|
||||
@@ -181,4 +191,16 @@ public class UARTService extends BleProfileService implements UARTManagerCallbac
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Broadcast receiver that listens for {@link #ACTION_SEND} from other apps. Sends the String content of the {@link Intent#EXTRA_TEXT} extra to the remote device.
|
||||
*/
|
||||
private BroadcastReceiver mIntentBroadcastReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
Logger.i(getLogSession(), "[Broadcast] Disconnect action pressed");
|
||||
final String message = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||
mManager.send(message);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user