I am new to Android and just started working with Android 4.0.3. which enables USB Host connection. I'm trying to send some signal via USB to a camera, let's say it is supposed to be some characters that the camera has to receive and e.g. start recording. I wanted to do it via controlTransfer(), but I am unable to understand what each part of the logic of this method means. I've checked many fora, but everywhere I see it people keep refering to it as if it was obvious.
What is the request ID, value and index?
Or maybe there is some other approach to the problem that I don't know. I know for sure that you can send a signal via USB from Linux terminal to that camera and as android has a linux kernel so maybe the way to go would be to start a terminal and do it the Linux way?
Thanks for any tips :)
controlTransfer() intended to send commands via control endpoint (endpoint 0). Request ID, index and value and part of USB protocol. Please refer to http://www.beyondlogic.org/usbnutshell/usb6.shtml#SetupPacket for more information.
Do you has protocol description for your camera?
I suppose, you need to use other endpoint (as described in camera protocol) to send characters to a camera.
Related
I am developing a parental kind of App in which there is a requirement to block specific urls from all the browsers in the Device. I think this is an old question but couldn't find any solution yet on stack.
Do you have any working solutions. Assumption - The device is rooted.
Regards,
sha
I have two resources for you:
Since the device is rooted you can work directly with iptables. iptables will give you very precise control over all coming and going data packets. Check out open source projects like AFWall+ on GitHub for iptables in action.
If you want to be able to run your app on unrooted devices look into creating a fake VPN. You don't send any data to an actual VPN server, you simply use the VPN API to filter all the information coming and going. Check out Disconnect (whenever they actually share their open source code...) or OpenVPN which is what Disconnect builds on.
I am student and currently working on a project for my university. I am trying to write an app which is capable of reading date by using the TUSB3410(http://www.ti.com/product/tusb3410) and its USB to connect it with the C2500(http://www.ti.com/product/cc2500) connected via UART. Something like USB to serial.
I can get information off the TUSB3140 like its vendor id or its endpoint so I can use the normal USB API. But it is rather tricky to receive the information of the cc2500. I don't know which methods I should use or which parameter are correct. So maybe you have an idea how the methods like controlTransfer() etc. should look like.
I hope you can help me with this problem!
I'm afraid the answer isn't quite as simple as all that.
According to the linked datasheet and associated documentation, the TUSB3410 is not a fixed function device. It's basically a USB device on one side, a UART on the other side, and an MCU applications processor in the middle. In order for that chip to do anything useful, it has to have a firmware application loaded into it to govern how the data moves from one side to the other. So you get to define in the firmware how the data moves through the USB (interrupt transfers, bulk transfers, etc.) and that will govern how an Android application interacts with it.
Also, the chip does not seem to support having its firmware burned in, it always loads the firmware externally from I2C EEPROM or from the USB Host. If your device setup does not already have the EEPROM on it, you will likely have a difficult time because the Android USB APIs don't really give your application access to the device during the enumeration process, which is when the firmware would need to be sent if downloaded from the Host. It also would require you to detect your device twice (once with the standard bootcode VID/PID, and once again after the firmware file takes over and the device reconnects to the bus).
If you are just looking for a simple embedded implementation to get UART, SPI, etc. data into an Android application, you are probably better off with something like the FTDI FT311, which implements the Open Accessory protocol and comes with library code to get you started on both sides of the equation: http://www.ftdichip.com/Products/ICs/FT311D.html
EDIT: From your comment
So if your device conforms to the CDC USB Device Class, then there are basically three points of interest:
Every device has an "endpoint 0" for configuration, and this is accessed in the Android APIs using the controlTransfer() method. CDC devices use this endpoint for changing items like baud rate, stop bits, etc.
CDC Devices like a VCP have two interfaces, one for communications and one for data. The data interface (usually enumerated second) has two bulk endpoints (one in and one out) where the serial data is usually transferred. You can transfer the data back and forth on those endpoints with the bulkTransfer() method, or using an asynchronous UsbRequest.
As a starting point, perhaps take a look at the source of this open source project, which implements CDC basics using the host APIs. You should be able to get a good idea of how to roll your own driver from there (specifically the CdcAcmSerialDriver):
http://code.google.com/p/usb-serial-for-android/
I think apart from the FT311D which is using the AOA protocol, you may also consider to use FT231X, via FT231X, you can use the APK of android hyperterminal which you can easily find in google search/ google play. This is using by OTG method. You may also have a look.
I have a task to integrate a Bluetooth device into my application. Now my requirement is very specific. The device has a specific communication protocol which relies on certain ACKs but I figured it would make my development much easier if there was a program that let me test communication with the device.
I was wondering if there was a program for Linux, or perhaps a simple Android program which let me communicate with any Bluetooth device with a series of pings using data I enter and simply log the responses.
EDIT: I might not have been clear enough in my question.
I have a scale that I need to integrate into my application, and the scale has a protocol similar to this:
Get a specific byte string from device
Transfer data
Transfer packet for disconnection
Receive acknowledgement for disconnect packet
Disconnect
Now when I have to issue a POST request from my application, I usually build a test script online so I can test if the POST works properly.
I was wondering if there was something similar I could do with the device.
Thanks
Your question is not clear enough. To communicate with a BT device, you need to know what profile your device supports. Depending on that, you can find a way in Android or Linux or windows to communicate with the device.
The simplest way is to open an RFCOMM channel from android/PC and transfer data to and from the device. For this the device has to support the serial port profile (SPP). If you want to do this in Android, look for the BluetoothChat example from google.
If you want to use a PC/mac/linux look at the Bluez python module. It's really simple to use. There are plenty of other options too..
I was looking for something like SENA BTerm. It lets me connect to any device and send whatever data I wish.
It is an extremely useful tool for testing my code.
http://www.sena.com/download/manual_bterm/overview.html is where you can find it.
I'm trying to learn android and for my app i have few questions.
If i type a computer name on the EditText in my android phone, I
should be able to ping the device (So basically i need to first
resolve the ARP to get the mac address of the device which I want to
ping and then send the ping as an ICMP request).
I believe there is some command to retrieve the computer name and
send this ping command, but i would like to do it the hard way so
that i can learn stuffs better - It would be nice if you can show me
some pointers to some tutorial apps and open source code which does
similar tasks.
Once I have identified and connected to the device. I should be able
to start a chat with the device.
Assume the second device is also an android device, how can I
establish basic message sending from one android device to another.
Basically my app will be a client and server (I guess 2 services - service listening to sockets for incoming messages and client can send out messages).
Does anyone know any sample app / tutorials [basically code examples] which does this in android.
To Nr.1
I'm not quite sure why you first need to ping the device, as you could simply try to connect to the given device (using a timeout) and see if it can be connected.
I found some informations on this, here.
To Nr.2
So, if you want your Devices to communicate to each other, you'll want to use Sockets.
But, if your App is only for chatting and you don't need to know if the last send package was successfully send, you could also use UDP instead of TCP (So you don't need your application to run both the Server and the Client-Socket).
Although, all your questions could have been answered by doing a little googleing...
anyone know if its posible to make an application to simulate a touchscreen mouse or trackpad by bluetooth??
How can I make that the PC (or MAC) knows me as a mouse device?
Regards,
Juan
You should have a look at the Bluetooth HID specification. It may be possible, depending on the stack of the device that you are using to emulate a mouse/trackpad. I'm not familiar with the stack on Android (assuming that's the platform you're using from the tag on your question) so I don't know if it's possible from there.
Essentially, you create a HID service on the L2CAP protocol. The service record specifies the HID descriptors which describe the data being sent from emulating device. The HID driver on the host computer should be able to interpret that data.
It might be useful to try to connect to another Bluetooth mouse/trackpad from the desktop (Bluecove on a stack other than Microsoft is a good way to hack around in Bluetooth). Have a look at the service record for the HID service on the mouse/trackpad. Also, look at the data coming from the mouse/trackpad for an idea of what needs to be sent and when.
Alternatively, you could write a server application on your computer that communicates via another Bluetooth protocol (e.g., RFCOMM/SPP) to the input-device emulator app running on your phone. The server application would simulate the input device (e.g., move the mouse pointer around on the screen, etc).
Instead of creating your own project why dont you contribute to the remotedroid project?
I'm assuming you know your bluetooth api's well. Remote droid uses Wifi and OSC messaging to communicate with the PC.
Yes you may use GlovePie with the wiimote connected to BlueSoeil, It will alow you to do anything with you computer with the wiimote. It also has a Language it uses
I think you want this:
Serverless Bluetooth Keyboard & Mouse for PC/Phone
It's even open-source!
Unfortunately it is not open source, it just has a GitHub readme for some reason.
But still the app is quite good!