Android Bluetoothgatt - Status 133 - Rückruf registrierenAndroid

Forum für diejenigen, die für Android programmieren
Anonymous
 Android Bluetoothgatt - Status 133 - Rückruf registrieren

Post by Anonymous »

Zunächst einmal gelesen gelöst: Gatt Callback registriert sich nicht und hat die in diesem Beitrag vorgeschlagenen Schritte unternommen, um dieses Problem ohne Erfolg zu lösen. Die empfohlene Behebung dort, wenn Sie nicht gelesen haben, besteht darin, alle BLE -Anrufe direkt oder mit einem Handler zu tätigen.1)Gets list of our products available to connect to (done, works)

2)For each available device:

2a)connect to device
2b)discover services
2c)read 5 characteristics in this fashion:
2c1)read characteristic
2c2)onCharacteristicRead parse data
2c3)when finished with data read next characteristic
2c4)repeat until all are read (this is done using a state var and switch statement)
2d)disconnect from device
2e)connect to next device
2f)repeat until all devices are read from
2g)stopSelf()
< /code>

Also das Problem ... alles funktioniert für ein bisschen hervorragend. Ich kann den gesamten Service start {startservice (...) ausführen; in MainActivity} , um {stopself () zu beenden; Im Dienst} < /strong> 6 Mal. Ich bin mir nicht sicher, warum ich es 6 -mal erfolgreich ausführen und dann zum 7. Mal versagen kann. />
private Handler handler = new Handler();
private BluetoothGatt cGatt = null;
private int unitIndex = 0; // keep track of currently connected unit
private int state = 0; //used to keep track of which characteristic to read next

public int onStartCommand(Intent intent, int flags, int startId)
{
Log.i(TAG, "Service Started...");
//get ArrayList of units

if(units.size > 0)
handler.post(connectNextRunnable); //calls connectNextDevice()
else
stopSelf();
}

private Runnable discoverServices = new Runnable()
{
public void run()
{
cGatt.discoverServices();
}
}

private Runnable readNextValue = new Runnable()
{
public void run()
{
BluetoothGattCharacteristic c = null;
switch(state)
{
//set c to appropriate characteristic
default: // all characteristics read
unitIndex++;
handler.post(connectNextRunnable)
return
}

cGatt.readCharacteristic(c);
}
}

private void connectNextDevice()
{
if(unitIndex == 0)
store System.nanoTime in variable

if(unitIndex >= units.size) //finished will all units
stopSelf();

if(unitIndex < units.size)
cGatt.disconnect //if null
cGatt.connectGatt(this, false, gattCallback)
}

private BluetoothGattCallback gattCallback = new BluetoothGattCallback()
{
public void onConnectionStateChange()
{
handler.post(discoverServices);
}

public void onServicesDeiscovered()
{
handler.post(readNextValue);
}

public void onCharacteristicRead()
{
ParseData();
}

private void ParseData()
{
//do stuff with data
handler.post(readNextValue);
}
}
< /code>

Wie ich schon sagte, wird alle BLE -Zeug vom Hauptfaden über einen Handler aufgerufen. Der Service läuft erfolgreich 6 Mal von Anfang bis Ende. Zum 7. Mal erhalte ich, dass das Dumme den Rückruf nicht registriert hat. Ich habe nicht im ursprünglichen Beitrag, weil ich viele Informationen darüber ausgibt, um die empfangenen Daten usw. zu überprüfen.08-15 12:00:10.746: I/PMIQ BTS(32027): Service Started...
08-15 12:00:10.746: I/PMIQ BTS(32027): Units: 1
08-15 12:00:10.746: D/AbsListView(32027): unregisterIRListener() is called
08-15 12:00:10.766: I/PMIQ BTS(32027): Connecting to next device...
08-15 12:00:10.766: I/PMIQ BTS(32027): Unit index = 0
08-15 12:00:10.766: I/PMIQ BTS(32027): Connecting to pmIQ-IQ130_D93A
08-15 12:00:10.766: I/System.out(32027): main
08-15 12:00:10.766: D/BluetoothGatt(32027): connect() - device: 00:1E:C0:19:D9:3A, auto: false
08-15 12:00:10.766: D/BluetoothGatt(32027): registerApp()
08-15 12:00:10.766: D/BluetoothGatt(32027): registerApp() - UUID=e9d10870-4b09-451c-a9fa-c6b5f3594a77
08-15 12:00:10.766: I/BluetoothGatt(32027): Client registered, waiting for callback
08-15 12:00:10.766: D/BluetoothGatt(32027): onClientRegistered() - status=133 clientIf=0
08-15 12:00:10.766: I/PMIQ BTS(32027): CONECTION STATE CHANGED...Binder_2
**08-15 12:00:10.766: E/BluetoothGatt(32027): Failed to register callback**
08-15 12:00:10.766: I/PMIQ BTS(32027): Could not connect to null ... 257
08-15 12:00:10.766: I/PMIQ BTS(32027): Connecting to next device...
08-15 12:00:10.766: I/PMIQ BTS(32027): Unit index = 1
08-15 12:00:10.766: I/PMIQ BTS(32027): ******************************
08-15 12:00:10.766: I/PMIQ BTS(32027): Start Time: 4360642409647
08-15 12:00:10.766: I/PMIQ BTS(32027): End Time: 4360648970925
08-15 12:00:10.766: I/PMIQ BTS(32027): Difference: 6561278
08-15 12:00:10.766: I/PMIQ BTS(32027): Time to complete: 6
08-15 12:00:10.766: I/PMIQ BTS(32027): ******************************
08-15 12:00:10.876: I/PMIQ BTS(32027): ...Service Destroyed
< /code>

Wenn Sie es hier geschafft haben, danke! Ich konnte keine Informationen darüber finden, welchen Status = 133 bedeutet?! Es geschieht nur, wenn der Rückruf fehlschlägt. Bei jedem anderen Mal ist Status = 0. < /P>

08-15 12:00:10.766: D/BluetoothGatt(32027): onClientRegistered() - status=133 clientIf=0
< /code>

Wenn jemand dies überhaupt beantworten könnte, kann es mir sehr helfen. Oder wenn mir jemand sagen kann, warum es nur 6 Mal läuft. Jeder Einblick oder jede Vermutung könnte hilfreich sein! < /p>

Danke alle! < /p>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post