OnservicesDiscovered () nicht angerufen, wenn RequestMtu () und entdeckt () () zusammengerufen wird, wenn sie eine VerbiAndroid

Forum für diejenigen, die für Android programmieren
Anonymous
 OnservicesDiscovered () nicht angerufen, wenn RequestMtu () und entdeckt () () zusammengerufen wird, wenn sie eine Verbi

Post by Anonymous »

Ich stieß auf ein Problem mit der Interoperabilität zwischen einem Android -Zentral/Client (CompilesDK = 35), der sich mit einem peripheren/Server verbindet, der seine eigene MTU -Verhandlung initiiert: Die Service -Entdeckung scheint stecken zu bleiben, und OnservicesDecovered () wird nie genannt. Rufen Sie an Bluetoothgatt.RequestMtu () an, nachdem sich das Gerät verbindet. Bei diesem bestimmten BLE -Gerät fungiert es auch bei nominell als peripheren/Server konfiguriert override fun onConnectionStateChange(gatt: BluetoothGatt, status: Int, newState: Int) {
if (status == BluetoothGatt.GATT_SUCCESS) {
when (newState) {
BluetoothProfile.STATE_CONNECTED -> {
// initiate MTU negotiation and service discovery
gatt.requestMtu(512)
gatt.discoverServices()
}
BluetoothProfile.STATE_DISCONNECTED -> {
// Disconnected from device
}
}
}
}

override fun onServicesDiscovered(gatt: BluetoothGatt, status: Int) {
if (status == BluetoothGatt.GATT_SUCCESS) {
// Services discovered, enable notifications if needed
.
.
.
}
}
< /code>
Wenn ich den Anruf nach Bluetoothgatt.RequestMtu () entferne, dann kein Problem, aber das funktioniert offensichtlich nicht mit anderen BLE -Geräten, die keine MTU -Verhandlungen initiieren. Wenn ich die vom Peripherie initiierte MTU-Verhandlung deaktiviere, dann ist kein Problem. />
Datum /Uhrzeit < /th>
pid-tid < /th>
Tag < /th>
log Level < /th>
Nachricht < /th>
< /> < /> < />

< /> < />
< /> < /> 2025-07-11 17: 47: 49.116 < /td>
8165-8165 < /td>
BluetoothAdapter < /td>
< /td>
< /> < />
GetbleNablear (): auf < /td>
GetbleAnteal (): auf < /td>
GetbleNabledaRray (): auf < /td>
GetbleAnableAnableer (): auf < /td>
GetbleAnablear (): auf < /td>
GetbleNablear (): auf < /td>
GetbleAnsAray (): on />
2025-07-11 17: 47: 49.118 < /td>
8165-8165 < /td>
bluetoothgatt < /td>
d < /td>
connect ()-Geräte: Geräte: Geräte: Geräte: Geräte: Geräte: XX:XX:XX:XX:77:30, auto: false


2025-07-11 17:47:49.118
8165-8165
BluetoothGatt
D
registerApp()


2025-07-11 17:47:49.119
8165-8165
BluetoothGatt
d < /td>
RegisterApp ()-UUID = A616F277-DD9B-4D9C-87C9-199CAFE1CFC8 < /TD>
< /Tr>

2025-07-11 17: 49.124
2025-07-11 17: 49. 49. 49.124
2025-07-11 17: 47: 49. 49.124
2025-07-11 17: 49: 49. 49.124
2025-07-11 17: 49: 49. 49. 49. 49. 49. 49. 49. 49. 49. 49. 49. 49: 49. 49. 49: 49.124). />8165-9333
BluetoothGatt
D
onClientRegistered() - status=0 clientIf=12


2025-07-11 17:47:49.126
8165-9333
BluetoothAdapter
D
getBleEnabledArray(): ON


2025-07-11 17: 47: 50,596 < /td>
8165-9333 < /td>
bluetoothgatt < /td>
d < /td>
onclientSconnectionState ()-STATUS: Gerät = xx: xx: xx: xx: 77: 30 < /td>
< /tr>

2025-07-11 17: 47: 50.600 < /td>
8165-9333 < /td>
brabluetoothgatt < /td>
Bluetoothgatt < /td>
brabluetoothgatt < /td>
brabluetoothgatt < /td>
brabluetoothgatth. /> d < /td>
configuremtu ()-Gerät: xx: xx: xx: xx: 77: 30 mTU: 512 < /td>
< /tr>

2025-07-11 17: 47: 50.603 < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td>
8165-9333
BluetoothGatt
D
discoverServices() - device: XX:XX:XX:XX:77:30


2025-07-11 17:47:51.120
8165-9333
BluetoothGatt
D
onConnectionUpdated() - Gerät = xx: xx: xx: xx: 77: 30 intervall = 6 latency />BluetoothGatt
D
onConfigureMTU() - Device=XX:XX:XX:XX:77:30 mtu=247 status=0


2025-07-11 17:47:51.569
8165-9333
BluetoothGatt
D
onConnectionUpdated() - Device=XX:XX:XX:XX:77:30 interval=36 latency=0 timeout = 500 status = 0 < /td>
< /tr>
< /tbody>
< /table> < /div>
und dasselbe, aber mit der peripheralen initiierten MTU-Verhandlung deaktiviert: < /p>

Datum /Uhrzeit < /th>
pid-tid < /th>
Tag < /th>
log Level < /th>
Nachricht < /th>
< /> < /> < />

< /> < />
< /> < /> 2025-07-11 17:52:18.055
8165-8165
BluetoothAdapter
D
getBleEnabledArray(): ON


2025-07-11 17: 52: 18.058 < /td>
8165-8165 < /td>
Bluetoothgatt < /td>
d < /td>
connect ()-Geräte: Geräte: Geräte: Geräte: Geräte: Geräte: Gerät: XX:XX:XX:XX:77:30, auto: false


2025-07-11 17:52:18.058
8165-8165
BluetoothGatt
D
registerApp()


2025-07-11 17:52:18.058
8165-8165
BluetoothGatt
d < /td>
RegisterApp ()-UUID = C055AE54-E1D1-4F45-A276-9281537E3E2F < /td>
< /tr>

2025-07-11 17: 52: 18.063 2025-07-11 17: 52: 18.063 2025-07-11 17: 52: 52: 18.063 ^ />8165-8181
BluetoothGatt
D
onClientRegistered() - status=0 clientIf=13


2025-07-11 17:52:18.065
8165-8181
BluetoothAdapter
D
getBleEnabledArray(): ON


2025-07-11 17: 52: 18.480 < /td>
8165-8181 < /td>
bluetoothgatt < /td>
d < /td>
onclientSconnectionState ()-STATUS = 0> onclientState ()-STATUS = STATION Id. device=XX:XX:XX:XX:77:30


2025-07-11 17:52:18.482
8165-8181
BluetoothGatt
d < /td>
configuremtu ()-Gerät: xx: xx: xx: xx: 77: 30 mTU: 512 < /td>
< /tr>

2025-07-11 17: 52: 18.484 < /td> < /td>
8165-8181 < /td>
Bluetoothgatt < /td>
d < /td>
Erkenntnisse () - Gerät: xx: xx: xx: 77: 30 < /td>
< /> < /> < /> < /> < /< /tr>
< /> < /< /tr> < /
2025-07-11 17:52:19.001
8165-8181
BluetoothGatt
D
onConnectionUpdated() - Gerät = xx: xx: xx: xx: 77: 30 intervall = 6 latency />BluetoothGatt
D
onConfigureMTU() - Device=XX:XX:XX:XX:77:30 mtu=247 status=0


2025-07-11 17:52:19.425
8165-8181
BluetoothGatt
D
onSearchComplete() = Device=XX:XX:XX:XX:77:30 Status=0


2025-07-11 17:52:19.425
8165-8181
BluetoothGatt
D
setCharacteristicNotification() - uuid: 85fc567e-31d9-4185-87c6-339924d1c5be enable: true


2025-07-11 17:52:19.496
8165-8181
bluetoothgatt < /td>
d < /td>
OnconnectionUpdated () - Device = xx: xx: xx: xx: 77: 30 intervall = 36 Latency /> < /table> < /div>
Nachdem ich diese Spuren erfasst habe override fun onConnectionStateChange(gatt: BluetoothGatt, status: Int, newState: Int) {
if (status == BluetoothGatt.GATT_SUCCESS) {
when (newState) {
BluetoothProfile.STATE_CONNECTED -> {
// initiate service discovery
gatt.discoverServices()
}
BluetoothProfile.STATE_DISCONNECTED -> {
// Disconnected from device
}
}
}
}
override fun onServicesDiscovered(gatt: BluetoothGatt, status: Int) {
if (status == BluetoothGatt.GATT_SUCCESS) {
// now initiate MTU negotiation
gatt.requestMtu(512)
}
}
override fun onMtuChanged(gatt: BluetoothGatt, mtu: Int, status: Int) {
if (status == BluetoothGatt.GATT_SUCCESS) {
// services discovered and MTU negotiated, enable notifications if needed
.
.
.
}
}
< /code>
Ist das ein Fehler? Ich sehe nichts in den Bluetoothgatt -Dokumenten, die sagen, RequestMtu () und DiscoverServices () kann nicht zusammengerufen werden.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post