Updated version number for test installation
This commit is contained in:
@@ -54,46 +54,47 @@ class TestModelActivity : AppCompatActivity(), RecognitionListener {
|
||||
toggleListening()
|
||||
}
|
||||
|
||||
private fun connectToPico() {
|
||||
val usbManager = getSystemService(Context.USB_SERVICE) as UsbManager
|
||||
|
||||
// 1. Find the Device
|
||||
// (This probes specifically for devices listed in your device_filter.xml)
|
||||
val availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(usbManager)
|
||||
if (availableDrivers.isEmpty()) {
|
||||
outputText.append("\n> No USB device found.")
|
||||
return
|
||||
}
|
||||
|
||||
// Assume the first device found is the Pico
|
||||
val driver = availableDrivers[0]
|
||||
val connection = usbManager.openDevice(driver.device)
|
||||
|
||||
if (connection == null) {
|
||||
outputText.append("\n> Permission denied. Re-plug device?")
|
||||
return
|
||||
}
|
||||
|
||||
// 2. Open the Port
|
||||
// Most Picos use port 0.
|
||||
usbPort = driver.ports[0]
|
||||
|
||||
try {
|
||||
usbPort?.open(connection)
|
||||
// 3. Set Parameters (Must match your Pico's C/Python code!)
|
||||
// 115200 Baud, 8 Data bits, 1 Stop bit, No Parity
|
||||
usbPort?.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
||||
|
||||
outputText.append("\n> USB Connected to Pico!")
|
||||
} catch (e: Exception) {
|
||||
outputText.append("\n> USB Error: ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the model in background
|
||||
initModel()
|
||||
}
|
||||
|
||||
private fun connectToPico() {
|
||||
val usbManager = getSystemService(Context.USB_SERVICE) as UsbManager
|
||||
|
||||
// 1. Find the Device
|
||||
// (This probes specifically for devices listed in your device_filter.xml)
|
||||
val availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(usbManager)
|
||||
if (availableDrivers.isEmpty()) {
|
||||
outputText.append("\n> No USB device found.")
|
||||
return
|
||||
}
|
||||
|
||||
// Assume the first device found is the Pico
|
||||
val driver = availableDrivers[0]
|
||||
val connection = usbManager.openDevice(driver.device)
|
||||
|
||||
if (connection == null) {
|
||||
outputText.append("\n> Permission denied. Re-plug device?")
|
||||
return
|
||||
}
|
||||
|
||||
// 2. Open the Port
|
||||
// Most Picos use port 0.
|
||||
usbPort = driver.ports[0]
|
||||
|
||||
try {
|
||||
usbPort?.open(connection)
|
||||
// 3. Set Parameters (Must match your Pico's C/Python code!)
|
||||
// 115200 Baud, 8 Data bits, 1 Stop bit, No Parity
|
||||
usbPort?.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
||||
|
||||
outputText.append("\n> USB Connected to Pico!")
|
||||
} catch (e: Exception) {
|
||||
outputText.append("\n> USB Error: ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun initModel() {
|
||||
// We look for the folder inside private storage (same logic as MainActivity)
|
||||
val modelPath = File(filesDir, "vosk-model")
|
||||
|
||||
Reference in New Issue
Block a user