1

I'm developing an app that uses Mi Band 1s to track Heart Rate. For now I achieved the pairing (with authentication). But I can't figure how to unpair the Mi Band.

Code the unpairing of the Mi Band is not my first priority, but I would like to do that with my app instead of going to MiFit pair the mi Band and unpair it every time I want to perform a pairing (with the auth motor) with my app.

Here you have the app and the protocol I searched/figured/etc.

I use the following sequence to do my initialization:

private void initialize() {
    // Enable notifications
    addCall(enableNotifications());

    // Set low latency to do a faster initialization
    addCall(setLowLatency());

    // Reading date for stability - TODO - Check if this is really necessary
    addCall(requestDate());

    // Authentication
    addCall(pair());
    addCall(requestDeviceInformation()); // Needed to send user info to the device
    addCall(requestDeviceName());
    addCall(sendUserInfo()); // Needed to authenticate
    addCall(checkAuthentication()); // Clear the queue when not authenticated

    // Other Initializations
    addCall(sendCommand(COMMAND.SET_WEAR_LOCATION_RIGHT)); // Set wear location // TODO - Check
    addCall(setHeartRateSleepSupport()); // TODO - Check
    addCall(setFitnessGoal(1000)); // TODO - Check and set fitness by the app

    // Enable other notifications // TODO - Check
    addCall(enableNotificationsFrom(UUID_CHAR.REALTIME_STEPS));
    addCall(enableNotificationsFrom(UUID_CHAR.ACTIVITY_DATA));
    addCall(enableNotificationsFrom(UUID_CHAR.BATTERY));
    addCall(enableNotificationsFrom(UUID_CHAR.SENSOR_DATA));

    // Enable Heart Rate notifications
    addCall(enableHeartRateNotifications());

    // Other Initializations
    addCall(setCurrentDate());
    addCall(requestBattery());

    // Set high latency to get an stable connection
    addCall(setHighLatency());

    // Finish initialization - device is ready to make other calls
    //addCall(setInitialized()); // TODO
}

As you can see there are still some calls that I have to check if they are really doing what they say. But for the moment it seems to be working. I would appreciate any other comments (not only about how to unpair).

EDIT

I started to capture the bluetooth packets of the oficial application and my application (I also mapped all handlers with its uuid, even if I don't known what characteristic is).

Ok, so, this is the capture of the disconnection from MiFit:

enter image description here

As you can see the host only send 4 packets to the band:

  • Two of them are ATT packets to read steps and to dissable steps notifications.
  • The other two are HCI commands.

I think I just have to send the second HCI command (first one is already sended when I call disconnect() or close()). The problem is that I don't know how to send that command.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.