mirror of
https://github.com/M4TH1EU/DJI-FCC-HACK.git
synced 2025-07-03 02:03:49 +00:00
filter usb devices
This commit is contained in:
parent
65d8cacd50
commit
3513b5ab0b
@ -97,8 +97,16 @@ class MainActivity : ComponentActivity() {
|
|||||||
private fun refreshUsbConnection() {
|
private fun refreshUsbConnection() {
|
||||||
if (usbManager.deviceList.isNotEmpty()) {
|
if (usbManager.deviceList.isNotEmpty()) {
|
||||||
val device: UsbDevice = usbManager.deviceList.values.first()
|
val device: UsbDevice = usbManager.deviceList.values.first()
|
||||||
|
|
||||||
|
// Check to be sure the device is the initialized DJI Remote (and not another USB device)
|
||||||
|
if (device.productId != 4128) {
|
||||||
|
Log.d("USB_CONNECTION", "Device not supported ${device.productId}")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
usbConnection = usbManager.openDevice(device)
|
usbConnection = usbManager.openDevice(device)
|
||||||
|
|
||||||
|
|
||||||
if (usbConnection == null) {
|
if (usbConnection == null) {
|
||||||
Log.d("USB_CONNECTION", "Requesting USB Permission")
|
Log.d("USB_CONNECTION", "Requesting USB Permission")
|
||||||
requestUsbPermission(device)
|
requestUsbPermission(device)
|
||||||
@ -143,7 +151,6 @@ class MainActivity : ComponentActivity() {
|
|||||||
-127, 31
|
-127, 31
|
||||||
), 1000
|
), 1000
|
||||||
)
|
)
|
||||||
usbSerialPort.close()
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("USB_PATCH", "Error sending patch: ${e.message}")
|
Log.e("USB_PATCH", "Error sending patch: ${e.message}")
|
||||||
Toast.makeText(this, "Patch failed: ${e.message}", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, "Patch failed: ${e.message}", Toast.LENGTH_SHORT).show()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user