跳转至

协议透传

API透传,即SDK内部不处理发送的数据,也不处理设备返回的数据,用户自行组合接口所需数据。

接口概览

接口名称 功能描述
NET_SDK_TransparentConfig API协议透传接口(支持公网)。
Note

接口详细参数见接口定义部分

流程说明

业务流程图如下:

---
title: 协议透传
---

flowchart TD
    A(设备SDK初始化<br><strong>NET_SDK_Init</strong>)
    B(用户注册设备<br><strong>NET_SDK_Login</strong>或<br><strong>NET_SDK_LoginEx</strong>)
    C(协议透传<br><strong>NET_SDK_TransparentConfig</strong>)
    F(用户业务逻辑<br>...)
    D(注销设备<br><strong>NET_SDK_Logout</strong>)
    E(释放SDK资源<br><strong>NET_SDK_Cleanup</strong>)

    A --> B --> C --> F --> D --> E

示例代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
#include <string>
#include "stdafx.h"
#include "DVR_NET_SDK.h"
#include <iomanip>
#include <sstream>
#include <ctime>
#include <afx.h>

void TransparentConfig()
{
    // device info
    CString username = "admin";
    CString password = "123456";
    CString device_ip = "10.80.1.177";
    DWORD device_port = 6036;
    // init sdk
    NET_SDK_Init();
    // device login
    NET_SDK_DEVICEINFO device_info;
    memset(&device_info, 0, sizeof(NET_SDK_DEVICEINFO));
    int userid = NET_SDK_Login(device_ip.GetBuffer(), device_port, username.GetBuffer(), password.GetBuffer(), &device_info);

    if (userid > 0)
    {
        cout << "Login successful: " << userid << endl;
    }
    else
    {
        cout << "Login failed: " << userid << endl;
        return;
    }

    // adjust interface and parameters according to actual needs.
    CString sendURL = "faceImgStatistic_v2";
    CString sendXML = R"(<?xml version: "1.0" encoding="utf-8" ?><BR><request version="1.0"   systemType="NVMS-9000" clientType="WEB"><BR><resultLimit>150000</resultLimit>  <BR><condition>    <BR><startTime>2023-04-19 00:00:00</startTime>    <BR><endTime>2023-04-19 23:59:59</endTime>    <BR><timeQuantum>24</timeQuantum>    <BR><deduplicate>false</deduplicate>    <BR><chls type="list"><BR><item id="{00000001-0000-0000-0000-000000000000}"></item><BR><item id="{00000002-0000-0000-0000-000000000000}"></item><BR><item id="{00000004-0000-0000-0000-000000000000}"></item><BR><item id="{00000005-0000-0000-0000-000000000000}"></item><BR><item id="{00000006-0000-0000-0000-000000000000}"></item><BR><item id="{00000000-0000-0000-0000-000000000000}"></item><BR></chls><BR><events type="list"><BR><item>passLine</item><BR></events><BR><vehicle type="list"><BR> <item>car</item><BR> <item>motor</item><BR></vehicle><BR></condition><BR></request>)";
    const int bufSize = 100 * 1024;
    char *tempOutBuf = new char[bufSize];
    memset(tempOutBuf, 0, bufSize);
    DWORD tmplpBytesReturned = 0;
    bool tran = NET_SDK_TransparentConfig(userid, sendXML.GetBuffer(), sendURL.GetBuffer(), tempOutBuf, bufSize, &tmplpBytesReturned);

    if (tran)
    {
        cout << "Request sent successfully: " << tran << endl;
        cout << tempOutBuf << endl;
        // Parse XML to process data.
        // Follow-up business processing.
    }
    else
    {
        cout << "Request failed: " << tran << endl;
    }

    // logout
    NET_SDK_Logout(userid);
    NET_SDK_Cleanup();
}

相关说明

  • 接口返回值是表示和设备通信是否成功

  • 透传的API接口具体内容是否成功,要解析 lpOutBuffer的内容

错误码