Skip to content

Commit

Permalink
fix code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrekir committed Oct 23, 2023
1 parent f98fa75 commit f8ae27f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
7 changes: 5 additions & 2 deletions app/src/main/java/com/geeksville/mesh/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.geeksville.mesh.model.primaryChannel
import com.geeksville.mesh.model.toChannelSet
import com.geeksville.mesh.repository.radio.BluetoothInterface
import com.geeksville.mesh.repository.radio.InterfaceId
import com.geeksville.mesh.repository.radio.RadioInterfaceService
import com.geeksville.mesh.service.*
import com.geeksville.mesh.ui.*
import com.geeksville.mesh.ui.map.MapFragment
Expand Down Expand Up @@ -121,6 +122,9 @@ class MainActivity : AppCompatActivity(), Logging {
@Inject
internal lateinit var serviceRepository: ServiceRepository

@Inject
internal lateinit var radioInterfaceService: RadioInterfaceService

private val bluetoothPermissionsLauncher =
registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { result ->
if (result.entries.all { it.value }) {
Expand Down Expand Up @@ -464,8 +468,7 @@ class MainActivity : AppCompatActivity(), Logging {
debug("Switching to USB radio ${usb.deviceName}")
val address = radioInterfaceService.toInterfaceAddress(InterfaceId.SERIAL, usb.deviceName)
service.setDeviceAddress(address)
usbDevice =
null // Only switch once - thereafter it should be stored in settings
usbDevice = null // Only switch once - thereafter it should be stored in settings
}

val connectionState =
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/com/geeksville/mesh/model/BTScanModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ class BTScanModel @Inject constructor(
val isTCP: Boolean get() = prefix == 't'
}

@SuppressLint("MissingPermission")
class BLEDeviceListEntry(device: BluetoothDevice) : DeviceListEntry(
device.name ?: "unnamed-${device.address}", // some devices might not have a name
"x${device.address}",
device.bondState == BluetoothDevice.BOND_BONDED
)

class USBDeviceListEntry(
radioInterfaceService: RadioInterfaceService,
usbManager: UsbManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ class BluetoothInterface @AssistedInject constructor(
context: Application,
bluetoothAdapter: dagger.Lazy<BluetoothAdapter?>,
private val service: RadioInterfaceService,
@Assisted val address: String) : IRadioInterface,
Logging {
@Assisted val address: String,
) : IRadioInterface, Logging {

companion object : Logging {
companion object {
/// this service UUID is publicly visible for scanning
val BTM_SERVICE_UUID: UUID = UUID.fromString("6ba1b218-15a8-461f-9fa8-5dcae273eafd")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SerialInterface @AssistedInject constructor(
service: RadioInterfaceService,
private val serialInterfaceSpec: SerialInterfaceSpec,
private val usbRepository: UsbRepository,
@Assisted private val address: String
@Assisted private val address: String,
) : StreamInterface(service), Logging {
private var connRef = AtomicReference<SerialConnection?>()

Expand Down
3 changes: 0 additions & 3 deletions app/src/main/java/com/geeksville/mesh/ui/SettingsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
private val bluetoothViewModel: BluetoothViewModel by activityViewModels()
private val model: UIViewModel by activityViewModels()

@Inject
internal lateinit var usbRepository: UsbRepository

@Inject
internal lateinit var radioInterfaceServiceLazy: dagger.Lazy<RadioInterfaceService>

Expand Down

0 comments on commit f8ae27f

Please sign in to comment.