Bluetooth forgot PIN

So, I am working on an application that connects to an integrated Bluetooth device. This device is deployed in different versions and on my test device, everything works fine. Communication through a secure rfcomm socket. However, another set of devices gives me creep. They seem to lose a limited state. Although they are marked as paired, every time I make a connection, I am asked to re-enter the PIN code. And this is really not desirable. In addition, this behavior does not occur at all, but most devices. In fact, the only device that does not forget the PIN is the Galaxy Nexus S. Samsung Galaxy Nexus, ACE, GIO and X10 mini Pro tend to β€œforget” that the device was previously paired. Using the lvl 10 API, I have already tried the unsafe RFCOMM connec, but to no avail. I'm lost here. Does anyone have an idea?

Yours faithfully!

+4
source share
1 answer

What is your device getBTMajorDeviceClass? If it's BluetoothClass.Device.Major.UNCATEGORIZED, try creating your own UUID:

private UUID generateUuid() { String android_id = Secure.getString(getApplicationContext() .getContentResolver(), Secure.ANDROID_ID); Log.i("System out", "android_id : " + android_id); final TelephonyManager tm = (TelephonyManager) getBaseContext() .getSystemService(Context.TELEPHONY_SERVICE); final String tmDevice, tmSerial, androidId; tmDevice = "" + tm.getDeviceId(); Log.i("System out", "tmDevice : " + tmDevice); tmSerial = "" + tm.getSimSerialNumber(); Log.i("System out", "tmSerial : " + tmSerial); androidId = "" + android.provider.Settings.Secure.getString( getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode()); return deviceUuid; } 

and use it when creating sockets createRfcommSocketToServiceRecord(generateUuid());

* READ_PHONE_STATE required

+1
source

All Articles