I made an app to turn my phone (LGV20) into a PC keyboard using Android Bluetooth. I'm trying to remove the PC server code by getting my app to pair my phone as a keyboard instead of a phone.
The only app I found that doesn't require a PC setup or rooting is Blek. It seems that when you turn the app on it tries to pair your phone as a keyboard like I want. However, I can't figure out how they did it. I imagine they did something like this:
public class MyBluetoothAdapter extends BluetoothAdapter {
private static final String DEVICE_PAIR_TYPE = "Keyboard"
...
}
That's not a real variable in BluetoothAdapter but I imagine something like this was used.
The hint should be when you looked at the app's description:
The receiver device must have Bluetooth 4.0 ....
So a search shows that among the many GATT specifications:
https://www.bluetooth.com/specifications/gatt
There is a HID over GATT profile
And it appears that each Bluetooth LE chip manufacturer has a keyboard HID over GATT example.
I suspect that each Bluetooth LE chip SDK has some JNI/C level type stuff to enable keyboard HID over GATT.
From this SO post: is there any ble api in Ndk
It looks like lower level Bluetooth access is available but invocation may vary on a chip to chip basis.
Given that Android allows for a number of different chip vendors, the author of the app you cite may have some of such SDK based code installed but may not work on all devices.
One open source(ish) implementation that I've found but not tested is:
https://github.com/kshoji/BLE-HID-Peripheral-for-Android
which appears to have a min SDK of 21. However the 'secret sauce' is still 'hidden' in an AAR in the author's lib directory.
So what else can be done?
Find out what Bluetooth Low Energy chipset your device uses. I don't have access to a LGV20 but perhaps something in the logcat will point to a manufacturer.
Once you know the manufacturer and chipset series, see if you can get access to that chipset makers particular Bluetooth Low Energy SDK for any sample code/modules which can enable HID over GATT.
Write app with such code/module with the understanding that you may need to deal with JNI/C.
Related
I have a Wii remote and I want to connect it to my android phone with just Java if possible. I have tried to look for libraries and other things like that but there was nothing. I am new to Bluetooth development, I don't know how it works entirely. Other than that, I would love to get some links on how to connect a Bluetooth device as an HID and send data to a specific address. Thank you all!!!!
I am developing an app in which I need to scans WiFi network and display the list of all connected devices.
Allow a use to tap on a device and the app should show all the hardware info of that particular device. Here by hardware I mean - RAM, Storage Media, Storage Capacity, Device Name, Device IP address, etc.
Now this device can be anything like xbox, a laptop with Linux/Windows, mobile phone like iPhone or any Andorid based smart phone or even a printer.
How can I scans WiFi network and query/detect all the devices attached to it?
What are the protocols that I need to use to get list of hardware in a particular device irrespective of the OS running on it?
Check requestPeers of
WifiP2pManager
As per documents it seeks
PeerListListener which returns WifiP2pDeviceList carrying list of WifiP2pDevice which carries deviceAddress, deviceName, primaryDeviceType, secondaryDeviceType, status and other attributes.
Maybe the Network Discovery github project could help you. It lists all users connected to WiFi with IP and MAC addresses and gathers even some information like open ports, device name, ping, etc.
Hope it helps
In my opinion, you can use Wi-Fi Peer-to-Peer
https://developer.android.com/guide/topics/connectivity/wifip2p.html
"Wi-Fi peer-to-peer (P2P) allows Android 4.0 (API level 14) or later devices with the appropriate hardware to connect directly to each other via Wi-Fi without an intermediate access point (Android's Wi-Fi P2P framework complies with the Wi-Fi Alliance's Wi-Fi Directâ„¢ certification program). Using these APIs, you can discover and connect to other devices when each device supports Wi-Fi P2P, then communicate over a speedy connection across distances much longer than a Bluetooth connection. This is useful for applications that share data among users, such as a multiplayer game or a photo sharing application."
Blockquote
is there a possibility to get USB mass storage information like the serial of an USB device in Java on Windows?
I tried to achieve that with USB4Java (low and high-level API) and it works, but the problem is that I have to install a customized driver to get access to the information from my Java app (described in the FAQ at http://usb4java.org/). When that special driver (created with Zadig) is installed I don't have any further access to the device from the Windows explorer (just from my Java app).
I would like to detect when a new USB device is attached and if it was attached, I would like to get some information like the serial number of the device, the device name, the drive letter that was assigned etc.
That app should be used by other users and I couldn't force them to create a customized driver for each device ...
Do you have any hints how to achieve that?
Thanks.
Edit: Is it possible to get the usb-port of a connected device with Java-built-in methods?
I've tried sth with FileSystemView.getFileSystemView().getSystemDisplayName() but there are no such options. Is there another possibility to get vendor id's or sth. similiar with Java?
Or is it possible to get the drive letter with USB4Java?
Thanks.
I am trying, without success, to pair a bluetooth device with a Android phone without asking to the user the PIN.
My idea is to fetch the desired PIN from a web service because the bluetooth device I want pair needs to be used from more people (and so for more android phones) without knowing and enter the PIN.
Do you have any idea for do it? I tried to see Bluetooth classes, but always, during device connection, I need to enter the PIN.
Thank you in advance!
You can use "just works" feature of Bluetooth pairing. This works only with SSP(secure simple pairing), from Bluetooth 2.1 onwards.
You have to set the IO capabilities of device for this to work.
I have an android devic, i wish to know when it is connected to the pc via java/.net
i know its possible - the Samsung New PC Studio is doing it, when ever i connect an android device it lets me know. how can i achieve the same?
You have to listen for one of this notifications
http://developer.android.com/reference/android/content/Intent.html
If you're using it as a mass storage device then use this
http://developer.android.com/reference/android/content/Intent.html#ACTION_UMS_CONNECTED
Other USB events aren't clearly described in the documentation
EDIT:
If you want to read on the computer side I would read this article
http://today.java.net/article/2006/07/05/java-and-usb
and then check which kind of devices are connected to the usb port. if it is a mobile phone, then you can try to send a short message to it. on your phone you make a small piece of code which returns an appropriate answer so you can detect thats its really android/your phone/this phones you want to identify
java device detection
This site have a guide on how to detect device with java web and java core
http://51degrees.com/Support/Documentation/Java/GettingStarted.aspx