Skip to content

Receive Device Enrollment Connection

The relevant parameters need to be actively reported before the equipment is configured

Interface Overview

interface Name Functional Description
NET_SDK_AddRegisterDeviceInfo Add Active Enrollment Device Info
NET_SDK_SetRegisterPort Device receives local platform port number for active DVR - registration
NET_SDK_SetRegisterCallback Register Callback Function
NET_SDK_SetUnRegisterCallback Logoff Callback Function

Process Description

---
title: Receive Device Registration Connection
---
flowchart TD
    A(Device SDK initialization <br> <strong>NET_SDK_Init</strong>)
    B(Add reported device information <br> <strong>NET_SDK_AddRegisterDeviceInfo</strong>)
    C(Configure reporting parameters on the device web page)
    D(Set the port for listening to reports <br> <strong>NET_SDK_SetRegisterPort</strong>)
    E(Set the callback function for device reporting success <br> <strong>NET_SDK_SetRegisterCallback</strong>)
    F(Set the callback function for device disconnection reporting <br> <strong>NET_SDK_SetUnRegisterCallback</strong>)
    G(Release SDK resources <br> <strong>NET_SDK_Cleanup</strong>)
    style C fill:#e7b13387
    A --> B --> C --> D --> E --> F --> G
Receive device enrollment connection process web
Receive device enrollment connection process web

Sample Code

 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <string>
#include "stdafx.h"
#include "DVR_NET_SDK.h"
#include <iomanip>
#include <sstream>
#include <ctime>
#include <afx.h>
#include <iostream>

using namespace std;
int m_userid1 = -1;

void CALLBACK AcceptRegisterProc1(LONG lUserID, LONG lRegisterID, LPNET_SDK_DEVICEINFO pDeviceInfo, void *pUser)
{
    m_userid1 = lUserID;
    cout << "lUserID: " << lUserID << endl;
    cout << "lRegisterID: " << lRegisterID << endl;
    cout << "deviceName: " << pDeviceInfo->deviceName << endl;
}

void my_LIVE_DATA_CALLBACK1(POINTERHANDLE lLiveHandle, NET_SDK_FRAME_INFO frameInfo, BYTE *pBuffer, void *pUser)
{
    cout << "deviceID: " << frameInfo.deviceID << endl;
    cout << "channel: " << frameInfo.channel << endl;
    cout << "length: " << frameInfo.length << endl;
}

void RegisterDevice()
{
    // init sdk
    NET_SDK_Init();
    NET_SDK_SetConnectTime(5000, 1);
    NET_SDK_SetReconnect();

    // Register the device.
    REG_LOGIN_INFO regInfo;
    regInfo.deviceId = 95272; // The reporting ID should be consistent with the device's registration.
    strcpy_s(regInfo.m_szUserName, "admin");
    strcpy_s(regInfo.m_szPasswd, "123456");

    NET_SDK_AddRegisterDeviceInfo(&regInfo, 1);

    // Initiate a report
    bool isOk = NET_SDK_SetRegisterPort(2009);
    cout << "NET_SDK_SetRegisterPort: " << isOk << endl;
    isOk = NET_SDK_SetRegisterCallback(AcceptRegisterProc1, NULL);
    cout << "NET_SDK_SetRegisterCallback: " << isOk << endl;

    while (true)
    {
        if (m_userid1 != -1)
        {
            cout << "login success!" << endl;
            break;
        }

        Sleep(1000);
        cout << "wait for login..." << endl;
    }

    // Open live display
    NET_SDK_CLIENTINFO lpClientInfo = {0};
    lpClientInfo.hPlayWnd = GetConsoleWindow();
    lpClientInfo.lChannel = 0;
    lpClientInfo.streamType = NET_SDK_MAIN_STREAM;
    lpClientInfo.bNoDecode = 0;
    LONG lhandle = NET_SDK_LivePlay(m_userid1, &lpClientInfo, NULL, NULL);
    if (lhandle == -1)
    {
        DWORD err1 = NET_SDK_GetLastError();
        cout << "Failed to preview!error code: " << err1 << endl;
        return;
    }
    else
    {
        NET_SDK_SetLiveDataCallBack(lhandle, my_LIVE_DATA_CALLBACK1, NULL);
    }
    cout << "Preview successful!" << endl;
    // Waiting for live display
    Sleep(100000);

    // Login
    NET_SDK_Logout(m_userid1);
    NET_SDK_Cleanup();
}

Relevant Instructions

nothing

Error Code