Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(INJI-39): skip request for PHY upgrade to PHY2 [ hotfix ] #56

Merged
merged 1 commit into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@ class GattClient(var context: Context) {
}
}

override fun onPhyRead(gatt: BluetoothGatt?, txPhy: Int, rxPhy: Int, status: Int) {
Log.d(logTag, "Central onPhyRead: txPhy: $txPhy, rxPhy: $rxPhy, status: $status")
}

override fun onPhyUpdate(gatt: BluetoothGatt?, txPhy: Int, rxPhy: Int, status: Int) {
Log.d(logTag, "Central onPhyUpdate: txPhy: $txPhy, rxPhy: $rxPhy, status: $status")
}

override fun onCharacteristicRead(
gatt: BluetoothGatt?,
characteristic: BluetoothGattCharacteristic?,
Expand Down Expand Up @@ -177,9 +169,6 @@ class GattClient(var context: Context) {
// TODO: In case device is never connected, how do we know?

gatt.requestConnectionPriority(CONNECTION_PRIORITY_HIGH)
gatt.readPhy()
gatt.setPreferredPhy(2, 2, 0)
gatt.readPhy()
this.bluetoothGatt = gatt
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class GattServer(private val context: Context) : BluetoothGattServerCallback() {
Log.i(logTag, "Connection initiated to central: $connect with device address: ${device?.address}")

onDeviceConnectedCallback(status, newState)
device?.let { setPhy(it) }
device
} else {
Log.i(logTag,"Received disconnect from central with device address: ${device?.address}")
Expand All @@ -90,14 +89,6 @@ class GattServer(private val context: Context) : BluetoothGattServerCallback() {
onMTUChangedCallback(allowedMTU)
}

private fun setPhy(bluetoothDevice: BluetoothDevice) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
gattServer.readPhy(bluetoothDevice)
gattServer.setPreferredPhy(bluetoothDevice, 2, 2, 0)
gattServer.readPhy(bluetoothDevice)
}
}

override fun onCharacteristicWriteRequest(
device: BluetoothDevice?,
requestId: Int,
Expand Down Expand Up @@ -144,14 +135,6 @@ class GattServer(private val context: Context) : BluetoothGattServerCallback() {
}
}

override fun onPhyRead(device: BluetoothDevice?, txPhy: Int, rxPhy: Int, status: Int) {
Log.d(logTag, "Peripheral onPhyRead: txPhy: $txPhy, rxPhy: $rxPhy, status: $status")
}

override fun onPhyUpdate(device: BluetoothDevice?, txPhy: Int, rxPhy: Int, status: Int) {
Log.d(logTag, "Peripheral onPhyUpdate: txPhy: $txPhy, rxPhy: $rxPhy, status: $status")
}

fun disconnect(): Boolean {
return if(bluetoothDevice != null) {
Log.d(logTag, "Disconnecting from central with device address: ${bluetoothDevice?.address}")
Expand Down