Android (Studio) + Dragino LA66 USB

3 days ago 7
ARTICLE AD BOX

I am working on an Android app to control a drone. I am using the Dragino LA66 USB LoRa device for comm. Unfortunately, I am having difficulty with getting a signal transmitted to my Arduino board.

The Arduino board is connected to the Arduino IDE to present information received over LoRa.

I originally created Android Studio code (Java) based on a serial com port. I have the app recognizing that the USB device is connected, but when I'm sending data (or trying), nothing shows up on the Arduino. Here is the code for my serial port comm:

public static void sendComm(String msg) { byte[] msgBuff = msg.getBytes(); int msgLen = msgBuff.length; if (serialPort != null) { try { serialPort.write(msgBuff, msgLen); } catch (IOException e) { e.printStackTrace(); } } }

Next, I tried working with the code from the example app from Dragino, but that seems to be primarily logging information, and, again, no communication is seen.

When setting up my USB connection, I use:

for (UsbDevice device : deviceList.values()) { PendingIntent permissionIntent = PendingIntent.getBroadcast(this, 0, new Intent("com.aidan.dronecontroller.USB_PERMISSION"), PendingIntent.FLAG_IMMUTABLE); if (device.getVendorId() == 4292 && device.getProductId() == 60000) { usbManager.requestPermission(device, permissionIntent); if (usbManager.hasPermission(device)) { GlobalState.getInstance().setUSBConnected(true); } } la66 = device; }

The above is run immediately upon onCreate() in the app. For opening the actual serial port, I use:

private void openSerialPort(UsbDevice device) { UsbDeviceConnection connection = usbManager.openDevice(device); UsbSerialDriver driver = UsbSerialProber.getDefaultProber().probeDevice(device); if (driver == null) { // Try a more aggressive probe driver = UsbSerialProber.getDefaultProber().probeDevice(device); } if (driver != null) { UsbSerialPort port = driver.getPorts().get(0); try { port.open(connection); port.setParameters( 9600, // baud rate 8, // data bits UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE ); serialPort = port; } catch (IOException e) { e.printStackTrace(); } } la66Msg = "AT+FRE="+freq+","+freq; sendComm(la66Msg); la66Msg = "AT+BW="+bw+","+bw; sendComm(la66Msg); la66Msg = "AT+SF="+sf+","+sf; sendComm(la66Msg); la66Msg = "AT+CR="+cr+","+cr; sendComm(la66Msg); }

The la66Msg is coded using the AT+ codes that the USB transceiver uses. These codes come from the general user information for the Dragino, and I'm assuming they are part of the chipset connecting the USB to the LoRa radio chip. These commands are sent using the sendComm function, or that is the goal.

I am unfamiliar, in general, with interfacing hardware+software, so this is proving to be something I am struggling with - Any insights into what I'm doing wrong? Any insights into a better/proper way to code this up?

Thanks.

Read Entire Article