add CLI support

This commit is contained in:
Gilles Boccon-Gibod
2023-12-03 16:35:14 -08:00
parent 247cb89332
commit 8385035400
2 changed files with 49 additions and 1 deletions

View File

@@ -0,0 +1,48 @@
package com.github.google.bumble.remotehci
import java.io.IOException
class CommandLineInterface {
companion object {
@JvmStatic fun main(args: Array<String>) {
System.out.println("Starting proxy")
var tcpPort = DEFAULT_TCP_PORT
if (args.size >= 1) {
try {
tcpPort = args[0].toInt()
} catch (error: NumberFormatException) {
System.out.println("ERROR: invalid TCP port argument")
return
}
}
try {
val hciProxy = HciProxy(tcpPort, object : HciProxy.Listener {
override fun onHostConnectionState(connected: Boolean) {
}
override fun onHciPacketCountChange(
commandPacketsReceived: Int,
aclPacketsReceived: Int,
scoPacketsReceived: Int,
eventPacketsSent: Int,
aclPacketsSent: Int,
scoPacketsSent: Int
) {
}
override fun onMessage(message: String?) {
System.out.println(message)
}
})
hciProxy.run()
} catch (error: IOException) {
System.err.println("Exception while running HCI Server: $error")
} catch (error: HciProxy.HalException) {
System.err.println("HAL exception: ${error.message}")
}
}
}
}

View File

@@ -1,5 +1,5 @@
[versions]
agp = "8.3.0-alpha11"
agp = "8.3.0-alpha16"
kotlin = "1.8.10"
core-ktx = "1.9.0"
junit = "4.13.2"