Where can I reduce the max connection interval

What part of my program can I put those codes in? (How can I use those codes?)

import android.os.Build;

settings.editBleConnParams()
.maxConnectionInterval(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? 11.25f : 7.5f)
.commit();

Thank you for your previous reply. They are really helpful.

Comments

  • Right after you connect, you can ASK to change connection parameters.

    Again, you can only ASK. Only the MASTER device can accept or reject and there is no way to know if your parameters will go through. This is part of the BLE spec and is not changeable.

  • @Laura said:
    Right after you connect, you can ASK to change connection parameters.

    Again, you can only ASK. Only the MASTER device can accept or reject and there is no way to know if your parameters will go through. This is part of the BLE spec and is not changeable.


    Is this correct? But if I put the codes in this position, the code behind will not work. Is it normal?

  • edited June 2020

    Your code looks right. Try adding a delay between this command (setbtlecon) and the next (readdeviceinfo).

    Global.connInterval = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? 11.25f : 7.5f;
    // More code here
    Settings.BleConnectionParametersEditor editor = m.getModule(Settings.class).editBleConnParams();
    if (editor != null) {
        editor.maxConnectionInterval(Global.connInterval)
            .commit();
        return Task.delay(1000L);
    }
    

    Some additional sample code in our streaming app:

    for(MetaWearBoard board: Global.sampleCounts.keySet()) {
        board.getModule(Settings.class).editBleConnParams()
            .maxConnectionInterval(125f)
            .commit();
    }
    

    Please find the CPP docs link here: https://mbientlab.com/androiddocs/latest/settings.html

Sign In or Register to comment.