diff --git a/.gitignore b/.gitignore
index db1555f09..a8936c3b3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,7 @@
.gradle
/local.properties
-/.idea/workspace.xml
-/.idea/dictionaries/*.xml
-/.idea/libraries
+/.idea
+*.iml
.DS_Store
/build
/key*
\ No newline at end of file
diff --git a/.idea/.name b/.idea/.name
deleted file mode 100644
index 41bcebb2a..000000000
--- a/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-nRFToolbox
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index 217af471a..000000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.idea/copyright/BSD.xml b/.idea/copyright/BSD.xml
deleted file mode 100644
index 178eefff0..000000000
--- a/.idea/copyright/BSD.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
deleted file mode 100644
index 564653fff..000000000
--- a/.idea/copyright/profiles_settings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
deleted file mode 100644
index f75895965..000000000
--- a/.idea/encodings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
deleted file mode 100644
index e67a6ec33..000000000
--- a/.idea/gradle.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index fc2d64b25..000000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 0a2137262..000000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
deleted file mode 100644
index 7f68460d8..000000000
--- a/.idea/runConfigurations.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml
deleted file mode 100644
index 922003b84..000000000
--- a/.idea/scopes/scope_settings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7f4..000000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/app.iml b/app/app.iml
deleted file mode 100644
index 5d755e3bc..000000000
--- a/app/app.iml
+++ /dev/null
@@ -1,111 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- generateDebugAndroidTestSources
- generateDebugSources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index a076e26ae..e55952a00 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -2,14 +2,14 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 23
- buildToolsVersion '23.0.2'
+ buildToolsVersion '23.0.3'
defaultConfig {
applicationId "no.nordicsemi.android.nrftoolbox"
minSdkVersion 18
targetSdkVersion 23
- versionCode 42
- versionName "1.16.3"
+ versionCode 43
+ versionName "1.16.4"
}
buildTypes {
release {
@@ -21,10 +21,10 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
- compile 'com.google.android.gms:play-services-wearable:8.3.0'
- compile 'com.android.support:appcompat-v7:23.1.1'
- compile 'com.android.support:design:23.1.1'
- compile 'no.nordicsemi.android.support.v18:scanner:0.1.1'
+ compile 'com.google.android.gms:play-services-wearable:9.0.2'
+ compile 'com.android.support:appcompat-v7:23.4.0'
+ compile 'com.android.support:design:23.4.0'
+ compile 'no.nordicsemi.android.support.v18:scanner:0.2.0'
compile 'no.nordicsemi.android:log:2.0.0'
compile('org.simpleframework:simple-xml:2.7.1') {
exclude group: 'stax', module: 'stax-api'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 859597cf8..9f7b47c77 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -233,7 +233,9 @@
android:label="@string/uart_feature_title" />
-
+
+
+
diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTActivity.java b/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTActivity.java
index 2625c4993..1f8aa3e0e 100644
--- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTActivity.java
+++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTActivity.java
@@ -128,9 +128,9 @@ public class UARTActivity extends BleProfileServiceReadyActivity parent, final View view, final int
final UARTEditDialog dialog = UARTEditDialog.getInstance(position, command);
dialog.show(getChildFragmentManager(), null);
} else {
- final String command = ((Command)mAdapter.getItem(position)).getCommand();
+ final Command command = (Command)mAdapter.getItem(position);
+ final Command.Eol eol = command.getEol();
+ String text = command.getCommand();
+ switch (eol) {
+ case CR_LF:
+ text = text.replaceAll("\n", "\r\n");
+ break;
+ case CR:
+ text = text.replaceAll("\n", "\r");
+ break;
+ }
final UARTInterface uart = (UARTInterface) getActivity();
- uart.send(command);
+ uart.send(text);
}
}
diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTEditDialog.java b/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTEditDialog.java
index 4b04a5fee..a553bd0e8 100644
--- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTEditDialog.java
+++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTEditDialog.java
@@ -23,9 +23,7 @@
package no.nordicsemi.android.nrftoolbox.uart;
import android.app.Dialog;
-import android.content.SharedPreferences;
import android.os.Bundle;
-import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
@@ -41,6 +39,7 @@
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
+import android.widget.RadioGroup;
import no.nordicsemi.android.nrftoolbox.R;
import no.nordicsemi.android.nrftoolbox.uart.domain.Command;
@@ -48,11 +47,13 @@
public class UARTEditDialog extends DialogFragment implements View.OnClickListener, GridView.OnItemClickListener {
private final static String ARG_INDEX = "index";
private final static String ARG_COMMAND = "command";
+ private final static String ARG_EOL = "eol";
private final static String ARG_ICON_INDEX = "iconIndex";
private int mActiveIcon;
private EditText mField;
- private CheckBox mCheckBox;
+ private CheckBox mActiveCheckBox;
+ private RadioGroup mEOLGroup;
private IconAdapter mIconAdapter;
public static UARTEditDialog getInstance(final int index, final Command command) {
@@ -61,6 +62,7 @@ public static UARTEditDialog getInstance(final int index, final Command command)
final Bundle args = new Bundle();
args.putInt(ARG_INDEX, index);
args.putString(ARG_COMMAND, command.getCommand());
+ args.putInt(ARG_EOL, command.getEol().index);
args.putInt(ARG_ICON_INDEX, command.getIconIndex());
fragment.setArguments(args);
@@ -76,6 +78,7 @@ public Dialog onCreateDialog(final Bundle savedInstanceState) {
final Bundle args = getArguments();
final int index = args.getInt(ARG_INDEX);
final String command = args.getString(ARG_COMMAND);
+ final int eol = args.getInt(ARG_EOL);
final int iconIndex = args.getInt(ARG_ICON_INDEX);
final boolean active = true; // change to active by default
mActiveIcon = iconIndex;
@@ -84,7 +87,7 @@ public Dialog onCreateDialog(final Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.feature_uart_dialog_edit, null);
final EditText field = mField = (EditText) view.findViewById(R.id.field);
final GridView grid = (GridView) view.findViewById(R.id.grid);
- final CheckBox checkBox = mCheckBox = (CheckBox) view.findViewById(R.id.active);
+ final CheckBox checkBox = mActiveCheckBox = (CheckBox) view.findViewById(R.id.active);
checkBox.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
@@ -95,6 +98,20 @@ public void onCheckedChanged(final CompoundButton buttonView, final boolean isCh
}
});
+ final RadioGroup eolGroup = mEOLGroup = (RadioGroup) view.findViewById(R.id.uart_eol);
+ switch (Command.Eol.values()[eol]) {
+ case CR_LF:
+ eolGroup.check(R.id.uart_eol_cr_lf);
+ break;
+ case CR:
+ eolGroup.check(R.id.uart_eol_cr);
+ break;
+ case LF:
+ default:
+ eolGroup.check(R.id.uart_eol_lf);
+ break;
+ }
+
field.setText(command);
field.setEnabled(active);
checkBox.setChecked(active);
@@ -112,13 +129,22 @@ public void onCheckedChanged(final CompoundButton buttonView, final boolean isCh
@Override
public void onClick(final View v) {
- final boolean active = mCheckBox.isChecked();
+ final boolean active = mActiveCheckBox.isChecked();
final String command = mField.getText().toString();
- if (active && TextUtils.isEmpty(command)) {
- mField.setError(getString(R.string.uart_edit_command_error));
- return;
+ int eol;
+
+ switch (mEOLGroup.getCheckedRadioButtonId()) {
+ case R.id.uart_eol_cr_lf:
+ eol = Command.Eol.CR_LF.index;
+ break;
+ case R.id.uart_eol_cr:
+ eol = Command.Eol.CR.index;
+ break;
+ case R.id.uart_eol_lf:
+ default:
+ eol = Command.Eol.LF.index;
+ break;
}
- mField.setError(null);
// Save values
final Bundle args = getArguments();
@@ -126,7 +152,7 @@ public void onClick(final View v) {
dismiss();
final UARTActivity parent = (UARTActivity) getActivity();
- parent.onCommandChanged(index, command, active, mActiveIcon);
+ parent.onCommandChanged(index, command, active, eol, mActiveIcon);
}
@Override
@@ -161,7 +187,7 @@ public View getView(final int position, final View convertView, final ViewGroup
}
final ImageView image = (ImageView) view;
image.setImageLevel(position);
- image.setActivated(position == mActiveIcon && mCheckBox.isChecked());
+ image.setActivated(position == mActiveIcon && mActiveCheckBox.isChecked());
return view;
}
}
diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTInterface.java b/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTInterface.java
index ea3c19340..6619ca57b 100644
--- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTInterface.java
+++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTInterface.java
@@ -25,5 +25,5 @@
public interface UARTInterface {
- public void send(final String text);
+ void send(final String text);
}
diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/domain/Command.java b/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/domain/Command.java
index 6b4c13e1e..e364c5515 100644
--- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/domain/Command.java
+++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/domain/Command.java
@@ -50,9 +50,21 @@ public enum Icon {
NUMBER_8(18),
NUMBER_9(19);
- public int index;
+ public final int index;
- private Icon(final int index) {
+ Icon(final int index) {
+ this.index = index;
+ }
+ }
+
+ public enum Eol {
+ LF(0),
+ CR(1),
+ CR_LF(2);
+
+ public final int index;
+
+ Eol(final int index) {
this.index = index;
}
}
@@ -63,6 +75,9 @@ private Icon(final int index) {
@Attribute(required = false)
private boolean active = false;
+ @Attribute(required = false)
+ private Eol eol = Eol.LF;
+
@Attribute(required = false)
private Icon icon = Icon.LEFT;
@@ -78,10 +93,18 @@ public void setCommand(final String command) {
* Sets whether the command is active.
* @param active true to make it active
*/
- public void setActive(boolean active) {
+ public void setActive(final boolean active) {
this.active = active;
}
+ /**
+ * Sets the new line type.
+ * @param eol end of line terminator
+ */
+ public void setEol(final int eol) {
+ this.eol = Eol.values()[eol];
+ }
+
/**
* Sets the icon index.
* @param index index of the icon.
@@ -106,6 +129,14 @@ public boolean isActive() {
return active;
}
+ /**
+ * Returns the new line type.
+ * @return end of line terminator
+ */
+ public Eol getEol() {
+ return eol;
+ }
+
/**
* Returns the icon index.
* @return the icon index
@@ -113,4 +144,11 @@ public boolean isActive() {
public int getIconIndex() {
return icon.index;
}
+ /**
+ * Returns the EOL index.
+ * @return the EOL index
+ */
+ public int getEolIndex() {
+ return eol.index;
+ }
}
diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/wearable/UARTConfigurationSynchronizer.java b/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/wearable/UARTConfigurationSynchronizer.java
index 8aef25f32..aa3299a29 100644
--- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/wearable/UARTConfigurationSynchronizer.java
+++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/wearable/UARTConfigurationSynchronizer.java
@@ -99,6 +99,7 @@ public PendingResult onConfigurationAddedOrEdited(final
final DataMap item = new DataMap();
item.putInt(Constants.UART.Configuration.Command.ICON_ID, command.getIconIndex());
item.putString(Constants.UART.Configuration.Command.MESSAGE, command.getCommand());
+ item.putInt(Constants.UART.Configuration.Command.EOL, command.getEolIndex());
commands.add(item);
}
}
diff --git a/app/src/main/res/layout/feature_uart_dialog_edit.xml b/app/src/main/res/layout/feature_uart_dialog_edit.xml
index 25e6a450d..72aa7045a 100644
--- a/app/src/main/res/layout/feature_uart_dialog_edit.xml
+++ b/app/src/main/res/layout/feature_uart_dialog_edit.xml
@@ -46,10 +46,47 @@
android:text="@string/uart_edit_active"/>
+
+
+
+
+
+
+
+
+
+
+
+
Configure button
Enter command
- Command must not be empty
Active
Select icon:
Disconnect
%s is connected.
-
+
+ EOL:
+ CR+LF
+ LF
+ CR
+
UART profile (Universal Asynchronous Receiver and Transmitter) is a Bluetooth Smart implementation of the UART standard. It allows for bidirectional
text based communication that is often used for debugging and control.
\nEach configuration contains 9 programmable buttons that may send commands to the UART TX characteristic. Click on the EDIT menu item to edit buttons actions.
diff --git a/build.gradle b/build.gradle
index a6fcfe1fe..f6e907312 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:1.5.0'
+ classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/common/build.gradle b/common/build.gradle
index 9937d49d4..b63b23166 100644
--- a/common/build.gradle
+++ b/common/build.gradle
@@ -24,7 +24,7 @@ apply plugin: 'com.android.library'
android {
compileSdkVersion 23
- buildToolsVersion "23.0.2"
+ buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 18
@@ -42,5 +42,5 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
- compile 'com.android.support:support-v4:23.1.1'
+ compile 'com.android.support:support-v4:23.4.0'
}
diff --git a/common/common.iml b/common/common.iml
deleted file mode 100644
index f58a14bb1..000000000
--- a/common/common.iml
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- generateDebugAndroidTestSources
- generateDebugSources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/common/src/main/java/no/nordicsemi/android/nrftoolbox/wearable/common/Constants.java b/common/src/main/java/no/nordicsemi/android/nrftoolbox/wearable/common/Constants.java
index 8c2e0d0d9..5d652d784 100644
--- a/common/src/main/java/no/nordicsemi/android/nrftoolbox/wearable/common/Constants.java
+++ b/common/src/main/java/no/nordicsemi/android/nrftoolbox/wearable/common/Constants.java
@@ -60,6 +60,7 @@ public static final class Configuration {
public static final class Command {
public static final String ICON_ID = "icon_id";
public static final String MESSAGE = "message";
+ public static final String EOL = "eol";
}
}
}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index f64777bde..99bbfde0f 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Mon Nov 02 11:30:44 CET 2015
+#Tue Jun 14 13:22:53 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
diff --git a/nRFToolbox.iml b/nRFToolbox.iml
deleted file mode 100644
index e37ba8751..000000000
--- a/nRFToolbox.iml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/wear/build.gradle b/wear/build.gradle
index ae358b8aa..37d9b55f1 100644
--- a/wear/build.gradle
+++ b/wear/build.gradle
@@ -3,7 +3,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 23
- buildToolsVersion "23.0.2"
+ buildToolsVersion "23.0.3"
defaultConfig {
applicationId "no.nordicsemi.android.nrftoolbox"
@@ -23,7 +23,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:1.3.0'
- compile 'com.google.android.gms:play-services-wearable:8.3.0'
+ compile 'com.google.android.gms:play-services-wearable:9.0.2'
compile 'no.nordicsemi.android.support.v18:scanner:0.1.1'
compile project(':common')
}
diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml
index d655f750e..f08e4a885 100644
--- a/wear/src/main/AndroidManifest.xml
+++ b/wear/src/main/AndroidManifest.xml
@@ -28,6 +28,7 @@
+
-
+
+
+
diff --git a/wear/src/main/java/no/nordicsemi/android/nrftoolbox/ScannerActivity.java b/wear/src/main/java/no/nordicsemi/android/nrftoolbox/ScannerActivity.java
index b7aaf32ac..c6e5e9b3e 100644
--- a/wear/src/main/java/no/nordicsemi/android/nrftoolbox/ScannerActivity.java
+++ b/wear/src/main/java/no/nordicsemi/android/nrftoolbox/ScannerActivity.java
@@ -22,6 +22,7 @@
package no.nordicsemi.android.nrftoolbox;
+import android.Manifest;
import android.app.Activity;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
@@ -29,9 +30,14 @@
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.content.pm.PackageManager;
+import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
+import android.support.annotation.NonNull;
+import android.support.v4.content.ContextCompat;
import android.support.v4.content.LocalBroadcastManager;
+import android.support.v4.content.PermissionChecker;
import android.support.wearable.view.WearableListView;
import android.util.Log;
import android.view.View;
@@ -43,6 +49,8 @@
public class ScannerActivity extends Activity {
private static final String TAG = "ScannerActivity";
+ private static final int PERMISSION_REQUEST_LOCATION = 1;
+
private DevicesAdapter mDeviceAdapter;
private View mHeader;
@@ -108,9 +116,30 @@ protected void onDestroy() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mServiceBroadcastReceiver);
}
+ @Override
+ public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) {
+ switch (requestCode) {
+ case PERMISSION_REQUEST_LOCATION:
+ if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ mDeviceAdapter.startLeScan();
+ } else {
+ Toast.makeText(ScannerActivity.this, "Location permission required", Toast.LENGTH_SHORT).show();
+ finish();
+ }
+ break;
+ }
+ }
+
@Override
protected void onResume() {
super.onResume();
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ if (checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
+ requestPermissions(new String[] { Manifest.permission.ACCESS_COARSE_LOCATION}, PERMISSION_REQUEST_LOCATION);
+ return;
+ }
+ }
mDeviceAdapter.startLeScan();
}
diff --git a/wear/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTCommandsActivity.java b/wear/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTCommandsActivity.java
index e74ae0df3..7fa891a40 100644
--- a/wear/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTCommandsActivity.java
+++ b/wear/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTCommandsActivity.java
@@ -190,7 +190,7 @@ public void onConnectionSuspended(final int cause) {
}
@Override
- public void onConnectionFailed(final ConnectionResult connectionResult) {
+ public void onConnectionFailed(@NonNull final ConnectionResult connectionResult) {
finish();
}
@@ -248,10 +248,21 @@ public void onMessageReceived(final MessageEvent messageEvent) {
@Override
public void onCommandSelected(final Command command) {
// Send command to handheld if the watch is not connected directly to the UART device.
+ final Command.Eol eol = command.getEol();
+ String text = command.getCommand();
+ switch (eol) {
+ case CR_LF:
+ text = text.replaceAll("\n", "\r\n");
+ break;
+ case CR:
+ text = text.replaceAll("\n", "\r");
+ break;
+ }
+
if (mProfile != null)
- mProfile.send(command.getCommand());
+ mProfile.send(text);
else
- sendMessageToHandheld(this, command.getCommand());
+ sendMessageToHandheld(this, text);
}
/**
diff --git a/wear/src/main/java/no/nordicsemi/android/nrftoolbox/uart/domain/Command.java b/wear/src/main/java/no/nordicsemi/android/nrftoolbox/uart/domain/Command.java
index 90f1def8b..fe0fca632 100644
--- a/wear/src/main/java/no/nordicsemi/android/nrftoolbox/uart/domain/Command.java
+++ b/wear/src/main/java/no/nordicsemi/android/nrftoolbox/uart/domain/Command.java
@@ -54,22 +54,37 @@ public enum Icon {
public int index;
- private Icon(final int index) {
+ Icon(final int index) {
this.index = index;
}
}
+ public enum Eol {
+ LF(0),
+ CR(1),
+ CR_LF(2);
+
+ public final int index;
+
+ Eol(final int index) {
+ this.index = index;
+ }
+ }
+
+ private Eol eol = Eol.LF;
private Icon icon = Icon.LEFT;
private String command;
/* package */ Command(final DataMap dataMap) {
icon = Icon.values()[dataMap.getInt(Constants.UART.Configuration.Command.ICON_ID)];
command = dataMap.getString(Constants.UART.Configuration.Command.MESSAGE);
+ eol = Eol.values()[dataMap.getInt(Constants.UART.Configuration.Command.EOL)];
}
private Command(final Parcel in) {
icon = (Icon) in.readSerializable();
command = in.readString();
+ eol = (Eol) in.readSerializable();
}
/**
@@ -80,6 +95,14 @@ private Command(final Parcel in) {
this.command = command;
}
+ /**
+ * Sets the new line type.
+ * @param eol end of line terminator
+ */
+ /* package */ void setEol(final int eol) {
+ this.eol = Eol.values()[eol];
+ }
+
/**
* Sets the icon index.
* @param index index of the icon.
@@ -96,6 +119,14 @@ public String getCommand() {
return command;
}
+ /**
+ * Returns the new line type.
+ * @return end of line terminator
+ */
+ public Eol getEol() {
+ return eol;
+ }
+
/**
* Returns the icon index.
* @return the icon index
@@ -125,5 +156,6 @@ public Command[] newArray(final int size) {
public void writeToParcel(final Parcel dest, int flags) {
dest.writeSerializable(icon);
dest.writeString(command);
+ dest.writeSerializable(eol);
}
}
diff --git a/wear/wear.iml b/wear/wear.iml
deleted file mode 100644
index fa175bef2..000000000
--- a/wear/wear.iml
+++ /dev/null
@@ -1,96 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- generateDebugAndroidTestSources
- generateDebugSources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file