I'm having trouble understanding how to communicate my android app to communicate with a custom board via serial connection. The android software supports USB host mode.
My android 3.1+ tablet as USB host <-----packet of bytes-----> custom board at 9600 baud rate
Here's what I understand about setting up my app:
Using USB manager I find my USB device (custom board)
After finding my USB device I set up a USBInterface to communicate.
Using the USBInterface I need to find the USBEndpoint(can someone tell me what that is?)
I can now use USBDeviceConnection to send and recieve information.
Any help to understand the process helps. Thanks
Think of endpoints as virtual conduits with defined behaviors, similar to sockets.
Endpoints for USB CDC devices consist of a control endpoint, a bulk IN, a bulk OUT, and an "interrupt" endpoint. The control endpoint is bi-directional and is used for configuring the connection. Once the connection is configured, the BULK IN is where the tablet will receive data (think RX) and BULK OUT will be where the tablet sends data (think TX). The interrupt endpoint is IN-ONLY and will notify the tablet of any state changes from the device.
The endpoint locations and functionality are specified by the device in its USB Interface Descriptor. The Host protocol stack will retrieve that descriptor and have it available for the application layer to use.
You will use the control endpoint to configure items such as baud rate, parity, stop bits, etc.
Related
To support this features , are there any changes require in hardware or firmware?
Wifi easy connect (DPP-Device Provisioning Protocol) and Enhanced Open (OWE) need wifi vendor's support. It might not be implemented in wifi HW, but in the wifi driver with/without FW patch, depends on wifi vendor design.
Most relative functions are implemented in wpa_supplicant, which is the application in user space. And the wifi driver needs to report the data, received from AP to wpa_supplicant, and transmit the correct data generated from wpa_supplicant to AP, by using kernel cfg80211 functions.
wifi easy connect
need to handle public action frame
OWE (Opportunistic Wireless Encryption OWE)
PMK is generated by association handshaking.
so the wifi driver needs to use e.g. cfg80211_connect_result() to report association response ie to the wpa_supplicant
I have a MR400s taximeter hardware. I want to communicate with this taximeter using RS232 cable and I have already achieved this connection and communication in windows. But I wanted to make connection using android device.
How can I achieve this?
Thanks
Ishan jain
I use the USB to serial library, you can find it here: USB Serial for Android.
It doesn't require any root access. You'll need to check if your Android device supports USB host mode. Then, using a usb OTG cable and a USB to serial adapter cable you can start communicating with your serial device via RS232. There are code examples to get you started on the Github page of the USB to Serial library.
An alternative to a cable connection to the Android device (using the "USB Serial for Android" library, see the other answer) is a converter from RS232 to Bluetooth.
Such a converter will use the serial connection profile of Bluetooth, and ways access such a connection in Android are discussed in this question.
You can build such a converter based on an Arduino by adding a Bluetooth shield and simple code that converts incoming data from the serial port to outgoing data on the Bluetooth connection. (I could not find detailed instructions for this right now.) When you want to connect the Arduino's serial port to a RS232 device you would need another shield for logic level conversion (RS232 is ±12 V, Arduino is 5 V or 3.3 V).
There is also a commercial product implementing this Photologic Text Streamer (ca. 265 USD !!!). It seems that this provides a read-only connection for Android (not totally sure about that, though). A read-only connection is still ok for cases where you only want to read sensor values.
Finally, you could do a similar thing using an Arduino and a wifi shield.
Using Arduino I can get the sensor values logged into the serial monitor over the USB cable...
Is there any way that I can read these values directly on an android tablet by connecting a usb convertor(So that I can tramnsmitt it via GPRS to a server Db)...Please give my some solid directions...
You can do it wired if you use a FT232 or CP2102 converter. Here are a couple apps on the Google Play store that act as a serial monitor.
USB Serial Terminal
Slick USB Serial Terminal
One thing to note is that wired USB communication with Android is not very common, so you may run into some problems depending on the phone you are using. If you want a more guaranteed solution, look into an Arduino Bluetooth module that supports SPP - Serial Port Profile. You can connect the Arduino's RX/TX pins to the Bluetooth module, and have it communicate with the Android device over a wireless Bluetooth serial connection.
Also, here is a similar question on SO, however the answer may have outdated information regarding using the wired solution.
How to make Android and Arduino communicate without a wireless module
I am doing my final year project and am facing a problem to send data through a mobile device (android) to a AUBTM-23 bluetooth module, which has a RS232 port something similar to this one, which is conected to a 8051 controller serially.
When I try connecting the module to PC and send data from mobile, the data is properly read in hyperterminal with following information:
OK
+CON1:1
data received from mobile device
+DCON:1
OK
+CON1:1-->received when mobile app tries connection with module.
Then the serial data gets transferred, then when the app disconnects I get DCON.
But when I use it with 8051, there is no data transfer.
I searched and found that module is programmed to send these tags(CON, DCON, OK) and also it is designed to be embedded in a host system (which i think 8051 is not) which requires cable replacement function.
SO, is it possible to connect the module to 8051 controller?
does a serial port really requires a host?
Can I make any arrangement for the extra tags (CON, DCON, OK)?
And to connect rs232 port serially, i am making use of only 3 pins and leaving the remaining 6 pins unconnected, could that be a problem?
You can use 8051, UART , just write code for sending AT commands check those on hyperterminal whether they woring or not .. then connect TX RX of 8051 to RX Tx of ur module. Be careful to add a voltage divider with 10kand 15k resistors between Rx line of Module,as it should receive only 3.3 v and max232 will output 5v.
It will work...
8051 can be used as a host for the AUBTM-23
There are several conditions that could be causing problems and additional information is necessary to correctly diagnose and troubleshoot them. That being said, the following information might be of some assistance.
You might need a MAX232 (or other TTL to RS232 level converter) between the 8051 UART pins and the RS232 port on the AUBTM-23 device. Otherwise, you may† be able to bypass the RS232 port and connect the appropriate 8051 UART pins directly to the UART pins on the AUBTM-23 chip. † note that this option depends on the voltages used by both chips and additional circuitry (e.g. level shifter) may be required
The AUBTM-23 datasheet says that flow control can be either RTS/CTS or None and is configured during factory calibration. When you connected the AUBTM-23 to HyperTerminal, what type of flow control was used?
If your AUBTM-23 device uses RTS/CTS (hardware) flow control, you should connect the the RTS and CTS lines to available port pins on the 8051 and add the appropriate code to handle the handshaking.
If your AUBTM-23 device does not use flow control, you should be able to use a minimal 3-wire (TX, RX, GND) RS232 connection.
I need to use Bluetooth for communication with another application which sends data via bluetooth SPP profile. I use the Bluetooth Chat app from Android developer site. I am using real phone (HTC Desire) as there is no Bluetooth API in Android emulator. I use a BlueSoleil bluetooth dongle.
When the other application tries to connect to my phone via Bluetooth and send data via SPP, it is not possible to connect the phone to the application. So I tried Windows Hyperterminal to send data and connect the phone through the dongle. In this situation, I can receive the data and display on the phone.
I would like to know how to find out which bluetooth profile was used when communicating with Hyperterminal.
I have read that bluetooth stack has a buggy implementation in HTC Desire and the SPP profile doesn't work consistently always.
Appreciate any suggestion and time spent on this.
Cheers,
Madhu Nandan
In the case of your Hyperterminal communication - SPP profile that was most likely used.
SPP profile is a generic profile that just establishes the RFCOMM data channel and sets up a virual COM port for applications to open and connect to and send data.
SPP does not specify any data formats or application level communication protocol to be used by application.
So applications at both end should establish the required format/protocol for communication.
Applications sets it selfs up on a virtual COM (over SPP) and advertises itself (on SDP) via a unique UUID (And Service Names)
So I would suggest that you use the chat application as a starting point, and start with connection / reading data etc, then modify it and complete the application that talks to your application on the device.
(The chat example is meant to work with a remote chat of the same type and is not a generic usage for SPP profile application)
Hope this helps you.