Skip to content

Exception Alarm

Can monitor equipment on-line, off-line; channel on-line, off-line

Interface Overview

interface Name Functional Description
NET_SDK_SetSDKMessageCallBack SDK operation exception callback function

Process Description

---
title: Exception Alarm
---
flowchart TD
A(Device SDK initialization <br> <strong>NET_SDK_Init</strong>)
B(User registration device <br> <strong>NET_SDK_Login</strong> or <br> <strong>NET_SDK_LoginEx</strong>)
C(Exception alarm callback function <br> <strong>NET_SDK_SetSDKMessageCallBack</strong>)
D(Device logout <br> <strong>NET_SDK_Logout</strong>)
E(Release SDK resources <br> <strong>NET_SDK_Cleanup</strong>)

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

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
#include <string>
#include "stdafx.h"
#include "DVR_NET_SDK.h"
#include <iomanip>
#include <sstream>
#include <ctime>
#include <afx.h>

void excertionCallback(DWORD dwType, LONG lUserID, LONG lHandle, void *pUser)
{
    if (NETWORK_DISCONNECT == dwType)
    {
        cout << "type: " << dwType << " userID: " << lUserID << " channel: " << lHandle << "-----NETWORK_DISCONNECT" << endl;
    }
    else if (NETWORK_RECONNECT == dwType)
    {
        cout << "type: " << dwType << " userID: " << lUserID << " channel: " << lHandle << "-----NETWORK_RECONNECT" << endl;
    }
    else if (NETWORK_CH_DISCONNECT == dwType)
    {
        cout << "type: " << dwType << " userID: " << lUserID << " channel: " << lHandle << "-----NETWORK_CH_DISCONNECT" << endl;
    }
    else if (NETWORK_CH_RECONNECT == dwType)
    {
        cout << "type: " << dwType << " userID: " << lUserID << " channel: " << lHandle << "-----NETWORK_CH_RECONNECT" << endl;
    }
    else
    {
        cout << "Unknow error code: " << dwType << endl;
    }
}

void AbnormalAlarmProcess()
{
    // 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;
    }

    // SDK operation abnormal callback function
    bool isOk = NET_SDK_SetSDKMessageCallBack(0, 0, excertionCallback, NULL);

    if (isOk)
    {
        cout << "Set message callback successfully" << endl;
    }
    else
    {
        cout << "Set message callback failed" << endl;
    }

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

Relevant Instructions

nothing

Error Code