I want to create a project where a mobile Android device is connecting via BLE to a USB dongle inserted in a normal PC (Windows and Linux).
For Android I see good support in the API to establish this connection.
It's not clear for me how to read the data sent from Android on the PC (from a C/Java/Anything program).
At the first look there is no easy way to start a "server" on the PC to listen for BLE connections.
Can you point me in the right direction?
For BLE, you'll need to decide which side is the peripheral and which is the master.
On the PC side, I know of the good old bluez library (http://www.bluez.org), written in C and readily available on Linux. For windows, I suspect that there are similar toolkits.
bluez-tools can help you run test at the command line: https://unix.stackexchange.com/questions/96693/connect-to-a-bluetooth-device-via-terminal
Related
Let's say I connect my Android phone to Windows PC using USB Type C. Is it possible to access TCP/IP services in the PC from my Android phone ? For example, connect to SQL Database in my Windows PC.
Thanks!
EDIT:
Why the downvote? I know this is obviously not the normal way. Therefore, I am asking for possibility.
Require a method of connecting an android app with a C++ program on PC via USB, which would allow the android app to send a constant stream of real time data (mostly integer values) to a c++ program on PC via USB and carry out actions accordingly. I know it is easier to do this by wifi or bluetooth, but I want to carry out the connection using USB.
I have searched the net alot for similar questions, and tried many code, but non of them have worked for me. I would greatly appreciate an example code for the c++ portion, and it's android counterpart that allow for this to be done easily.
You could use the USB Tethering option on the phone. This should work with Android 4.4 and the most popular Linux Distributions out of the box. Then you are able use TCP/IP between Android and the PC. You could use an UDP multicast based protocol for service discovery (e.g. Multicast DNS, NSD or SSDP) if you need to avoid entering IP addresses on one side.
One way of doing this is to setup your pc application to talk to the android device as an android accessory. http://developer.android.com/guide/topics/connectivity/usb/accessory.html
This will allow both applications to send whatever data they want over usb, Google do provide source code for doing this with the accessory development kit http://developer.android.com/tools/adk/index.html
I don't have any example source code but there might be some out there if you search.
You can use ADB and call custom commands on your Android device. This commands should just type integers to stdout. As an option, you can use standard shell commands like cat and make your Android app write output integers to files in some directory where ADB can read it.
You can have Android behave like a USB device with a USB CDC (ACM) interface, which is seen as a serial port on the PC (COMx on Windows, /dev/ttyXXX on Linux). On C++ (PC) side, this would be "regular" serial port handling, while on Android there are several libraries for such purposes, though I never used one so I can't recommend any.
I need some guidance..
I have an application (.net) on my PC (windows) that needs to send some data or file (JSON format) through USB to android tablet (4.4.2). I want to design a new app which could accept this data.
I did some research over internet and found some options to implement this but still all of it is not so clear for me:
My first option to do this is – port forwarding by adb shell. My PC need to have adb installed and some drivers. Is it right? Is it possible that .net exe will use this way on pc side?
Second option – my PC should be "USB host" and android tablet should be "USB accessory". Is it better way? And again, is it possible that .net application will implement it?
Last option is use WPD api.. https://github.com/geersch/WPD/blob/master/src/part-3/README.md
Which one is better?
I'll be glad to hear some clarifications on this subject or any recommendations or if there is some other way to do this.
Thanks a lot
I have to communicate from tablet to PC using USB. I have studied about using TCP and abd but i have to do with the Serial port. I am even not sure is that possible or not. So please guide me through what is the way to achieve this. Any help is appreciated.
You can use a USB to UART bridge device to do this, but the caveat is that your tablet device will need a driver to do so. Your tag shows you are using Android, which is based on the Linux kernel. Linux already supports plenty of USB to UART bridge devices natively, so once you choose one you can go through the steps of building in the driver to your Android image and probably perform a make menuconfig and add in support for your driver that way.
Communication to the PC on the other side of the bridge can be through a standard RS232 serial port (if available), or you can use USB to UART bridge on the other side as well.
I've started a project on Andorid, but I don't know NDK very much. I want to send custom data as per receiving message on usb port. I saw some applications that can send/recieve custom data on usb port if the phone is in recovery. I've programmed usb connection in windows before. But I haven't any clue where should I start in android. Is there any documentation for usb programming for android? If NDK isn't suitable to implement this, which options do I have? It is not important if the application is device specific.
The issues are more of system architecture and permission, an area where the NDK offers little in excess of the SDK.
Android does not really support (direct) custom use of the USB port, at least when the device is connected to a computer (there are some recent options when the device is hosting a USB peripheral). What is possible in recovery mode is essentially irrelevant, unless you want to make substantial modifications to the installation of Android running on your device.
Generally, the only practical way to do application-level communication between the device and a hosting PC is to use the IP networking paradigm over the USB cable. You do this either by enabling USB debugging on the device and installing much of the android SDK on the PC, or by enabling some forms of tethering which may create a general network as a side effect.
For the SDK method, read up on adb port forwards, including the limitation that the PC side must initiate the connection.
It may also be possible to create custom drivers which get a PC to pretend to be an android accessory kit (ADK) circuit and use the apis related to that.
Unfortunately, pretty much all of these ideas are more suitable for developers/power users, than for general consumer application. For consumer apps, most developers ignore the USB cable and do IP networking over WIFI, requiring the user to put the device and the PC on the same network, or proxy through an Internet server visible to both the PC and the device's mobile network.