aboutsummaryrefslogtreecommitdiff
path: root/extras/android/RemoteHCI/app/src/main/java/com/github/google/bumble/remotehci/CommandLineInterface.kt
diff options
context:
space:
mode:
Diffstat (limited to 'extras/android/RemoteHCI/app/src/main/java/com/github/google/bumble/remotehci/CommandLineInterface.kt')
-rw-r--r--extras/android/RemoteHCI/app/src/main/java/com/github/google/bumble/remotehci/CommandLineInterface.kt57
1 files changed, 57 insertions, 0 deletions
diff --git a/extras/android/RemoteHCI/app/src/main/java/com/github/google/bumble/remotehci/CommandLineInterface.kt b/extras/android/RemoteHCI/app/src/main/java/com/github/google/bumble/remotehci/CommandLineInterface.kt
new file mode 100644
index 0000000..2f1b59e
--- /dev/null
+++ b/extras/android/RemoteHCI/app/src/main/java/com/github/google/bumble/remotehci/CommandLineInterface.kt
@@ -0,0 +1,57 @@
+package com.github.google.bumble.remotehci
+
+import java.io.IOException
+
+class CommandLineInterface {
+ companion object {
+ fun printUsage() {
+ System.out.println("usage: <launch-command> [-h|--help] [<tcp-port>]")
+ }
+
+ @JvmStatic fun main(args: Array<String>) {
+ System.out.println("Starting proxy")
+
+ var tcpPort = DEFAULT_TCP_PORT
+ if (args.isNotEmpty()) {
+ if (args[0] == "-h" || args[0] == "--help") {
+ printUsage()
+ return
+ }
+ try {
+ tcpPort = args[0].toInt()
+ } catch (error: NumberFormatException) {
+ System.out.println("ERROR: invalid TCP port argument")
+ printUsage()
+ 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}")
+ }
+ }
+ }
+} \ No newline at end of file