From 30d295d0f06d78d6a5808cd32f913b155ab2772d Mon Sep 17 00:00:00 2001 From: Morten Kristiansen Date: Fri, 13 Nov 2015 13:15:34 +0100 Subject: [PATCH] Added menu with option do redirect log to a file, email the log file and clear it. --- app/src/main/AndroidManifest.xml | 3 +- .../nordicsemi/nrfUARTv2/MainActivity.java | 132 +++++++++++++++++- .../com/nordicsemi/nrfUARTv2/UartService.java | 72 ++++++++-- app/src/main/res/menu/main_menu.xml | 9 ++ app/src/main/res/values/strings.xml | 4 +- 5 files changed, 207 insertions(+), 13 deletions(-) create mode 100644 app/src/main/res/menu/main_menu.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e2bf7c7..d5e3551 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -31,7 +31,8 @@ android:targetSdkVersion="18" /> - + + getSupportedGattServices() { return mBluetoothGatt.getServices(); } + + FileOutputStream logFile; + + public void openLogFile(String path) throws IOException { + logFile = new FileOutputStream(path, true); + Time now = new Time(); + now.setToNow(); + String endMessage = "=== Start logging " + now.toString() + "===\n"; + logFile.write(endMessage.getBytes("UTF-8")); + broadcastUpdate(ACTION_LOGGING_ENABLED); + } + + public void closeLogFile() { + if(logFile != null) { + try { + Time now = new Time(); + now.setToNow(); + String endMessage = "=== Finished logging " + now.toString() + "===\n"; + logFile.write(endMessage.getBytes("UTF-8")); + logFile.close(); + } + catch(IOException e) { + } + logFile = null; + broadcastUpdate(ACTION_LOGGING_DISABLED); + } + } + + public boolean isLogging() { + return logFile != null; + } } diff --git a/app/src/main/res/menu/main_menu.xml b/app/src/main/res/menu/main_menu.xml new file mode 100644 index 0000000..7964730 --- /dev/null +++ b/app/src/main/res/menu/main_menu.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d5e67fb..422db8c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -69,5 +69,7 @@ Bluetooth Low Energy not supported Scan Cancel - + Log to file + Clear log + Mail log