Simplify the project and adapt to thee GPS device coded in Zephyr
parent
2732d2d6f9
commit
12d8046c5c
|
@ -28,6 +28,7 @@ dependencies {
|
|||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||
implementation 'com.github.Jasonchenlijian:FastBle:2.4.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
|
|
Binary file not shown.
|
@ -16,7 +16,9 @@
|
|||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".MainActivity">
|
||||
<activity android:name=".MainActivity"
|
||||
android:launchMode="singleTask"
|
||||
>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
@ -24,7 +26,6 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
<service android:name=".BLEMockLocationService" ></service>
|
||||
<service android:name=".BLEHRService" ></service>
|
||||
<receiver android:name=".TaskerReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="net.nigreon.blegps.TASKER_COMMAND" />
|
||||
|
|
|
@ -1,224 +0,0 @@
|
|||
package net.nigreon.blegps
|
||||
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.app.Service
|
||||
import android.bluetooth.BluetoothGatt
|
||||
import android.content.Intent
|
||||
import android.os.Binder
|
||||
import android.os.Build
|
||||
import android.os.IBinder
|
||||
import android.support.v4.app.NotificationCompat
|
||||
import android.support.v4.content.LocalBroadcastManager
|
||||
import android.util.Log
|
||||
import com.clj.fastble.BleManager
|
||||
import com.clj.fastble.callback.BleGattCallback
|
||||
import com.clj.fastble.callback.BleNotifyCallback
|
||||
import com.clj.fastble.callback.BleWriteCallback
|
||||
import com.clj.fastble.data.BleDevice
|
||||
import com.clj.fastble.exception.BleException
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import java.util.*
|
||||
|
||||
class BLEHRService : Service() {
|
||||
private val LOG_TAG = "BLEHRService"
|
||||
private val CHANNEL_ID = "NotifID2"
|
||||
private val binder = sBinder()
|
||||
|
||||
val timerActivity = Timer()
|
||||
|
||||
private lateinit var bleDevice: BleDevice
|
||||
private val serviceHeartRateUuid: String = "0000180d-0000-1000-8000-00805f9b34fb"
|
||||
private val characteristicHRControlPointUuid: String = "00002a39-0000-1000-8000-00805f9b34fb"
|
||||
private val characteristicHRMeasurementUuid: String = "00002a37-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
private fun initNotificationHR() {
|
||||
BleManager.getInstance().notify(
|
||||
bleDevice,
|
||||
serviceHeartRateUuid,
|
||||
characteristicHRMeasurementUuid,
|
||||
object : BleNotifyCallback() {
|
||||
override fun onNotifySuccess() {
|
||||
Log.v(LOG_TAG, "Notify HR Success")
|
||||
//initNotificationPressure()
|
||||
}
|
||||
|
||||
override fun onNotifyFailure(exception: BleException) {
|
||||
Log.v(LOG_TAG, "BLE Notify HR Failure $exception")
|
||||
//initNotificationPressure()
|
||||
}
|
||||
|
||||
override fun onCharacteristicChanged(data: ByteArray) {
|
||||
//Log.v(LOG_TAG, "Notify Temperature Characteristic changed")
|
||||
val buffer = ByteBuffer.wrap(data)
|
||||
buffer.order(ByteOrder.LITTLE_ENDIAN)
|
||||
//texttemp.text = buffer.float.toString()
|
||||
LocalBroadcastManager.getInstance(baseContext).sendBroadcast(
|
||||
Intent(ServicesConstants.BROADCAST_FILTER.FILTERBTHRM).putExtra(ServicesConstants.BROADCAST_KEY.KEYBTHRM, buffer.get(1))
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun startHRBLE() {
|
||||
BleManager.getInstance().connect("CC:2C:24:71:9C:BC", object : BleGattCallback() {
|
||||
override fun onStartConnect() {
|
||||
|
||||
}
|
||||
|
||||
override fun onConnectFail(bleDevice: BleDevice, exception: BleException) {
|
||||
Log.v(LOG_TAG, "BLE HR Connection Failed $exception")
|
||||
}
|
||||
|
||||
override fun onConnectSuccess(
|
||||
bleDeviceConnect: BleDevice,
|
||||
gattConnect: BluetoothGatt,
|
||||
status: Int
|
||||
) {
|
||||
Log.v(LOG_TAG, "BLE HR Connection OK")
|
||||
LocalBroadcastManager.getInstance(baseContext).sendBroadcast(
|
||||
Intent(ServicesConstants.BROADCAST_FILTER.FILTERBTHR).putExtra(
|
||||
ServicesConstants.BROADCAST_KEY.KEYBTSTATUSHR,
|
||||
true
|
||||
)
|
||||
)
|
||||
bleDevice = bleDeviceConnect
|
||||
|
||||
initNotificationHR()
|
||||
|
||||
val t = object : TimerTask() {
|
||||
override fun run() {
|
||||
startHRBLEActivity()
|
||||
}
|
||||
}
|
||||
timerActivity.scheduleAtFixedRate(t, 0, 9500)
|
||||
|
||||
}
|
||||
|
||||
override fun onDisConnected(
|
||||
isActiveDisConnected: Boolean,
|
||||
bleDevice: BleDevice,
|
||||
gatt: BluetoothGatt,
|
||||
status: Int
|
||||
) {
|
||||
LocalBroadcastManager.getInstance(baseContext).sendBroadcast(
|
||||
Intent(ServicesConstants.BROADCAST_FILTER.FILTERBTHR).putExtra(
|
||||
ServicesConstants.BROADCAST_KEY.KEYBTSTATUSHR,
|
||||
false
|
||||
)
|
||||
)
|
||||
timerActivity.cancel()
|
||||
Log.v(LOG_TAG, "BLE HR Disconnected")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun stopHRBLE() {
|
||||
LocalBroadcastManager.getInstance(baseContext).sendBroadcast(
|
||||
Intent(ServicesConstants.BROADCAST_FILTER.FILTERBTHR).putExtra(ServicesConstants.BROADCAST_KEY.KEYBTSTATUSHR, false)
|
||||
)
|
||||
|
||||
BleManager.getInstance().disconnect(bleDevice)
|
||||
}
|
||||
|
||||
private fun startHRBLEActivity() {
|
||||
val data: ByteArray = byteArrayOf(0x15,0x01,0x01)
|
||||
BleManager.getInstance().write(
|
||||
bleDevice,
|
||||
serviceHeartRateUuid,
|
||||
characteristicHRControlPointUuid,
|
||||
data,
|
||||
object : BleWriteCallback() {
|
||||
override fun onWriteSuccess(current: Int, total: Int, justWrite: ByteArray) {
|
||||
//Log.v(LOG_TAG, "Start Activity sended")
|
||||
}
|
||||
|
||||
override fun onWriteFailure(exception: BleException) {
|
||||
Log.v(LOG_TAG, "Start Activity Failure $exception")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun stopHRBLEActivity() {
|
||||
val data: ByteArray = byteArrayOf(0x15,0x01,0x00)
|
||||
BleManager.getInstance().write(
|
||||
bleDevice,
|
||||
serviceHeartRateUuid,
|
||||
characteristicHRControlPointUuid,
|
||||
data,
|
||||
object : BleWriteCallback() {
|
||||
override fun onWriteSuccess(current: Int, total: Int, justWrite: ByteArray) {
|
||||
Log.v(LOG_TAG, "Stop Activity sended")
|
||||
}
|
||||
|
||||
override fun onWriteFailure(exception: BleException) {
|
||||
Log.v(LOG_TAG, "Stop Activity send Failure $exception")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
||||
if(intent.action == ServicesConstants.HRSERVICEACTION.STARTFOREGROUND_ACTION) {
|
||||
Log.i(LOG_TAG, "Received Start Foreground Intent ")
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// Create the NotificationChannel
|
||||
val name = "ChannelName"
|
||||
val descriptionText = "ChannelDescription"
|
||||
val importance = NotificationManager.IMPORTANCE_DEFAULT
|
||||
val mChannel = NotificationChannel(CHANNEL_ID, name, importance)
|
||||
mChannel.description = descriptionText
|
||||
// Register the channel with the system; you can't change the importance
|
||||
// or other notification behaviors after this
|
||||
val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
|
||||
notificationManager.createNotificationChannel(mChannel)
|
||||
}
|
||||
|
||||
var notification = NotificationCompat.Builder(this, CHANNEL_ID)
|
||||
.setSmallIcon(R.drawable.ic_launcher_foreground)
|
||||
.setContentTitle("BLE HR")
|
||||
.setContentText("BLE HR active")
|
||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
||||
//.setContentIntent(pendingIntent)
|
||||
.build()
|
||||
|
||||
//pBLE = BLEProvider(application, baseContext)
|
||||
startHRBLE()
|
||||
|
||||
startForeground(ServicesConstants.NOTIFICATION_ID.FOREGROUND_HR_SERVICE,notification)
|
||||
} else if(intent.action == ServicesConstants.HRSERVICEACTION.STOPFOREGROUND_ACTION) {
|
||||
Log.i(LOG_TAG, "Received Stop Foreground Intent ")
|
||||
//pBLE.disconnectBLE()
|
||||
stopHRBLE()
|
||||
stopForeground(true)
|
||||
stopSelf()
|
||||
}
|
||||
return START_STICKY
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
Log.i(LOG_TAG, "In onDestroy")
|
||||
}
|
||||
|
||||
override fun onBind(intent: Intent): IBinder? {
|
||||
Log.v(LOG_TAG, "in onBind")
|
||||
return binder
|
||||
}
|
||||
|
||||
override fun onRebind(intent: Intent) {
|
||||
Log.v(LOG_TAG, "in onRebind")
|
||||
super.onRebind(intent)
|
||||
}
|
||||
|
||||
override fun onUnbind(intent: Intent): Boolean {
|
||||
Log.v(LOG_TAG, "in onUnbind")
|
||||
return true
|
||||
}
|
||||
|
||||
inner class sBinder : Binder() {
|
||||
// Return this instance of LocalService so clients can call public methods
|
||||
fun getService(): BLEHRService = this@BLEHRService
|
||||
}
|
||||
}
|
|
@ -2,15 +2,14 @@ package net.nigreon.blegps
|
|||
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.app.Service
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.*
|
||||
import android.location.LocationManager
|
||||
import android.os.*
|
||||
import android.support.v4.app.NotificationCompat
|
||||
import android.support.v4.content.LocalBroadcastManager
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.util.Log
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
|
@ -31,12 +30,11 @@ class BLEMockLocationService : Service() {
|
|||
private lateinit var mockGPS: MockLocationProvider
|
||||
private var locationReceived = false
|
||||
private var qualityReceived = false
|
||||
private var gpsverbose = false
|
||||
private var gpxopened = false
|
||||
private var hrenable = false
|
||||
private var tempenable = false
|
||||
private lateinit var gpxoutputstream: FileOutputStream
|
||||
|
||||
private lateinit var sharedPreferences: SharedPreferences
|
||||
|
||||
var gpsConf: GPSConfiguration = GPSConfiguration()
|
||||
|
||||
// Location
|
||||
|
@ -50,11 +48,8 @@ class BLEMockLocationService : Service() {
|
|||
private var currentEVPE: Float = -1.0f
|
||||
private var currentHDOP: Float = -1.0f
|
||||
private var currentVDOP: Float = -1.0f
|
||||
private var currentSatview: Byte = -1
|
||||
private var currentSatused: Byte = -1
|
||||
private var currentElevationGPS: Double = -1.0
|
||||
|
||||
private var currentHR: Byte = 0
|
||||
private var currentTemperature: Float = 0.0f
|
||||
|
||||
private val binder = sBinder()
|
||||
|
@ -70,7 +65,6 @@ class BLEMockLocationService : Service() {
|
|||
currentHeading = intent.getFloatExtra(ServicesConstants.BROADCAST_KEY.KEYLOCATIONHEADING,-1.0f)
|
||||
mockGPS.pushLocation(currentLatitude,currentLongitude,currentElevation, currentSpeed, currentHeading, currentEHPE)
|
||||
locationReceived = true
|
||||
storeGPX()
|
||||
}
|
||||
|
||||
fun qualityChanged(intent: Intent)
|
||||
|
@ -80,16 +74,8 @@ class BLEMockLocationService : Service() {
|
|||
currentEVPE = intent.getFloatExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYEVPE,-1.0f)
|
||||
currentHDOP = intent.getFloatExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYHDOP,-1.0f)
|
||||
currentVDOP = intent.getFloatExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYVDOP,-1.0f)
|
||||
currentSatview = intent.getByteExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYSATVIEW,-1)
|
||||
currentSatused = intent.getByteExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYSATUSED,-1)
|
||||
currentElevationGPS = intent.getDoubleExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYELEGPS,-1.0)
|
||||
qualityReceived = true
|
||||
storeGPX()
|
||||
}
|
||||
|
||||
fun HRChanged(intent: Intent)
|
||||
{
|
||||
currentHR = intent.getByteExtra(ServicesConstants.BROADCAST_KEY.KEYBTHRM,-1)
|
||||
}
|
||||
|
||||
fun bmpStatusChanged(intent: Intent)
|
||||
|
@ -105,71 +91,25 @@ class BLEMockLocationService : Service() {
|
|||
fun taskerChanged(bundle: Bundle) {
|
||||
Log.v(LOG_TAG, "taskerChanged")
|
||||
if(bundle.containsKey(ServicesConstants.BROADCAST_KEY.KEYBOOST)) {
|
||||
/*if (bundle.getBoolean(ServicesConstants.BROADCAST_KEY.KEYBOOST)) {
|
||||
if (bundle.getBoolean(ServicesConstants.BROADCAST_KEY.KEYBOOST)) {
|
||||
//gpsConf.gpsBoost = intent.getBooleanExtra(ServicesConstants.BROADCAST_KEY.KEYBOOST, false)
|
||||
gpsConf.gpsBoost = true
|
||||
sendConfBLE(2)
|
||||
} else {
|
||||
gpsConf.gpsBoost = false
|
||||
}*/
|
||||
gpsConf.gpsBoost = bundle.getBoolean(ServicesConstants.BROADCAST_KEY.KEYBOOST)
|
||||
sendConfBLE(gpsConf)
|
||||
Log.v(LOG_TAG, "Received Tasker Intent : Boost ${gpsConf.gpsBoost}")
|
||||
}
|
||||
}
|
||||
|
||||
fun storeGPX()
|
||||
{
|
||||
if(gpxopened) {
|
||||
if(!gpsverbose and locationReceived)
|
||||
{
|
||||
//writeGPX("${SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(Date())} $currentLatitude $currentLongitude $currentElevation m\n")
|
||||
writeGPX("<trkpt lat=\"$currentLatitude\" lon=\"$currentLongitude\"><ele>$currentElevation</ele><time>${SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(Date())}</time></trkpt>\n")
|
||||
locationReceived = false
|
||||
qualityReceived = false
|
||||
} else if(gpsverbose and locationReceived and qualityReceived) {
|
||||
//writeGPX("${SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(Date())} $currentLatitude $currentLongitude $currentElevation m\n")
|
||||
//writeGPX("$currentEHPE m $currentEVPE m $currentHDOP $currentVDOP $currentSatused/$currentSatview $currentElevationGPS m\n")
|
||||
//if(hrenable) { writeGPX("$currentHR bpm\n")}
|
||||
//if(tempenable) { writeGPX("${currentTemperature}°C\n")}
|
||||
writeGPX("<trkpt lat=\"$currentLatitude\" lon=\"$currentLongitude\"><ele>$currentElevation</ele><time>${SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(Date())}</time>\n" +
|
||||
"<extensions>\n")
|
||||
if(hrenable or tempenable)
|
||||
{
|
||||
writeGPX("<gpxtpx:TrackPointExtension>")
|
||||
if(hrenable)
|
||||
{
|
||||
writeGPX("<gpxtpx:atemp>$currentHR</gpxtpx:atemp>")
|
||||
}
|
||||
if(tempenable)
|
||||
{
|
||||
writeGPX("<gpxtpx:atemp>$currentTemperature</gpxtpx:atemp>")
|
||||
}
|
||||
writeGPX("</gpxtpx:TrackPointExtension>\n")
|
||||
}
|
||||
|
||||
writeGPX("<blegps:BLEGPSExtension><blegps:ehpe>$currentEHPE</blegps:ehpe><blegps:evpe>$currentEVPE</blegps:evpe><blegps:hdop>$currentHDOP</blegps:hdop><blegps:vdop>$currentVDOP</blegps:vdop><blegps:satused>$currentSatused</blegps:satused><blegps:satview>$currentSatview</blegps:satview><blegps:gpselevation>$currentElevationGPS</blegps:gpselevation></blegps:BLEGPSExtension>\n")
|
||||
writeGPX("</extensions>\n</trkpt>\n")
|
||||
locationReceived = false
|
||||
qualityReceived = false
|
||||
sendConfBLE(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
//gpsConf.gpsBoost = bundle.getBoolean(ServicesConstants.BROADCAST_KEY.KEYBOOST)
|
||||
|
||||
fun writeGPX(str: String)
|
||||
{
|
||||
try {
|
||||
gpxoutputstream.write(str.toByteArray())
|
||||
} catch (e: FileNotFoundException) {
|
||||
e.printStackTrace()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
//Log.v(LOG_TAG, "Received Tasker Intent : Boost ${gpsConf.gpsBoost}")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
sharedPreferences = baseContext.getSharedPreferences("blegps_config",
|
||||
AppCompatActivity.MODE_PRIVATE
|
||||
)
|
||||
|
||||
mockGPS = MockLocationProvider(LocationManager.GPS_PROVIDER, baseContext)
|
||||
|
||||
val brReceiver = object : BroadcastReceiver() {
|
||||
|
@ -177,7 +117,6 @@ class BLEMockLocationService : Service() {
|
|||
when (intent?.action) {
|
||||
ServicesConstants.BROADCAST_FILTER.FILTERLOCATION -> locationChanged(intent)
|
||||
ServicesConstants.BROADCAST_FILTER.FILTERQUALITY-> qualityChanged(intent)
|
||||
ServicesConstants.BROADCAST_FILTER.FILTERBTHRM-> HRChanged(intent)
|
||||
ServicesConstants.BROADCAST_FILTER.FILTERTEMP-> tempChanged(intent)
|
||||
ServicesConstants.BROADCAST_FILTER.FILTERBMP-> bmpStatusChanged(intent)
|
||||
|
||||
|
@ -190,7 +129,6 @@ class BLEMockLocationService : Service() {
|
|||
val manager = LocalBroadcastManager.getInstance(this)
|
||||
manager.registerReceiver(brReceiver, IntentFilter(ServicesConstants.BROADCAST_FILTER.FILTERLOCATION))
|
||||
manager.registerReceiver(brReceiver, IntentFilter(ServicesConstants.BROADCAST_FILTER.FILTERQUALITY))
|
||||
manager.registerReceiver(brReceiver, IntentFilter(ServicesConstants.BROADCAST_FILTER.FILTERBTHRM))
|
||||
manager.registerReceiver(brReceiver, IntentFilter(ServicesConstants.BROADCAST_FILTER.FILTERTEMP))
|
||||
manager.registerReceiver(brReceiver, IntentFilter(ServicesConstants.BROADCAST_FILTER.FILTERBMP))
|
||||
//pBLE.registerBMP()
|
||||
|
@ -200,11 +138,10 @@ class BLEMockLocationService : Service() {
|
|||
if(intent.action == ServicesConstants.MOCKSERVICEACTION.STARTFOREGROUND_ACTION) {
|
||||
Log.i(LOG_TAG, "Received Start Foreground Intent ")
|
||||
|
||||
// val intentNotif = Intent(this, MainActivity::class.java)
|
||||
// intentNotif.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
// intentNotif.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACT
|
||||
|
||||
//val pendingIntent = PendingIntent.getActivity(this, 0, intentNotif, 0)
|
||||
val startIntent = Intent(this, MainActivity::class.java)
|
||||
startIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
|
||||
val contentIntent = PendingIntent.getActivity(this, 0, startIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
|
@ -225,7 +162,8 @@ class BLEMockLocationService : Service() {
|
|||
.setContentTitle("BLE GPS")
|
||||
.setContentText("BLE & Mock active")
|
||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
||||
//.setContentIntent(pendingIntent)
|
||||
.setContentIntent(contentIntent)
|
||||
.setAutoCancel(false)
|
||||
.build()
|
||||
|
||||
pBLE = BLEProvider(application, baseContext)
|
||||
|
@ -239,7 +177,9 @@ class BLEMockLocationService : Service() {
|
|||
stopSelf()
|
||||
} else if(intent.action == ServicesConstants.MOCKSERVICEACTION.TASKER_ACTION){
|
||||
Log.i(LOG_TAG, "intent action : ${intent.action}")
|
||||
taskerChanged(intent.extras)
|
||||
if(this::pBLE.isInitialized) {
|
||||
taskerChanged(intent.extras)
|
||||
}
|
||||
}
|
||||
return START_STICKY
|
||||
}
|
||||
|
@ -271,103 +211,25 @@ class BLEMockLocationService : Service() {
|
|||
pBLE.sendCalibrate(buffer.array())
|
||||
}
|
||||
|
||||
fun HRStatusChanged(enable: Boolean)
|
||||
{
|
||||
hrenable = enable
|
||||
}
|
||||
|
||||
fun openGPX(datefilename: String) {
|
||||
//val datefilename: String = SimpleDateFormat("yyyyMMdd_HHmmss").format(Date())
|
||||
var gpxfilename = File(
|
||||
Environment.getExternalStorageDirectory().path + File.separator + "BTGPS",
|
||||
datefilename + ".gpx"
|
||||
)
|
||||
var gpxdir = File(Environment.getExternalStorageDirectory().path + File.separator + "BTGPS")
|
||||
var success = true;
|
||||
if (!gpxdir.exists()) {
|
||||
success = gpxdir.mkdir();
|
||||
}
|
||||
|
||||
if (success) {
|
||||
if(!gpxfilename.exists()) {
|
||||
try {
|
||||
gpxoutputstream = FileOutputStream(gpxfilename, true)
|
||||
//val gpxheader = "GPX Header\n"
|
||||
val gpxheader =
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n" +
|
||||
"<gpx xmlns=\"http://www.topografix.com/GPX/1/1\" version=\"1.1\" " +
|
||||
"xmlns:gpxtpx=\"http://www.garmin.com/xmlschemas/TrackPointExtension/v1\" " +
|
||||
"xmlns:blegps=\"https://www.nigreon.net\"" +
|
||||
">\n" +
|
||||
"<metadata>" +
|
||||
"<name>${datefilename}</name>" +
|
||||
"<desc>${datefilename}</desc>\n" +
|
||||
"<time>${SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(Date())}</time>\n" +
|
||||
"</metadata>\n" +
|
||||
"<trk>\n" +
|
||||
"<name>${datefilename}</name>\n" +
|
||||
"<trkseg>\n"
|
||||
writeGPX(gpxheader)
|
||||
} catch (e: FileNotFoundException) {
|
||||
e.printStackTrace()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
gpxoutputstream = FileOutputStream(gpxfilename, true)
|
||||
} catch (e: FileNotFoundException) {
|
||||
e.printStackTrace()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
gpxopened = true
|
||||
}
|
||||
}
|
||||
|
||||
fun closeGPX()
|
||||
{
|
||||
//val gpxfooter = "GPX Footer\n"
|
||||
val gpxfooter = "</trkseg></trk></gpx>\n"
|
||||
writeGPX(gpxfooter)
|
||||
gpxoutputstream.close()
|
||||
gpxopened = false
|
||||
}
|
||||
|
||||
//fun sendConfBLE(bmpnrf: Boolean, bmpble: Boolean, bmp2gps: Boolean, exttemp: Boolean, gpsble: Boolean, gpsbleverb: Boolean, gpsserial: Boolean, gpsmode: Int, gpspoller: Short, gpssendbt: Short, bmppoller: Short) {
|
||||
fun sendConfBLE(gpsConfNew: GPSConfiguration) {
|
||||
gpsConf = gpsConfNew
|
||||
val buffer = ByteBuffer.allocate(8)
|
||||
//fun sendConfBLE(bmpnrf: Boolean, bmpble: Boolean, bmp2gps: Boolean, exttemp: Boolean, gpsble: Boolean, gpsbleverb: Boolean, gpsserial: Boolean, gpsmode: Int, gpspoller: Short, gpssendbt: Short, bmppoller: Short) {
|
||||
fun sendConfBLE(mode: Int) {
|
||||
val buffer = ByteBuffer.allocate(2)
|
||||
buffer.order(ByteOrder.LITTLE_ENDIAN)
|
||||
var activateByte1: Byte = 0
|
||||
var activateByte2: Byte = 0
|
||||
|
||||
if(gpsConf.bmpNrf) { activateByte1 = activateByte1.or(0x01) }
|
||||
if(gpsConf.bmpBT) { activateByte1 = activateByte1.or(0x02) }
|
||||
if(gpsConf.bmp2gps) { activateByte1 = activateByte1.or(0x04) }
|
||||
if(gpsConf.extTemp) { activateByte1 = activateByte1.or(0x08) }
|
||||
|
||||
if(gpsConf.gpsBLE) { activateByte2 = activateByte2.or(0x01) }
|
||||
if(gpsConf.gpsVerbose) { activateByte2 = activateByte2.or(0x02) }
|
||||
if(gpsConf.gpsSerial) { activateByte2 = activateByte2.or(0x04) }
|
||||
if(gpsConf.gpsMode == 1 || gpsConf.gpsBoost) {
|
||||
activateByte2 = activateByte2.or(0x08)
|
||||
} else if(gpsConf.gpsMode == 2) {
|
||||
activateByte2 = activateByte2.or(0x10)
|
||||
if(sharedPreferences.getBoolean("swbmp2gps", false)) { activateByte1 = activateByte1.or(0x01) }
|
||||
if(mode == 1) {
|
||||
activateByte2 = activateByte2.or(0x01)
|
||||
} else if(mode == 2) {
|
||||
activateByte2 = activateByte2.or(0x02)
|
||||
} else if(mode == 3) {
|
||||
activateByte2 = activateByte2.or(0x04)
|
||||
}
|
||||
|
||||
buffer.put(activateByte1)
|
||||
buffer.put(activateByte2)
|
||||
if(gpsConf.gpsBoost) {
|
||||
buffer.putShort(4)
|
||||
buffer.putShort(gpsConf.bmpPollerSend)
|
||||
buffer.putShort(4)
|
||||
} else {
|
||||
buffer.putShort(gpsConf.gpsPollerSend)
|
||||
buffer.putShort(gpsConf.bmpPollerSend)
|
||||
buffer.putShort(gpsConf.gpsSendBTSend)
|
||||
}
|
||||
|
||||
pBLE.sendConf(buffer.array())
|
||||
}
|
||||
|
||||
|
|
|
@ -3,19 +3,19 @@ import android.app.Application
|
|||
import android.bluetooth.BluetoothGatt
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.support.v4.content.LocalBroadcastManager
|
||||
import android.util.Log
|
||||
import com.clj.fastble.BleManager
|
||||
import com.clj.fastble.data.BleDevice
|
||||
import com.clj.fastble.exception.BleException
|
||||
import com.clj.fastble.callback.BleGattCallback
|
||||
import com.clj.fastble.callback.BleNotifyCallback
|
||||
import com.clj.fastble.callback.BleReadCallback
|
||||
import com.clj.fastble.callback.BleWriteCallback
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import android.os.CountDownTimer
|
||||
import android.os.Handler
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import com.clj.fastble.callback.*
|
||||
import com.clj.fastble.scan.BleScanRuleConfig
|
||||
|
||||
|
||||
class BLEProvider(val application: Application, val baseContext: Context)
|
||||
|
@ -36,13 +36,17 @@ class BLEProvider(val application: Application, val baseContext: Context)
|
|||
private var connected = false
|
||||
private var reconnectcount = 0
|
||||
|
||||
|
||||
private val LOG_TAG = "BLEProvider"
|
||||
//private lateinit var baseContext: Context
|
||||
|
||||
private lateinit var sharedPreferences: SharedPreferences
|
||||
|
||||
init
|
||||
{
|
||||
sharedPreferences = baseContext.getSharedPreferences("blegps_config",
|
||||
AppCompatActivity.MODE_PRIVATE
|
||||
)
|
||||
BleManager.getInstance().enableBluetooth()
|
||||
connectBLE()
|
||||
}
|
||||
|
||||
|
@ -50,7 +54,27 @@ class BLEProvider(val application: Application, val baseContext: Context)
|
|||
Handler().postDelayed(function, delay)
|
||||
}
|
||||
|
||||
private fun connectBLE()
|
||||
private fun connectBLE() {
|
||||
val scanRuleConfig = BleScanRuleConfig.Builder()
|
||||
//.setServiceUuids(serviceUuids)
|
||||
//.setDeviceName(true, names)
|
||||
//.setDeviceMac(mac)
|
||||
//.setAutoConnect(isAutoConnect)
|
||||
.setScanTimeOut(5000)
|
||||
.build()
|
||||
BleManager.getInstance().initScanRule(scanRuleConfig)
|
||||
|
||||
BleManager.getInstance().scan(object : BleScanCallback() {
|
||||
override fun onScanStarted(success: Boolean) {}
|
||||
override fun onScanning(bleDevice: BleDevice) {}
|
||||
override fun onScanFinished(scanResultList: List<BleDevice>) {
|
||||
connectBLE2()
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
private fun connectBLE2()
|
||||
{
|
||||
//BleManager.getInstance().init(application)
|
||||
/*BleManager.getInstance()
|
||||
|
@ -59,7 +83,8 @@ class BLEProvider(val application: Application, val baseContext: Context)
|
|||
|
||||
//BleManager.getInstance().operateTimeout = 5000
|
||||
//BleManager.getInstance().connect("24:6F:28:16:C1:F2", object : BleGattCallback() {
|
||||
BleManager.getInstance().connect("E9:8E:8A:12:6F:3F", object : BleGattCallback() {
|
||||
var macaddr = sharedPreferences.getString("macaddr", null)
|
||||
BleManager.getInstance().connect(macaddr, object : BleGattCallback() {
|
||||
override fun onStartConnect() {
|
||||
|
||||
}
|
||||
|
@ -266,17 +291,18 @@ class BLEProvider(val application: Application, val baseContext: Context)
|
|||
val buffer = ByteBuffer.wrap(data)
|
||||
buffer.order(ByteOrder.LITTLE_ENDIAN)
|
||||
//val flags = buffer.short
|
||||
val sat_view: Byte = buffer.get().toUByte().toByte()
|
||||
val sat_used: Byte = buffer.get().toUByte().toByte()
|
||||
//val sat_view: Byte = buffer.get().toUByte().toByte()
|
||||
//val sat_used: Byte = buffer.get().toUByte().toByte()
|
||||
val ehpe: Float = buffer.int.toUInt().toFloat()/100.0f
|
||||
val evpe: Float = buffer.int.toUInt().toFloat()/100.0f
|
||||
val hdop: Float = buffer.get().toUByte().toByte()*2/10.0f
|
||||
val vdop: Float = buffer.get().toUByte().toByte()*2/10.0f
|
||||
val elevation_gps: Double = buffer.int/100.0
|
||||
Log.v(LOG_TAG, "PQ $sat_view $sat_used $ehpe $evpe $hdop $vdop $elevation_gps")
|
||||
Log.v(LOG_TAG, "PQ $ehpe $evpe $hdop $vdop $elevation_gps")
|
||||
LocalBroadcastManager.getInstance(baseContext).sendBroadcast(
|
||||
Intent(ServicesConstants.BROADCAST_FILTER.FILTERQUALITY).putExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYSATVIEW, sat_view)
|
||||
.putExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYSATUSED, sat_used)
|
||||
Intent(ServicesConstants.BROADCAST_FILTER.FILTERQUALITY)
|
||||
//.putExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYSATVIEW, sat_view)
|
||||
//.putExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYSATUSED, sat_used)
|
||||
.putExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYEHPE, ehpe)
|
||||
.putExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYEVPE, evpe)
|
||||
.putExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYHDOP, hdop)
|
||||
|
@ -308,13 +334,14 @@ class BLEProvider(val application: Application, val baseContext: Context)
|
|||
val buffer = ByteBuffer.wrap(data)
|
||||
buffer.order(ByteOrder.LITTLE_ENDIAN)
|
||||
LocalBroadcastManager.getInstance(baseContext).sendBroadcast(
|
||||
Intent(ServicesConstants.BROADCAST_FILTER.FILTERSAT).putExtra(ServicesConstants.BROADCAST_KEY.KEYSATGPSALL, buffer.get())
|
||||
Intent(ServicesConstants.BROADCAST_FILTER.FILTERSAT)
|
||||
//.putExtra(ServicesConstants.BROADCAST_KEY.KEYSATGPSALL, buffer.get())
|
||||
.putExtra(ServicesConstants.BROADCAST_KEY.KEYSATGPSUSED, buffer.get())
|
||||
.putExtra(ServicesConstants.BROADCAST_KEY.KEYSATSBASALL, buffer.get())
|
||||
.putExtra(ServicesConstants.BROADCAST_KEY.KEYSATSBASUSED, buffer.get())
|
||||
.putExtra(ServicesConstants.BROADCAST_KEY.KEYSATGLONASSALL, buffer.get())
|
||||
//.putExtra(ServicesConstants.BROADCAST_KEY.KEYSATSBASALL, buffer.get())
|
||||
//.putExtra(ServicesConstants.BROADCAST_KEY.KEYSATSBASUSED, buffer.get())
|
||||
//.putExtra(ServicesConstants.BROADCAST_KEY.KEYSATGLONASSALL, buffer.get())
|
||||
.putExtra(ServicesConstants.BROADCAST_KEY.KEYSATGLONASSUSED, buffer.get())
|
||||
.putExtra(ServicesConstants.BROADCAST_KEY.KEYSATGALILEOALL, buffer.get())
|
||||
//.putExtra(ServicesConstants.BROADCAST_KEY.KEYSATGALILEOALL, buffer.get())
|
||||
.putExtra(ServicesConstants.BROADCAST_KEY.KEYSATGALILEOUSED, buffer.get())
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,16 +1,6 @@
|
|||
package net.nigreon.blegps
|
||||
|
||||
class GPSConfiguration {
|
||||
var bmpNrf: Boolean = false
|
||||
var bmpBT: Boolean = false
|
||||
var bmp2gps: Boolean = false
|
||||
var extTemp: Boolean = false
|
||||
var gpsBLE: Boolean = false
|
||||
var gpsVerbose: Boolean = false
|
||||
var gpsSerial: Boolean = false
|
||||
var gpsMode: Int = 0
|
||||
var gpsBoost: Boolean = false
|
||||
var gpsPollerSend: Short = 0
|
||||
var gpsSendBTSend: Short = 0
|
||||
var bmpPollerSend: Short = 0
|
||||
}
|
|
@ -35,17 +35,12 @@ class MainActivity : AppCompatActivity() {
|
|||
private lateinit var mBoundService: BLEMockLocationService
|
||||
var mServiceBound = false
|
||||
|
||||
private lateinit var mBoundServiceHR: BLEHRService
|
||||
var mServiceBoundHR = false
|
||||
|
||||
var currentPressure: Int = -1
|
||||
var currentTemperature: Float = -1.0f
|
||||
var BTConnected = false
|
||||
var BTHRConnected = false
|
||||
var lastLocation: Location = Location("LastLocation")
|
||||
|
||||
private lateinit var gpxfilename: String
|
||||
private var gpxopened = false
|
||||
var resumeActivityState: Boolean = true;
|
||||
|
||||
private lateinit var sharedPreferences: SharedPreferences
|
||||
|
||||
|
@ -70,16 +65,6 @@ class MainActivity : AppCompatActivity() {
|
|||
mServiceBound = false
|
||||
}
|
||||
|
||||
fun disconnectBTHR()
|
||||
{
|
||||
Intent(this, BLEHRService::class.java).also { intent ->
|
||||
intent.action = ServicesConstants.HRSERVICEACTION.STOPFOREGROUND_ACTION
|
||||
startService(intent)
|
||||
}
|
||||
unbindService(mServiceConnectionHR)
|
||||
mServiceBoundHR = false
|
||||
}
|
||||
|
||||
fun filter01changed(intent: Intent)
|
||||
{
|
||||
Log.v(LOG_TAG, "Filter01 Broadcast received")
|
||||
|
@ -104,46 +89,19 @@ class MainActivity : AppCompatActivity() {
|
|||
val connected = intent.getBooleanExtra(ServicesConstants.BROADCAST_KEY.KEYBTSTATUS,false)
|
||||
if(connected) {
|
||||
BTConnected=true
|
||||
if(resumeActivityState == true) { sendGPSModeToBLEService(3) }
|
||||
text01.text = "BT Connected"
|
||||
buttonconnectbt.text = "Disconnect"
|
||||
Log.v(LOG_TAG, "BT Connected Broadcast received")
|
||||
mBoundService.HRStatusChanged(BTHRConnected)
|
||||
sendConfToBLEService()
|
||||
if(swlog2file.isChecked())
|
||||
{
|
||||
mBoundService.openGPX(gpxfilename)
|
||||
gpxopened = true
|
||||
}
|
||||
} else {
|
||||
text01.text = "BT Disconnected"
|
||||
buttonconnectbt.text = "Connect"
|
||||
Log.v(LOG_TAG, "BT Disconnected Broadcast received")
|
||||
BTConnected=false
|
||||
swblepower.setChecked(false)
|
||||
}
|
||||
writeBMPText()
|
||||
}
|
||||
|
||||
fun BTChangedHR(intent: Intent)
|
||||
{
|
||||
val connected = intent.getBooleanExtra(ServicesConstants.BROADCAST_KEY.KEYBTSTATUSHR,false)
|
||||
if(connected) {
|
||||
BTHRConnected=true
|
||||
text01.text = "BT HR Connected"
|
||||
Log.v(LOG_TAG, "BT HR Connected Broadcast received")
|
||||
if(BTConnected) { mBoundService.HRStatusChanged(true) }
|
||||
} else {
|
||||
text01.text = "BT HR Disconnected"
|
||||
Log.v(LOG_TAG, "BT HR Disconnected Broadcast received")
|
||||
BTHRConnected=false
|
||||
if(BTConnected) { mBoundService.HRStatusChanged(false) }
|
||||
}
|
||||
writeBMPText()
|
||||
}
|
||||
|
||||
fun BTChangedHRM(intent: Intent)
|
||||
{
|
||||
texthr.text = intent.getByteExtra(ServicesConstants.BROADCAST_KEY.KEYBTHRM,0).toString() + " bpm"
|
||||
}
|
||||
|
||||
private fun convertLatLon(latitude: Double, longitude: Double): String {
|
||||
val builder = StringBuilder()
|
||||
|
||||
|
@ -204,11 +162,6 @@ class MainActivity : AppCompatActivity() {
|
|||
textlocation.text = "${convertLatLon(currentLatitude, currentLongitude)} $currentElevation m \n $currentLatitude $currentLongitude $currentElevation m"
|
||||
textspeedheading.text = "$currentSpeed km/h $currentHeading° ${currentLocation.distanceTo(lastLocation)} m"
|
||||
lastLocation = currentLocation
|
||||
|
||||
if(swblegpsverbose.isChecked == false) {
|
||||
textquality.text = "$currentEHPE m"
|
||||
textsatellites.text = "Satellites in verbose"
|
||||
}
|
||||
}
|
||||
|
||||
fun writeQualityText(intent: Intent)
|
||||
|
@ -217,23 +170,16 @@ class MainActivity : AppCompatActivity() {
|
|||
val currentEVPE = intent.getFloatExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYEVPE,-1.0f)
|
||||
val currentHDOP = intent.getFloatExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYHDOP,-1.0f)
|
||||
val currentVDOP = intent.getFloatExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYVDOP,-1.0f)
|
||||
val sat_view = intent.getByteExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYSATVIEW,-1)
|
||||
val sat_used = intent.getByteExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYSATUSED,-1)
|
||||
val elevation_gps = intent.getDoubleExtra(ServicesConstants.BROADCAST_KEY.KEYQUALITYELEGPS,-1.0)
|
||||
textquality.text = "$currentEHPE m $currentEVPE m $currentHDOP $currentVDOP $sat_used/$sat_view $elevation_gps m"
|
||||
textquality.text = "$currentEHPE m $currentEVPE m $currentHDOP $currentVDOP $elevation_gps m"
|
||||
}
|
||||
|
||||
fun writeSatText(intent: Intent)
|
||||
{
|
||||
val gpsall = intent.getByteExtra(ServicesConstants.BROADCAST_KEY.KEYSATGPSALL,-1)
|
||||
val gpsused = intent.getByteExtra(ServicesConstants.BROADCAST_KEY.KEYSATGPSUSED,-1)
|
||||
val sbasall = intent.getByteExtra(ServicesConstants.BROADCAST_KEY.KEYSATSBASALL,-1)
|
||||
val sbasused = intent.getByteExtra(ServicesConstants.BROADCAST_KEY.KEYSATSBASUSED,-1)
|
||||
val glonassall = intent.getByteExtra(ServicesConstants.BROADCAST_KEY.KEYSATGLONASSALL,-1)
|
||||
val glonassused = intent.getByteExtra(ServicesConstants.BROADCAST_KEY.KEYSATGLONASSUSED,-1)
|
||||
val galileoall = intent.getByteExtra(ServicesConstants.BROADCAST_KEY.KEYSATGALILEOALL,-1)
|
||||
val galileoused = intent.getByteExtra(ServicesConstants.BROADCAST_KEY.KEYSATGALILEOUSED,-1)
|
||||
textsatellites.text = "GPS: $gpsused/$gpsall SBAS: $sbasused/$sbasall GLONASS: $glonassused/$glonassall GALILEO: $galileoused/$galileoall"
|
||||
textsatellites.text = "GPS: $gpsused GLONASS: $glonassused GALILEO: $galileoused"
|
||||
}
|
||||
private fun sendCalibrateToBLEService()
|
||||
{
|
||||
|
@ -242,72 +188,14 @@ class MainActivity : AppCompatActivity() {
|
|||
mBoundService.sendCalibrateBLE(calibrateval)
|
||||
}
|
||||
}
|
||||
private fun sendConfToBLEService()
|
||||
|
||||
private fun sendGPSModeToBLEService(gpsmode: Int)
|
||||
{
|
||||
if(BTConnected) {
|
||||
val bmppollersend: Float = resources.getStringArray(R.array.pollerval)[spinbmp.selectedItemPosition].toFloat() * 4
|
||||
var gpspollersend: Float
|
||||
var gpssendbtsend: Float
|
||||
var gpsmode: Int
|
||||
|
||||
/*if(swblegpsboost.isChecked)
|
||||
{
|
||||
gpspollersend = 4f
|
||||
gpssendbtsend = 4f
|
||||
gpsmode = 1
|
||||
} else {*/
|
||||
gpspollersend = resources.getStringArray(R.array.pollerval)[spingps.selectedItemPosition].toFloat() * 4
|
||||
gpssendbtsend = resources.getStringArray(R.array.pollerval)[spingpssendbt.selectedItemPosition].toFloat() * 4
|
||||
gpsmode = spingpsmode.selectedItemPosition
|
||||
//}
|
||||
|
||||
var gpsConf: GPSConfiguration = GPSConfiguration()
|
||||
|
||||
gpsConf.bmpNrf = swbmpnrf.isChecked
|
||||
gpsConf.bmpBT = swbmpbt.isChecked
|
||||
gpsConf.bmp2gps = swbmp2gps.isChecked
|
||||
gpsConf.extTemp = swexttemp.isChecked
|
||||
gpsConf.gpsBLE = swgpsble.isChecked
|
||||
gpsConf.gpsVerbose = swblegpsverbose.isChecked
|
||||
//gpsConf.gpsBoost = swblegpsboost.isChecked
|
||||
gpsConf.gpsSerial = swgpsserial.isChecked
|
||||
gpsConf.gpsMode = gpsmode
|
||||
gpsConf.gpsPollerSend = gpspollersend.toShort()
|
||||
gpsConf.gpsSendBTSend = gpssendbtsend.toShort()
|
||||
gpsConf.bmpPollerSend = bmppollersend.toShort()
|
||||
|
||||
mBoundService.sendConfBLE(gpsConf)
|
||||
|
||||
mBoundService.sendConfBLE(gpsmode)
|
||||
}
|
||||
}
|
||||
private fun sendStopConfToBLEService()
|
||||
{
|
||||
if(BTConnected) {
|
||||
val gpspollersend: Float =
|
||||
resources.getStringArray(R.array.pollerval)[spingps.selectedItemPosition].toFloat() * 4
|
||||
val bmppollersend: Float =
|
||||
resources.getStringArray(R.array.pollerval)[spinbmp.selectedItemPosition].toFloat() * 4
|
||||
val gpssendbtsend: Float =
|
||||
resources.getStringArray(R.array.pollerval)[spingpssendbt.selectedItemPosition].toFloat() * 4
|
||||
|
||||
var gpsConf: GPSConfiguration = GPSConfiguration()
|
||||
|
||||
gpsConf.bmpNrf = false
|
||||
gpsConf.bmpBT = false
|
||||
gpsConf.bmp2gps = false
|
||||
gpsConf.extTemp = false
|
||||
gpsConf.gpsBLE = false
|
||||
gpsConf.gpsVerbose = false
|
||||
gpsConf.gpsSerial = false
|
||||
gpsConf.gpsMode = spingpsmode.selectedItemPosition
|
||||
gpsConf.gpsPollerSend = gpspollersend.toShort()
|
||||
gpsConf.gpsSendBTSend = gpssendbtsend.toShort()
|
||||
gpsConf.bmpPollerSend = bmppollersend.toShort()
|
||||
|
||||
mBoundService.sendConfBLE(gpsConf)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -326,8 +214,6 @@ class MainActivity : AppCompatActivity() {
|
|||
when (intent?.action) {
|
||||
ServicesConstants.BROADCAST_FILTER.FILTER01 -> filter01changed(intent)
|
||||
ServicesConstants.BROADCAST_FILTER.FILTERBT -> BTChanged(intent)
|
||||
ServicesConstants.BROADCAST_FILTER.FILTERBTHR -> BTChangedHR(intent)
|
||||
ServicesConstants.BROADCAST_FILTER.FILTERBTHRM -> BTChangedHRM(intent)
|
||||
ServicesConstants.BROADCAST_FILTER.FILTERTEMP -> temperatureChanged(intent)
|
||||
ServicesConstants.BROADCAST_FILTER.FILTERPRESSURE -> pressureChanged(intent)
|
||||
ServicesConstants.BROADCAST_FILTER.FILTERLOCATION -> writeLocationText(intent)
|
||||
|
@ -339,16 +225,14 @@ class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
spinbmp.setSelection(11)
|
||||
spingps.setSelection(3)
|
||||
spingpsmode.setSelection(1)
|
||||
spingpssendbt.setSelection(10)
|
||||
|
||||
lastLocation.latitude = 0.0
|
||||
lastLocation.longitude = 0.0
|
||||
|
||||
sharedPreferences = baseContext.getSharedPreferences("blegps_config", MODE_PRIVATE)
|
||||
|
||||
editbtaddr.setText(sharedPreferences.getString("macaddr", ""))
|
||||
swbmp2gps.isChecked = sharedPreferences.getBoolean("swbmp2gps", false)
|
||||
|
||||
/*sharedPreferences
|
||||
.edit()
|
||||
.putInt("inttest", 64)
|
||||
|
@ -396,144 +280,34 @@ class MainActivity : AppCompatActivity() {
|
|||
)
|
||||
}*/
|
||||
|
||||
swblepower.setOnCheckedChangeListener { _, isChecked ->
|
||||
if(isChecked) {
|
||||
buttonconnectbt.setOnClickListener {
|
||||
if(BTConnected == false && editbtaddr.text.toString() != "") {
|
||||
sharedPreferences
|
||||
.edit()
|
||||
.putString("macaddr", editbtaddr.text.toString())
|
||||
.apply()
|
||||
Intent(this, BLEMockLocationService::class.java).also { intent ->
|
||||
bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE)
|
||||
intent.action = ServicesConstants.MOCKSERVICEACTION.STARTFOREGROUND_ACTION
|
||||
startService(intent)
|
||||
}
|
||||
} else {
|
||||
sendStopConfToBLEService()
|
||||
delayFunction({ disconnectBT() }, 1500)
|
||||
delayFunction({ disconnectBT() }, 1500)
|
||||
}
|
||||
}
|
||||
|
||||
swblehrpower.setOnCheckedChangeListener { _, isChecked ->
|
||||
if(isChecked) {
|
||||
Intent(this, BLEHRService::class.java).also { intent ->
|
||||
bindService(intent, mServiceConnectionHR, Context.BIND_AUTO_CREATE)
|
||||
intent.action = ServicesConstants.HRSERVICEACTION.STARTFOREGROUND_ACTION
|
||||
startService(intent)
|
||||
}
|
||||
} else {
|
||||
//sendStopConfToBLEService()
|
||||
delayFunction({ disconnectBTHR() }, 1500)
|
||||
}
|
||||
}
|
||||
|
||||
swbmpnrf.setOnCheckedChangeListener { _,_ ->
|
||||
sendConfToBLEService()
|
||||
}
|
||||
swbmpbt.setOnCheckedChangeListener { _, checked ->
|
||||
if(checked) {
|
||||
LocalBroadcastManager.getInstance(baseContext).sendBroadcast(
|
||||
Intent(ServicesConstants.BROADCAST_FILTER.FILTERBMP).putExtra(ServicesConstants.BROADCAST_KEY.KEYBMPSTATUS, true)
|
||||
)
|
||||
} else {
|
||||
LocalBroadcastManager.getInstance(baseContext).sendBroadcast(
|
||||
Intent(ServicesConstants.BROADCAST_FILTER.FILTERBMP).putExtra(ServicesConstants.BROADCAST_KEY.KEYBMPSTATUS, false)
|
||||
)
|
||||
}
|
||||
sendConfToBLEService()
|
||||
}
|
||||
swbmp2gps.setOnCheckedChangeListener { _,_ ->
|
||||
sendConfToBLEService()
|
||||
}
|
||||
swexttemp.setOnCheckedChangeListener { _,_ ->
|
||||
sendConfToBLEService()
|
||||
}
|
||||
swgpsble.setOnCheckedChangeListener { _,_ ->
|
||||
sendConfToBLEService()
|
||||
}
|
||||
swblegpsverbose.setOnCheckedChangeListener { _, _ ->
|
||||
sendConfToBLEService()
|
||||
}
|
||||
swgpsserial.setOnCheckedChangeListener { _,_ ->
|
||||
sendConfToBLEService()
|
||||
}
|
||||
/*swblegpsboost.setOnCheckedChangeListener { _,_ ->
|
||||
sendConfToBLEService()
|
||||
}*/
|
||||
swlog2file.setOnCheckedChangeListener { _, checked ->
|
||||
if(checked) {
|
||||
gpxfilename = SimpleDateFormat("yyyyMMdd_HHmmss").format(Date())
|
||||
if (BTConnected) {
|
||||
mBoundService.openGPX(gpxfilename)
|
||||
gpxopened = true
|
||||
}
|
||||
} else {
|
||||
if(BTConnected) {
|
||||
mBoundService.closeGPX()
|
||||
} else if(gpxopened) {
|
||||
var gpxhandle = File(
|
||||
Environment.getExternalStorageDirectory().path + File.separator + "BTGPS",
|
||||
gpxfilename + ".gpx"
|
||||
)
|
||||
var gpxoutputstream = FileOutputStream(gpxhandle, true)
|
||||
try {
|
||||
val gpxfooter = "</trkseg></trk></gpx>\n"
|
||||
gpxoutputstream.write(gpxfooter.toByteArray())
|
||||
} catch (e: FileNotFoundException) {
|
||||
e.printStackTrace()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
gpxoutputstream.close()
|
||||
}
|
||||
gpxopened = false
|
||||
}
|
||||
//sendConfToBLEService()
|
||||
}
|
||||
|
||||
spingpsmode.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onNothingSelected(p0: AdapterView<*>?) {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun onItemSelected(p0: AdapterView<*>?, p1: View?, p2: Int, p3: Long) {
|
||||
sendConfToBLEService()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
spinbmp.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onNothingSelected(p0: AdapterView<*>?) {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun onItemSelected(p0: AdapterView<*>?, p1: View?, p2: Int, p3: Long) {
|
||||
sendConfToBLEService()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
spingps.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onNothingSelected(p0: AdapterView<*>?) {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun onItemSelected(p0: AdapterView<*>?, p1: View?, p2: Int, p3: Long) {
|
||||
sendConfToBLEService()
|
||||
}
|
||||
|
||||
}
|
||||
spingpssendbt.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onNothingSelected(p0: AdapterView<*>?) {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun onItemSelected(p0: AdapterView<*>?, p1: View?, p2: Int, p3: Long) {
|
||||
sendConfToBLEService()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
buttoncalibratebmp2gps.setOnClickListener {
|
||||
//text01.text = editcalibratebmp2gps.text
|
||||
sendCalibrateToBLEService()
|
||||
}
|
||||
|
||||
swbmp2gps.setOnClickListener {
|
||||
sharedPreferences
|
||||
.edit()
|
||||
.putBoolean("swbmp2gps", swbmp2gps.isChecked)
|
||||
.apply()
|
||||
}
|
||||
|
||||
/*startmock.setOnClickListener {
|
||||
//val startIntent = Intent(this,BLEMockLocationService::class.java)
|
||||
//startIntent.action = ServicesConstants.MOCKSERVICEACTION.STARTFOREGROUND_ACTION
|
||||
|
@ -566,8 +340,6 @@ class MainActivity : AppCompatActivity() {
|
|||
val manager = LocalBroadcastManager.getInstance(this)
|
||||
manager.registerReceiver(brReceiver, IntentFilter(ServicesConstants.BROADCAST_FILTER.FILTER01))
|
||||
manager.registerReceiver(brReceiver, IntentFilter(ServicesConstants.BROADCAST_FILTER.FILTERBT))
|
||||
manager.registerReceiver(brReceiver, IntentFilter(ServicesConstants.BROADCAST_FILTER.FILTERBTHR))
|
||||
manager.registerReceiver(brReceiver, IntentFilter(ServicesConstants.BROADCAST_FILTER.FILTERBTHRM))
|
||||
manager.registerReceiver(brReceiver, IntentFilter(ServicesConstants.BROADCAST_FILTER.FILTERTEMP))
|
||||
manager.registerReceiver(brReceiver, IntentFilter(ServicesConstants.BROADCAST_FILTER.FILTERPRESSURE))
|
||||
manager.registerReceiver(brReceiver, IntentFilter(ServicesConstants.BROADCAST_FILTER.FILTERLOCATION))
|
||||
|
@ -580,9 +352,14 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
if(!swlog2file.isChecked) {
|
||||
swblegpsverbose.setChecked(false)
|
||||
}
|
||||
resumeActivityState = false
|
||||
sendGPSModeToBLEService(2)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
resumeActivityState = true
|
||||
sendGPSModeToBLEService(3)
|
||||
}
|
||||
|
||||
private val mServiceConnection = object : ServiceConnection {
|
||||
|
@ -598,17 +375,4 @@ class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private val mServiceConnectionHR = object : ServiceConnection {
|
||||
|
||||
override fun onServiceDisconnected(name: ComponentName) {
|
||||
mServiceBoundHR = false
|
||||
}
|
||||
|
||||
override fun onServiceConnected(name: ComponentName, service: IBinder) {
|
||||
val binderHR = service as BLEHRService.sBinder
|
||||
mBoundServiceHR = binderHR.getService()
|
||||
mServiceBoundHR = true
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,19 +4,37 @@ import android.content.Context
|
|||
import android.location.Location
|
||||
import android.location.LocationManager
|
||||
import android.os.SystemClock
|
||||
import android.util.Log
|
||||
|
||||
class MockLocationProvider(val providerName: String, val ctx: Context) {
|
||||
|
||||
private val LOG_TAG = "MockLocationProvider"
|
||||
|
||||
private val lm = ctx.getSystemService(
|
||||
Context.LOCATION_SERVICE
|
||||
) as LocationManager
|
||||
|
||||
fun start() {
|
||||
|
||||
lm.addTestProvider(
|
||||
providerName, false, false, false, false, true,
|
||||
true, true, 0, 5
|
||||
)
|
||||
try {
|
||||
lm.removeTestProvider(providerName)
|
||||
} catch(exception: Exception) {
|
||||
Log.w(LOG_TAG,"No TestProvider to remove")
|
||||
}
|
||||
/* if(providerName in lm.getAllProviders()) {
|
||||
lm.removeTestProvider(providerName)
|
||||
}*/
|
||||
//try {
|
||||
lm.addTestProvider(
|
||||
providerName, false, false, false, false, true,
|
||||
true, true, 0, 5
|
||||
)
|
||||
/*} catch() {
|
||||
lm.removeTestProvider(providerName)
|
||||
lm.addTestProvider(
|
||||
providerName, false, false, false, false, true,
|
||||
true, true, 0, 5
|
||||
)
|
||||
}*/
|
||||
lm.setTestProviderEnabled(providerName, true)
|
||||
}
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@ class ServicesConstants {
|
|||
const val FILTER01 = "just.a.filter"
|
||||
const val FILTERBT = "filter.bt"
|
||||
const val FILTERBMP = "filter.bmp"
|
||||
const val FILTERBTHR = "filter.bthr"
|
||||
const val FILTERBTHRM = "filter.bthrm"
|
||||
const val FILTERTEMP = "filter.temp"
|
||||
const val FILTERPRESSURE = "filter.pressure"
|
||||
const val FILTERLOCATION = "filter.location"
|
||||
|
@ -41,8 +39,6 @@ class ServicesConstants {
|
|||
companion object {
|
||||
const val KEY01 = "key01"
|
||||
const val KEYBTSTATUS = "btstatus"
|
||||
const val KEYBTSTATUSHR = "btstatushr"
|
||||
const val KEYBTHRM = "bthrm"
|
||||
const val KEYBMPSTATUS = "bmpstatus"
|
||||
const val KEYTEMP = "temperature"
|
||||
const val KEYPRESSURE = "pressure"
|
||||
|
@ -60,13 +56,8 @@ class ServicesConstants {
|
|||
const val KEYQUALITYHDOP = "hdop"
|
||||
const val KEYQUALITYVDOP = "vdop"
|
||||
const val KEYQUALITYELEGPS = "elevation_gps"
|
||||
const val KEYSATGPSALL = "gpsall"
|
||||
const val KEYSATGPSUSED = "gpsused"
|
||||
const val KEYSATSBASALL = "sbasall"
|
||||
const val KEYSATSBASUSED = "sbasused"
|
||||
const val KEYSATGLONASSALL = "glonassall"
|
||||
const val KEYSATGLONASSUSED = "glonassused"
|
||||
const val KEYSATGALILEOALL = "galileoall"
|
||||
const val KEYSATGALILEOUSED = "galileoused"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,14 +10,19 @@ import android.util.Log
|
|||
class TaskerReceiver: BroadcastReceiver() {
|
||||
private val LOG_TAG = "TaskerReceiver"
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
Log.v(LOG_TAG, "Receive")
|
||||
val screen = intent.extras.getBoolean("screen")
|
||||
Log.v(LOG_TAG, "Receive Tasker $screen")
|
||||
|
||||
|
||||
val serviceIntent = Intent(context, BLEMockLocationService::class.java)
|
||||
serviceIntent.action=ServicesConstants.MOCKSERVICEACTION.TASKER_ACTION
|
||||
|
||||
//serviceIntent.putExtras(Intent(ServicesConstants.BROADCAST_FILTER.FILTERTASKER).putExtra(ServicesConstants.BROADCAST_KEY.KEYBOOST, false))
|
||||
serviceIntent.putExtras(intent)
|
||||
serviceIntent.putExtras(Intent(ServicesConstants.BROADCAST_FILTER.FILTERTASKER).putExtra(ServicesConstants.BROADCAST_KEY.KEYBOOST, screen))
|
||||
//serviceIntent.putExtras(intent)
|
||||
|
||||
//LocalBroadcastManager.getInstance(context).sendBroadcast(
|
||||
// Intent(ServicesConstants.BROADCAST_FILTER.FILTERTASKER).putExtra(ServicesConstants.BROADCAST_KEY.KEYBOOST, true))
|
||||
// Intent(ServicesConstants.BROADCAST_FILTER.FILTERTASKER).putExtra(ServicesConstants.BROADCAST_KEY.KEYBOOST, screen))
|
||||
ContextCompat.startForegroundService(context, serviceIntent)
|
||||
|
||||
}
|
||||
}
|
|
@ -11,85 +11,40 @@
|
|||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".MainActivity">
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:context=".MainActivity">
|
||||
<Switch
|
||||
android:text="BLE GPS Power"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/swblepower">
|
||||
|
||||
</Switch>
|
||||
<Switch
|
||||
android:text="BLE HR Power"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/swblehrpower"/>
|
||||
<!--<Button
|
||||
android:text="Start Mock"
|
||||
tools:context=".MainActivity"
|
||||
android:focusableInTouchMode="true">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:text="BT Address"
|
||||
android:layout_margin="0dp"
|
||||
android:padding="10dp"
|
||||
android:id="@+id/startmock"/>
|
||||
<Button
|
||||
android:text="Stop Mock"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:id="@+id/textbtaddr"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editbtaddr"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_margin="0dp"
|
||||
android:padding="10dp"
|
||||
android:id="@+id/stopmock"/>-->
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:context=".MainActivity">
|
||||
<Switch
|
||||
android:text="BMP nRF"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/swbmpnrf"/>
|
||||
<Switch
|
||||
android:text="BMP BT"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/swbmpbt"/>
|
||||
|
||||
<Switch
|
||||
android:text="Ext Temp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/swexttemp"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<Switch
|
||||
android:text="GPS BLE"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/swgpsble"/>
|
||||
<Switch
|
||||
android:text="GPS Serial"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/swgpsserial"/>
|
||||
<Switch
|
||||
android:text="BMP2GPS"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/swbmp2gps"/>
|
||||
|
||||
android:maxLength="17"
|
||||
android:inputType="textCapCharacters" />
|
||||
|
||||
</LinearLayout>
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Connect"
|
||||
android:layout_margin="0dp"
|
||||
android:padding="10dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:id="@+id/buttonconnectbt"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -130,31 +85,6 @@
|
|||
android:padding="10dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:id="@+id/textspeedheading"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="HR"
|
||||
android:layout_margin="0dp"
|
||||
android:padding="10dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:id="@+id/texthr"/>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:context=".MainActivity">
|
||||
<Switch
|
||||
android:text="BLE GPS Verbose"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/swblegpsverbose"/>
|
||||
<Switch
|
||||
android:text="Log2File"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/swlog2file"/>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -171,21 +101,6 @@
|
|||
android:padding="10dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:id="@+id/textsatellites"/>
|
||||
<!-- <TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Read"
|
||||
android:layout_margin="0dp"
|
||||
android:padding="10dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:id="@+id/textread"/>
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="0dp"
|
||||
android:padding="10dp"
|
||||
android:hint="Value Hint"
|
||||
android:id="@+id/edit01"/>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
|
@ -194,113 +109,11 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:context=".MainActivity">
|
||||
<Button
|
||||
android:text="Read"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:padding="10dp"
|
||||
android:id="@+id/buttonread"/>
|
||||
<Button
|
||||
android:text="Write"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:padding="10dp"
|
||||
android:id="@+id/buttonwrite"/>
|
||||
<Button
|
||||
android:text="Get Counter"
|
||||
<Switch
|
||||
android:text="BMP2GPS"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:padding="10dp"
|
||||
android:id="@+id/bCounter"/>
|
||||
</LinearLayout>-->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:context=".MainActivity">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="BMP Poller"
|
||||
android:layout_margin="0dp"
|
||||
android:padding="10dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:id="@+id/textspinbmp"/>
|
||||
<Spinner
|
||||
android:id="@+id/spinbmp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:entries="@array/poller" />
|
||||
android:layout_height="wrap_content" android:id="@+id/swbmp2gps"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:context=".MainActivity">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="GPS Mode"
|
||||
android:layout_margin="0dp"
|
||||
android:padding="10dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:id="@+id/textspingpsmode"/>
|
||||
<Spinner
|
||||
android:id="@+id/spingpsmode"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:entries="@array/gpsmode"/>
|
||||
<!--<Switch
|
||||
android:text="BLE GPS Boost"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/swblegpsboost"/>-->
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:context=".MainActivity">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="GPS Poller"
|
||||
android:layout_margin="0dp"
|
||||
android:padding="10dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:id="@+id/textspingps"/>
|
||||
<Spinner
|
||||
android:id="@+id/spingps"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:entries="@array/poller"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="GPS BT"
|
||||
android:layout_margin="0dp"
|
||||
android:padding="10dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:id="@+id/textspingpssendbt"/>
|
||||
<Spinner
|
||||
android:id="@+id/spingpssendbt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:entries="@array/poller"/>
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -5,7 +5,7 @@ buildscript {
|
|||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
||||
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.4.2'
|
||||
|
@ -19,6 +19,7 @@ allprojects {
|
|||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
maven { url 'https://jitpack.io' }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue