I have seen several questions about this topic but none are answered, complete, or actually have answers "to the question asked".
I have a phone which has bluetooth tethering turned on and a tablet which is paired with the phone. Problem is that to get the connections started I must open the bluetooth menu on the tablet and click on the phone's name to actually connect. I would like to have my custom app which runs on the tablet emulate this button click programmatically.
Many online suggestions require creating a socket; however, I do not want to transfer my own data. I only want to "connect" to the device using whatever the default android interface is. (Unknown to me)
I suspect there must be some kind of intent that can be sent to trigger this connection but can't find it.
Currently android has not exposed the classes inorder to connect to Bluetooth PAN profile. Only HEADSET, HANDSFREE and A2DP classes are exposed to interact with them. However, you can dig into the bluetooth framework and identify the classes for PAN profile and use reflection to acheive this. This approach may fail and not guranteed to work as expected.
Refer more in the official documentation
Refer more on accessing Bluetooth classes using Reflection
Enable Bluetooth tethering programmatically
Related
Can an Android device pretend and connect as a Bluetooth controller?
Can Android devices connect as a device to, say, a PC and act as a gamepad or similar device?
Is it allowed and doable in code without root access?
I tried this code: Connect Bluetooth devices. But it can not get it to pair.
Short answer, yes.
I recommend looking at Google's example project on Bluetooth communication BlueToothChat initially. Based on what you've written, I think you're missing several important steps.
You need all of the following components / steps:
General Overview
Set up Bluetooth
Set Permissions
Scan for other Bluetooth devices
Query the local Bluetooth adapter for paired Bluetooth devices
Connect to a remote device as client or server
Transfer data over Bluetooth
If you have access to the device your attempting work with as a controller, then you can create your own communication setup. Define a set of parameters to write and read on both sides that emulate the functionality you're looking for.
If you do not have access to creating your own read/write setup, or you want to use standard interaction methods for the industry, then the best bet is the Bluetooth HID Device profile mentioned by #Morrison Chang.
The HID profile basically establish an industry standard of required device features, read/write formats, combinations of features equaling a controller type (ie: "this is a keyboard"), and data mappings for what read/write numbers mean on either side of the client / server connection.
From the linked comment thread, the Kontroller project on Github has source available for your peruse.
There's also a reasonable Intro to Bluetooth HID that covers some of the topics on what Bluetooth HID is actually doing.
Finally, also recommend looking at Google's own BluetoothHidDevice page.
Since many libraries are meant to be used with TCP/IP, I was wondering if it is possible to activate TCP/IP and therefore TCP/UDP for Bluetooth connections. I found some information already like that it is called Bluetooth PAN and piconet.
Furthermore, I noticed that my Android device created a network interface with an IP upon a connection with an iPhone (after I paired it and hit connect). Nevertheless, it appears that interface cannot be used right away. I don't have the option to root these devices so it needs to be activated programmatically somehow.
Any hints? Is it actually possible?
Thanks.
I've started to develop a chat application for Android. This app is supposed to function without internet and, most importantly, without an access point; It has to connect Android devices in a pure P2P manner.
However I've followed the following tutorials posted in android developers guide:
http://developer.android.com/training/connect-devices-wirelessly/nsd.html
http://developer.android.com/training/connect-devices-wirelessly/wifi-direct.html#fetch
Afterwards, I've tested my app on 3 devices, the problem is one of the devices acts as an access point, preventing other devices from connecting with each other if they are connected to it.
This doesn't work for my app, because I want each user to be able to connect to multiple users at the same time.
What do you suggest I do in order to achieve pure P2P connection for my Android app?
Does the group owner acts as an access point?
EDIT
After I've done some research I found the WiFi Direct is not suitable for my project since it has to assign a device as an access point, what I'm looking for is WiFi ad hoc mode or (IBSS) in Android Anybody got any suggestion on how to start working on that?
By using bt and wifi simultaneously, you can try to extend the network further. This will require some kind of packet routing.
Also, it seems android ignores wlan cards connected to usb otg - just plugging in extra wlan dongles could allow easy extension of network.
I have an android app, it does the following:
Connects with a server to read and update a database at the same time as others.
I want to convert this to an app that does not need an internet connection. Therefore i would like to know if its possible to have an android device acting as the server with the database, whilst multiple phones connect to it via bluetooth getting and updating the information in the database?
Thanks
Yes. It possible.
However all of your devices will have to be located nearby, so they can connect to each other through bluetooth.
You can take a look at Android Bluetooth API.
However, my recommendation would be to use Wifi instead of Bluetooth. YOu will need additional WiFi router. However, you won't need to deal with Bluetooth API in such case.
You will only need to write a server on one of Android device and the rest of devices will work the same (as now)
There are a few options to doing so, that don't involve a server. Both of them require a slightly different approach than both devices connecting to a server.
Wi-fi Direct- Only available with Android 4.0+.
Bluetooth
Personally, I have been using the Bluetooth option, and not found it terribly difficult. Essentially, you have to do the following to make it work.
Have one of the devices listen for a connection. If it is unpaired, you will have to make the device discoverable.
The second device needs to initiate a connection. It can do this by looking at the known devices and trying to connect to one, or listening for a new device
After the two devices connect, they must initiate some kind of a communication protocol. The communication is essential a serial connection.
Blue-tooth requires that the devices be within about 10 m of each other. Wi-fi direct will allow somewhat further, but as mentioned, is less supported. It is possible to allow for both communication methods, but is somewhat challenging.
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!