-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #209: Fixed. api.shutDown did not correctly release it resources.
- Loading branch information
1 parent
9e2ac33
commit 8176a4a
Showing
27 changed files
with
890 additions
and
690 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...c/main/java/com/polar/androidcommunications/api/ble/exceptions/BleNotAvailableInDevice.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.polar.androidcommunications.api.ble.exceptions | ||
|
||
/** | ||
* Error indicating the device is not supporting BLE | ||
*/ | ||
class BleNotAvailableInDevice(message: String) : Exception(message) |
14 changes: 0 additions & 14 deletions
14
...y/src/main/java/com/polar/androidcommunications/api/ble/exceptions/BleStartScanError.java
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...ary/src/main/java/com/polar/androidcommunications/api/ble/exceptions/BleStartScanError.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.polar.androidcommunications.api.ble.exceptions | ||
|
||
class BleStartScanError(message: String, val error: Int) : Exception("$message failed with error: $error") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...va/com/polar/androidcommunications/api/ble/model/gatt/client/pmd/model/TemperatureData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.polar.androidcommunications.api.ble.model.gatt.client.pmd.model | ||
|
||
import com.polar.androidcommunications.api.ble.model.gatt.client.pmd.BlePMDClient | ||
import com.polar.androidcommunications.api.ble.model.gatt.client.pmd.BlePMDClient.PmdDataFieldEncoding | ||
import com.polar.androidcommunications.api.ble.model.gatt.client.pmd.BlePMDClientUtils | ||
import java.lang.Float.intBitsToFloat | ||
import java.util.* | ||
|
||
/** | ||
* Temperature data | ||
* @param timeStamp ns in epoch time. The time stamp represent time of last sample in [temperatureSamples] list | ||
*/ | ||
class TemperatureData internal constructor(val timeStamp: Long) { | ||
|
||
data class TemperatureSample internal constructor( | ||
// Sample contains signed temperature value in celcius | ||
val temperature: Float | ||
) | ||
|
||
@JvmField | ||
val temperatureSamples: MutableList<TemperatureSample> = ArrayList() | ||
|
||
companion object { | ||
fun parseDataFromDataFrame(isCompressed: Boolean, frameType: BlePMDClient.PmdDataFrameType, frame: ByteArray, factor: Float, timeStamp: Long): TemperatureData { | ||
return if (isCompressed) { | ||
when (frameType) { | ||
BlePMDClient.PmdDataFrameType.TYPE_0 -> dataFromCompressedType0(frame, factor, timeStamp) | ||
else -> throw java.lang.Exception("Compressed FrameType: $frameType is not supported by Temperature data parser") | ||
} | ||
} else { | ||
when (frameType) { | ||
BlePMDClient.PmdDataFrameType.TYPE_0 -> dataFromRawType0(frame, timeStamp) | ||
else -> throw java.lang.Exception("Raw FrameType: $frameType is not supported by Temperature data parser") | ||
} | ||
} | ||
} | ||
|
||
private fun dataFromCompressedType0(frame: ByteArray, factor: Float, timeStamp: Long): TemperatureData { | ||
val samples = BlePMDClient.parseDeltaFramesAll(frame, 1, 32, PmdDataFieldEncoding.FLOAT_IEEE754) | ||
val temperatureData = TemperatureData(timeStamp) | ||
for (sample in samples) { | ||
val pressure = if (factor != 1.0f) intBitsToFloat(sample[0]) * factor else intBitsToFloat(sample[0]) | ||
temperatureData.temperatureSamples.add(TemperatureSample(pressure)) | ||
} | ||
return temperatureData | ||
} | ||
|
||
private fun dataFromRawType0(frame: ByteArray, timeStamp: Long): TemperatureData { | ||
val temperatureData = TemperatureData(timeStamp) | ||
var offset = 0 | ||
|
||
while (offset < frame.size) { | ||
val temperature = BlePMDClientUtils.parseFrameDataField(frame.sliceArray(offset..(offset + 3)), PmdDataFieldEncoding.FLOAT_IEEE754) as Float | ||
offset += 4 | ||
temperatureData.temperatureSamples.add(TemperatureSample(temperature)) | ||
} | ||
return temperatureData | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.