Real-time communication with frontend

- Frontend shows heatmap of most visit places
- Maximum accuracy can now be set
- Fix bug where battery chart filtered values wrongly
This commit is contained in:
2020-10-26 23:38:34 +01:00
parent fa60f58d3c
commit e12ed7775b
20 changed files with 770 additions and 161 deletions

View File

@@ -40,16 +40,12 @@ class TrackerService : Service() {
// This thread only connects to RabbitMQ
val connectionThread = Thread(Runnable {
val client = OkHttpClient()
val req = Request.Builder()
.url(MainActivity.API_URL)
.get()
.build()
val factory = ConnectionFactory()
factory.username = "lineage"
factory.password = "ZSo\$X97GQ547JXL7nGq"
factory.username = MainActivity.USER!!.name
factory.password = MainActivity.USER!!.brokerToken
factory.virtualHost = "/"
factory.host = "nk-home.ddns.net"
factory.host = "192.168.178.26"
factory.port = 5672
factory.isAutomaticRecoveryEnabled = true
try {
@@ -59,11 +55,10 @@ class TrackerService : Service() {
val intent = Intent("de.nicolasklier.livebeat")
val bundle = Bundle()
bundle.putBoolean("statusRabbit", true)
bundle.putInt("statusHttp", client.newCall(req).execute().code)
intent.putExtras(bundle)
this.sendBroadcast(intent)
channel[0]?.queueDeclare("tracker", true, false, false, null)
channel[0]?.queueDeclare("tracker-" + factory.username, true, false, false, null)
//channel[0]?.basicPublish("", "Tracker", null, "Test message".toByteArray())
Log.i("RabbitMQ", "run: Published test message")
} catch (e: IOException) {
@@ -83,7 +78,7 @@ class TrackerService : Service() {
val androidId = Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
locationManager.requestLocationUpdates("gps", 5000, 0f
locationManager.requestLocationUpdates("gps", 10000, 0f
) { location ->
Log.i("Location", "Location is: " + location.latitude + " | " + location.longitude)