fix: NimBLE 128-bit UUID scan response + Android key/UUID loading
- Firmware: add explicit setScanResponseData with setCompleteServices for 128-bit service UUID so Android ScanFilter finds the device - Android: hexStringToBytes accepts any even-length hex (fixes UUID=32chars failing the hardcoded 64-char check) - Android: onActivityResult matches SettingsActivity.RESULT_SCAN instead of Activity.RESULT_OK
This commit is contained in:
parent
96d3620535
commit
d6e37322f3
3 changed files with 12 additions and 5 deletions
Binary file not shown.
|
|
@ -213,7 +213,7 @@ class MainActivity : AppCompatActivity() {
|
|||
@Deprecated("Deprecated in Java")
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (requestCode == REQUEST_SETTINGS && resultCode == Activity.RESULT_OK) {
|
||||
if (requestCode == REQUEST_SETTINGS && resultCode == SettingsActivity.RESULT_SCAN) {
|
||||
stopScan()
|
||||
bluetoothGatt?.close()
|
||||
bluetoothGatt = null
|
||||
|
|
@ -260,7 +260,7 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
private fun hexStringToBytes(hex: String): ByteArray? {
|
||||
val cleaned = hex.uppercase().filter { it in "0123456789ABCDEF" }
|
||||
if (cleaned.length != 64) return null
|
||||
if (cleaned.isEmpty() || cleaned.length % 2 != 0) return null
|
||||
return cleaned.chunked(2).map { it.toInt(16).toByte() }.toByteArray()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue