[中文]

SDK Overview

BKSmartSDK provides an interface encapsulation for communication with remote camera devices, accelerating the application development process. In the subsequent sections, it will be referred to as the SDK. It mainly includes the following functions:

  • Configure devices for network connection.

  • Obtain real-time images captured by the camera.

  • Receive audio from the camera and engage in real-time communication with the camera device.

  • Record and play audio.

AVDK Version :

Chip Name

Product Type

AVDK Version

BK7258

Smart Doorbell, Door Lock

2.0.1.9+

Development Guide

Quick Integration

This section explains how to quickly integrate the SDK into your project. The SDK requires a minimum iOS version of 12.0 and does not support running on simulators.

Download the SDK

Visit the Gitlab repository , simply download the SDK.

Note

The latest SDK code is downloaded from gitlab on the official website, and relevant accounts can be found on the project to review the application.

Integration

Drag BKSmartSDK into your project, as shown in the image below:

framework

framework

drag_in

drag_in

Add dependency libraries:

  • libz.tbd

  • libbz2.tbd

  • libiconv.tbd

  • VideoToolbox.framework

As shown in the image below:

dependency

dependency

Add configuration

  • Xcode -> Build Settings -> Other Linker Flags add -Objc

  • Xcode > Build Settings -> Other C Flags add -DLINUX

At this point, BKSmartSDK has been successfully integrated, and you can start using SDK to develop features.

Note

Since BKSmartSDK is a mixed Objective-C and Swift library, if your project is purely Objective-C, you may encounter compilation errors after integration. In this case, create a Swift file (empty file is sufficient) in the project.

oc_error

oc_error

Device Network Configuration

Version Compatibility

iOS 13 Version Compatibility

Starting from iOS 13, if the user has not granted location permissions, even with Wi-Fi permissions enabled, valid Wi-Fi SSID or BSSID cannot be obtained.

Functionality Overview

Explanation of Related Classes (Protocols)

Class Name (Protocol Name)

Explanation

BKSmartWifiTool

Wi-Fi utility class

BKSmartActivator

Provides Bluetooth network configuration capability

BKSmartActivatorDelegate

Network configuration delegate protocol

BKSmartDeviceModel

BK device

BKSmartP2PLicense

CS P2P license information

BKSmartWifiInfo

Wi-Fi information

Network Configuration Process

Note

Before network configuration, please add Bluetooth usage instructions in Info.plist: NSBluetoothAlwaysUsageDescription

Get Current Phone’s Connected SSID

You can use the utility class BKSmartWifiTool to get the current phone’s connected Wi-Fi SSID.

Import the header file: #import <BKSmartUtilKit/BKSmartUtilKit.h>

+ (void)getSSID:(BKSmartWifiToolSSIDCompletionHandler)handler;

Note

For iOS 12 and above, you need to add Access WiFi Information permission in Capabilities to obtain Wi-Fi information.

wifi

wifi

Monitor Bluetooth Status

Import the header file: #import "BKSmartActivatorKit/BKSmartActivatorKit.h"

Initialize the BKSmartActivator object and set the delegate to start monitoring the status.

Delegate Callback

- (void)activator:(BKSmartActivator*)activator didUpdateState:(BOOL)isPowerOn;

Scan Devices

If the Bluetooth status is available (isPowerOn), you can start scanning for devices.

Interface Explanation

Start scanning for devices

- (void)startScan;

Stop scanning for devices

- (void)stopScan;

Delegate Callback

Discover a new device during scanning

- (void)activator:(BKSmartActivator*)activator didDiscoverDevice:(BKSmartDeviceModel*)device;

Device Configuration

Interface Explanation

Start configuring the device

- (void)activeDevice:(BKSmartDeviceModel*)device p2pConfig:(BKSmartCameraP2PConfig*)p2pConfig;

Stop device configuration

- (void)stopActiveDevice;

Delegate Callback

// Configuration progress update
- (void)activator:(BKSmartActivator*)activator didUpdateActiveProgress:(CGFloat)progress;

// Configuration progress information
- (void)activator:(BKSmartActivator*)activator didUpdateActiveInfo:(NSString*)info;

// Configuration completion: If successful, error is nil; if failed, error is not nil.
- (void)activator:(BKSmartActivator*)activator didFinishActiveDevice:(BKSmartDeviceModel*)device
                                 error:(NSError* _Nullable)error;

Error Callback

If an error occurs during the network configuration process, it will be returned through the following interface, providing the corresponding error.

- (void)activator:(BKSmartActivator*)activator didFinishActiveDevice:(BKSmartDeviceModel*)device
                                 error:(NSError* _Nullable)error;

Error code enumeration values

Enumeration Value

Value

Explanation

BKSmartActivatorErrorBLENotAvailable

100

Bluetooth is not available (not supported or not authorized)

BKSmartActivatorErrorDeviceNotFound

101

Device search failed during connection

BKSmartActivatorErrorDeviceConnectFailed

102

Device connection failed

BKSmartActivatorErrorDeviceDisconnected

103

Disconnected from the device

BKSmartActivatorErrorActiveDeviceFailed

104

Configuration failed

Camera Functionality

The SDK provides basic capabilities for obtaining real-time video images, audio data, and engaging in real-time communication with intelligent cameras.

Explanation of Related Classes (Protocols)

Class Name (Protoco lName)

Explanation

BKSmartCameraConfig

Camera configuration parameters, including video, audio, LCD, and other configuration parameters

BKSmartCamera

Camera object, needs to be initialized through BKSmartP2PLicense and BKSmartCameraConfig

BKSmartCameraDelegate

Camera delegate, results of camera functionality methods will be returned through delegate methods

Import the header file: #import <BKSmartCameraKit/BKSmartCameraKit.h>

P2P Connection

Before playing video, you need to connect to the CS P2P channel. The P2P connection status needs to be maintained by the developer, and the SDK is only responsible for sending commands and receiving camera response results.

Interface Explanation

Start connecting to the P2P channel

- (void)connect;

Disconnect from the P2P channel

- (void)disconnect;

Delegate Callback

P2P channel connected successfully

- (void)cameraDidConnected:(BKSmartCamera*)camera;

P2P channel disconnected

- (void)cameraDidDisconnected:(BKSmartCamera*)camera;

Real-time Video

After a successful P2P connection, you can start obtaining real-time video image data.

Interface Explanation

Open video playback

- (void)openVideoPreview;

Open/Close video image denoise. (default is close)

- (void)denoiseEnable:(BOOL)isEnable;

Close video playback

- (void)closeVideoPreview;

Delegate Callback

Video playback opened successfully

- (void)cameraDidOpenVideoPreview:(BKSmartCamera*)camera;

Video data callback

// Raw, unpacked data
- (void)camera:(BKSmartCamera*)camera didReciveVideoFrameRawData:(NSData*)data;

// Unpacked usable data
- (void)camera:(BKSmartCamera*)camera didReciveVideoFrameUnpackedData:(NSData*)data;

// Unpacked bad data
- (void)camera:(BKSmartCamera*)camera didReciveVideoFrameUnpackedBadData:(NSData*)data;

// Unpacked data frame (UIImage), ready for display
- (void)camera:(BKSmartCamera*)camera didReciveVideoFrame:(BKSmartCameraVideoFrame*)videoFrame;

Video playback closed successfully

- (void)cameraDidCloseVideoPreview:(BKSmartCamera*)camera;

Audio

After a successful P2P connection, you can start obtaining audio data.

Interface Explanation

Open audio

- (void)openAudio;

Close audio

- (void)closeAudio;

Send speaker audio data

- (void)sendSpeakerData:(NSData*)data;

Note

You can only send recorded audio data after successfully opening audio.

Delegate Callback

Audio opened successfully

- (void)cameraDidOpenAudio:(BKSmartCamera*)camera;

Audio data callback

// Received audio data (decoded data)
- (void)camera:(BKSmartCamera*)camera didReciveAudioFrame:(BKSmartCameraAudioFrame*)audioFrame;

// Received audio data metadata (undecoded metadata)
- (void)camera:(BKSmartCamera*)camera didReciveAudioFrameRawData:(NSData*)data;

Audio closed successfully

- (void)cameraDidCloseAudio:(BKSmartCamera*)camera;

Audio Recording and Playback

The SDK provides functionality for audio recording and playing audio. Once audio and intercom are opened, you can use this utility class for audio playback and recording.

Explanation of Related Classes (Protocols)

Interface Explanation

Class Name (Protocol Name)

Explanation

BKSmartAudioIOManager

Audio management class

BKSmartAudioIOManagerDelegate

Delegate class

Import the header file: #import <BKSmartAudioKit/BKSmartAudioKit.h>

Audio Playback

Interface Explanation

// Start audio playback
- (void)startPlay;

// Play audio data
- (void)play:(NSData*)data;

// Stop audio playback
- (void)stopPlay;

Audio Recording

Note

Audio recording requires adding microphone permission instructions in Info.plist: NSMicrophoneUsageDescription

Interface Explanation

// Start audio recording
- (void)startRecord;

// Set AEC status
- (void)setRecordAECEnable:(BOOL)enable;

// Stop audio recording
- (void)stopRecord;

Delegate Callback

Receive recorded audio data, you can send the data after obtaining it.

- (void)audioIOManager:(BKSmartAudioIOManager*)manager didRecord:(NSData*)data;

LCD Control

After a successful P2P connection, you can control the LCD.

Open LCD

- (void)openLCD;

Close LCD

- (void)closeLCD;

Delegate Callback

LCD opened successfully

- (void)cameraDidOpenLCD:(BKSmartCamera*)camera;

LCD closed successfully

- (void)cameraDidCloseLCD:(BKSmartCamera*)camera;

Error Callback

All errors during camera operations will be returned through delegate methods.

Interface Explanation

Camera operation failure callback

- (void)camera:(BKSmartCamera*)camera didOccuredError:(NSError*)error whenAction:(BKSmartCameraAction)action;

Error code enumeration values:

Enumeration Value

Value

Explanation

BKSmartCameraErrorP2PLicenseInvalid

200

CS license invalid

BKSmartCameraErrorP2PConnectFailed

201

CS P2P connection failed

BKSmartCameraErrorP2PDisconnected

202

CS P2P disconnected

BKSmartCameraErrorOpenVideoFailed

300

Failed to open real-time video

BKSmartCameraErrorCloseVideoFailed

301

Failed to close real-time video

BKSmartCameraErrorOpenAudioFailed

401

Failed to open audio

BKSmartCameraErrorCloseAudioFailed

401

Failed to close audio

BKSmartCameraErrorOpenLCDFailed

500

Failed to open LCD

BKSmartCameraErrorCloseLCDFailed

501

Failed to close LCD