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>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
|
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<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="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="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="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="" />
|
<orderEntry type="module" module-name="dfu" exported="" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ apply plugin: 'com.android.application'
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 22
|
compileSdkVersion 22
|
||||||
buildToolsVersion '22.0.0'
|
buildToolsVersion '22.0.1'
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "no.nordicsemi.android.nrftoolbox"
|
applicationId "no.nordicsemi.android.nrftoolbox"
|
||||||
minSdkVersion 18
|
minSdkVersion 18
|
||||||
targetSdkVersion 22
|
targetSdkVersion 22
|
||||||
versionCode 31
|
versionCode 32
|
||||||
versionName "1.13.0"
|
versionName "1.13.1"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
@@ -20,7 +20,7 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
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 project(':..:DFULibrary:dfu')
|
||||||
compile files('libs/achartengine-1.1.0.jar')
|
compile files('libs/achartengine-1.1.0.jar')
|
||||||
compile files('libs/nrf-logger-v2.0.jar')
|
compile files('libs/nrf-logger-v2.0.jar')
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="no.nordicsemi.android.nrftoolbox"
|
package="no.nordicsemi.android.nrftoolbox"
|
||||||
android:installLocation="auto"
|
android:installLocation="auto"
|
||||||
android:versionCode="31"
|
android:versionCode="32"
|
||||||
android:versionName="1.13.0" >
|
android:versionName="1.13.1" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="18"
|
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 BROADCAST_UART_RX = "no.nordicsemi.android.nrftoolbox.uart.BROADCAST_UART_RX";
|
||||||
public static final String EXTRA_DATA = "no.nordicsemi.android.nrftoolbox.uart.EXTRA_DATA";
|
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 String ACTION_DISCONNECT = "no.nordicsemi.android.nrftoolbox.uart.ACTION_DISCONNECT";
|
||||||
|
|
||||||
private final static int NOTIFICATION_ID = 349; // random
|
private final static int NOTIFICATION_ID = 349; // random
|
||||||
@@ -79,9 +84,8 @@ public class UARTService extends BleProfileService implements UARTManagerCallbac
|
|||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
final IntentFilter filter = new IntentFilter();
|
registerReceiver(mDisconnectActionBroadcastReceiver, new IntentFilter(ACTION_DISCONNECT));
|
||||||
filter.addAction(ACTION_DISCONNECT);
|
registerReceiver(mIntentBroadcastReceiver, new IntentFilter(ACTION_SEND));
|
||||||
registerReceiver(mDisconnectActionBroadcastReceiver, filter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
// when user has disconnected from the sensor, we have to cancel the notification that we've created some milliseconds before using unbindService
|
||||||
cancelNotification();
|
cancelNotification();
|
||||||
unregisterReceiver(mDisconnectActionBroadcastReceiver);
|
unregisterReceiver(mDisconnectActionBroadcastReceiver);
|
||||||
|
unregisterReceiver(mIntentBroadcastReceiver);
|
||||||
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
@@ -118,10 +123,15 @@ public class UARTService extends BleProfileService implements UARTManagerCallbac
|
|||||||
final Intent broadcast = new Intent(BROADCAST_UART_RX);
|
final Intent broadcast = new Intent(BROADCAST_UART_RX);
|
||||||
broadcast.putExtra(EXTRA_DATA, data);
|
broadcast.putExtra(EXTRA_DATA, data);
|
||||||
LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast);
|
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
|
@Override
|
||||||
public void onDataSent(String data) {
|
public void onDataSent(final String data) {
|
||||||
Logger.a(getLogSession(), "\"" + data + "\" sent");
|
Logger.a(getLogSession(), "\"" + data + "\" sent");
|
||||||
|
|
||||||
final Intent broadcast = new Intent(BROADCAST_UART_TX);
|
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