ttlock / iOS_SDK_Demo

TTLock is a global provider of solutions for smart locks. We provide PCBA and softwares for lock manufactures and end users. We provide open API/SDK for developers. With these APIs/SDKs, you can develop your own applications to manage smart locks. The SDK here is for mobile app to communicate with locks via bluetooth.
MIT License
13 stars 12 forks source link

TTLock: Battery Value Variations between SDK and API #35

Closed parvezkhanpsspl closed 6 months ago

parvezkhanpsspl commented 6 months ago

We've noticed some inconsistencies in the battery values retrieved from the TTLock SDK and the TTLock API. This affects both Android and iOS devices across multiple models. Below, We've listed the devices along with the observed battery values.

Screenshot 2024-05-15 at 12 14 06 PM image

iOS SDK Method:

TTLock.getElectricQuantity(withLockData: lockData) { value in
    completion(.success(value))
} failure: { _, errorMSG in
    if let errorMSG {
        completion(.failure(TTLockHelperError.custom(errorMSG)))
    } else {
        completion(.failure(TTLockHelperError.somethingWentWrong))
    }
}

Android SDK Method:

private void getLockBatteryLevel() {
    showConnectLockToast();
    TTLockClient.getDefault().getBatteryLevel(
        mCurrentLock.getLockData(),
        mCurrentLock.getLockMac(),
        new GetBatteryLevelCallback() {
            @Override
            public void onGetBatteryLevelSuccess(int electricQuantity) {
                makeToast("lock battery is " + electricQuantity + "%");
            }
            @Override
            public void onFail(LockError error) {
                makeErrorToast(error);
            }
        });
}

Expected Behavior: The battery values retrieved from both the SDK and the API should be consistent and accurate across all supported devices.

ttlock commented 6 months ago
  1. TTLock app and TTLock API have done calculations. int electricQuantity = electricQuantity / 5 * 5 ; (such as 18->15, 31->30, 20->20)
  2. The reading of electricity level is not as accurate, and a slight fluctuation is normal.