Skip to content

Commit

Permalink
Version 1.16.1
Browse files Browse the repository at this point in the history
DFU Library imported from jcenter. Few other changes.
  • Loading branch information
philips77 committed Nov 10, 2015
1 parent 3ed75c5 commit 4ca632e
Show file tree
Hide file tree
Showing 16 changed files with 130 additions and 88 deletions.
1 change: 0 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 18 additions & 12 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,15 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/7.8.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-wearable/7.8.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-wearable/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/no.nordicsemi.android.support.v18/scanner/0.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/no.nordicsemi.android/dfu/0.6/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/no.nordicsemi.android/log/2.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
Expand All @@ -94,19 +98,21 @@
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-annotations-23.1.0" level="project" />
<orderEntry type="library" exported="" name="design-23.1.0" level="project" />
<orderEntry type="library" exported="" name="play-services-wearable-8.3.0" level="project" />
<orderEntry type="library" exported="" name="log-2.0.0" level="project" />
<orderEntry type="library" exported="" name="gson-2.3.1" level="project" />
<orderEntry type="library" exported="" name="design-23.0.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="dfu-0.6" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="stax-1.2.0" level="project" />
<orderEntry type="library" exported="" name="play-services-wearable-7.8.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="play-services-base-8.3.0" level="project" />
<orderEntry type="library" exported="" name="scanner-0.1.1" level="project" />
<orderEntry type="library" exported="" name="achartengine-1.1.0" level="project" />
<orderEntry type="library" exported="" name="simple-xml-2.7.1" level="project" />
<orderEntry type="library" exported="" name="log-2.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-base-7.8.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" />
<orderEntry type="library" exported="" name="play-services-basement-8.3.0" level="project" />
<orderEntry type="module" module-name="common" exported="" />
<orderEntry type="module" module-name="dfu" exported="" />
</component>
</module>
20 changes: 14 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "no.nordicsemi.android.nrftoolbox"
minSdkVersion 18
targetSdkVersion 23
versionCode 39
versionName "1.16.0"
versionCode 40
versionName "1.16.1"
}
buildTypes {
release {
Expand All @@ -21,17 +21,25 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-wearable:7.8.0'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.google.android.gms:play-services-wearable:8.3.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'no.nordicsemi.android.support.v18:scanner:0.1.1'
compile 'no.nordicsemi.android:log:2.0.0'
compile('org.simpleframework:simple-xml:2.7.1') {
exclude group: 'stax', module: 'stax-api'
exclude group: 'xpp3', module: 'xpp3'
}
compile files('libs/achartengine-1.1.0.jar')
compile project(':dfu')
compile project(':common')
wearApp project(':wear')

// The DFU Library is imported automatically from jcenter.
compile 'no.nordicsemi.android:dfu:0.6'
// If you want to make some changes in the DFU Library, clone the https://github.com/NordicSemiconductor/Android-DFU-Library project into DFULibrary folder,
// add it as a module in Project Structure and uncomment the following line:

// compile project(':dfu')

// Also uncomment selected lines in settings.gradle
}
Original file line number Diff line number Diff line change
Expand Up @@ -862,24 +862,6 @@ private void nextRequest() {
}
}
}

/**
* Converts the connection state to String value
* @param state the connection state
* @return state as String
*/
private String stateToString(final int state) {
switch (state) {
case BluetoothProfile.STATE_CONNECTED:
return "CONNECTED";
case BluetoothProfile.STATE_CONNECTING:
return "CONNECTING";
case BluetoothProfile.STATE_DISCONNECTING:
return "DISCONNECTING";
default:
return "DISCONNECTED";
}
}
}

private static final int PAIRING_VARIANT_PIN = 0;
Expand All @@ -890,7 +872,7 @@ private String stateToString(final int state) {
private static final int PAIRING_VARIANT_DISPLAY_PIN = 5;
private static final int PAIRING_VARIANT_OOB_CONSENT = 6;

private String pairingVariantToString(final int variant) {
protected String pairingVariantToString(final int variant) {
switch (variant) {
case PAIRING_VARIANT_PIN:
return "PAIRING_VARIANT_PIN";
Expand All @@ -911,7 +893,7 @@ private String pairingVariantToString(final int variant) {
}
}

private String bondStateToString(final int state) {
protected String bondStateToString(final int state) {
switch (state) {
case BluetoothDevice.BOND_NONE:
return "BOND_NONE";
Expand All @@ -924,7 +906,7 @@ private String bondStateToString(final int state) {
}
}

private String getWriteType(final int type) {
protected String getWriteType(final int type) {
switch (type) {
case BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT:
return "WRITE REQUEST";
Expand All @@ -936,4 +918,22 @@ private String getWriteType(final int type) {
return "UNKNOWN: " + type;
}
}

/**
* Converts the connection state to String value
* @param state the connection state
* @return state as String
*/
protected String stateToString(final int state) {
switch (state) {
case BluetoothProfile.STATE_CONNECTED:
return "CONNECTED";
case BluetoothProfile.STATE_CONNECTING:
return "CONNECTING";
case BluetoothProfile.STATE_DISCONNECTING:
return "DISCONNECTING";
default:
return "DISCONNECTED";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.Queue;
import java.util.UUID;

import no.nordicsemi.android.error.GattError;
import no.nordicsemi.android.log.Logger;
import no.nordicsemi.android.nrftoolbox.profile.BleManager;
import no.nordicsemi.android.nrftoolbox.parser.AlertLevelParser;
Expand Down Expand Up @@ -102,7 +103,7 @@ private void addLinklossService() {
* This method must be called in UI thread. It works fine on Nexus devices but if called from other thread (f.e. from onServiceAdded in gatt server callback) it hangs the app.
*/
final BluetoothGattCharacteristic linklossAlertLevel = new BluetoothGattCharacteristic(ALERT_LEVEL_CHARACTERISTIC_UUID, BluetoothGattCharacteristic.PROPERTY_WRITE
| BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_WRITE);
| BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_WRITE | BluetoothGattCharacteristic.PERMISSION_READ);
linklossAlertLevel.setValue(HIGH_ALERT);
final BluetoothGattService linklossService = new BluetoothGattService(LINKLOSS_SERVICE_UUID, BluetoothGattService.SERVICE_TYPE_PRIMARY);
linklossService.addCharacteristic(linklossAlertLevel);
Expand All @@ -122,7 +123,7 @@ public void run() {
if (IMMEDIATE_ALERT_SERVICE_UUID.equals(service.getUuid()))
addLinklossService();
else {
Logger.i(mLogSession, "[Proximity Server] Gatt server started");
Logger.i(mLogSession, "[Server] Gatt server started");
ProximityManager.super.connect(mDeviceToConnect);
mDeviceToConnect = null;
}
Expand All @@ -132,32 +133,56 @@ public void run() {

@Override
public void onConnectionStateChange(final BluetoothDevice device, final int status, final int newState) {
if (status == BluetoothGatt.GATT_SUCCESS && newState == BluetoothGatt.STATE_CONNECTED) {
Logger.i(mLogSession, "[Server] Device with address " + device.getAddress() + " connected");
} else {
if (newState == BluetoothGatt.STATE_DISCONNECTED) {
Logger.i(mLogSession, "[Server] Device disconnected");
Logger.d(mLogSession, "[Server callback] Connection state changed with status: " + status + " and new state: " + stateToString(newState) + " (" + newState + ")");
if (status == BluetoothGatt.GATT_SUCCESS) {
if (newState == BluetoothGatt.STATE_CONNECTED) {
Logger.i(mLogSession, "[Server] Device with address " + device.getAddress() + " connected");
} else {
Logger.e(mLogSession, "[Server] Connection state changed with error " + status);
Logger.i(mLogSession, "[Server] Device disconnected");
}
} else {
Logger.e(mLogSession, "[Server] Error " + status + " (0x" + Integer.toHexString(status) + "): " + GattError.parseConnectionError(status));
}
}

@Override
public void onCharacteristicReadRequest(final BluetoothDevice device, final int requestId, final int offset, final BluetoothGattCharacteristic characteristic) {
Logger.i(mLogSession, "[Server] Read request for characteristic " + characteristic.getUuid() + " (requestId = " + requestId + ", offset = " + offset + ")");
Logger.v(mLogSession, "[Server] Sending response: SUCCESS");
Logger.d(mLogSession, "[Server] sendResponse(GATT_SUCCESS, " + ParserUtils.parse(characteristic.getValue()) + ")");
mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, characteristic.getValue());
Logger.d(mLogSession, "[Server callback] Read request for characteristic " + characteristic.getUuid() + " (requestId=" + requestId + ", offset=" + offset + ")");
Logger.i(mLogSession, "[Server] READ request for characteristic " + characteristic.getUuid() + " received");

byte[] value = characteristic.getValue();
if (value != null && offset > 0) {
byte[] offsetValue = new byte[value.length - offset];
System.arraycopy(value, offset, offsetValue, 0, offsetValue.length);
value = offsetValue;
}
if (value != null)
Logger.d(mLogSession, "server.sendResponse(GATT_SUCCESS, value=" + ParserUtils.parse(value) + ")");
else
Logger.d(mLogSession, "server.sendResponse(GATT_SUCCESS, value=null)");
mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, value);
Logger.v(mLogSession, "[Server] Response sent");
}

@Override
public void onCharacteristicWriteRequest(final BluetoothDevice device, final int requestId, final BluetoothGattCharacteristic characteristic, final boolean preparedWrite,
final boolean responseNeeded, final int offset, final byte[] value) {
Logger.i(mLogSession, "[Server] Write request to characteristic " + characteristic.getUuid() + " (requestId = " + requestId + ", value = " + ParserUtils.parse(value) + ", offset = " + offset + ")");
characteristic.setValue(value);
Logger.d(mLogSession, "[Server callback] Write request to characteristic " + characteristic.getUuid()
+ " (requestId=" + requestId + ", prepareWrite=" + preparedWrite + ", responseNeeded=" + responseNeeded + ", offset=" + offset + ", value=" + ParserUtils.parse(value) + ")");
final String writeType = !responseNeeded ? "WRITE NO RESPONSE" : "WRITE COMMAND";
Logger.i(mLogSession, "[Server] " + writeType + " request for characteristic " + characteristic.getUuid() + " received, value: " + ParserUtils.parse(value));

if (value != null && value.length == 1) { // small validation
if (offset == 0) {
characteristic.setValue(value);
} else {
final byte[] currentValue = characteristic.getValue();
final byte[] newValue = new byte[currentValue.length + value.length];
System.arraycopy(currentValue, 0, newValue, 0, currentValue.length);
System.arraycopy(value, 0, newValue, offset, value.length);
characteristic.setValue(newValue);
}

if (!preparedWrite && value != null && value.length == 1) { // small validation
if (value[0] != NO_ALERT[0]) {
Logger.a(mLogSession, "[Server] Immediate alarm request received: " + AlertLevelParser.parse(characteristic));
mCallbacks.onAlarmTriggered();
Expand All @@ -166,39 +191,44 @@ public void onCharacteristicWriteRequest(final BluetoothDevice device, final int
mCallbacks.onAlarmStopped();
}
}
if (responseNeeded) {
Logger.v(mLogSession, "[Server] Sending response: SUCCESS");
Logger.d(mLogSession, "[Server] sendResponse(GATT_SUCCESS)");
mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, null);
}

Logger.d(mLogSession, "server.sendResponse(GATT_SUCCESS, offset=" + offset + ", value=" + ParserUtils.parse(value) + ")");
mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, null);
Logger.v(mLogSession, "[Server] Response sent");
}

@Override
public void onDescriptorReadRequest(final BluetoothDevice device, final int requestId, final int offset, final BluetoothGattDescriptor descriptor) {
Logger.i(mLogSession, "[Server] Write request to descriptor " + descriptor.getUuid() + " (requestId = " + requestId + ", offset = " + offset + ")");
Logger.d(mLogSession, "[Server callback] Write request to descriptor " + descriptor.getUuid() + " (requestId=" + requestId + ", offset=" + offset + ")");
Logger.i(mLogSession, "[Server] READ request for descriptor " + descriptor.getUuid() + " received");
// This method is not supported
Logger.v(mLogSession, "[Server] Sending response: REQUEST_NOT_SUPPORTED");
Logger.d(mLogSession, "[Server] sendResponse(GATT_REQUEST_NOT_SUPPORTED)");
Logger.w(mLogSession, "[Server] Operation not supported");
Logger.d(mLogSession, "[Server] server.sendResponse(GATT_REQUEST_NOT_SUPPORTED)");
mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_REQUEST_NOT_SUPPORTED, offset, null);
Logger.v(mLogSession, "[Server] Response sent");
}

@Override
public void onDescriptorWriteRequest(final BluetoothDevice device, final int requestId, final BluetoothGattDescriptor descriptor, final boolean preparedWrite,
final boolean responseNeeded, final int offset, final byte[] value) {
Logger.i(mLogSession, "[Server] Write request to descriptor " + descriptor.getUuid() + " (requestId = " + requestId + ", value = " + ParserUtils.parse(value) + ", offset = " + offset + ")");
Logger.d(mLogSession, "[Server callback] Write request to descriptor " + descriptor.getUuid()
+ " (requestId=" + requestId + ", prepareWrite=" + preparedWrite + ", responseNeeded=" + responseNeeded + ", offset=" + offset + ", value=" + ParserUtils.parse(value) + ")");
Logger.i(mLogSession, "[Server] READ request for descriptor " + descriptor.getUuid() + " received");
// This method is not supported
Logger.v(mLogSession, "[Server] Sending response: REQUEST_NOT_SUPPORTED");
Logger.d(mLogSession, "[Server] sendResponse(GATT_REQUEST_NOT_SUPPORTED)");
Logger.w(mLogSession, "[Server] Operation not supported");
Logger.d(mLogSession, "[Server] server.sendResponse(GATT_REQUEST_NOT_SUPPORTED)");
mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_REQUEST_NOT_SUPPORTED, offset, null);
Logger.v(mLogSession, "[Server] Response sent");
}

@Override
public void onExecuteWrite(final BluetoothDevice device, final int requestId, final boolean execute) {
Logger.i(mLogSession, "[Server] Execute write request (requestId = " + requestId + ")");
Logger.d(mLogSession, "[Server callback] Execute write request (requestId=" + requestId + ", execute=" + execute + ")");
// This method is not supported
Logger.v(mLogSession, "[Server] Sending response: REQUEST_NOT_SUPPORTED");
Logger.d(mLogSession, "[Server] sendResponse(GATT_REQUEST_NOT_SUPPORTED)");
Logger.w(mLogSession, "[Server] Operation not supported");
Logger.d(mLogSession, "[Server] server.sendResponse(GATT_REQUEST_NOT_SUPPORTED)");
mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_REQUEST_NOT_SUPPORTED, 0, null);
Logger.v(mLogSession, "[Server] Response sent");
}
};

Expand Down
Binary file removed app/src/main/res/mipmap-mdpi/ic_launcher.png
Binary file not shown.
Binary file added app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.android.tools.build:gradle:1.3.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:support-v4:23.1.0'
}
Loading

0 comments on commit 4ca632e

Please sign in to comment.