Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
roshanrajaratnam committed Mar 6, 2019
2 parents f268d38 + 4ea25d6 commit aa21e2d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 11 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 28
versionCode 28
versionName "1.2.0"
versionCode 29
versionName "1.2.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ protected void onRestoreInstanceState(final Bundle savedInstanceState) {
@Override
public void setPublishAddress(final byte[] publishAddress) {
if (publishAddress != null) {
mPublishAddress = AddressUtils.getUnicastAddressInt(publishAddress);
mPublishAddress = MeshParserUtils.unsignedBytesToInt(publishAddress[1], publishAddress[0]);
mPublishAddressView.setText(MeshParserUtils.bytesToHex(publishAddress, true));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import butterknife.ButterKnife;
import no.nordicsemi.android.meshprovisioner.provisionerstates.ProvisioningConfirmationState;
import no.nordicsemi.android.meshprovisioner.provisionerstates.UnprovisionedMeshNode;
import no.nordicsemi.android.meshprovisioner.utils.AuthenticationOOBMethods;
import no.nordicsemi.android.meshprovisioner.utils.InputOOBAction;
import no.nordicsemi.android.meshprovisioner.utils.MeshParserUtils;
import no.nordicsemi.android.meshprovisioner.utils.OutputOOBAction;
Expand Down Expand Up @@ -131,6 +132,19 @@ private boolean validateInput(final String input) {
return false;
}

if(mNode.getAuthMethodUsed() == AuthenticationOOBMethods.STATIC_OOB_AUTHENTICATION){
if(input.length() != 32) {
pinInputLayout.setError(getString(R.string.error_invalid_static_oob));
return false;
}

final byte[] staticOObKey = MeshParserUtils.toByteArray(input);
if (staticOObKey.length != 16) {
pinInputLayout.setError(getString(R.string.error_invalid_static_oob));
return false;
}
}

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.method.KeyListener;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;

Expand All @@ -49,6 +50,7 @@

public class DialogFragmentNetworkKey extends DialogFragment {

private static final String TAG = DialogFragmentNetworkKey.class.getSimpleName();
private static final String PATTERN_NETWORK_KEY = "[0-9a-fA-F]{32}";
private static final String NETWORK_KEY = "NETWORK_KEY";

Expand Down Expand Up @@ -122,10 +124,14 @@ public void afterTextChanged(final Editable s) {
alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(v -> {
final String networkKey = networkKeyInput.getText().toString();
if (validateInput(networkKey)) {
if(getParentFragment() == null) {
((DialogFragmentNetworkKeyListener) getActivity()).onNetworkKeyGenerated(networkKey);
} else {
((DialogFragmentNetworkKeyListener) getParentFragment()).onNetworkKeyGenerated(networkKey);
try {
if (getParentFragment() == null) {
((DialogFragmentNetworkKeyListener) getActivity()).onNetworkKeyGenerated(networkKey);
} else {
((DialogFragmentNetworkKeyListener) getParentFragment()).onNetworkKeyGenerated(networkKey);
}
} catch (Exception ex) {
Log.v(TAG, ex.getMessage());
}
dismiss();
}
Expand All @@ -138,12 +144,12 @@ public void afterTextChanged(final Editable s) {
private boolean validateInput(final String input) {
try {

if(!input.matches(Utils.HEX_PATTERN)) {
if (!input.matches(Utils.HEX_PATTERN)) {
networkKeyInputLayout.setError(getString(R.string.invalid_hex_value));
return false;
}

if(MeshParserUtils.validateNetworkKeyInput(getContext(), input)){
if (MeshParserUtils.validateNetworkKeyInput(getContext(), input)) {
return true;
}
} catch (IllegalArgumentException ex) {
Expand Down
1 change: 1 addition & 0 deletions Example/nrf-mesh/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<string name="hint_numeric">e.g. 019655</string>
<string name="hint_alpha_numeric">e.g. 123ABC</string>
<string name="error_empty_pin">Error, authentication value cannot be empty!</string>
<string name="error_invalid_static_oob">Error, static oob value must be 128 bits!</string>

<string name="title_select_oob">Select OOB Type</string>
<string name="public_key_information_available">Public Key information available</string>
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 @@ -28,8 +28,8 @@ android {
defaultConfig {
minSdkVersion 18
targetSdkVersion 28
versionCode 28
versionName "1.2.0"
versionCode 29
versionName "1.2.1"

javaCompileOptions {
annotationProcessorOptions {
Expand Down

0 comments on commit aa21e2d

Please sign in to comment.