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

Mapping TTLock Error Cases to Custom Error Cases for Logging #41

Closed parvez-geokey closed 1 month ago

parvez-geokey commented 2 months ago

We are in the process of mapping TTLock error cases to custom error enums for each operation, and we need to categorize the errors based on function name to ensure proper logging. Could you please guide us on which function might throw which specific errors?

This will help us log relevant and accurate errors for each operation.

Here are the TTLock functions that we're working with:

TTLock.getLockTime
TTLock.setLockTimeWithTimestamp
TTLock.getLightTime
TTLock.setLightTime
TTLock.controlLock
TTLock.getElectricQuantity
TTLock.getOperationLog
TTLock.getAllValidPasscodes
TTLock.createCustomPasscode
TTLock.modifyPasscode
TTLock.deletePasscode
TTLock.resetPasscodes
TTGateway.scanWiFiByGateway
TTGateway.initializeGateway
TTGateway.disconnectGateway
TTGateway.connectGateway

Error Types: Here are the error types that TTLock might throw:

typedef NS_ENUM(NSInteger, TTError)
{
    TTErrorHadReseted = 0x00,
    TTErrorCRCError = 0x01,
    TTErrorNoPermisstion = 0x02,
    TTErrorWrongAdminCode = 0x03,
    TTErrorLackOfStorageSpace = 0x04,
    TTErrorInSettingMode = 0x05,
    TTErrorNoAdmin = 0x06,
    TTErrorNotInSettingMode = 0x07,
    TTErrorWrongDynamicCode = 0x08,
    TTErrorIsNoPower = 0x0a,
    TTErrorResetPasscode = 0x0b,
    TTErrorUpdatePasscodeIndex = 0x0c,
    TTErrorInvalidLockFlagPos = 0x0d,
    TTErrorEkeyExpired = 0x0e,
    TTErrorPasscodeLengthInvalid = 0x0f,
    TTErrorSamePasscodes = 0x10,
    TTErrorEkeyInactive = 0x11,
    TTErrorAesKey = 0x12,
    TTErrorFail = 0x13,
    TTErrorPasscodeExist = 0x14,
    TTErrorPasscodeNotExist = 0x15,
    TTErrorLackOfStorageSpaceWhenAddingPasscodes = 0x16,
    TTErrorInvalidParaLength = 0x17,
    TTErrorCardNotExist =    0x18,
    TTErrorFingerprintDuplication =    0x19,
    TTErrorInvalidParam =    0x20,
    TTErrorFingerprintNotExist = 0x1A,
    TTErrorInvalidCommand = 0x1B,
    TTErrorInFreezeMode = 0x1C,
    TTErrorInvalidClientPara = 0x1D,
    TTErrorLockIsLocked = 0x1E,
    TTErrorRecordNotExist = 0x1F,
    TTErrorWrongSSID = 0x25,
    TTErrorWrongWifiPassword = 0x26,

    TTErrorBluetoothPoweredOff = 0x61,
    TTErrorConnectionTimeout = 0x62,
    TTErrorDisconnection = 0x63,
    TTErrorLockIsBusy = 0x64,
    TTErrorWrongLockData = 0x65,
    TTErrorInvalidParameter = 0x66,
};

typedef NS_ENUM(NSInteger, TTGatewayStatus){
    TTGatewaySuccess = 0,
    TTGatewayFail = 1,
    TTGatewayWrongSSID = 3,
    TTGatewayWrongWifiPassword = 4,
    TTGatewayInvalidCommand = 6,
    TTGatewayTimeout = 7,
    TTGatewayNoSIM = 8,
    TTGatewayNoPlugCable = 9,
    TTGatewayWrongCRC = -1,
    TTGatewayWrongAeskey = -2,
    TTGatewayNotConnect = -3,
    TTGatewayDisconnect = -4,
    TTGatewayFailConfigRouter = -5,
    TTGatewayFailConfigServer = -6,
    TTGatewayFailConfigAccount = -7,
    TTGatewayFailConfigIP = -8,
    TTGatewayFailInvaildIP = -9,
};

Please lets us know if we have missed other TTLock error enums.

We would appreciate your guidance on categorising these errors for each operation.

Thank you!

ttlock commented 2 months ago

These error codes are shared, and no method throws a specific error.