[Solved]Communication with Android via UsbHost

[italic]It works now-> scroll down :wink: [/italic]

Is it possible to communicate with Android devices via the UsbHost - Module. I looked up the UsbHost class but it I only found methods for communication with keyboards, mice or usb-drives :frowning:

Check out USB raw device

http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation/Index.html

Check this thread

http://www.tinyclr.com/forum/15/3459/

Unfortunately I’m always getting this error "The type or namespace USBH_RawDevice could not be found …"
What is wrong here? The version of my UsbHost refernce is 4.1.1.0, how can I update it to 4.1.8.0?

Start with http://www.ghielectronics.com/downloads/FEZ/Beginners%20guide%20to%20NETMF.pdf

Ok, my Galaxy S appearantly doesn’t support accessory mode, although it’s android version 2.3.7 with cyanogenmod 7.1.
So I have to use the adb-method. I took this project Google Code Archive - Long-term storage for Google Code Project Hosting. and modified the code for my gadgetgeer and installed the servocontrol app on my galaxy s.
However it doesn’t work ???
I am getting many Null-Pointer-Exceptions…

[Device, Port 0]
Interface: 0
ID: 2700052200
Type: 6
VID: 6353
PID: 20002
  === Interface ===
  Class: 255
  SubClass: 66
  Number: 1
  Protocol: 1
  Type: 4
   -- Endpoint --
    Attributes: 2
    Address: 136
    Type: 5
    Interval: 0
 
   -- Endpoint --
    Attributes: 2
    Address: 7
    Type: 5
    Interval: 0
 
Out >> 1314410051,16777216,4096
    #### Exception System.NullReferenceException - CLR_E_NULL_REFERENCE (3) ####
    #### Message: 
    #### FezAdbBridge.Program::SendAdbMessage [IP: 00b1] ####
    #### FezAdbBridge.Program::SendAdbMessage [IP: 000b] ####
    #### FezAdbBridge.Program::DeviceConnectedEvent [IP: 0277] ####
    #### GHIElectronics.NETMF.USBHost.USBH_DeviceConnectionEventHandler::Invoke [IP: 0000] ####
    #### GHIElectronics.NETMF.USBHost.USBHostController::nativeEventDispatcher_OnInterrupt [IP: 0037] ####
    #### GHIElectronics.NETMF.System.InternalEvent::nativeEventDispatcher_OnInterrupt [IP: 0054] ####

I attached the Solution, if you want to test it yourself: File-Upload.net - Datei nicht gefunden

Thanks for help :slight_smile:

Ok, I fixed this. So now receiving messages from the android phone is working :slight_smile:
However sending commands does not. Can somebody help me with the adb protocol? I have to send messages like that:

public static void SendAdbMessage(UInt32 st, UInt32 arg0, UInt32 arg1, string str)

...

SendAdbMessage(A_WRTE, 0, 1, "test");

Can anyone help me out?

Finally I made it ::slight_smile:

Awesome! All is left is to put a tutorial on Wiki or do a blog post! :wink:

Very cool! Please do document the process.

Has anyone established communication with an Android via the Bluetooth module yet?

I would be interested in the bluetooth method also…

Bluetooth is even simpler since you send/receive your commands via a serial port (if you use a bluetooth SPP module).

I understand. But, has anyone actually done it with the new Bluetooth module and tested this out?

I am very interested as well in knowing how hard it will be to communicate with an Android device using the Bluetooth module…

@ Hank - As others have pointed out, the bluetooth module uses SPP. Serial communication is easy and has not changed much in the last 20 years. Writing an app that sends serial data over BT on a FEZ is easy. You can download any number of apps for your Android that read/write serial data via BT.

So… it is not hard to “communicate with an Android device”. The question is what to do with the data when you get it.

Concerning the Usb-Communication there is not that much to documentate, because I just modified robofreak’s code for my hardware: so have a look at Google Code Archive - Long-term storage for Google Code Project Hosting.

Can you upload your solution somewhere, this link is broken File-Upload.net - Datei nicht gefunden.
Tnx