getLockState

open suspend override fun getLockState(): ByteArray?

Sends a GET_STATE (0x5A) command to the lock. The response is a ByteArray representing the lock's status, structured as follows: [COMMAND, COMMAND_RESULT_STATUS, ACTUAL_LOCK_STATE, LOCK_STATUS].

For example, a response might look like 5A, 00, 02, 00 where:

  • 5A indicates the GET_STATE command.

  • 00 means the command completed successfully.

  • 02 represents the lock's current state (e.g., Lock Closed).

  • 00 indicates the last change in lock status occurred without any problems. A LOCK_STATUS value of 01 indicates an error (LOCK_STATUS_ERROR_JAMMED), meaning the lock was jammed during the last attempt to change its state.

Before sending the command, this function checks the state of Bluetooth and location services:

  • RxBleClient.State.BLUETOOTH_NOT_AVAILABLE: Bluetooth is unavailable on the device.

  • RxBleClient.State.LOCATION_PERMISSION_NOT_GRANTED: Required location permissions are not granted.

  • RxBleClient.State.BLUETOOTH_NOT_ENABLED: Bluetooth is not enabled.

  • RxBleClient.State.LOCATION_SERVICES_NOT_ENABLED: Location services are disabled. If any preconditions are not met, onError with BluetoothDisabled is called to handle the situation. Otherwise (i.e., RxBleClient.State.READY), lockConnectionWrapper?.getLockState() will be called.