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
12 stars 12 forks source link

How can we update Gateway Firmware Update in android and iOS? #33

Closed bhavsinhjadav closed 3 months ago

bhavsinhjadav commented 4 months ago

Hi Team,

We've been working on integrating the firmware update feature for our gateways using the APIs provided by TTLock. However, we've encountered an issue and we're seeking your assistance in resolving it.

Here's a breakdown of the problem:

Firmware Check API: https://euopen.ttlock.com/document/doc?urlName=cloud%2Fgateway%2FcheckUpgradeEn.html We've successfully implemented the firmware check API, which provides us with the current and latest versions of the gateway firmware.

Firmware Update API: https://euopen.ttlock.com/document/doc?urlName=cloud%2Fgateway%2FsetIntoUpgradeModeEn.html We've also implemented the firmware update API to set the gateway into upgrade mode and initiate the firmware update process.

While we sometimes receive a success response from this API, the gateway firmware version remains unchanged.

Verification: To ensure accuracy, we've verified the firmware version before and after calling the update API using the https://euapi.ttlock.com/v3/gateway/upgradeCheck API. Despite receiving a success response, the firmware version remains the same after calling the update API. We've reviewed our implementation and documentation provided by TTLock, but we seem to be missing something crucial to successfully update the gateway firmware.

Could you please assist us in identifying any potential issues with our integration and guide us on how to manage this process effectively on both Android and iOS platforms?

Thank you.

JuannyiOS commented 4 months ago

Upgrading firmware must be done through SDK. iOS use TTLockDFU.framework :pod 'TTLockDFU' Android use LockDfuClient.

You can refer to the demo. https://github.com/ttlock/iOS_SDK_Demo https://github.com/ttlock/Android_SDK_Demo

bhavsinhjadav commented 4 months ago

@JuannyiOS

We are currently working on integrating the Gateway Firmware update functionality for our Android and iOS applications using the TTLock SDK. We have successfully implemented the update process for TTLock firmware using the LockDfuClient but GatewayDfuClient for Android Gateway Firmware update required , as per the provided SDK documentation.

We have a couple of queries and requirements regarding this integration:

1. Android Firmware Update Implementation:

We have utilized the GatewayDfuClient for Android to initiate the Gateway firmware update process for gateways. However, we encountered an issue where specific error handling similar to the iOS implementation is needed. Could you please provide guidance on how to capture and handle specific errors during the Gateway firmware update process in Android, similar to the iOS implementation provided below?

[Android Implementation Snippet] // Android Gateway Firmware Update Implementation // GatewayDfuClient.getDefault().startDfu(...) [iOS Implementation Snippet] // iOS Gateway Firmware Update Implementation // [[TTGatewayDFU shareInstance] startDfuWithType:clientId:accessToken:gatewayId:gatewayMac:successBlock:failBlock:]

iOS override error method failBlock:(UpgradeOpration type, UpgradeErrorCode code) { [weakSelf.view showToast:[NSString stringWithFormat:@"failBlock UpgradeOpration%ld UpgradeErrorCode%ld ",(long)type,(long)code]]; }

Android override error method @Override public void onError() { makeToast("dfu error"); } so need to required any specify error on above method for android same as iOS

2. Gateway Upgrade for G3 Gateways:

In our testing, we noticed that the "Gateway Upgrade" option is only visible for G2 gateways in your demo code. Could you please confirm if the firmware update functionality also supports upgrading G3 gateways? We need to ensure that the upgrade process works seamlessly for both G2 and G3 gateways. If it does support G3 gateways, could you provide guidance on how to implement the upgrade process for G3 gateways?

We appreciate your assistance in addressing these queries and requirements. Your guidance will help us ensure the successful implementation of the firmware update functionality across both Android and iOS platforms.

ttlock commented 3 months ago
  1. For issues with the Android SDK, you can send an email to "ttlock-developers-email-list@googlegroups.com".

  2. G3 can be upgraded. The upgrade methods are the same as G2.

deven1908 commented 3 months ago

@ttlock We send mail and also share reminder as you shared email to "ttlock-developers-email-list@googlegroups.com" but not getting any response for android so please check and let us know if possible.

Please find below mail as we shared.

Dear Support Team,

I hope this message finds you well.

We are experiencing an issue with upgrading the gateway firmware using the TTLock SDK on our Android application. The process works seamlessly on iOS; however, on Android, it consistently fails and enters the onError() callback without providing specific error details. This lack of error information makes it challenging to debug the issue.

Below are the details of the implementation and the issue we are facing:

Implementation Details SDK Initialization:

private void startDfu() {
    GatewayDfuClient.getDefault().startDfu(GatewayDfuActivity.this, ApiService.CLIENT_ID, "1dd497b8b3752e8b0156b7c47226bda6", gatewayObj.getGatewayId(), gatewayObj.getGatewayMac(), new DfuCallback() {
        @Override
        public void onDfuSuccess(String deviceAddress) {
            makeToast("dfu completed");
            startTargetActivity(UserGatewayActivity.class);
        }

        @Override
        public void onDfuAborted(String deviceAddress) {
            makeToast("dfu aborted");
        }

        @Override
        public void onProgressChanged(String deviceAddress, int percent, float speed, float avgSpeed, int currentPart, int partsTotal) {
            LogUtil.d("percent:" + percent);
        }

        @Override
        public void onError() {
            binding.llRetry.setVisibility(View.VISIBLE);
            makeToast("dfu error");
        }
    });
}

Error Handling When the onError() callback is triggered, we display a retry interface with two buttons. Both buttons redirect to the same error method without providing specific error details.

Retry Buttons:

binding.btnRetryByBle.setOnClickListener(v->{
    //use retryEnterDfuModeByBle,need Re Connect the Power
    GatewayDfuClient.getDefault().retryEnterDfuModeByBle();
});
binding.btnRetryByNet.setOnClickListener(v -> {
    GatewayDfuClient.getDefault().retryEnterDfuModeByNet();
});

Issue Details Every time the firmware upgrade process starts, it fails and triggers the onError() callback without any specific error message. We have tried the retry mechanisms provided (retryEnterDfuModeByBle and retryEnterDfuModeByNet), but they do not resolve the issue and the process loops back to the same error state.

User and Client Information

•   User: [jackey.kabra@geokeyaccess.com](mailto:jackey.kabra@geokeyaccess.com)
•   Password: Admin@123
•   CLIENT_ID: b9453d3cfbf94e38ad8dd0a264f58207
•   CLIENT_SECRET: 41db98873334e67318bb165665985166

Request for Support

  1. Could you please provide detailed error messages or codes in the onError() callback to help us identify the root cause of the failure?
  2. Are there any specific configurations or steps that we might be missing in our Android implementation compared to iOS?
  3. Any additional debugging steps or logs we should capture to better understand the issue? Thank you for your assistance in resolving this matter. We look forward to your guidance.