Docs / igloohome / BLE SDK / Sync
Sync
Synchronize device state via Bluetooth.
sync
Syncs the lock via Bluetooth: sets the lock's internal clock, retrieves battery level, uploads activity logs, and updates the device on the server.
Signature
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
deviceId |
String |
Yes | Bluetooth device name of the lock. |
key |
String |
Yes | eKey with GET_TIME, SET_TIME, GET_BATTERY_LEVEL, GET_LOGS permissions. |
timeInSeconds |
Long? |
No | Unix timestamp (seconds) to set on the lock. If omitted, SDK uses last server time. |
getDeviceToken |
String |
Yes | OAuth access token for fetching device info. |
storeLogsToken |
String |
Yes | OAuth access token for uploading activity logs. |
updateDeviceToken |
String |
Yes | OAuth access token for updating device state on the server. |
operationId |
Int? |
No | Operation ID for tracking. |
Return Type
| Field | Description |
|---|---|
batteryLevel |
Battery level as percentage (0-100). |
Error Codes
| Exception | Code | Description |
|---|---|---|
BluetoothException |
708 | Bluetooth is off or unavailable. |
ConnectionException |
12 | Device disconnected during sync. |
TimeoutException |
703 | BLE operation exceeded the timeout. |
ApiException |
varies | Activity log upload or device update failed. |
Example
Notes
- Sync reads all pending activity logs from the lock in a loop until no more remain.
- Logs are stored in a local database first, then batch-uploaded to the server.
- If
timeInSecondsis omitted and no cached server time is available, the lock time is not updated. - The three token parameters (
getDeviceToken,storeLogsToken,updateDeviceToken) can be the same token if it has all required scopes, or different tokens with scoped permissions.