Skip to content
Merged
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
17 changes: 16 additions & 1 deletion app/src/main/java/com/example/dronedetect/DroneSignalDetector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,34 @@ import android.content.Intent
import android.net.wifi.WifiManager
import android.os.Handler
import android.os.Looper
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

class DroneSignalDetector(private val context: Context) {
private val handler = Handler(Looper.getMainLooper())
private val wifiManager = context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
private val receiver = WifiScanReceiver()
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)

fun startScan() {
// TODO: implement scanning logic
scope.launch {
fetchFlightData()
// TODO: implement scanning logic
}
}

suspend fun fetchFlightData() = withContext(Dispatchers.IO) {
// TODO: implement fetching flight data
}

fun stopScan() {
handler.removeCallbacksAndMessages(null)
context.unregisterReceiver(receiver)
scope.cancel()
}
}

Expand Down
Loading