Skip to content

Commit

Permalink
Did some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
bayosip committed Dec 28, 2021
1 parent eddb2d3 commit c28b701
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import inc.osips.bleproject.interfaces.ControllerViewInterface;
import inc.osips.iot_wireless_communication.wireless_comms_module.interfaces.WirelessDeviceConnector;
Expand Down Expand Up @@ -276,7 +275,7 @@ private IntentFilter commsUpdateIntentFilter() {
}

private void sendInstructionsToDevice(String instruct) {
deviceConnector.sendInstructionsToRemoteDevice(deviceAddr, instruct);
deviceConnector.sendStringInstructionsToRemoteDevice(deviceAddr, instruct);
}

public void setDeviceAddressAndSendInstructions(String uuidAddr, String instructions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public interface WirelessDeviceConnector {
void connectAnotherDeviceSimultaneously(@NonNull Parcelable device, @Nullable String serviceUUID) throws Exception;
void selectServiceUsingUUID (@Nullable String deviceAddress, @NonNull String UUID);
void connectToDeviceWithDeviceInfoFrom(@NonNull Intent intent);
void sendInstructionsToRemoteDevice(@Nullable String deviceAddress, @NonNull String instructions);
void sendInstructionsToRemoteDevice(@Nullable String deviceAddress,
@Nullable UUID charxUuid, @NonNull String instructions);
void sendInstructionsToConnectedDevice(String deviceAddr,
@Nullable UUID charxUuid, byte[] data);
void sendInstructionsToConnectedDevice(String deviceAddr, byte[] data);
void sendStringInstructionsToRemoteDevice(@Nullable String deviceAddress, @NonNull String instructions);
void sendStringInstructionsToRemoteDevice(@Nullable String deviceAddress,
@Nullable UUID charxUuid, @NonNull String instructions);
void sendBytesInstructionsToRemoteDevice(String deviceAddr,
@Nullable UUID charxUuid, byte[] data);
void sendBytesInstructionsToRemoteDevice(String deviceAddr, byte[] data);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package inc.osips.iot_wireless_communication.wireless_comms_module.remote_comms.ble_comms;

import android.app.Activity;
import android.app.Service;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGattCharacteristic;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
Expand Down Expand Up @@ -123,25 +120,25 @@ public void selectServiceUsingUUID(@Nullable String deviceAddress, @NonNull Stri
}

@Override
public void sendInstructionsToRemoteDevice(@Nullable String deviceAddress, @NonNull String instructions) {
sendInstructionsToRemoteDevice(deviceAddress, null, instructions);
public void sendStringInstructionsToRemoteDevice(@Nullable String deviceAddress, @NonNull String instructions) {
sendStringInstructionsToRemoteDevice(deviceAddress, null, instructions);
}

@Override
public void sendInstructionsToRemoteDevice(@Nullable String deviceAddress,
@Nullable UUID charxUuid, @NonNull String instructions) {
gattService.sendInstructionsToConnectedDevice(deviceAddress, charxUuid, instructions);
public void sendStringInstructionsToRemoteDevice(@Nullable String deviceAddress,
@Nullable UUID charxUuid, @NonNull String instructions) {
gattService.sendStringInstructionsToConnectedDevice(deviceAddress, charxUuid, instructions);
}

@Override
public void sendInstructionsToConnectedDevice(String deviceAddr, @Nullable UUID charxUuid,
byte[] data) {
gattService.sendInstructionsToConnectedDevice(deviceAddr, charxUuid, data);
public void sendBytesInstructionsToRemoteDevice(String deviceAddr, @Nullable UUID charxUuid,
byte[] data) {
gattService.sendBytesInstructionsToConnectedDevice(deviceAddr, charxUuid, data);
}

@Override
public void sendInstructionsToConnectedDevice(String deviceAddr, byte[] data) {
gattService.sendInstructionsToConnectedDevice(deviceAddr, null, data);
public void sendBytesInstructionsToRemoteDevice(String deviceAddr, byte[] data) {
sendBytesInstructionsToRemoteDevice(deviceAddr, null, data);
}

private final ServiceConnection mConnection =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,8 @@ private void close(BluetoothGatt bleGatt) {
bleGatt.close();
}

public void sendInstructionsToConnectedDevice(String deviceAddr, @Nullable UUID charxUuid, byte[] data){
public void sendBytesInstructionsToConnectedDevice(String deviceAddr, @Nullable UUID charxUuid,
byte[] data){
BluetoothGatt bleGatt = multiBleGatt.get(deviceAddr);
try {
if (bleGatt != null) {
Expand Down Expand Up @@ -669,8 +670,8 @@ public void sendInstructionsToConnectedDevice(String deviceAddr, @Nullable UUID
}
}

public void sendInstructionsToConnectedDevice(String deviceAddr, @Nullable UUID charxUuid,
String instructions) {
public void sendStringInstructionsToConnectedDevice(String deviceAddr, @Nullable UUID charxUuid,
String instructions) {
BluetoothGatt bleGatt = multiBleGatt.get(deviceAddr);
Log.d(TAG, "sendInstructionsToConnectedDevice: -> device address: " + deviceAddr );
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,23 @@ public void selectServiceUsingUUID(@Nullable String deviceAddress, @NonNull Stri
}

@Override
public void sendInstructionsToRemoteDevice(@Nullable String deviceAddr, @NonNull String instructions) {
public void sendStringInstructionsToRemoteDevice(@Nullable String deviceAddr, @NonNull String instructions) {
p2pService.writeInstructions(instructions);
}

@Override
public void sendInstructionsToRemoteDevice(@Nullable String deviceAddress,
@Nullable UUID charxUuid, @NonNull String instructions) {
public void sendStringInstructionsToRemoteDevice(@Nullable String deviceAddress,
@Nullable UUID charxUuid, @NonNull String instructions) {
p2pService.writeInstructions(instructions);
}

@Override
public void sendInstructionsToConnectedDevice(String deviceAddr, @Nullable UUID charxUuid, byte[] data) {
public void sendBytesInstructionsToRemoteDevice(String deviceAddr, @Nullable UUID charxUuid, byte[] data) {
p2pService.writeInstructions(data);
}

@Override
public void sendInstructionsToConnectedDevice(String deviceAddr, byte[] data) {
public void sendBytesInstructionsToRemoteDevice(String deviceAddr, byte[] data) {
p2pService.writeInstructions(data);
}

Expand Down

0 comments on commit c28b701

Please sign in to comment.