Skip to content

Commit

Permalink
Merge pull request #230 from NordicSemiconductor/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
roshanrajaratnam authored Aug 7, 2019
2 parents 87398b3 + 8d642d3 commit d8051a3
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 24 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 48
versionName "2.0.0"
versionCode 49
versionName "2.0.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattService;
import android.content.Context;
import androidx.annotation.NonNull;
import android.util.Log;

import java.lang.reflect.Method;
Expand All @@ -37,6 +36,7 @@

import javax.inject.Inject;

import androidx.annotation.NonNull;
import no.nordicsemi.android.ble.BleManager;
import no.nordicsemi.android.ble.Request;
import no.nordicsemi.android.log.LogContract;
Expand Down Expand Up @@ -138,7 +138,7 @@ public boolean isRequiredServiceSupported(final BluetoothGatt gatt) {
final int rxProperties = mMeshProvisioningDataInCharacteristic.getProperties();
writeRequest = (rxProperties & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) > 0;
}
return mMeshProvisioningDataInCharacteristic != null && mMeshProvisioningDataInCharacteristic != null && writeRequest;
return mMeshProvisioningDataInCharacteristic != null && mMeshProvisioningDataOutCharacteristic != null && writeRequest;
}
}
return false;
Expand Down Expand Up @@ -196,10 +196,6 @@ protected BleManagerGattCallback getGattCallback() {
return mGattCallback;
}

public BluetoothDevice getBluetoothDevice(){
return mBluetoothDevice;
}

@Override
protected boolean shouldAutoConnect() {
// If you want to connect to the device using autoConnect flag = true, return true here.
Expand All @@ -210,14 +206,15 @@ protected boolean shouldAutoConnect() {
/**
* Sends the mesh pdu
* <p>
* The function will chunk the pdu to fit in to the mtu size supported by the node
* The function will chunk the pdu to fit in to the mtu size supported by the node
* </p>
*
* @param pdu mesh pdu
*/
public void sendPdu(final byte[] pdu) {
final int chunks = (pdu.length + (mtuSize - 1)) / mtuSize;
int srcOffset = 0;
if(chunks > 1) {
if (chunks > 1) {
for (int i = 0; i < chunks; i++) {
final int length = Math.min(pdu.length - srcOffset, mtuSize);
final byte[] segmentedBuffer = new byte[length];
Expand All @@ -233,7 +230,7 @@ public void sendPdu(final byte[] pdu) {
/**
* Refreshes the device cache. This is to make sure that Android will discover the services as the the mesh node will change the provisioning service to a proxy service.
*/
public boolean refreshDeviceCache(){
public boolean refreshDeviceCache() {
//Once the service discovery is complete we will refresh the device cache and discover the services again.
return refreshDeviceCache(mBluetoothGatt);
}
Expand All @@ -242,10 +239,6 @@ public boolean isProvisioningComplete() {
return isProvisioningComplete;
}

public void setProvisioningComplete(final boolean provisioningComplete) {
this.isProvisioningComplete = provisioningComplete;
}

public final int getMtuSize() {
return mtuSize;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import no.nordicsemi.android.meshprovisioner.transport.ConfigNodeReset;
import no.nordicsemi.android.meshprovisioner.transport.ConfigNodeResetStatus;
import no.nordicsemi.android.meshprovisioner.transport.ConfigProxyGet;
import no.nordicsemi.android.meshprovisioner.transport.ConfigProxySet;
import no.nordicsemi.android.meshprovisioner.transport.ConfigProxyStatus;
import no.nordicsemi.android.meshprovisioner.transport.Element;
import no.nordicsemi.android.meshprovisioner.transport.MeshMessage;
Expand All @@ -81,6 +82,7 @@ public class NodeConfigurationActivity extends AppCompatActivity implements Inje
DialogFragmentNodeName.DialogFragmentNodeNameListener,
DialogFragmentElementName.DialogFragmentElementNameListener,
DialogFragmentTtl.DialogFragmentTtlListener,
DialogFragmentProxySet.DialogFragmentProxySetListener,
ElementAdapter.OnItemClickListener,
DialogFragmentResetNode.DialogFragmentNodeResetListener,
DialogFragmentConfigurationComplete.ConfigurationCompleteListener {
Expand Down Expand Up @@ -540,4 +542,11 @@ public boolean setDefaultTtl(final int ttl) {
sendMessage(ttlSet);
return true;
}

@Override
public void onProxySet(final int state) {
final ConfigProxySet configProxySet = new ConfigProxySet(state);
sendMessage(configProxySet);
mRequestedState = state == 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.net.Uri;
import android.os.Environment;
import android.os.Handler;
import android.os.ParcelUuid;
Expand Down Expand Up @@ -820,7 +819,7 @@ public void onMeshMessageReceived(final int src, @NonNull final MeshMessage mesh
mHandler.postDelayed(() -> {
final ConfigDefaultTtlGet configDefaultTtlGet = new ConfigDefaultTtlGet();
mMeshManagerApi.createMeshPdu(node.getUnicastAddress(), configDefaultTtlGet);
}, 2500);
}, 500);
} else {
updateNode(node);
}
Expand All @@ -836,7 +835,7 @@ public void onMeshMessageReceived(final int src, @NonNull final MeshMessage mesh
final NetworkKey networkKey = mMeshNetwork.getNetKeys().get(index);
final ConfigAppKeyAdd configAppKeyAdd = new ConfigAppKeyAdd(networkKey, appKey);
mMeshManagerApi.createMeshPdu(node.getUnicastAddress(), configAppKeyAdd);
}, 2500);
}, 1500);
} else {
updateNode(node);
mMeshMessageLiveData.postValue(status);
Expand All @@ -851,7 +850,7 @@ public void onMeshMessageReceived(final int src, @NonNull final MeshMessage mesh
mHandler.postDelayed(() -> {
final ConfigNetworkTransmitSet networkTransmitSet = new ConfigNetworkTransmitSet(2, 1);
mMeshManagerApi.createMeshPdu(node.getUnicastAddress(), networkTransmitSet);
}, 2500);
}, 1500);
}
} else {
updateNode(node);
Expand Down
2 changes: 1 addition & 1 deletion android-nrf-mesh-library/meshprovisioner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ android {
minSdkVersion 18
targetSdkVersion 29
versionCode 49
versionName "2.0.0"
versionName "2.0.1"

javaCompileOptions {
annotationProcessorOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@

package no.nordicsemi.android.meshprovisioner.transport;

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

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import no.nordicsemi.android.meshprovisioner.MeshManagerApi;
import no.nordicsemi.android.meshprovisioner.control.BlockAcknowledgementMessage;
import no.nordicsemi.android.meshprovisioner.opcodes.TransportLayerOpCodes;
Expand All @@ -47,6 +47,7 @@
abstract class LowerTransportLayer extends UpperTransportLayer {

private static final String TAG = LowerTransportLayer.class.getSimpleName();
private static final int BLOCK_ACK_TIMER = 600; //Increased from minimum value 150;
private static final int UNSEGMENTED_HEADER = 0;
private static final int SEGMENTED_HEADER = 1;
private static final int UNSEGMENTED_MESSAGE_HEADER_LENGTH = 1;
Expand Down Expand Up @@ -683,7 +684,7 @@ private void cancelIncompleteTimer() {
private void initSegmentedAccessAcknowledgementTimer(final int seqZero, final int ttl, final int src, final int dst, final int segN) {
if (!mSegmentedAccessAcknowledgementTimerStarted) {
mSegmentedAccessAcknowledgementTimerStarted = true;
final int duration = (150 + (50 * ttl));
final int duration = (BLOCK_ACK_TIMER + (50 * ttl));
mDuration = System.currentTimeMillis() + duration;
mHandler.postDelayed(() -> {
Log.v(TAG, "Acknowledgement timer expiring");
Expand All @@ -703,7 +704,7 @@ private void initSegmentedAccessAcknowledgementTimer(final int seqZero, final in
private void initSegmentedControlAcknowledgementTimer(final int seqZero, final int ttl, final int src, final int dst, final int segN) {
if (!mSegmentedControlAcknowledgementTimerStarted) {
mSegmentedControlAcknowledgementTimerStarted = true;
final int duration = (150 + (50 * ttl));
final int duration = BLOCK_ACK_TIMER + (50 * ttl);
mDuration = System.currentTimeMillis() + duration;
mHandler.postDelayed(() -> sendBlockAck(seqZero, ttl, src, dst, segN), duration);
}
Expand Down

0 comments on commit d8051a3

Please sign in to comment.