Skip to content

Commit

Permalink
Merge pull request #276 from NordicSemiconductor/dev
Browse files Browse the repository at this point in the history
nRF Mesh release v2.1.2
  • Loading branch information
roshanrajaratnam authored Nov 21, 2019
2 parents 8e90dcb + 814a1f5 commit 3afe508
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 126 deletions.
4 changes: 2 additions & 2 deletions Example/nrf-mesh/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ android {
applicationId "no.nordicsemi.android.nrfmeshprovisioner"
minSdkVersion 18
targetSdkVersion 29
versionCode 57
versionName "2.1.1"
versionCode 58
versionName "2.1.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected void initialize() {

// This callback will be called each time a notification is received.
final DataReceivedCallback onDataReceived = (device, data) ->
mCallbacks.onDataReceived(device, getMtu(), data.getValue());
mCallbacks.onDataReceived(device, getMaximumPacketSize(), data.getValue());

// Set the notification callback and enable notification on Data In characteristic.
final BluetoothGattCharacteristic characteristic = isProvisioningComplete ?
Expand Down Expand Up @@ -178,7 +178,7 @@ public void sendPdu(final byte[] pdu) {

// This callback will be called each time the data were sent.
final DataSentCallback callback = (device, data) ->
mCallbacks.onDataSent(device, getMtu(), data.getValue());
mCallbacks.onDataSent(device, getMaximumPacketSize(), data.getValue());

// Write the right characteristic.
final BluetoothGattCharacteristic characteristic = isProvisioningComplete ?
Expand All @@ -189,9 +189,8 @@ public void sendPdu(final byte[] pdu) {
.enqueue();
}

@Override
public int getMtu() {
return super.getMtu();
public int getMaximumPacketSize() {
return super.getMtu() - 3;
}

public boolean isProvisioningComplete() {
Expand All @@ -209,4 +208,4 @@ private boolean hasWriteNoResponseProperty(@NonNull final BluetoothGattCharacter
private boolean hasNotifyProperty(@NonNull final BluetoothGattCharacteristic characteristic) {
return (characteristic.getProperties() & BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ public void onMeshPduCreated(final byte[] pdu) {

@Override
public int getMtu() {
return mBleMeshManager.getMtu();
return mBleMeshManager.getMaximumPacketSize();
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions android-nrf-mesh-library/meshprovisioner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ android {
defaultConfig {
minSdkVersion 18
targetSdkVersion 29
versionCode 57
versionName "2.1.1"
versionCode 58
versionName "2.1.2"

javaCompileOptions {
annotationProcessorOptions {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@

public class ProvisioningFailedState extends ProvisioningState {

private final Context mContext;
private final UnprovisionedMeshNode mUnprovisionedMeshNode;
private int error;

public ProvisioningFailedState(final Context context, final UnprovisionedMeshNode unprovisionedMeshNode) {
public ProvisioningFailedState() {
super();
this.mContext = context;
this.mUnprovisionedMeshNode = unprovisionedMeshNode;
}

@Override
Expand Down Expand Up @@ -86,35 +82,6 @@ public static String parseProvisioningFailure(final Context context, final int e
}
}

public static String parseProvisioningFailure(final Context context, final byte[] pdu) {
if(pdu == null)
return "Unknown";
final int errorCode = pdu[2];
switch (ProvisioningFailureCode.fromErrorCode(errorCode)) {
case PROHIBITED:
return context.getString(R.string.error_prohibited);
case INVALID_PDU:
return context.getString(R.string.error_invalid_pdu);
case INVALID_FORMAT:
return context.getString(R.string.error_invalid_format);
case UNEXPECTED_PDU:
return context.getString(R.string.error_prohibited);
case CONFIRMATION_FAILED:
return context.getString(R.string.error_confirmation_failed);
case OUT_OF_RESOURCES:
return context.getString(R.string.error_prohibited);
case DECRYPTION_FAILED:
return context.getString(R.string.error_decryption_failed);
case UNEXPECTED_ERROR:
return context.getString(R.string.error_unexpected_error);
case CANNOT_ASSIGN_ADDRESSES:
return context.getString(R.string.error_cannot_assign_addresses);
case UNKNOWN_ERROR_CODE:
default:
return context.getString(R.string.error_rfu);
}
}

public enum ProvisioningFailureCode {
PROHIBITED(0x00),
INVALID_PDU(0x01),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
package no.nordicsemi.android.meshprovisioner.provisionerstates;


import androidx.annotation.NonNull;
import android.util.Log;

import org.spongycastle.jce.ECNamedCurveTable;
Expand All @@ -49,6 +48,7 @@

import javax.crypto.KeyAgreement;

import androidx.annotation.NonNull;
import no.nordicsemi.android.meshprovisioner.InternalTransportCallbacks;
import no.nordicsemi.android.meshprovisioner.MeshManagerApi;
import no.nordicsemi.android.meshprovisioner.MeshProvisioningStatusCallbacks;
Expand Down Expand Up @@ -142,6 +142,10 @@ private byte[] generatePublicKeyXYPDU() {
}

private void generateSharedECDHSecret(final byte[] provisioneePublicKeyXYPDU) {
if (provisioneePublicKeyXYPDU.length != 66) {
throw new IllegalArgumentException("Invalid Provisionee Public Key PDU," +
" length of the Provisionee public key must be 66 bytes, but was " + provisioneePublicKeyXYPDU.length);
}
final ByteBuffer buffer = ByteBuffer.allocate(provisioneePublicKeyXYPDU.length - 2);
buffer.put(provisioneePublicKeyXYPDU, 2, buffer.limit());
final byte[] xy = mTempProvisioneeXY = buffer.array();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public enum States {
SENDING_NETWORK_TRANSMIT_SET(23),
NETWORK_TRANSMIT_STATUS_RECEIVED(24),
SENDING_BLOCK_ACKNOWLEDGEMENT(98),
BLOCK_ACKNOWLEDGEMENT_RECEIVED(99),;
BLOCK_ACKNOWLEDGEMENT_RECEIVED(99);

private int state;

Expand All @@ -102,9 +102,9 @@ public int getState() {
return state;
}

public static States fromStatusCode(final int statusCode){
for(States state : States.values()){
if(state.getState() == statusCode){
public static States fromStatusCode(final int statusCode) {
for (States state : States.values()) {
if (state.getState() == statusCode) {
return state;
}
}
Expand Down

0 comments on commit 3afe508

Please sign in to comment.