SDK Overview
BKSmartSDK provides interface encapsulation for communicating with remote camera devices, accelerating application development process, hereafter referred to as SDK in the following chapters. It mainly includes the following functionalities:
Configuring network settings for devices.
Retrieving real-time video streams captured by the camera.
Receiving audio from the camera for two-way communication with the camera device.
Recording and playing audio.
AVDK Version Correspondence
Chip Name |
Product Type |
AVDK Version |
|---|---|---|
BK7258 |
Smart Doorbell, Door Lock |
2.0.1.9+ |
Development Guide
Quick Integration
This article introduces how to quickly integrate the SDK into your project, requiring Android 5.0 and above versions.
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
Including the downloaded AAR file using Gradle.
Example:
implementation(files("libs/iotsdk-v2.0.1.aar"))
Device Networking
System Requirements
Bluetooth usage requires Android 5.0 and above versions.
Manifest Permissions
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
Bluetooth Permission Check
Before each scan and connection, a check must be performed, otherwise the app cannot use the SDK properly.
The app needs to check if location permission is allowed before using Bluetooth connection or scanning operations.
Check if Bluetooth status is enabled.
Check if location services are turned on.
Function Description
Explanation of Related Classes (Protocols)
Class Name (Protocol Name) |
Explanation |
|---|---|
BkSmartBleScanOptions |
BLE scan configuration class |
BkSmartBleActivateOptions |
BLE provisioning configuration class |
BKSmartBleActivator |
BLE scan and provisioning delegate |
Scan Process
Interface Specification
Configuration of Scanning Options
fun setActivateOptions(options: BkSmartBleActivateOptions)
Start Scanning
fun startScan(context: Context)
Stop Scanning
fun stopScan(context: Context)
Delegate Callbacks
Scan Result
fun onScanResult(device: BluetoothDevice, rssi: Int)
Error during Scanning
fun onError(code: Int)
Provisioning
Interface Specification
Setting Provisioning Options
fun setActivateOptions(options: BkSmartBleActivateOptions)
Start Provisioning
fun activate(context: Context)
Stop Provisioning
fun stopActivate(context: Context)
Delegate Callbacks
Provisioning Information Callback
fun onProgressMsg(msg: String)
Provisioning Completion
fun onResult(code: Int)
Camera Functionality
The SDK provides basic capabilities such as real-time video image acquisition from intelligent cameras, audio data acquisition from cameras, and real-time communication with cameras.
System Requirements
Bluetooth usage requires Android 5.0 and above versions.
Manifest Permissions
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
P2P Connection
Before starting video playback, it’s necessary to connect to the Shangyun P2P channel. The connection status of the P2P channel needs to be maintained by the developer, while the SDK is responsible for sending commands and receiving camera response results.
Interface Specification
Configuration of Connection Options
fun setConnectOptions(bkSmartCameraConnectOptions: BkSmartCameraConnectOptions)
Start Connecting to P2P Channel
fun connect()
Disconnect P2P Channel
fun disconnect()
Delegate Callbacks
P2P Channel Connected Successfully
fun onConnected()
P2P Channel Disconnected
fun onDisconnected()
Real-time Video
After successful P2P connection, you can start retrieving real-time video image data.
Interface Specification
Configuration of Video Options
fun setVideoOptions(bkSmartCameraVideoOptions: BkSmartCameraVideoOptions)
Start Video Playback
fun openVideoPreview()
Close Video Playback
fun closeVideoPreview()
Noise Reduction Switch
fun enableNoiseReduction(enable: Boolean)
Delegate Callbacks
Video Preview Switch Callback
fun onVideoPreviewState(videoPreviewOn: Boolean)
Available Unpacked Data after Decoding
fun onReceiveFrameUnpackedData(frameData: ByteArray)
Bad Data after Decoding
fun onReceiveFrameUnpackedBadData(frameData: ByteArray)
Data Frame after Decoding, Ready for Display
fun onReceiveFrame(bitmap: Bitmap, noiseReduction: Boolean)
Audio
After successful P2P connection, you can start retrieving audio data.
Interface Specification
Configuration of Audio Options
fun setAudioOptions(bkSmartCameraAudioOptions: BkSmartCameraAudioOptions)
Start Audio (Audio sent from the board to the mobile)
fun openAudio()
Close Audio (Audio sent from the board to the mobile)
fun closeAudio()
Start Intercom (Will simultaneously open audio sent from the board to the mobile)
fun openIntercom()
Close Intercom
fun closeIntercom()
Delegate Callbacks
Player and Recorder State Callback
fun onState(playerOn: Boolean, recorderOn: Boolean)
audio channel operating State Callback
fun onChannelState(operating: Boolean)
Error Callback
fun onError(code: Int)
audio up original stream
fun onAudioUpOriginalStream(pcmData: ByteArray)
audio up encoded stream
fun onAudioUpEncodedStream(encodedData: ByteArray, format: Int)
audio down encoded stream
fun onAudioDownUnpackedStream(unpackedData: ByteArray, format: Int)
audio down decoded stream
fun onAudioDownDecodedStream(pcmData: ByteArray)
LCD Control
After successful P2P connection, you can control the LCD.
Interface Specification
Get LCD State
fun fetchLcdState()
Open LCD
fun openLcd()
Close LCD
fun closeLcd()
Delegate Callbacks
LCD State Callback
fun onLcdState(on: Boolean)
Error Callback
fun onError(code: Int)
Code
Name |
Value |
Description |
|---|---|---|
SUCCESS |
0 |
Success |
BLE_NOT_AVAILABLE |
100 |
Bluetooth not available(not supported or authorization not enabled) |
BLE_DEVICE_NOT_FOUND |
101 |
Device search failed during connection |
BLE_DEVICE_CONNECT_FAILED |
102 |
Device connection failed |
BLE_DEVICE_DISCONNECTED |
103 |
Disconnected from the device |
BLE_ACTIVATE_FAILED |
104 |
Activation failed |
BLE_ACTIVATE_TIME_OUT |
105 |
Activation timeout |
BLE_SCAN_TIME_OUT |
106 |
Scan timeout |
P2P_LICENSE_INVALID |
200 |
Invalid key |
P2P_CONNECT_FAILED |
201 |
Connection failed |
P2P_DISCONNECTED |
202 |
Disconnected |
P2P_CONNECT_SUCCESS |
203 |
Connection successful |
OPEN_VIDEO_FAILED |
300 |
Failed to open video |
CLOSE_VIDEO_FAILED |
301 |
Failed to close video |
OPEN_AUDIO_FAILED |
400 |
Failed to open audio |
CLOSE_AUDIO_FAILED |
401 |
Failed to close audio |
OPEN_LCD_FAILED |
500 |
Failed to open LCD |
CLOSE_LCD_FAILED |
501 |
Failed to close LCD |