Commit 9d7e21ee authored by Anon's avatar Anon
Browse files

LowEffortService: Move UUIDs to constants.

parent f7215a13
...@@ -37,6 +37,10 @@ val SINGLE_LED_CHARACTERISTIC_UUID = UUID.fromString("42230211-2342-2342-2342-23 ...@@ -37,6 +37,10 @@ val SINGLE_LED_CHARACTERISTIC_UUID = UUID.fromString("42230211-2342-2342-2342-23
val LIGHT_SENSOR_CHARACTERISTIC_UUID = UUID.fromString("422302f0-2342-2342-2342-234223422342") val LIGHT_SENSOR_CHARACTERISTIC_UUID = UUID.fromString("422302f0-2342-2342-2342-234223422342")
val TIME_CHARACTERISTIC_UUID = UUID.fromString("42230201-2342-2342-2342-234223422342") val TIME_CHARACTERISTIC_UUID = UUID.fromString("42230201-2342-2342-2342-234223422342")
val FILE_SERVICE_UUID = UUID.fromString("42230100-2342-2342-2342-234223422342")
val FILE_TX_UUID = UUID.fromString("42230101-2342-2342-2342-234223422342")
val FILE_RX_UUID = UUID.fromString("42230102-2342-2342-2342-234223422342")
const val UPDATE_CLOCK_FREQUENCY_MINS = 5 const val UPDATE_CLOCK_FREQUENCY_MINS = 5
const val HATCHERY_BASE_URL = "https://badge.team" const val HATCHERY_BASE_URL = "https://badge.team"
...@@ -27,6 +27,7 @@ import android.content.Context ...@@ -27,6 +27,7 @@ import android.content.Context
import android.util.Log import android.util.Log
import de.ccc.events.badge.card10.CARD10_BLUETOOTH_MAC_PREFIX import de.ccc.events.badge.card10.CARD10_BLUETOOTH_MAC_PREFIX
import de.ccc.events.badge.card10.CARD10_SERVICE_UUID import de.ccc.events.badge.card10.CARD10_SERVICE_UUID
import de.ccc.events.badge.card10.FILE_SERVICE_UUID
import de.ccc.events.badge.card10.R import de.ccc.events.badge.card10.R
import de.ccc.events.badge.card10.filetransfer.LowEffortService import de.ccc.events.badge.card10.filetransfer.LowEffortService
import de.ccc.events.badge.card10.time.Card10Service import de.ccc.events.badge.card10.time.Card10Service
...@@ -47,8 +48,6 @@ object ConnectionService { ...@@ -47,8 +48,6 @@ object ConnectionService {
private var connectionState = BluetoothGatt.STATE_DISCONNECTED private var connectionState = BluetoothGatt.STATE_DISCONNECTED
private var gattListeners = mutableMapOf<String, GattListener>() private var gattListeners = mutableMapOf<String, GattListener>()
private val fileServiceUuid = UUID.fromString("42230100-2342-2342-2342-234223422342")
val deviceName: String? val deviceName: String?
get() = device?.name get() = device?.name
...@@ -99,7 +98,7 @@ object ConnectionService { ...@@ -99,7 +98,7 @@ object ConnectionService {
for (service in gatt.services) { for (service in gatt.services) {
Log.d(TAG, "Found service: ${service.uuid}") Log.d(TAG, "Found service: ${service.uuid}")
if (service.uuid == fileServiceUuid) { if (service.uuid == FILE_SERVICE_UUID) {
leService = LowEffortService(service) leService = LowEffortService(service)
} else if (service.uuid == CARD10_SERVICE_UUID) { } else if (service.uuid == CARD10_SERVICE_UUID) {
card10Service = Card10Service(service) card10Service = Card10Service(service)
......
...@@ -26,6 +26,8 @@ import android.bluetooth.BluetoothGatt ...@@ -26,6 +26,8 @@ import android.bluetooth.BluetoothGatt
import android.bluetooth.BluetoothGattCharacteristic import android.bluetooth.BluetoothGattCharacteristic
import android.bluetooth.BluetoothGattService import android.bluetooth.BluetoothGattService
import android.util.Log import android.util.Log
import de.ccc.events.badge.card10.FILE_RX_UUID
import de.ccc.events.badge.card10.FILE_TX_UUID
import de.ccc.events.badge.card10.common.ConnectionService import de.ccc.events.badge.card10.common.ConnectionService
import de.ccc.events.badge.card10.common.GattListener import de.ccc.events.badge.card10.common.GattListener
import de.ccc.events.badge.card10.filetransfer.protocol.Packet import de.ccc.events.badge.card10.filetransfer.protocol.Packet
...@@ -39,15 +41,12 @@ class LowEffortService( ...@@ -39,15 +41,12 @@ class LowEffortService(
private val centralTx: BluetoothGattCharacteristic private val centralTx: BluetoothGattCharacteristic
private val centralRx: BluetoothGattCharacteristic private val centralRx: BluetoothGattCharacteristic
private val centralTxCharacteristicUuid = UUID.fromString("42230101-2342-2342-2342-234223422342")
private val centralRxCharacteristicUuid = UUID.fromString("42230102-2342-2342-2342-234223422342")
private var notifyEnabled = false private var notifyEnabled = false
private var listener: OnPacketReceivedListener? = null private var listener: OnPacketReceivedListener? = null
init { init {
val tx = service.getCharacteristic(centralTxCharacteristicUuid) val tx = service.getCharacteristic(FILE_TX_UUID)
val rx = service.getCharacteristic(centralRxCharacteristicUuid) val rx = service.getCharacteristic(FILE_RX_UUID)
if (tx == null || rx == null) { if (tx == null || rx == null) {
throw IllegalStateException() throw IllegalStateException()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment