Home/Support/Support Forum/Transmit XBee API frame written to android USB OTG port

Transmit XBee API frame written to android USB OTG port

0 votes
I'm using UsbSerial: A serial port driver library for Android v3.0 by Felipe Rabanal as in A dirty and quick example of serial port communication in Android felhr85.

My goal is to write an Xbee API frame to the android USB OTG port where a Coordinator API XBee Series 2 connected via a Sparkfun USB Xbee dongle should transmit it to another Router API Xbee. (The same Coordinator+dongle has no problem receiving on the OTG port and also properly transmits if used on a Windows PC port)

So, I modified the dirty and quick code:

public static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i + 1), 16));
return data;

Button sendButton = (Button) findViewById(R.id.buttonSend);
sendButton.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
if (usbService != null) { // if UsbService was correctly bound, Send data

//The interpretation of the API packet:
//Transmit Request (API 1)

//7E 00 10 10 01 00 13 A2 00 40 FC 87 60 FF FE 00 00 48 69 68

//Start delimiter: 7E
//Length: 00 10 (16)
//Frame type: 10 (Transmit Request)
//Frame ID: 01 (1)
//64-bit dest. address: 00 13 A2 00 40 FC 87 60
//16-bit dest. address: FF FE
//Broadcast radius: 00 (0)
//Options: 00
//RF data: 48 69
//Checksum: 68

Clicking the send button nothing transmits...

Maybe I'm not writing the frame to the android USB port properly? Should I buy a hardware USB analyzer? Any other mistakes in my code, API packet, hardware assumptions, or conceivably XBee configuration?

Please advise. Thanks!
asked Aug 16, 2016 in RF Solutions and XBee by digitalsubtraction New to the Community (0 points)

Please log in or register to answer this question.

1 Answer

0 votes
Looks like you are sending ASCII data when you want to send Hex. But then again I don't know the android so I can't comment on your code.
answered Aug 18, 2016 by mvut Veteran of the Digi Community (15,156 points)