Forum Xamarin.Android

USB communication, Android phone with special hardware (with phone modul and usb/bluetooth)

Hello I need information if the current version of xamarin.Android contains the implementation USB communication with other devices. I found it no examples or documentation (the documentation is solved USB for debugging, but it is not my case).

Currently I Commissioning communication with the target device via bluetooth (BluetoothAdapter, BroadcastReceiver, get bluetooth device form intent.GetParcelableExtra (BluetoothDevice.ExtraDevice) etc.).

I guess that the USB communication should be like bluetooth.

I found some info regarding UsbManager, UsbDevice, UsbAccessory, but it works differently and I'm not able to make it work.

Thank you for more info


Best Answer


  • MichalFrantaMichalFranta CZMember ✭✭

    Hi, i find that the problem was in Android version on my Phone. If i test tablet and other phone with android version 4.4.2 than it find usb device correctly.
    In doccumentation writes that it shall works on 3.1 and newer but MyPhone has 4.1.1 and does not work well. I will use newer version android and it will be OK.

    This question is answered and can be closed.

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    @JamieHouston I have to send some characters to the Device discovered... I can I do? Do I have to use UsbEndpoint?

  • YassineMAMAYassineMAMA Member ✭✭

    im working in android xamarin project , and i want send a string data ("WR11100_r") to serial port, so currently i can find my dvice and i can open it but i cant't send data i think i must set control Trasnfer before sending data, the config of my dvice is :
    Baud rate 9600 bits per second
    Data bits 8
    Stop bit 1
    Parity None
    Flow control No
    so i tried this code, but its dosent work :
    string cmd = "WR11100/n";
    byte[] buff = System.Text.Encoding.ASCII.GetBytes(cmd);

                        deviceConnection.ControlTransfer(0, 0, 0, 0, null, 0, 0);// reset
                        deviceConnection.ControlTransfer(0, 2, 0, 0, null, 0, 0);// flow  control none   
                        deviceConnection.ControlTransfer(UsbAddressing.Out, 3, 16696, 0, null, 0, 0);
                        deviceConnection.ControlTransfer(0, 4, 8, 0, null, 0, 0);
                        deviceConnection.BulkTransfer(usbEndpoint, buff, 0, 8, 0);

    when the bulkTransfer instrucion is exectued the buff[0] = 0 and the buff[1] = 96 so i think there is a probleme in my config can you help me plz such you was working working on a project that uses the Android device as a USB Host to connect to a separate USB device

  • delfinomoralesdelfinomorales Member ✭✭
    edited March 27

    @YessineMAMA, crees que me puedas apoyar, yo necesito enviar datos de mi telefono a la pc por el puerto serial, he buscado informacion pero no logro entender como hacer esto.

    Te agradeceria mucho cualquier ayuda.


    Nota: Disculpa que no escriva en ingles, no domino el idioma.

Sign In or Register to comment.