This topic describes how to use the LinkVisual SDK to connect an IP camera to an IoT Platform instance of the video type after you obtain the LinkVisual SDK.
Environment requirements
The following list describes the resource and platform requirements for the LinkVisual SDK:
Resource:
RAM: occupies about 500 KB of Random Access Memory (RAM) for 1 MB of data streams.
ROM: occupies 1.4 MB of ROM.
Platform: Linux systems that support C++11 and the GNU Compiler Collection (GCC) whose version is later than 4.8.1.
Prerequisites
A product and device are created in the IoT Platform console. For more information, see Device Connection.
In this example, Link SDK for C is used in Linux. We recommend that you use Ubuntu 18.04 as the environment to develop or compile the SDK.
Multiple tools such as CMake and Git are required when you develop or compile the SDK. You can run the following command to install the tools:
sudo apt-get install -y build-essential make git gcc g++ cmake tree
Background information
The LinkVisual SDK contains the Link SDK. If you want to connect an IP camera to a video instance, you must compile the Link SDK and the LinkVisual SDK in sequence.
To compile the SDKs, follow the instructions in the Procedure section. If you want to compile the SDKs in an integrated development environment (IDE), take note of the following items:
Add the
-std=c++11
compiler option.Link the following libraries in sequence: link_visual_device, iot_sdk cjson, iot_hal, iot_tls, pthread, and rt.
When you link the preceding libraries, add the
-lstdc++
link option.
Procedure
Run the
tar -xf lv_2.1.2-lk_2.3.0-xxx-xxx.tar.gz
command to decompress the LinkVisual SDK package.NoteThe name of a package contains variable information such as the version. Replace lv_2.1.2-lk_2.3.0-xxx-xxx.tar.gz with the name of an actual package.
Open the third_party folder in the
lv_2.1.2-lk_2.3.0-xxx-xxx
file, decompress the cJSON-1.7.7 file, and then go to the cJSON-1.7.7 directory that is decompressed.cd third_party # Run the following commands to decompress the cJSON-1.7.7 file and go to the cJSON-1.7.7 directory: tar -xf cJSON-1.7.7.tar.gz cd cJSON-1.7.7
Open the Makefile file and add the disclaimer of a toolchain at the beginning of the file.
NoteReplace the toolchain with an actual cross-compilation toolchain.
CC = arm-linux-gcc LD = arm-linux-ld AR = arm-linux-ar
After you run the
make
command to compile the file, make sure that the libcjson.a and JSON.h files are generated.make # Run the following commands to ensure that the libcjosn.a and the required header files exist. ls lib*.a ls *.h
Compile the Link SDK.
Run the following commands to go to the linkkit directory, decompress the linkkit-sdk-c file, and then go to the decompressed folder:
cd linkkit tar -xf linkkit-sdk-c.tar.gz # Decompress the linkkit-sdk-c.tar.gz package. cd linkkit-sdk-c
Go to the src/board directory, open the config.ubuntu.x86 file, and then add
CROSS_PREFIX:=<Prefix of the path in which a cross-compilation toolchain is stored->
at the end of the file, for example,CROSS_PREFIX:=arm-linux-
.NoteReplace arm-linux- with the prefix of the path in which an actual cross-compilation toolchain is stored.
Run the
make reconfig
command and enter a digit that corresponds to config.ubuntu.x86. In most cases, the digit is 6.Compile the file and make sure that the libiot_tls.a, libiot_sdk.a, and libiot_hal.a library files are generated.
make # Run the following command to check whether the libiot_tls.a, libiot_sdk.a, and libiot_hal.a files exist: ls output/lib/*.a # Run the following command to check whether iot_import.h and other required header files exist: tree include
Compile the SDK and the preceding files.
The root directory of the LinkVisual SDK is returned.
Open the CMakeLists.txt file and specify the path prefix of a cross-compilation toolchain for the
TOOLCHAINS_PREFIX
parameter, for example,arm-linux-
, as shown in the following code:set(TOOLCHAINS_PREFIX "arm-linux-" CACHE STRING "set the toolchain")
Run the required commands in sequence to compile files.
# Run the following command to create a folder named build that is used to categorize the compilation result: mkdir -p build # Run the cd build command to go to the build directory and run the cmake command based on the CMakeLists.txt file in the root directory of the LinkVisual SDK: cd build cmake .. # Run the following commands to compile and install all files that are required to run the SDK. make make install
Run the
./link_visual_ipc -p ${YourProductKey} -n ${YourDeviceName} -s ${YourDeviceSecret}
command to create a sample device.The following table describes the parameters:
${YourProductKey}
ProductKey
g18l****
When the device is connected to LinkVisual, the device certificate information is saved. For more information, see Result. You can also view the information on the Device Details page in the IoT Platform console.
${YourDeviceName}
DeviceName
Device1
${YourDeviceSecret}
DeviceSecret
b2e6e4f1058d8****
If you want to view the status of the device on the Device Details page of the IoT Platform console, perform the following steps:
Log on to the IoT Platform console.
On the Overview page, find the instance that you want to manage, and then click the name of the instance to go to Instance Details page.
In the left-side navigation pane, choose Devices > Devices.
On the Devices page, click the name of the device to go to the Device Details page.
Click TSL Data. On the TSL Data tab, the data of the device is displayed.
If the device is active and the data of the device is displayed on the TSL Data tab, the device is connected to IoT Platform.