Last Updated on : 2026-02-12 02:50:35download
ThingCameraSDCardManager is an SD card manager for smart cameras, providing a comprehensive set of interfaces for SD card-related functionality, including SD card status queries, formatting, recording management, and more.
Functional description
Creates an SD card manager instance.
Function signature
createSDCardManager(devId: string): Promise<boolean>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| devId | string | The device ID. |
Return value
Promise<boolean>: Indicates whether the creation was successful.
The current implementation always returns true.
Example
const result = await sdCardManager.createSDCardManager("device123");
console.log(result); // true
Functional description
Checks whether a device supports SD card functionality.
Function signature
isSupportSDCard(): Promise<boolean>
Return value
Promise<boolean>: Indicates whether the SD card functionality is supported.
Different DPs will be selected and checked based on the device type.
Example
const isSupported = await sdCardManager.isSupportSDCard();
if (isSupported) {
console.log("The device supports SD cards")
;}
Functional description
Checks whether a device supports formatting an SD card.
Function signature
isSupportFormatSDCard(): Promise<boolean>
Return value
Promise<boolean>: Indicates whether the SD card formatting is supported.
Gateways or sub-devices use different DPs.
Example
const canFormat = await sdCardManager.isSupportFormatSDCard();
Functional description
Checks whether a device supports unmounting an SD card.
Function signature
isSupportUnmountSDCard(): Promise<boolean>
Return value
Promise<boolean>: Indicates whether the SD card unmounting is supported.
Gateways or sub-devices use different DPs.
Example
const canUnmount = await sdCardManager.isSupportUnmountSDCard();
Functional description
Checks whether a device supports silent recording.
Function signature
isSupportMuteRecord(): Promise<boolean>
Return value
Promise<boolean>: Indicates whether silent recording is supported.
Example
const supportMute = await sdCardManager.isSupportMuteRecord();
Functional description
Gets the current status of an SD card.
Function signature
getSDCardState(devId: string): Promise<TSmartCameraSDCardSate | undefined>
Parameters
| Parameter | Type | Description |
|---|---|---|
| devId | string | The device ID. |
Return value
Promise<TSmartCameraSDCardSate | undefined>: SD card status enumeration values or undefined. Valid values:
normal: Normalexception: ExceptionmemoryLow: Low memoryformatting: Formatting in progressnone: No cardloading: Loading in progressExample
const state = await sdCardManager.getSDCardState("device123");
if (state === TSmartCameraSDCardSate.normal) {
console.log("SD card works properly")
;}
Functional description
Gets the capacity information of the SD card.
Function signature
getSDCardInformation(devId: string): Promise<boolean | undefined>
Parameters
| Parameter | Type | Description |
|---|---|---|
| devId | string | The device ID. |
Return value
Promise<boolean | undefined>: Indicates whether the operation was successful.
Actual capacity information is returned via a listener callback.
Example
const success = await sdCardManager.getSDCardInformation("device123");
Functional description
Formats the SD card.
Function signature
formatSDCard(devId: string): Promise<boolean>
Parameters
| Parameter | Type | Description |
|---|---|---|
| devId | string | The device ID. |
Return value
Promise<boolean>: Indicates whether the formatting command was sent successfully.
Example
const result = await sdCardManager.formatSDCard("device123");
Functional description
Unmounts the SD card.
Function signature
unMountSDCard(devId: string): Promise<boolean>
Parameters
| Parameter | Type | Description |
|---|---|---|
| devId | string | The device ID. |
Return value
Promise<boolean>: Indicates whether the unmounting command was sent successfully.
After unmounting it, you need to reinsert the SD card to use it.
Example
const result = await sdCardManager.unMountSDCard("device123");
Functional description
Gets the recording enabling status of the SD card.
Function signature
sdCardRecordOpenState(devId: string): Promise<boolean | undefined>
Parameters
| Parameter | Type | Description |
|---|---|---|
| devId | string | The device ID. |
Return value
Promise<boolean | undefined>: Indicates whether recording is enabled.
Example
const isRecording = await sdCardManager.sdCardRecordOpenState("device123");
Functional description
Enables or disables SD card recording.
Function signature
enableSDCardRecord(devId: string, enable: boolean): Promise<boolean>
Parameters
| Parameter | Type | Description |
|---|---|---|
| devId | string | The device ID. |
| enable | boolean | Indicates whether recording is enabled. |
Return value
Promise<boolean>: Indicates whether the setting was successful.
Example
await sdCardManager.enableSDCardRecord("device123", true);// Enable recording
await sdCardManager.enableSDCardRecord("device123", false);// Disable recording
Functional description
Enables or disables the loop recording functionality of the SD card.
Function signature
enableSDCardLoopRecord(devId: string, enable: boolean): Promise<boolean>
Parameters
| Parameter | Type | Description |
|---|---|---|
| devId | string | The device ID. |
| enable | boolean | Indicates whether loop recording is enabled. |
Return value
Promise<boolean>: Indicates whether the setting was successful.
Loop recording will automatically overwrite the oldest recordings when storage is full.
Example
await sdCardManager.enableSDCardLoopRecord("device123", true);
Functional description
Gets the recording mode of the SD card.
Function signature
getSDCardRecordMode(devId: string): Promise<TSmartCameraDSCardRecordMode | undefined>
Parameters
| Parameter | Type | Description |
|---|---|---|
| devId | string | The device ID. |
Return value
Promise<TSmartCameraDSCardRecordMode | undefined>: The enumeration values for recording modes, including:
event: Event-based recordingalways: Continuous recordingtime: Scheduled recordingExample
const mode = await sdCardManager.getSDCardRecordMode("device123");
if (mode === TSmartCameraDSCardRecordMode.event) {
console.log("Currently in event recording mode")
;}
Functional description
Sets the recording mode of the SD card.
Function signature
setSDCardRecordMode(devId: string, mode: TSmartCameraDSCardRecordMode): Promise<boolean>
Parameters
| Parameter | Type | Description |
|---|---|---|
| devId | string | The device ID. |
| mode | TSmartCameraDSCardRecordMode | The enumeration values for the recording mode. |
Return value
Promise<boolean>: Indicates whether the setting was successful.
Different modes have varying requirements for device performance and storage.
Example
await sdCardManager.setSDCardRecordMode(
"device123", TSmartCameraDSCardRecordMode.always);
Functional description
Registers a listener for SD card data.
Function signature
registerSDCardListener(listener: ThingCameraSDCardManagerListener): void
Parameters
| Parameter | Type | Description |
|---|---|---|
| listener | ThingCameraSDCardManagerListener | The listener object, containing formatting progress and capacity information callbacks. |
Example
const listener = {
sdCardFormatProgeress: (devId: string, progress: number) => {
console.log(`Formatting progress: ${progress}%`);
},
sdCardInfomationDidReceive: (devId: string, info: Map<string, string>) => {
console.log(`Total capacity of SD card: ${info.get('totalSpace')}`);
}};
sdCardManager.registerSDCardListener(listener);
Functional description
Unregisters a listener for SD card data.
Function signature
unregisterSDCardListener(listener: ThingCameraSDCardManagerListener): void
Parameters
| Parameter | Type | Description |
|---|---|---|
| listener | ThingCameraSDCardManagerListener | The listener object to be unregistered. |
The listener object passed in must be the same as the one used during registration.
Example
sdCardManager.unregisterSDCardListener(listener);
Features
SD card formatting progress callback.
Parameter
| Parameter | Type | Description |
|---|---|---|
| devId | string | The device ID. |
| progress | number | The formatting progress, ranging from 0 to 100. |
Features
SD card capacity information callback.
Parameter
| Parameter | Type | Description |
|---|---|---|
| devId | string | The device ID. |
| information | Map<string,string> | The capacity information map, including totalSpace, usedSpace, and freeSpace. |
| Parameter | Enum value | Description |
|---|---|---|
| normal | 1 | The SD card works properly. |
| exception | 2 | An exception occurred. |
| memoryLow | 3 | The SD card has insufficient space. |
| formatting | 4 | Formatting is in progress. |
| none | 5 | No SD card is found. |
| loading | 6 | Loading is in progress. |
| Parameter | Enum value | Description |
|---|---|---|
| event | 1 | Event-based recording mode |
| always | 2 | Continuous recording mode |
| time | 3 | Scheduled recording mode |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback