I am trying to pair TI CC2564 module with Android (5.0) and Android (6.0).
5.0: It never connects through the device settings. But I can use it from my app with call to function createRfcommSocket. Issue here is that I need to connect the device manually every time I reopen the app.
6.0: I am able to pair the device through device settings occasionally and it is hit and miss. Once I pair the device it works flawlessly in the app. But if I remove the pairing and try to pair again it doesn't allow me to pair with the following error in Logcat
Device is not allowed because it is either insecure or of unknown security and needs user confirmation
Any suggestion regarding how to get the device pair?
I was able to resolve the issue. The Bluetooth module's broadcast name is null by default, giving it a proper name allows the connection to succeed flawlessly. I am guessing there is some issue with either Android or CC2564 BT stack, which might be causing a crash and hence disconnecting.
Related
I'm attempting to write an app that connects to another device via bluetooth, identify itself as a keyboard via the new BluetoothHidDevice and then send text and/or single characters to the target device as keyboard input.
So far I got everything to work except establishing the bluetooth connection from my Huawei P10 to a Windows 10 laptop. It seems to work fine when connecting to another Android device when I tested it with a Galaxy S8+ on the receiving end, when I tried to establish a connection the P10 got correctly detected as a physical keyboard and I could send keyboard inputs to the S8+
I also tried it with two different laptops, one with a built-in bluetooth adapter and another with an external usb adapter, in both cases I was unable to establish a connection.
My code is mostly based on https://github.com/ginkage/wearmouse by google which I found thanks to another question while I was looking for solutions to my own issue.
The issue is that there is no connection established after calling BluetoothHidDevice#connect which returns true as expected but then seemingly just times out.
When observing the log I just see the state switching between 1 (connecting) and 0 (disconnected):
D/BluetoothHidDevCallback: onConnectionStateChanged: device=[redacted MAC] state=1
D/BluetoothHidDevCallback: onConnectionStateChanged: device=[redacted MAC] state=0
...
I set up an android studio project where you just need to change TARGET_DEVICE_NAME inside of MainActivity.java to your target devices name and it should run out of the box (requires Android 9 Pie): https://github.com/domi1294/BluetoothHidDemo
Your devices need to be paired beforehand since it will check your paired devices for TARGET_DEVICE_NAME and attempt to connect to it when you press the button. If the connection was successful the button will instead send the string "TestMessage" to the target device.
If you run the app yourself and track BluetoothHidDevCallback in Logcat you should see it try to connect (state=1), disconnect (state=0) and repeat. It should change to state 2 which stands for connected and is what I expect to happen like it did when I tried the P10 --> S8+ connection.
Feel free to try connecting to a macOS device if you don't own a Windows pc, as I would like to know whether this is a Windows only problem or not.
Turns out there is an open source project doing just that and it works great with PC too:
https://github.com/raghavk92/Kontroller
On Android wear, the NodeAPi has interfaces to fetch the connected node. This connected node is maintained by the OS itself somewhere (guessing it is in gms.wearable shared preferences). Because of this reason, when one tries to switch a connected device of the watch to another one, Android Wear 4.4W2 prevents this switch.
is there a way to remove the connected node on wear side programmatically?
addListener(GoogleApiClient client, NodeApi.NodeListener listener)
getConnectedNodes(GoogleApiClient client)
getLocalNode(GoogleApiClient client)
removeListener(GoogleApiClient client, NodeApi.NodeListener listener)
Above is the list of NodeAPIs from Android wear documentation. From my analysis, I just think they are either missing the API to removeConnectedNode or they simply want to hang on to the 1st connected node after factory reset.. The latter seems bad design and currently seems to be the case with Android 4.4W2 update.
I don't know for 4.4W2 since there's now an option to dissociate connected devices, but as far as 4.4W1, you could not associate your Wear device with more than 1 handlheld device per factory reset, ie if you want to disconnect your watch from your companion handheld, apart from turning off the Bluetooth connection from the handheld (if you just want to interrupt the communication) or manually resetting your watch, you can't dissociate the devices.
EDIT
Just tested the dissociate option. Doesn't do anything on my Samsung Gear Live except starting an activity saying "Dissociate the devices". So I guess that what was true on 4.4W1 is still true for 4.4W2
Well, recently Google release the Android 4.3, and it support Bluetooth 4.0 device connection. Unlucy, I have a bluetooth 4.0 project before this appear. My testing phone is Samsung S4, so I can only use SamsungBLEConnect to implement the first version of my apps. And I meet a unexpected situation.
The bluetooth connector(hardware) and Wifi will automatically shut down by itself without any exception.
After this happen, we need to reactivate the bluetooth and wifi by using system setting. This is surely unacceptable for any client. And I don't believe we can program the apps to activate the bluetooth and wifi, as we surely cannot disable the client's bluetooth and wifi by any exception or logical error.
So, the situation is very weired, and the reason of this accident is unknown.
Restart your mobile first and then check it out
I am a newbie working on bluetooth, and I would like to get some advice regarding the pairing process. I have googled this but I did not find much information ...
My goal is simple: I want to do a pairing to a headset without entering a pin. I have an android (nexus S running Android 4.1.2) and an iphone (3GS running ios 6.1.3).
If I connect to a device like a Jabra BT3030 (bluetooth headset), the pairing is performed without asking me any pin code.
Now I want to do the same from an Ubuntu (with BlueZ 4.6), i.e. I fake a bluetooth headset by enable only the correct service and so on. I disabled the authentication.
When I pair my iphone to this device, no pin code is required (as expected), but when I connect from my Android device, it still asks me for a pin code, whereas I would expect to have the same behavior than with the Jabra.
Would you have any idea of what I am missing here?
Thanks in advance,
Best regards,
Guillaume
Android Uses UUID for pairing and connection for two devices...for two devices conneting, one device should send request and one should accept and for both UUID should be same...
Like also used bluetooth there I need to intall my android app to both the devices then only I can pair the two devices...because only that app is knowing the UUID. and for iPhone it may be different so if from the native code of iOS u can know the UUID ur android device can be paired through app...
The Standard password for a Jabra BT3030 is 0000. Many other bluetooth devices have a standard password. For the Case a system only accepts devices with passwords, and u cant enter a pasword on a device without keys :D
Maybe the solution is implementing the standard passwords for mutliple devices and use them instead f forcing a connection without password.
I want to initiate a pairing request (not connection at this point of time) to a non android device. This can be found working on Settings Application > Network > Bluetooth Settings > Click on a device after scan. A pop up appears on both the devices with a 6 digit pin.
As per Android's documentation this should have popped up in my application as well, if I do something like this
device.createRfcommSocketToServiceRecord(MY_UUID);
As per Android's API documentation
"Once a connection is made with a
remote device for the first time, a
pairing request is automatically
presented to the user."
And it is also mentioned that
"The current Android Bluetooth API's
require devices to be paired before an
RFCOMM connection can be established.
(Pairing is automatically performed
when you initiate an encrypted
connection with the Bluetooth APIs.)"
Even when I used the sample Bluetooth Chat application (only to test if it initiates a pairing on first connection) it didn't worked.
I also tried using a generic UDID like "00001101-0000-1000-8000-00805F9B34FB" but to no avail.
Couldn't find the source code of Settings Application (Android OS 2.1) to figure out myself. The sources available in Android GIT were for Android 2.3
Even if you cannot answer the question, only pointing out to Android Packages Settings App sources for Android 2.1 might do the trick for me.
It works for me with this UUID : "00001101-0000-1000-8000-00805F9B34FB".
The intent for pairing request is launched when you call socket.connect() if I remember correctly.