[+] Connect bluetooth inside serice

This commit is contained in:
Azalea Gui
2023-01-24 13:14:03 -05:00
parent b1097a007f
commit ed7200d801
@@ -20,6 +20,7 @@ import org.hydev.wearsync.bles.decoders.HeartRateDecoder
import org.hydev.wearsync.bles.decoders.IDecoder import org.hydev.wearsync.bles.decoders.IDecoder
import timber.log.Timber import timber.log.Timber
import java.util.concurrent.atomic.AtomicLong import java.util.concurrent.atomic.AtomicLong
import java.util.concurrent.atomic.AtomicReference
class MyService : Service() class MyService : Service()
@@ -40,9 +41,12 @@ class MyService : Service()
fun init() fun init()
{ {
influx = prefs.createInflux() influx = prefs.createInflux()
startCollect() ble.connectAddress(prefs.chosenDevice ?: return notif(text = "❌ No bluetooth devices chosen")) {
registerReceiver(mBatInfoReceiver, IntentFilter(Intent.ACTION_BATTERY_CHANGED)) startCollect()
notif(sub = "Bluetooth Connected!")
registerReceiver(mBatInfoReceiver, IntentFilter(Intent.ACTION_BATTERY_CHANGED))
}
notif(sub = "Bluetooth Connecting...") notif(sub = "Bluetooth Connecting...")
} }