Skip to content

Commit 97ef1a4

Browse files
authored
Merge pull request #89 from sieunju/develop
[Release] 1.3.5
2 parents 8f9c5a5 + 9441f55 commit 97ef1a4

4 files changed

Lines changed: 21 additions & 42 deletions

File tree

β€Žapp/src/main/java/com/hmju/httptracking/BleTestProvider.ktβ€Ž

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,21 @@ import android.bluetooth.BluetoothDevice
66
import android.bluetooth.BluetoothGatt
77
import android.bluetooth.BluetoothGattCallback
88
import android.bluetooth.BluetoothGattCharacteristic
9-
import android.bluetooth.BluetoothGattDescriptor
109
import android.bluetooth.BluetoothManager
1110
import android.bluetooth.BluetoothProfile
1211
import android.bluetooth.le.ScanCallback
1312
import android.bluetooth.le.ScanFilter
1413
import android.bluetooth.le.ScanResult
1514
import android.bluetooth.le.ScanSettings
1615
import android.content.Context
17-
import android.os.Build
1816
import androidx.annotation.RequiresPermission
1917
import androidx.appcompat.app.AppCompatActivity
2018
import hmju.http.tracking_interceptor.TrackingDataManager
2119
import hmju.tracking.hardware.HardwareTrackingModel
2220
import timber.log.Timber
23-
import java.nio.ByteBuffer
2421
import java.text.SimpleDateFormat
2522
import java.util.Locale
2623
import java.util.UUID
27-
import java.util.concurrent.Executors
2824

2925

3026
class BleTestProvider(
@@ -36,7 +32,13 @@ class BleTestProvider(
3632
open fun onConnected(gatt: BluetoothGatt) {}
3733
open fun onDisconnected(gatt: BluetoothGatt) {}
3834
open fun onServicesDiscovered(gatt: BluetoothGatt) {}
39-
open fun onCharacteristicRead(gatt: BluetoothGatt, value: ByteArray) {}
35+
open fun onCharacteristicRead(
36+
gatt: BluetoothGatt,
37+
characteristic: BluetoothGattCharacteristic,
38+
value: ByteArray
39+
) {
40+
}
41+
4042
open fun onCharacteristicChanged(gatt: BluetoothGatt, value: ByteArray) {}
4143

4244
val origin = object : BluetoothGattCallback() {
@@ -65,7 +67,7 @@ class BleTestProvider(
6567
status: Int
6668
) {
6769
if (gatt == null || characteristic == null) return
68-
onCharacteristicRead(gatt, characteristic.value)
70+
onCharacteristicRead(gatt, characteristic, characteristic.value)
6971
}
7072

7173
override fun onCharacteristicRead(
@@ -74,7 +76,7 @@ class BleTestProvider(
7476
value: ByteArray,
7577
status: Int
7678
) {
77-
onCharacteristicRead(gatt, value)
79+
onCharacteristicRead(gatt, characteristic, value)
7880
}
7981

8082
@Suppress("DEPRECATION")
@@ -97,15 +99,11 @@ class BleTestProvider(
9799
}
98100
}
99101

100-
private val connectionSet = mutableSetOf<String>()
101102
private val manager: BluetoothManager by lazy {
102103
activity.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager
103104
}
104105

105106
private val adapter: BluetoothAdapter by lazy { manager.adapter }
106-
private val dateFmt: SimpleDateFormat by lazy {
107-
SimpleDateFormat("HH:mm:ss.SSS", Locale.getDefault())
108-
}
109107

110108
@SuppressLint("MissingPermission")
111109
fun startBleAdv() {
@@ -165,39 +163,20 @@ class BleTestProvider(
165163
}
166164
}
167165
}
168-
Timber.d("characteristic μ°ΎμŠ΅λ‹ˆλ‹€..$characteristic")
169166
if (characteristic == null) return
170-
val writeBytes = ByteBuffer.allocate(2)
171-
.putShort(10000.toShort())
172-
.array() + ByteBuffer.allocate(2)
173-
.putShort(10387.toShort()).array()
174-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
175-
Timber.d("데이터 μ‚¬μš©ν•©λ‹ˆλ‹€. ${writeBytes.contentToString()}")
176-
gatt.writeCharacteristic(
177-
characteristic,
178-
writeBytes,
179-
BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT
180-
)
181-
Executors.newSingleThreadExecutor().submit {
182-
Thread.sleep(300)
183-
gatt.setCharacteristicNotification(characteristic, true)
184-
val descriptor = characteristic.getDescriptor(
185-
UUID.fromString("00002902-0000-1000-8000-00805f9b34fb")
186-
)
187-
gatt.writeDescriptor(
188-
descriptor,
189-
BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE
190-
)
191-
}
192-
}
167+
gatt.readCharacteristic(characteristic)
193168
}
194169

195-
override fun onCharacteristicRead(gatt: BluetoothGatt, value: ByteArray) {
170+
171+
override fun onCharacteristicRead(
172+
gatt: BluetoothGatt,
173+
characteristic: BluetoothGattCharacteristic,
174+
value: ByteArray
175+
) {
196176
TrackingDataManager.getInstance().add(HardwareTrackingModel(gatt, value))
197177
}
198178

199179
override fun onCharacteristicChanged(gatt: BluetoothGatt, value: ByteArray) {
200-
Timber.d("onCharacteristicChanged ${value.contentToString()}")
201180
TrackingDataManager.getInstance().add(HardwareTrackingModel(gatt, value))
202181
}
203182
}

β€Žapp/src/main/java/com/hmju/httptracking/MainActivity.ktβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ internal class MainActivity : AppCompatActivity() {
4444
findViewById<Button>(R.id.bBleAdv).setOnClickListener { bleTest.startBleAdv() }
4545
findViewById<Button>(R.id.bBleConnect).setOnClickListener {
4646
bleTest.startConnection(
47-
macAddress = "01:A1:02:14:89:27",
48-
findUuid = "02001201-4202-EAB5-ED11"
47+
macAddress = "11:22:33:44:55:66",
48+
findUuid = "00002a00-0000-1000-8000-00805f9b34fb" // GAP, Device Name (ν‘œμ€€ UUID)
4949
)
5050
}
5151

β€Žrelease_note.txtβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Version: 1.3.5-beta02
2-
Title: 1.3.5-beta02 λ°°ν¬μž…λ‹ˆλ‹€.
1+
Version: 1.3.5
2+
Title: 1.3.5 λ°°ν¬μž…λ‹ˆλ‹€.
33
KO-KR
44
### μ†Œκ°œ
55
> 앱을 μ‚¬μš©ν•˜λ‹€κ°€ 단말기λ₯Ό 흔듀면 νŠΈλž˜ν‚Ήν•œ λ‘œκ·Έλ“€μ„ κ°„λ‹¨νžˆ 볼수 μžˆμŠ΅λ‹ˆλ‹€. πŸ‘¨πŸΏβ€πŸ’»πŸ™‡β€

β€Žversion.gradleβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ext.deps = [:]
22

33
def deps = [:]
44

5-
deps.release = "1.3.5-beta02"
5+
deps.release = "1.3.5"
66

77
ext.deps = deps
88

0 commit comments

Comments
Β (0)